Fix fake connection leaking for Ci::ApplicationRecord
What does this MR do and why?
Fix fake connection leaking for Ci::ApplicationRecord
After the example has run, the Ci::ApplicationRecord#connection_specification_name remained stuck as "Ci::ApplicationRecord" instead of reverting back to "ActiveRecord::Base".
We call model.remove_connection
to fix this.
Also, there is no need to setup a (fake) ci connection, if we already have one
Fixes #345181 (closed)
Screenshots or screen recordings
The minimal set of specs passes under all scenarios:
- With
ci:
configured inconfig/database.yml
- With
ci:
configured inconfig/database.yml
, withGITLAB_LOAD_BALANCING_REUSE_PRIMARY_ci=main
- Without
ci:
configured inconfig/database.yml
$ bundle exec rspec spec/lib/gitlab/database/load_balancing/load_balancer_spec.rb spec/models/acts_as_taggable_on/tagging_spec.rb
Run options: include {:focus=>true}
All examples were filtered out; ignoring {:focus=>true}
Test environment set up in 9.662431 seconds
.................................................
Finished in 15.78 seconds (files took 20.04 seconds to load)
49 examples, 0 failures
These are strongly recommended to assist reviewers and reduce the time to merge your change.
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.
Edited by Thong Kuah