diff --git a/features/steps/actor_loading_steps.py b/features/steps/actor_loading_steps.py index ded8f226f..46fc5794e 100644 --- a/features/steps/actor_loading_steps.py +++ b/features/steps/actor_loading_steps.py @@ -443,31 +443,26 @@ def step_when_concurrent_list_actors_with_clear( assert not errors, f"Threads raised exceptions: {errors}" - # Store results for assertion + # Store results and namespace for assertion context._concurrent_list_results = results + context._concurrent_namespace = namespace @then("all concurrent list_actors calls should return consistent results") def step_then_concurrent_results_consistent(context: Context) -> None: """Verify that all concurrent list_actors calls returned consistent results.""" results: list[list[ActorConfigSchema]] = context._concurrent_list_results + namespace: str = context._concurrent_namespace - # All results should either be empty (if clear won) or have the same actors - # The key is that no result should have stale/partial data + # Each result should only contain actors from the requested namespace. + # When clear() runs concurrently, some threads may see the full list while + # others see an empty list, but no result should have stale/partial data. if not results: return - # Check that all results have the same length - lengths = [len(r) for r in results] - assert all(length == lengths[0] for length in lengths), ( - f"Inconsistent result lengths: {lengths}" - ) - - # Check that all results have the same actor names - if results[0]: # If not empty - first_names = {c.name for c in results[0]} - for i, result in enumerate(results[1:], 1): - result_names = {c.name for c in result} - assert result_names == first_names, ( - f"Result {i} has different actors: {result_names} vs {first_names}" + # Check that each result only contains actors from the requested namespace + for i, result in enumerate(results): + for actor_config in result: + assert actor_config.name.startswith(f"{namespace}/"), ( + f"Result {i} contains actor from wrong namespace: {actor_config.name}" )