diff --git a/amber/src/main/python/core/util/customized_queue/linked_blocking_multi_queue.py b/amber/src/main/python/core/util/customized_queue/linked_blocking_multi_queue.py index fcf175d6bcd..629fe92d6c6 100644 --- a/amber/src/main/python/core/util/customized_queue/linked_blocking_multi_queue.py +++ b/amber/src/main/python/core/util/customized_queue/linked_blocking_multi_queue.py @@ -421,9 +421,12 @@ def add_sub_queue(self, key: K, priority: int) -> Optional[SubQueue]: added = True break elif pg.priority > priority: + # pg has a lower priority than the new group, so the new + # group belongs in front of it: priority_groups must stay + # sorted because the selection strategy walks it in order. new_pg = self.PriorityGroup(priority) new_pg.add_queue(sub_queue) - self.priority_groups.append(new_pg) + self.priority_groups.insert(i, new_pg) added = True break diff --git a/amber/src/test/python/core/models/test_internal_queue.py b/amber/src/test/python/core/models/test_internal_queue.py index 663f95d89a8..50797f69c2d 100644 --- a/amber/src/test/python/core/models/test_internal_queue.py +++ b/amber/src/test/python/core/models/test_internal_queue.py @@ -116,13 +116,6 @@ def test_it_accepts_all_recognized_element_types( assert queue.is_empty() @pytest.mark.timeout(2) - @pytest.mark.xfail( - reason=( - "LinkedBlockingMultiQueue.add_sub_queue does not currently insert new " - "priority groups ahead of lower-priority ones, so registering data before " - "control can break control-priority ordering." - ) - ) def test_control_elements_dequeue_before_data_even_if_data_channel_registered_first( self, queue, control_channel, data_channel ):