emergency save.
This commit is contained in:
@ -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:
|
||||
|
@ -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.")
|
||||
|
Reference in New Issue
Block a user