Skip to content

Commit 8aa5903

Browse files
committed
Stop suites from starting and stopping each other's workers
scan_for_annotated_workers makes a TaskHandler start a worker for every @worker_task/@WorkerTask in every imported test module -- both decorators share one registry -- not just the calling suite's. In one CI run the core bucket showed it plainly: Discovered 8 annotated worker(s): ['async_basic_475f576a', ..., 'v2_fallback_task_a_84d0a6cf', 'v2_fallback_task_b_84d0a6cf'] Two different RUN_IDs: test_comprehensive_e2e's handler was running the v2-fallback workers 13s before that suite started, and each suite's teardown stopped the other's workers. A task whose worker disappears sits in SCHEDULED until it ages out, which surfaces later as the opaque "workflow expected to be COMPLETED, but received RUNNING" and as "0 completed, 0 failed, 5 pending" -- the two failures that have been taking down runs that are otherwise green. Pass each suite the workers it actually drives, filtered from get_registered_workers() by name, and turn scanning off. This is the pattern test_async_lease_extension already uses, whose comment describes this exact symptom. test_workflow_execution keeps import_modules so the decorators still register in spawned children; it just no longer adopts everything they registered.
1 parent 6baa86e commit 8aa5903

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

‎tests/integration/test_v2_fallback_intg.py‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
2020

21-
from conductor.client.automator.task_handler import TaskHandler
21+
from conductor.client.automator.task_handler import TaskHandler, get_registered_workers
2222
from conductor.client.configuration.configuration import Configuration
2323
from conductor.client.http.models.start_workflow_request import StartWorkflowRequest
2424
from conductor.client.http.models.workflow_def import WorkflowDef
@@ -129,9 +129,20 @@ def test_1_workflows_complete_with_v2_or_fallback(self):
129129
handler_ref = {}
130130

131131
def _run_workers():
132+
# Only this module's two workers. With scan_for_annotated_workers
133+
# every TaskHandler in the session starts a worker for every
134+
# @worker_task in every imported test module -- so this suite was
135+
# running test_comprehensive_e2e's workers, and its handler was
136+
# running ours, each stopping the other's on teardown. Same pattern
137+
# as test_async_lease_extension.
138+
workers = [
139+
w for w in get_registered_workers()
140+
if w.get_task_definition_name() in (TASK_A, TASK_B)
141+
]
132142
handler = TaskHandler(
143+
workers=workers,
133144
configuration=self.config,
134-
scan_for_annotated_workers=True,
145+
scan_for_annotated_workers=False,
135146
)
136147
handler_ref["h"] = handler
137148
handler.start_processes()

‎tests/integration/workflow/test_workflow_execution.py‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import time
33
from time import sleep
44

5-
from conductor.client.automator.task_handler import TaskHandler
5+
from conductor.client.automator.task_handler import TaskHandler, get_registered_workers
66
from conductor.client.configuration.configuration import Configuration
77
from conductor.client.http.models import StartWorkflowRequest
88
from conductor.client.http.models import TaskDef
@@ -19,6 +19,9 @@
1919
TASK_NAME = "python_integration_test_task"
2020
WORKFLOW_VERSION = 1234
2121
WORKFLOW_OWNER_EMAIL = "test@test"
22+
# Decorated workers this module drives, pulled from the shared decorator
23+
# registry by name instead of scanning everything that happens to be imported.
24+
DECORATED_TASK_NAMES = ('test_python_decorated_worker',)
2225
COMPLEX_WF_NAME = 'complex_wf_signal_test'
2326
SUB_WF_1_NAME = 'complex_wf_signal_test_subworkflow_1'
2427
SUB_WF_2_NAME = 'complex_wf_signal_test_subworkflow_2'
@@ -47,10 +50,20 @@ def run_workflow_execution_tests(configuration: Configuration, workflow_executor
4750
generate_worker(worker_with_task_input_and_generic_output),
4851
generate_worker(worker_with_task_input_and_task_result_output),
4952
]
53+
# Add only the decorated workers this module actually drives. Scanning would
54+
# start one for every @worker_task/@WorkerTask in every imported test module
55+
# (both decorators share one registry), so this handler was starting other
56+
# suites' workers and stopping them again on teardown -- which strands their
57+
# tasks in SCHEDULED and surfaces as "workflow expected to be COMPLETED, but
58+
# received RUNNING". Same pattern as test_async_lease_extension.
59+
workers += [
60+
w for w in get_registered_workers()
61+
if w.get_task_definition_name() in DECORATED_TASK_NAMES
62+
]
5063
task_handler = TaskHandler(
5164
workers=workers,
5265
configuration=configuration,
53-
scan_for_annotated_workers=True,
66+
scan_for_annotated_workers=False,
5467
import_modules=['tests.integration.resources.worker.python.python_worker']
5568
)
5669
task_handler.start_processes()

0 commit comments

Comments
 (0)