Skip to content

Commit

Permalink
Add integration test for broadcast mode with consumers having differe…
Browse files Browse the repository at this point in the history
…nt subscriptions and priorities (#418)

Signed-off-by: Dmitrii Petukhov <[email protected]>
  • Loading branch information
bbpetukhov authored Sep 11, 2024
1 parent 538776c commit 5aaf596
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/integration-tests/test_subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
- test_non_overlapping
- test_priorities
- test_fanout
- test_broadcast
- test_round_robin
- test_redelivery
- test_max_unconfirmed
Expand Down Expand Up @@ -737,6 +738,41 @@ def test_fanout(cluster: Cluster):
consumer.expect_messages(expected, confirm=True)


def test_broadcast(cluster: Cluster):
"""
Test: subscriptions work in broadcast mode.
- Create 1 producer
- Create 4 consumers with 2 different priorities.
- Open 1 broadcast queue, the subscription expressions are different for
each high priority consumer.
- Produce messages with different properties to the queue.
- Expect messages to be received by the high priority consumers
in respect with their subscriptions.
- No need to confirm messages in broadcast mode.
"""
uri = tc.URI_BROADCAST

producer = Producer(cluster, uri)
# Consumer matching all messages, but having not the highest priority
consumer_low_priority = Consumer(cluster, uri, ["x >= 0"], consumer_priority=0)

consumer_gteq_0 = Consumer(cluster, uri, ["x >= 0"], consumer_priority=1)

consumer_less_100 = Consumer(cluster, uri, ["x < 100"], consumer_priority=1)

consumer_gteq_100 = Consumer(cluster, uri, ["x >= 100"], consumer_priority=1)

expected_less_100 = [producer.post(x=x) for x in range(50, 55)]
expected_gteq_100 = [producer.post(x=x) for x in range(100, 105)]

consumer_low_priority.expect_empty()
consumer_gteq_0.expect_messages(
expected_less_100 + expected_gteq_100, confirm=False
)
consumer_less_100.expect_messages(expected_less_100, confirm=False)
consumer_gteq_100.expect_messages(expected_gteq_100, confirm=False)


def test_round_robin(cluster: Cluster):
"""
Test: round-robin routing of messages with subscriptions.
Expand Down

0 comments on commit 5aaf596

Please sign in to comment.