@@ -149,11 +149,21 @@ def test_get_orchestration_state_by_max_instance_count():
149149 c = DurableTaskSchedulerClient (host_address = endpoint , secure_channel = True ,
150150 taskhub = taskhub_name , token_credential = None )
151151
152- # Query with max_instance_count
152+ # Create at least 3 orchestrations to test the limit
153+ ids = []
154+ for i in range (3 ):
155+ id = c .schedule_new_orchestration (empty_orchestrator , input = f"Test{ i } " )
156+ ids .append (id )
157+
158+ # Wait for all to complete
159+ for id in ids :
160+ c .wait_for_orchestration_completion (id , timeout = 30 )
161+
162+ # Query with max_instance_count=2
153163 orchestrations = c .get_orchestration_state_by (max_instance_count = 2 )
154164
155- # Should return at most 2 instances
156- assert len (orchestrations ) < = 2
165+ # Should return exactly 2 instances since we created at least 3
166+ assert len (orchestrations ) = = 2
157167
158168
159169def test_purge_orchestration ():
@@ -374,20 +384,19 @@ def simple_entity(ctx: entities.EntityContext, _):
374384
375385
376386def test_clean_entity_storage ():
377- def empty_entity (ctx : entities .EntityContext , _ ):
378- if ctx .operation == "delete" :
379- ctx .delete_state ()
387+ class EmptyEntity (entities .DurableEntity ):
388+ pass
380389
381390 with DurableTaskSchedulerWorker (host_address = endpoint , secure_channel = True ,
382391 taskhub = taskhub_name , token_credential = None ) as w :
383- w .add_entity (empty_entity )
392+ w .add_entity (EmptyEntity )
384393 w .start ()
385394
386395 c = DurableTaskSchedulerClient (host_address = endpoint , secure_channel = True ,
387396 taskhub = taskhub_name , token_credential = None )
388397
389398 # Create an entity and then delete its state to make it empty
390- entity_id = entities .EntityInstanceId ("empty_entity " , "toClean" )
399+ entity_id = entities .EntityInstanceId ("EmptyEntity " , "toClean" )
391400 c .signal_entity (entity_id , "delete" )
392401 time .sleep (2 ) # Wait for signal to be processed
393402
@@ -397,6 +406,5 @@ def empty_entity(ctx: entities.EntityContext, _):
397406 release_orphaned_locks = True
398407 )
399408
400- # Verify clean result
409+ # Verify clean result - we expect at least the entity we just deleted to be removed
401410 assert result .empty_entities_removed >= 0
402- assert result .orphaned_locks_released >= 0
0 commit comments