Copilot commented on code in PR #76217:
URL: https://github.com/apache/airflow/pull/76217#discussion_r4744381711
##########
airflow-core/tests/unit/triggers/test_shared_stream.py:
##########
@@ -3086,10 +3089,73 @@ async def
test_group_stop_abandons_unconfirmed_advance():
# the group stops and the advance is abandoned — the broker redelivers.
await manager.unsubscribe(1, key)
assert manager._groups == {}
+ assert manager._seq_owner == {}, "the stopping group must sweep its
unconfirmed seqs from the owner map"
assert cls.advanced == [], "an unconfirmed advance must be abandoned at
group stop"
assert cls.aclose_calls == 1
[email protected]
[email protected](
+ _SharedStreamGroup,
+ "confirm_persisted",
+ autospec=True,
+ side_effect=_SharedStreamGroup.confirm_persisted,
+)
+async def
test_confirm_persisted_routes_seqs_to_owning_group_only(group_confirm_persisted):
+ """A confirmation resolves the seq in the group that drew it; other live
groups are untouched."""
+ cls_a = _make_ack_required_trigger_class([({"n": "a"}, "pa")])
+ cls_b = _make_ack_required_trigger_class([({"n": "b"}, "pb")])
+ for cls in (cls_a, cls_b):
+ cls.advanced.clear()
+ cls.outcomes.clear()
+
+ t_a = cls_a(queue_url="https://qa")
+ t_b = cls_b(queue_url="https://qb")
+ key_a, key_b = t_a.shared_stream_key(), t_b.shared_stream_key()
+ assert key_a != key_b
+ manager = SharedStreamManager()
+ next_a = next_b = None
+ try:
+ s_a = manager.subscribe(trigger_id=1, trigger=t_a, key=key_a)
+ s_b = manager.subscribe(trigger_id=2, trigger=t_b, key=key_b)
+
+ it_a, it_b = s_a.__aiter__(), s_b.__aiter__()
+ await _pull_raw(it_a)
+ seq_a = manager.bind_pending_event(trigger_id=1, key=key_a)
+ await _pull_raw(it_b)
+ seq_b = manager.bind_pending_event(trigger_id=2, key=key_b)
+ assert seq_a is not None
+ assert seq_b is not None
+ assert manager._seq_owner == {seq_a: key_a, seq_b: key_b}
+ group_a, group_b = manager._groups[key_a], manager._groups[key_b]
+
+ next_a = await _resume_past_yield(it_a)
+ next_b = await _resume_past_yield(it_b)
+
+ manager.confirm_persisted([seq_a])
+ group_confirm_persisted.assert_called_once_with(group_a, [seq_a])
Review Comment:
This test confirms each owner's sequence in a separate call, so it never
exercises the new partitioning of one supervisor response across multiple
groups. An implementation that dispatches only the first entry in `seqs_by_key`
would still pass this and the existing single-group batch tests. Please
parametrize the test for separate and mixed-owner batches, asserting that each
group receives only its own sequences, both advances complete, and all
confirmed owner entries are removed.
--
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]