Few tests are failing in pipeline with error Redis::CannotConnectError: Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)
.
My .gitlab-ci.yml
file
image: starefossen/ruby-node:latest
services:
- mongo:latest
- redis:latest
variables:
MONGODB_URI: mongodb://mongo:27017/db_test
REDISTOGO_URL: redis://localhost:6379
before_script:
- bundle install --path=cache/bundler
- cp config/mongoid.yml.gitlab config/mongoid.yml
- RAILS_ENV=test bundle exec rake db:create db:migrate
test:
script:
- bundle exec rake test
my config/initializers/sidekiq.rb
file
require 'sidekiq'
require 'sidekiq-status'
Sidekiq.configure_client do |config|
config.redis = { size: 5, url: ENV['REDISTOGO_URL'] }
end
Sidekiq.configure_server do |config|
config.server_middleware do |chain|
chain.add Sidekiq::Throttler, storage: :redis
end
config.redis = { size: 10, url: ENV['REDISTOGO_URL'] }
end
can anyone point me the right direction? Thank you
There's no one single localhost in Docker which is used by Gitlab CI. The convention is that the service name declared below will be available for other containers in the docker network by it's name - redis
in that case:
services:
- redis:latest
So replacing localhost
with redis
should be enough:
variables:
- REDISTOGO_URL: redis://localhost:6379
+ REDISTOGO_URL: redis://redis:6379
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With