Skip to content

Commit ba3d50f

Browse files
authored
Add a test for split worker scenario (#1193)
* Add a test for split worker scenario * Formatting * Fix Test
1 parent 8f754b4 commit ba3d50f

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/contrib/openai_agents/test_openai.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2701,3 +2701,42 @@ async def test_local_hello_world_agent(client: Client):
27012701
if e.HasField("marker_recorded_event_attributes"):
27022702
local_activity_found = True
27032703
assert local_activity_found
2704+
2705+
2706+
async def test_split_workers(client: Client):
2707+
new_config = client.config()
2708+
2709+
workflow_plugin = openai_agents.OpenAIAgentsPlugin(
2710+
model_params=ModelActivityParameters(
2711+
start_to_close_timeout=timedelta(seconds=30)
2712+
),
2713+
model_provider=TestModelProvider(TestHelloModel()),
2714+
register_activities=False,
2715+
)
2716+
new_config["plugins"] = [workflow_plugin]
2717+
workflow_client = Client(**new_config)
2718+
2719+
# Workflow worker
2720+
async with new_worker(
2721+
workflow_client, HelloWorldAgent, no_remote_activities=True
2722+
) as worker:
2723+
activity_plugin = openai_agents.OpenAIAgentsPlugin(
2724+
model_params=ModelActivityParameters(
2725+
start_to_close_timeout=timedelta(seconds=30)
2726+
),
2727+
model_provider=TestModelProvider(TestHelloModel()),
2728+
)
2729+
new_config["plugins"] = [activity_plugin]
2730+
activity_client = Client(**new_config)
2731+
# Activity Worker
2732+
async with new_worker(
2733+
activity_client, task_queue=worker.task_queue
2734+
) as activity_worker:
2735+
result = await activity_client.execute_workflow(
2736+
HelloWorldAgent.run,
2737+
"Tell me about recursion in programming.",
2738+
id=f"hello-workflow-{uuid.uuid4()}",
2739+
task_queue=worker.task_queue,
2740+
execution_timeout=timedelta(seconds=120),
2741+
)
2742+
assert result == "test"

0 commit comments

Comments
 (0)