Commit 0de568d9 authored by Bob Van Landuyt's avatar Bob Van Landuyt Committed by Rémy Coutable

Clear Redis-queues on Sidekiq::Testing.inline!

Since in specs we run though all the middleware for Sidekiq jobs, and
that Sidekiq middleware writes to Redis for job deduplication we
should clear that Redis before and after each spec to make sure that
the idempotency keys don't bleed into other specs.

The client middleware for job-deduplication writes a key to redis. The
server middleware removes it again before running the job. If the
spec were to get interrupted between these 2 steps, then the key could
remain in Redis causing failures on the next run in development.
parent 7dadf9b8
# frozen_string_literal: true
RSpec.configure do |config|
def gitlab_sidekiq_inline(&block)
# We need to cleanup the queues before running jobs in specs because the
# middleware might have written to redis
redis_queues_cleanup!
Sidekiq::Testing.inline!(&block)
ensure
redis_queues_cleanup!
end
# As we'll review the examples with this tag, we should either:
# - fix the example to not require Sidekiq inline mode (and remove this tag)
# - explicitly keep the inline mode and change the tag for `:sidekiq_inline` instead
config.around(:example, :sidekiq_might_not_need_inline) do |example|
Sidekiq::Testing.inline! { example.run }
gitlab_sidekiq_inline { example.run }
end
config.around(:example, :sidekiq_inline) do |example|
Sidekiq::Testing.inline! { example.run }
gitlab_sidekiq_inline { example.run }
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment