DEV: Clean up more state in between system tests (#23009)

Why this change?

By default in the test environment, MessageBus used the memory backend
which means all messages are stored in an in-memory data structure. However,
the in-memory data structure is not cleared after each system test so we
have the potential to be leaking stuff between system tests.

Similarly for the defer queue which process work in another thread, we
want to ensure that the defer queue processes everything it has to do
before the transaction is rolled back.
This commit is contained in:
Alan Guo Xiang Tan 2023-08-10 07:32:27 +08:00 committed by GitHub
parent 8ce7f260d7
commit 7954d34448
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -509,6 +509,8 @@ RSpec.configure do |config|
end
page.execute_script("if (typeof MessageBus !== 'undefined') { MessageBus.stop(); }")
MessageBus.backend_instance.reset! # Clears all existing backlog from memory backend
Scheduler::Defer.do_all_work # Process everything that was added to the defer queue when running the test
Capybara.reset_sessions!
Capybara.use_default_driver
Discourse.redis.flushdb