emergency save.

This commit is contained in:
2024-05-05 23:18:42 -04:00
parent 555cf209ba
commit 3955048157
6 changed files with 169 additions and 5 deletions

View File

@ -1,6 +1,6 @@
"""Base for MoreThanTest test cases."""
from asyncio import create_subprocess_exec, sleep
from asyncio import create_subprocess_exec, gather, sleep
from pathlib import Path
from socket import socket
from unittest import IsolatedAsyncioTestCase
@ -87,6 +87,19 @@ class MTTClusterTC(IsolatedAsyncioTestCase):
port = await self.get_port()
await self.create_server_with_flags("-p", str(port))
async def create_cluster(self, num=2):
"""Create a cluster of servers."""
ports = []
while len(ports) < num:
port = await self.get_port()
if port not in ports:
ports.append(port)
servers = []
for port in ports:
servers.append(self.create_server_with_flags("-p", str(port)))
cluster = gather(*servers)
await cluster
async def run_tests(self, uri, func):
"""Run the tests on each server."""
for server in self.servers:

View File

@ -85,3 +85,15 @@ class BootUpTC(MTTClusterTC):
) as response:
self.assertIn(SESSION_KEY, response.cookies)
self.assertNotEqual(response.cookies[SESSION_KEY].value, value)
async def test_sessions_are_shared_between_servers(self):
"""Does the session apply to the cluster."""
await self.create_cluster()
ids = []
def tests(response):
if SESSION_KEY in response.cookies:
ids.append(response.cookies[SESSION_KEY].value)
await self.run_tests("/", tests)
self.assertEqual(len(ids), 1, "Session info should be shared to the cluster.")