Move RedisClient::Cluster::Router double into context block
What does this MR do and why?
This MR moves the stub definition into the context that use it to better scope.
This is meant to resolve leakage of the instance double into another example:
#<InstanceDouble(RedisClient::Cluster::Router) (anonymous)> was originally created in one example but has leaked into another example and can no longer be used. rspec-mocks' doubles are designed to only last for one example, and you need to create a new one in each example you wish to use it for.
Addresses gitlab-org/quality/engineering-productivity/master-broken-incidents#7457 (closed)
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
On master branch, run bin/rspec spec/lib/gitlab/redis/rate_limiting_spec.rb spec/lib/gitlab/redis/cluster_util_spec.rb
Expect a bunch of failures as seen:
Failed examples:
rspec ./spec/lib/gitlab/redis/cluster_util_spec.rb:105 # Gitlab::Redis::ClusterUtil.batch_get gets multiple keys
rspec './spec/lib/gitlab/redis/cluster_util_spec.rb[1:2:1:1:1]' # Gitlab::Redis::ClusterUtil.batch_get behaves like batches pipelined commands behaves like batches commands calls pipelined multiple times
rspec './spec/lib/gitlab/redis/cluster_util_spec.rb[1:2:1:2:1:1]' # Gitlab::Redis::ClusterUtil.batch_get behaves like batches pipelined commands when larger than batch limit behaves like batches commands calls pipelined multiple times
rspec './spec/lib/gitlab/redis/cluster_util_spec.rb[1:2:1:3:1:1]' # Gitlab::Redis::ClusterUtil.batch_get behaves like batches pipelined commands when smaller than batch limit behaves like batches commands calls pipelined multiple times
rspec ./spec/lib/gitlab/redis/cluster_util_spec.rb:147 # Gitlab::Redis::ClusterUtil.batch_unlink unlinks multiple keys
rspec './spec/lib/gitlab/redis/cluster_util_spec.rb[1:4:2:1:1]' # Gitlab::Redis::ClusterUtil.batch_unlink behaves like batches pipelined commands behaves like batches commands calls pipelined multiple times
rspec './spec/lib/gitlab/redis/cluster_util_spec.rb[1:4:2:2:1:1]' # Gitlab::Redis::ClusterUtil.batch_unlink behaves like batches pipelined commands when larger than batch limit behaves like batches commands calls pipelined multiple times
rspec './spec/lib/gitlab/redis/cluster_util_spec.rb[1:4:2:3:1:1]' # Gitlab::Redis::ClusterUtil.batch_unlink behaves like batches pipelined commands when smaller than batch limit behaves like batches commands calls pipelined multiple times
rspec ./spec/lib/gitlab/redis/cluster_util_spec.rb:125 # Gitlab::Redis::ClusterUtil.batch_del deletes multiple keys
rspec './spec/lib/gitlab/redis/cluster_util_spec.rb[1:3:2:1:1]' # Gitlab::Redis::ClusterUtil.batch_del behaves like batches pipelined commands behaves like batches commands calls pipelined multiple times
rspec './spec/lib/gitlab/redis/cluster_util_spec.rb[1:3:2:2:1:1]' # Gitlab::Redis::ClusterUtil.batch_del behaves like batches pipelined commands when larger than batch limit behaves like batches commands calls pipelined multiple times
rspec './spec/lib/gitlab/redis/cluster_util_spec.rb[1:3:2:3:1:1]' # Gitlab::Redis::ClusterUtil.batch_del behaves like batches pipelined commands when smaller than batch limit behaves like batches commands calls pipelined multiple times
Repeat the spec on this branch. Both should pass without errors.
Edited by Sylvester Chin