Skip to content

Fix flaky Sidekiq job deletion specs

Stan Hu requested to merge sh-clear-redis-queues-spec into master

What does this MR do and why?

Both ./spec/requests/api/admin/sidekiq_spec.rb and ./spec/requests/api/admin/sidekiq_spec.rb attempt to add similar Sidekiq jobs to a queue and check that they are added. However, if these tests were run together, the second test would fail because the Sidekiq jobs would be deduplicated by the Sidekiq client middleware.

In CI, this occurs because we use Redis Cluster for the queues_metadata Redis cluster, which was not being cleared out despite clean_gitlab_redis_queues being specified in the RSpec metadata.

To avoid this flakiness, implicitly clean up the queues_metadata cluster anytime clean_gitlab_redis_queues is specified or if Sidekiq.redis#flushdb is called.

Relates to #425824 (closed)

How to set up and validate locally

  1. Enable Redis Cluster in the GDK. In gdk.yml, I have:
gdk config set redis_cluster.enabled true
gdk reconfigure
  1. Configure config/redis.yml with test.queues_metadata:
development:
  queues_metadata:
    cluster:
      - "redis://gdk.test:6001"
      - "redis://gdk.test:6002"
      - "redis://gdk.test:6000"

test:
  queues_metadata:
    cluster:
      - "redis://gdk.test:6001"
      - "redis://gdk.test:6002"
      - "redis://gdk.test:6000"
  1. Drop the quarantine: line in spec/requests/api/graphql/mutations/admin/sidekiq_queues/delete_jobs_spec.rb.

  2. Then run:

bundle exec rspec --format documentation "./spec/requests/api/admin/sidekiq_spec.rb[1:1:1:1:1:1:1:1]" "./spec/requests/api/graphql/mutations/admin/sidekiq_queues/delete_jobs_spec.rb[1:2:1:1]"

This will fail in master, but not in this branch.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Stan Hu

Merge request reports