Skip to content

Commit

Permalink
fix cluster test to run within delay context
Browse files Browse the repository at this point in the history
  • Loading branch information
kristjanvalur committed Apr 14, 2023
1 parent cf07d75 commit 57d6fda
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions tests/test_asyncio/test_cwe_404.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,18 @@ def set_delay(delay: int = 0):
await r.set("foo", "foo")
await r.set("bar", "bar")

async def op(r):
with set_delay(delay=delay):
return await r.get("foo")

all_clear()
with set_delay(delay=delay):
t = asyncio.create_task(r.get("foo"))
# One of the proxies will handle our request, wait for it to send
await any_wait()
await asyncio.sleep(delay)
t.cancel()
with pytest.raises(asyncio.CancelledError):
await t
t = asyncio.create_task(op(r))
# One of the proxies will handle our request, wait for it to send
await any_wait()
await asyncio.sleep(delay)
t.cancel()
with pytest.raises(asyncio.CancelledError):
await t

# try a number of requests to excercise all the connections
async def doit():
Expand Down

0 comments on commit 57d6fda

Please sign in to comment.