From ff606943cd5f9fd9cc0c26a1b0f3abc96a88e560 Mon Sep 17 00:00:00 2001 From: Stan Hu <stanhu@gmail.com> Date: Tue, 23 Jul 2024 00:39:54 -0700 Subject: [PATCH] Fix order-dependent test failures in Redis/Sidekiq specs Previously the second test would fail if you did this: ``` bundle exec rspec spec/lib/gitlab/redis/queues_spec.rb \ spec/lib/gitlab/sidekiq_queue_spec.rb ``` This happens because the `@instances` class variable is memoized by the first spec with some temporary settings. Clear this out to ensure this doesn't pollute the global state. --- spec/lib/gitlab/redis/queues_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/lib/gitlab/redis/queues_spec.rb b/spec/lib/gitlab/redis/queues_spec.rb index f548bc9f6ff3a..6c9c6e8437250 100644 --- a/spec/lib/gitlab/redis/queues_spec.rb +++ b/spec/lib/gitlab/redis/queues_spec.rb @@ -60,6 +60,10 @@ described_class.remove_instance_variable(:@instances) if described_class.instance_variable_defined?(:@instances) end + after do + described_class.remove_instance_variable(:@instances) if described_class.instance_variable_defined?(:@instances) + end + shared_examples 'no extra shards' do it 'returns a single map of self' do expect(described_class.instances).to eq({ 'main' => described_class }) -- GitLab