Copilot commented on code in PR #7850:
URL: https://github.com/apache/texera/pull/7850#discussion_r3846663254


##########
amber/src/test/python/core/util/customized_queue/test_linked_blocking_multi_queue.py:
##########
@@ -456,6 +456,59 @@ def test_drops_the_priority_group_once_it_is_empty(self, 
queue):
         assert queue.priority_groups[0].priority == 1
 
 
+class TestAddSubQueue:
+    """Verify that add_sub_queue uses putIfAbsent semantics (issue #7810).
+
+    On a repeated key the existing sub-queue must be kept in the map;
+    a fresh SubQueue must NOT replace it.
+    """
+
+    def test_new_key_returns_none(self):
+        """First registration of a key returns None (no previous mapping)."""
+        lbmq = LinkedBlockingMultiQueue()
+        result = lbmq.add_sub_queue("k", 0)
+        assert result is None
+
+    def test_repeated_key_returns_existing_sub_queue(self):
+        """Second call with the same key returns the original SubQueue 
object."""
+        lbmq = LinkedBlockingMultiQueue()
+        lbmq.add_sub_queue("k", 0)
+        original = lbmq.get_sub_queue("k")
+
+        returned = lbmq.add_sub_queue("k", 0)
+
+        assert returned is original
+
+    def test_repeated_key_keeps_existing_queue_in_map(self):
+        """After a duplicate add the map still holds the original SubQueue."""
+        lbmq = LinkedBlockingMultiQueue()
+        lbmq.add_sub_queue("k", 0)
+        original = lbmq.get_sub_queue("k")
+
+        lbmq.add_sub_queue("k", 0)
+
+        assert lbmq.get_sub_queue("k") is original
+
+    def test_repeated_key_priority_group_is_not_none(self):
+        """The sub-queue kept in the map must still be attached to a priority 
group."""
+        lbmq = LinkedBlockingMultiQueue()
+        lbmq.add_sub_queue("k", 0)
+
+        lbmq.add_sub_queue("k", 0)
+
+        assert lbmq.get_sub_queue("k").priority_group is not None

Review Comment:
   All duplicate-registration tests pass priority `0` both times, so they do 
not pin the stated requirement that duplicate calls leave the priority groups 
untouched. A regression that keeps the same queue but moves/re-registers it at 
the new priority would still pass these tests. Repeat the key with a different 
priority and assert that the original group remains the only group.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to