Skip to content

Commit d5642db

Browse files
authored
Test Strands with unique task queues (#1729)
1 parent b1325ad commit d5642db

9 files changed

Lines changed: 15 additions & 14 deletions

tests/contrib/strands/test_hooks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ async def run(self, prompt: str) -> list[str]:
6767

6868
async def test_hooks(client: Client):
6969
_AUDIT_LOG.clear()
70-
task_queue = "test_hooks"
70+
task_queue = f"test_hooks-{uuid4()}"
7171
plugin = StrandsPlugin(
7272
models={
7373
"mock": lambda: MockModel(

tests/contrib/strands/test_interrupt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ async def run(self, prompt: str) -> str:
6565

6666

6767
async def test_interrupt(client: Client):
68-
task_queue = "test_interrupt"
68+
task_queue = f"test_interrupt-{uuid4()}"
6969
plugin = StrandsPlugin(
7070
models={
7171
"mock": lambda: MockModel(

tests/contrib/strands/test_interrupt_exception.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ async def run(self, prompt: str) -> str:
9999

100100

101101
async def test_in_workflow_tool_interrupt(client: Client):
102-
task_queue = "test_in_workflow_tool_interrupt"
102+
task_queue = f"test_in_workflow_tool_interrupt-{uuid4()}"
103103
plugin = StrandsPlugin(
104104
models={
105105
"mock": lambda: MockModel(
@@ -140,7 +140,7 @@ async def test_in_workflow_tool_interrupt(client: Client):
140140
async def test_activity_tool_interrupt(client: Client):
141141
global _activity_delete_calls
142142
_activity_delete_calls = 0
143-
task_queue = "test_activity_tool_interrupt"
143+
task_queue = f"test_activity_tool_interrupt-{uuid4()}"
144144
plugin = StrandsPlugin(
145145
models={
146146
"mock": lambda: MockModel(

tests/contrib/strands/test_invocation_state.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,12 @@ async def run(self, prompt: str) -> str:
5858

5959
async def test_invocation_state_round_trip(client: Client):
6060
_RECEIVED.clear()
61+
task_queue = f"test_invocation_state-{uuid4()}"
6162
plugin = StrandsPlugin(models={"recording": lambda: _RecordingModel()})
6263

6364
async with Worker(
6465
client,
65-
task_queue="test_invocation_state",
66+
task_queue=task_queue,
6667
workflows=[_InvocationStateWorkflow],
6768
plugins=[plugin],
6869
max_cached_workflows=0,
@@ -71,7 +72,7 @@ async def test_invocation_state_round_trip(client: Client):
7172
_InvocationStateWorkflow.run,
7273
"hi",
7374
id=f"test_invocation_state_{uuid4()}",
74-
task_queue="test_invocation_state",
75+
task_queue=task_queue,
7576
)
7677

7778
# The serializable key crosses the activity boundary; the non-serializable

tests/contrib/strands/test_mcp.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async def run(self, prompt: str) -> str:
5252

5353

5454
async def test_mcp(client: Client):
55-
task_queue = "test_mcp"
55+
task_queue = f"test_mcp-{uuid4()}"
5656
plugin = StrandsPlugin(
5757
models={
5858
"mock": lambda: MockModel(
@@ -125,7 +125,7 @@ async def run(self, prompt: str) -> str:
125125

126126
async def test_mcp_reuses_connection(client: Client):
127127
"""Successive MCP tool calls reuse one cached worker-side connection."""
128-
task_queue = "test_mcp_reuses_connection"
128+
task_queue = f"test_mcp_reuses_connection-{uuid4()}"
129129
# Count how often the worker opens a connection. One lazily-opened
130130
# connection serves the list-tools discovery and both tool calls (1);
131131
# reconnecting per call would make it more.
@@ -206,7 +206,7 @@ async def run(self, prompt: str) -> str:
206206

207207
async def test_mcp_connection_idle_timeout(client: Client):
208208
"""A short idle timeout evicts the cached connection while the worker runs."""
209-
task_queue = "test_mcp_connection_idle_timeout"
209+
task_queue = f"test_mcp_connection_idle_timeout-{uuid4()}"
210210
factory_calls = [0]
211211

212212
def counting_factory() -> MCPClient:
@@ -282,7 +282,7 @@ async def run(self, prompt: str) -> str:
282282

283283
async def test_mcp_lists_tools_each_turn_when_uncached(client: Client):
284284
"""With cache_tools=False the tool list is re-fetched on every model call."""
285-
task_queue = "test_mcp_lists_tools_each_turn_when_uncached"
285+
task_queue = f"test_mcp_lists_tools_each_turn_when_uncached-{uuid4()}"
286286
plugin = StrandsPlugin(
287287
models={
288288
"mock": lambda: MockModel(

tests/contrib/strands/test_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async def run(self, prompt: str) -> str:
2424

2525

2626
async def test_model(client: Client):
27-
task_queue = "test_model"
27+
task_queue = f"test_model-{uuid4()}"
2828
plugin = StrandsPlugin(models={"mock": lambda: MockModel(["Done!"])})
2929

3030
async with Worker(

tests/contrib/strands/test_model_streaming.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async def run(self, prompt: str) -> str:
3030

3131

3232
async def test_model_streaming(client: Client):
33-
task_queue = "test_model_streaming"
33+
task_queue = f"test_model_streaming-{uuid4()}"
3434
plugin = StrandsPlugin(models={"mock": lambda: MockModel(["Done!"])})
3535
workflow_id = f"test_model_streaming_{uuid4()}"
3636

tests/contrib/strands/test_structured_output.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async def run(self, prompt: str) -> PersonInfo:
3333

3434

3535
async def test_structured_output(client: Client):
36-
task_queue = "test_structured_output"
36+
task_queue = f"test_structured_output-{uuid4()}"
3737
plugin = StrandsPlugin(
3838
models={
3939
"mock": lambda: MockModel(

tests/contrib/strands/test_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async def run(self, prompt: str) -> str:
5959

6060

6161
async def test_tool(client: Client, tmp_path: Path):
62-
task_queue = "test_tool"
62+
task_queue = f"test_tool-{uuid4()}"
6363
fixture = tmp_path / "greeting.txt"
6464
fixture.write_text("hello\n")
6565

0 commit comments

Comments
 (0)