Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/integration_tests/test_servercontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
from tests.utils import exhaust_callbacks, fast_forward


async def wait_for_connection_registered(ctx, max_iters=1000):
for _ in range(max_iters):
if ctx.connections:
return
await asyncio.sleep(0)
raise AssertionError(
"Server did not register the connection within the allotted iterations"
)


class MockConnection:
def __init__(self):
self.protocol = None
Expand Down Expand Up @@ -91,6 +101,7 @@ async def test_connection_broken_external(context):
"""
srv, ctx = context
_, writer = await asyncio.open_connection(*srv.sockets[0].getsockname())
await wait_for_connection_registered(ctx)
writer.close()
# Need this sleep for test to work, otherwise closed protocol isn't detected
await asyncio.sleep(0)
Expand Down Expand Up @@ -119,6 +130,7 @@ async def test_unexpected_exception(context, caplog, mocker):

with caplog.at_level("TRACE"):
_, writer = await asyncio.open_connection(*srv.sockets[0].getsockname())
await exhaust_callbacks()

with closing(writer):
assert "Exception in protocol" in caplog.text
Expand All @@ -144,6 +156,7 @@ async def test_unexpected_exception_in_connection_lost(context, caplog):
async def test_drain_connections(context):
srv, ctx = context
_, writer = await asyncio.open_connection(*srv.sockets[0].getsockname())
await wait_for_connection_registered(ctx)

with pytest.raises(asyncio.TimeoutError):
await asyncio.wait_for(
Expand Down
10 changes: 9 additions & 1 deletion tests/integration_tests/test_teammatchmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,15 @@ async def test_info_message(lobby_server):
"mod": "tmm2v2"
})

msg = await read_until_command(proto, "matchmaker_info")
def tmm2v2_populated(msg):
if msg["command"] != "matchmaker_info":
return False
return any(
q["queue_name"] == "tmm2v2" and q["boundary_80s"]
for q in msg.get("queues", [])
)

msg = await read_until(proto, tmm2v2_populated)

assert msg["queues"]
for queue in msg["queues"]:
Expand Down
Loading