Skip to content

Commit

Permalink
test: try to deflake rmq delay test
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdanp committed Aug 27, 2023
1 parent 9a107cf commit f23e060
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions tests/test_rabbitmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def record():
assert run_time - start_time >= 1000


def test_rabbitmq_actors_can_delay_messages_independent_of_each_other(rabbitmq_broker, rabbitmq_worker):
def test_rabbitmq_actors_can_delay_messages_independent_of_each_other(rabbitmq_broker):
# Given that I have a database
results = []

Expand All @@ -176,22 +176,26 @@ def test_rabbitmq_actors_can_delay_messages_independent_of_each_other(rabbitmq_b
def append(x):
results.append(x)

# When I pause the worker
rabbitmq_worker.pause()
# And a worker
broker = rabbitmq_broker
worker = Worker(broker, worker_threads=1)

# And I send it a delayed message
append.send_with_options(args=(1,), delay=1500)
try:
# And I send it a delayed message
append.send_with_options(args=(1,), delay=1500)

# And then another delayed message with a smaller delay
append.send_with_options(args=(2,), delay=1000)
# And then another delayed message with a smaller delay
append.send_with_options(args=(2,), delay=1000)

# Then resume the worker and join on the queue
rabbitmq_worker.resume()
rabbitmq_broker.join(append.queue_name, min_successes=20)
rabbitmq_worker.join()
# Then resume the worker and join on the queue
worker.start()
broker.join(append.queue_name, min_successes=20)
worker.join()

# I expect the latter message to have been run first
assert results == [2, 1]
# I expect the latter message to have been run first
assert results == [2, 1]
finally:
worker.stop()


def test_rabbitmq_actors_can_have_retry_limits(rabbitmq_broker, rabbitmq_worker):
Expand Down

0 comments on commit f23e060

Please sign in to comment.