DEV: Better clean up for PostgreSQL failover test.
This commit is contained in:
parent
5374a0e720
commit
4163f9e61e
|
@ -7,6 +7,7 @@ class SidekiqPauser
|
|||
|
||||
def pause!
|
||||
redis.setex paused_key, 60, "paused"
|
||||
|
||||
@mutex.synchronize do
|
||||
@extend_lease_thread ||= extend_lease_thread
|
||||
sleep 0.001 while !paused?
|
||||
|
@ -35,7 +36,7 @@ class SidekiqPauser
|
|||
while true do
|
||||
break unless @mutex.synchronize { @extend_lease_thread }
|
||||
redis.expire paused_key, 60
|
||||
sleep 30
|
||||
sleep(Rails.env.test? ? 0.01 : 30)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,6 +27,7 @@ describe ActiveRecord::ConnectionHandling do
|
|||
let(:postgresql_fallback_handler) { PostgreSQLFallbackHandler.instance }
|
||||
|
||||
before do
|
||||
@threads = Thread.list
|
||||
postgresql_fallback_handler.initialized = true
|
||||
|
||||
['default', multisite_db].each do |db|
|
||||
|
@ -35,10 +36,13 @@ describe ActiveRecord::ConnectionHandling do
|
|||
end
|
||||
|
||||
after do
|
||||
Sidekiq.unpause!
|
||||
postgresql_fallback_handler.setup!
|
||||
Discourse.disable_readonly_mode(Discourse::PG_READONLY_MODE_KEY)
|
||||
ActiveRecord::Base.unstub(:postgresql_connection)
|
||||
ActiveRecord::Base.establish_connection
|
||||
|
||||
(Thread.list - @threads).each(&:join)
|
||||
end
|
||||
|
||||
describe "#postgresql_fallback_connection" do
|
||||
|
|
Loading…
Reference in New Issue