You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into a bug where my system tests weren't running as expected when parallelized. I discovered that the Puma threads spawned by Capybara don't have the namespace set (see https://github.com/rails/kredis/blob/57cedf59a50a0ef81779b5259806821fc4a15423/lib/ kredis/railtie.rb#L8). This is because the namespacing is done using Thread.current, and the threads spawned by Puma wouldn't have Thread.current[:kredis_namespace] set.
I have a workaround for my system tests, but it'd be nice if this worked out of the box.
For my workaround, I have a module that my ApplicationSystemTestCase includes:
module KredisNamespaceFix
def self.included(base)
base.class_eval do
setup do
add_kredis_namespace_before_action
end
parallelize_setup do |worker|
Rails.application.config.x.kredis_test_namespace = "test-#{worker}"
end
end
end
def add_kredis_namespace_before_action
ApplicationController.class_eval do
before_action :set_kredis_namespace_for_test
private
def set_kredis_namespace_for_test
Kredis.namespace = Rails.application.config.x.kredis_test_namespace
end
end
end
end
This seems to work, but it was a bit painful to track down.
The text was updated successfully, but these errors were encountered:
That is painful. Ran into this also; partially fixed in #156.
Namespacing should be up-front config rather than a thread local, but changing that is a major break. Addressed that with Kredis.global_namespace in #158.
I ran into a bug where my system tests weren't running as expected when parallelized. I discovered that the Puma threads spawned by Capybara don't have the namespace set (see https://github.com/rails/kredis/blob/57cedf59a50a0ef81779b5259806821fc4a15423/lib/ kredis/railtie.rb#L8). This is because the namespacing is done using
Thread.current
, and the threads spawned by Puma wouldn't haveThread.current[:kredis_namespace]
set.I have a workaround for my system tests, but it'd be nice if this worked out of the box.
For my workaround, I have a module that my ApplicationSystemTestCase includes:
This seems to work, but it was a bit painful to track down.
The text was updated successfully, but these errors were encountered: