Fix order-dependent failure
To reproduce:
bin/rspec spec/tasks/dev_rake_spec.rb spec/tasks/gitlab/setup_rake_spec.rb
The latter spec fails because the former spec does not reset the env var.
Failure on master
$ bin/rspec spec/tasks/dev_rake_spec.rb spec/tasks/gitlab/setup_rake_spec.rb
Run options: include {:focus=>true}
All examples were filtered out; ignoring {:focus=>true}
==> GitLab Workhorse set up in 8.472107 seconds...
==> Gitaly set up in 50.662004 seconds...
Test environment set up in 58.523113 seconds
...........F.
Failures:
1) gitlab:setup namespace rake tasks setup when the task is aborted exits without setting up the database
Got 5 failures:
1.1) Failure/Error: Rake::Task["dev:terminate_all_connections"].invoke unless Rails.env.production?
(<Rake::Task dev:terminate_all_connections => []>).invoke(no args)
expected: 0 times with any arguments
received: 1 time
# ./lib/tasks/gitlab/setup.rake:33:in `setup_db'
# ./lib/tasks/gitlab/setup.rake:7:in `block (2 levels) in <main>'
# ./spec/support/helpers/rake_helpers.rb:6:in `run_rake_task'
# ./spec/tasks/gitlab/setup_rake_spec.rb:14:in `block (3 levels) in <main>'
# ./spec/tasks/gitlab/setup_rake_spec.rb:82:in `block (5 levels) in <main>'
# ./spec/tasks/gitlab/setup_rake_spec.rb:82:in `block (4 levels) in <main>'
# ./spec/spec_helper.rb:423:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:414:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:410:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:48:in `with_raw_context'
# ./spec/spec_helper.rb:410:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:268: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:106:in `block (3 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:60:in `with_cross_joins_prevented'
# ./spec/support/database/prevent_cross_joins.rb:106:in `block (2 levels) in <main>'
1.2) Failure/Error: Rake::Task["db:reset"].invoke
(<Rake::Task db:reset => [db:drop, db:setup]>).invoke(no args)
expected: 0 times with any arguments
received: 1 time
# ./lib/tasks/gitlab/setup.rake:35:in `setup_db'
# ./lib/tasks/gitlab/setup.rake:7:in `block (2 levels) in <main>'
# ./spec/support/helpers/rake_helpers.rb:6:in `run_rake_task'
# ./spec/tasks/gitlab/setup_rake_spec.rb:14:in `block (3 levels) in <main>'
# ./spec/tasks/gitlab/setup_rake_spec.rb:82:in `block (5 levels) in <main>'
# ./spec/tasks/gitlab/setup_rake_spec.rb:82:in `block (4 levels) in <main>'
# ./spec/spec_helper.rb:423:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:414:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:410:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:48:in `with_raw_context'
# ./spec/spec_helper.rb:410:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:268: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:106:in `block (3 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:60:in `with_cross_joins_prevented'
# ./spec/support/database/prevent_cross_joins.rb:106:in `block (2 levels) in <main>'
1.3) Failure/Error: Rake::Task["db:seed_fu"].invoke
(<Rake::Task db:seed_fu => [environment]>).invoke(no args)
expected: 0 times with any arguments
received: 1 time
# ./lib/tasks/gitlab/setup.rake:36:in `setup_db'
# ./lib/tasks/gitlab/setup.rake:7:in `block (2 levels) in <main>'
# ./spec/support/helpers/rake_helpers.rb:6:in `run_rake_task'
# ./spec/tasks/gitlab/setup_rake_spec.rb:14:in `block (3 levels) in <main>'
# ./spec/tasks/gitlab/setup_rake_spec.rb:82:in `block (5 levels) in <main>'
# ./spec/tasks/gitlab/setup_rake_spec.rb:82:in `block (4 levels) in <main>'
# ./spec/spec_helper.rb:423:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:414:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:410:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:48:in `with_raw_context'
# ./spec/spec_helper.rb:410:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:268: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:106:in `block (3 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:60:in `with_cross_joins_prevented'
# ./spec/support/database/prevent_cross_joins.rb:106:in `block (2 levels) in <main>'
1.4) Failure/Error:
expect { setup_task }.to output(/Quitting/).to_stdout
.and raise_error(SystemExit) { |error| expect(error.status).to eq(1) }
expected block to output /Quitting/ to stdout, but output nothing
...and:
expected SystemExit but nothing was raised
# ./spec/tasks/gitlab/setup_rake_spec.rb:82:in `block (4 levels) in <main>'
# ./spec/spec_helper.rb:423:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:414:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:410:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:48:in `with_raw_context'
# ./spec/spec_helper.rb:410:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:268: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:106:in `block (3 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:60:in `with_cross_joins_prevented'
# ./spec/support/database/prevent_cross_joins.rb:106:in `block (2 levels) in <main>'
1.5) Failure/Error: expect(main_object).to receive(:ask_to_continue).and_raise(Gitlab::TaskAbortedByUserError)
(main).ask_to_continue(*(any args))
expected: 1 time with any arguments
received: 0 times with any arguments
# ./spec/tasks/gitlab/setup_rake_spec.rb:77:in `block (4 levels) in <main>'
# ./spec/spec_helper.rb:423:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:414:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:410:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:48:in `with_raw_context'
# ./spec/spec_helper.rb:410:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:268: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:106:in `block (3 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:60:in `with_cross_joins_prevented'
# ./spec/support/database/prevent_cross_joins.rb:106:in `block (2 levels) in <main>'
Finished in 1 minute 5.25 seconds (files took 22.75 seconds to load)
13 examples, 1 failure
Failed examples:
rspec ./spec/tasks/gitlab/setup_rake_spec.rb:74 # gitlab:setup namespace rake tasks setup when the task is aborted exits without setting up the database
Edited by Thong Kuah