From e9ed0cfbb4ab594113845c78ef625196c1f32fbb Mon Sep 17 00:00:00 2001 From: s5u13b Date: Mon, 21 Oct 2024 08:17:14 +0000 Subject: [PATCH] Fix unit test of dispatch scheduler --- .../unit_test/global_scheduler/test_dispatch_scheduler.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/unit_test/global_scheduler/test_dispatch_scheduler.py b/tests/unit_test/global_scheduler/test_dispatch_scheduler.py index 8cee3a69..2398d97f 100644 --- a/tests/unit_test/global_scheduler/test_dispatch_scheduler.py +++ b/tests/unit_test/global_scheduler/test_dispatch_scheduler.py @@ -46,7 +46,10 @@ def test_add_instance_and_remove_instance(dispatch_scheduler): dispatch_scheduler.remove_instance('instance_2') assert dispatch_scheduler.num_instances == 1 - assert len(dispatch_scheduler.available_dispatch_instance_set) == 1 + if dispatch_scheduler.num_dispatch_instances >= 2: + assert len(dispatch_scheduler.available_dispatch_instance_set) == 1 + else: + assert len(dispatch_scheduler.available_dispatch_instance_set) == 0 dispatch_scheduler.remove_instance('instance_3') assert dispatch_scheduler.num_instances == 0 @@ -99,7 +102,7 @@ def test_dispatch_queue(): instance_info.instance_id = instance_id instance_info.num_waiting_requests = random.randint(1, 10) instance_info_dict[instance_id] = instance_info - if len(dispatch_scheduler.available_dispatch_instance_set) < dispatch_scheduler.num_dispatch_instances: + if len(dispatch_scheduler.available_dispatch_instance_set) < dispatch_scheduler.num_dispatch_instances: dispatch_scheduler.available_dispatch_instance_set.add(instance_id) instance_num_requests[instance_id] = 0 dispatch_scheduler.instance_num_requests = instance_num_requests