Fix stub in redis shared examples
What does this MR do and why?
This MR adds a stub for config_file_name
within the #fetch_config
to point to the temp directory.
Running the specs locally lead to errors. Try bundle exec rspec spec/lib/gitlab/redis/sessions_spec.rb
on the master
branch.
Failures:
1) Gitlab::Redis::Sessions behaves like redis_new_instance_shared_examples behaves like redis_shared_examples #fetch_config when no config file exsits returns nil
Failure/Error: expect(subject).to eq(nil)
expected: nil
got: "unix:/Users/sylvesterchin/work/gitlab-development-kit/redis/redis.socket?db=15"
(compared using ==)
Shared Example Group: "redis_shared_examples" called from ./spec/support/redis/redis_new_instance_shared_examples.rb:17
Shared Example Group: "redis_new_instance_shared_examples" called from ./spec/lib/gitlab/redis/sessions_spec.rb:6
# ./spec/support/redis/redis_shared_examples.rb:436:in `block (4 levels) in <main>'
# ./spec/spec_helper.rb:509:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:18:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:501:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:497:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:59:in `with_raw_context'
# ./spec/spec_helper.rb:497:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:239:in `block (2 levels) in <top (required)>'
# ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:108:in `block (3 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:62:in `with_cross_joins_prevented'
# ./spec/support/database/prevent_cross_joins.rb:108:in `block (2 levels) in <main>'
2) Gitlab::Redis::Sessions behaves like redis_new_instance_shared_examples behaves like redis_shared_examples #fetch_config when no config file exsits but resque.yml exists returns the config from resque.yml
Failure/Error: expect(subject).to eq({ 'foobar' => 123 })
expected: {"foobar"=>123}
got: "unix:/Users/sylvesterchin/work/gitlab-development-kit/redis/redis.socket?db=15"
(compared using ==)
Diff:
@@ -1 +1 @@
-"foobar" => 123,
+"unix:/Users/sylvesterchin/work/gitlab-development-kit/redis/redis.socket?db=15"
Shared Example Group: "redis_shared_examples" called from ./spec/support/redis/redis_new_instance_shared_examples.rb:17
Shared Example Group: "redis_new_instance_shared_examples" called from ./spec/lib/gitlab/redis/sessions_spec.rb:6
# ./spec/support/redis/redis_shared_examples.rb:448:in `block (5 levels) in <main>'
# ./spec/spec_helper.rb:509:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:18:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:501:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:497:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:59:in `with_raw_context'
# ./spec/spec_helper.rb:497:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:239:in `block (2 levels) in <top (required)>'
# ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:108:in `block (3 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:62:in `with_cross_joins_prevented'
# ./spec/support/database/prevent_cross_joins.rb:108:in `block (2 levels) in <main>'
Finished in 7.79 seconds (files took 13.24 seconds to load)
52 examples, 2 failures
Using the rubymine debugger, it seems that within #fetch_config
context, config_file_name
would return the actual Rails root rather than the stubbed one introduced by https://gitlab.com/gitlab-org/gitlab/-/blob/master/spec/support/redis/redis_shared_examples.rb#L22.
Declaring the stub again in #fetch_config
context would resolve the issue. I'm unsure why it isn't causing failures in the CI. Perhaps it is because config/redis.xxx.yml
are not present (https://gitlab.com/gitlab-org/gitlab/-/blob/master/scripts/prepare_build.sh#L39) ?
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.