Skip to content

Should it work with current sidekiq? #270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
maurercw opened this issue May 30, 2023 · 2 comments
Open

Should it work with current sidekiq? #270

maurercw opened this issue May 30, 2023 · 2 comments

Comments

@maurercw
Copy link

Reaching way back here, but back in #66 (almost 10 years ago!) some discussion was happening about how to get fakeredis to work with sidekiq, but I haven't had any luck. It might be related to redis changes moreso than sidekiq, but I'll lay out what I have tried...

Just setting the driver as stated like redis_details.merge!(:driver => Redis::Connection::Memory) if defined?(Redis::Connection::Memory) doesn't work as sidekiq's adapter is expecting a symbol:

Minitest::UnexpectedError: NoMethodError: undefined method `to_sym' for Redis::Connection::Memory:Class

        opts[:driver] = opts[:driver].to_sym
                                     ^^^^^^^
Did you mean?  to_s
    sidekiq (7.1.0) lib/sidekiq/redis_client_adapter.rb:79:in `client_opts'

Ok, so I attempt to register the driver myself:

  RedisClient.register_driver :memory do
    Redis::Connection::Memory
  end

  redis_details.merge!(:driver => :memory) if defined?(Redis::Connection::Memory)

But the redis-client can't initialize the Memory object because the arguments don't line up:

Minitest::UnexpectedError: ArgumentError: wrong number of arguments (given 2, expected 0..1)
    fakeredis (0.9.2) lib/redis/connection/memory.rb:57:in `initialize'
    redis-client (0.14.1) lib/redis_client.rb:671:in `new'

Is there some other way to make this happen, or is the Memory driver no longer compatible?

@guilleiguaran
Copy link
Owner

@maurercw Unfortunately, fakeredis isn't compatible with redis-client and Sidekiq 7 depends on redis-client.

There are more details about redis-client/sidekiq at sds/mock_redis#253 (the issue with fakeredis is exactly the same)

martijnbolhuis added a commit to compliance-innovations/sidekiq-batch that referenced this issue Mar 1, 2024
- Replace fakeredis by a real redis because it is not compatible with Sidekiq 7
  and the new redis-client gem [1].
- Fix tests.

[1]: guilleiguaran/fakeredis#270
martijnbolhuis added a commit to compliance-innovations/sidekiq-batch that referenced this issue Mar 7, 2024
- Use string version of true in redis. The redis-client gem does not support
  booleans [1]. Note that although previously, these values were passed as
  boolean from Ruby they were already returned as strings when read from redis.

- Replace fakeredis gem with an actual Redis in github actions because
  fakeredis is not compatible with Sidekiq 7 and the redis-client gem [2].

- Remove unsupported Ruby version from Github actions CI.


[1]: https://github.com/redis-rb/redis-client?tab=readme-ov-file#type-support
[2]: guilleiguaran/fakeredis#270
@jeffbax
Copy link

jeffbax commented Mar 8, 2024

FWIW, depending on what you need in the test env for sidekiq, you can enable inline mode

require 'sidekiq/testing'
Sidekiq::Testing.inline!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants