Allows for other common redis options to be in cable.yml, by default

- Adds RedisAdapterTest::AlternateConfiguration to account
  for a relatively common alternative setup, as it’s used
  as the first example in the
  [Redis rubygem](https://github.com/redis/redis-rb#getting-started)

- Supplies original RedisAdapterTest with more complete
  redis:// url format by adding a ‘userinfo’ (blank user),
  so that it resembles the alternate configuration

- Supplies original EventedRedisAdapterTest with more complete
  redis:// url as well

- Adds before_script to start redis-server with password as a daemon
  and with explicit defaults copied from the default redis.conf
  (Instead of using Travis' default init/upstart scripts for `redis` service)
This commit is contained in:
Marc Ignacio 2017-06-22 09:10:08 +08:00
parent 95ee77b3ae
commit f55ecc6a7c
4 changed files with 14 additions and 8 deletions

View File

@ -11,7 +11,6 @@ cache:
services:
- memcached
- redis
addons:
postgresql: "9.4"
@ -34,6 +33,7 @@ before_script:
# Decodes to e.g. `export VARIABLE=VALUE`
- $(base64 --decode <<< "ZXhwb3J0IFNBVUNFX0FDQ0VTU19LRVk9YTAzNTM0M2YtZTkyMi00MGIzLWFhM2MtMDZiM2VhNjM1YzQ4")
- $(base64 --decode <<< "ZXhwb3J0IFNBVUNFX1VTRVJOQU1FPXJ1YnlvbnJhaWxz")
- redis-server --bind 127.0.0.1 --port 6379 --requirepass 'password' --daemonize yes
script: 'ci/travis.rb'
@ -65,25 +65,21 @@ matrix:
env: "GEM=aj:integration"
services:
- memcached
- redis
- rabbitmq
- rvm: 2.3.4
env: "GEM=aj:integration"
services:
- memcached
- redis
- rabbitmq
- rvm: 2.4.1
env: "GEM=aj:integration"
services:
- memcached
- redis
- rabbitmq
- rvm: ruby-head
env: "GEM=aj:integration"
services:
- memcached
- redis
- rabbitmq
- rvm: 2.3.4
env:

View File

@ -10,7 +10,9 @@ module ActionCable
# Overwrite this factory method for redis connections if you want to use a different Redis library than Redis.
# This is needed, for example, when using Makara proxies for distributed Redis.
cattr_accessor :redis_connector, default: ->(config) { ::Redis.new(url: config[:url]) }
cattr_accessor :redis_connector, default: ->(config) do
::Redis.new(config.slice(:url, :host, :port, :db, :password))
end
def initialize(*)
super

View File

@ -54,6 +54,6 @@ class EventedRedisAdapterTest < ActionCable::TestCase
end
def cable_config
{ adapter: "evented_redis", url: "redis://127.0.0.1:6379/12" }
{ adapter: "evented_redis", url: "redis://:password@127.0.0.1:6379/12" }
end
end

View File

@ -7,7 +7,7 @@ class RedisAdapterTest < ActionCable::TestCase
include ChannelPrefixTest
def cable_config
{ adapter: "redis", driver: "ruby", url: "redis://127.0.0.1:6379/12" }
{ adapter: "redis", driver: "ruby", url: "redis://:password@127.0.0.1:6379/12" }
end
end
@ -16,3 +16,11 @@ class RedisAdapterTest::Hiredis < RedisAdapterTest
super.merge(driver: "hiredis")
end
end
class RedisAdapterTest::AlternateConfiguration < RedisAdapterTest
def cable_config
alt_cable_config = super.dup
alt_cable_config.delete(:url)
alt_cable_config.merge(host: "127.0.0.1", port: 6379, db: 12, password: "password")
end
end