Skip to content

Commit

Permalink
chore: add a ruby container to docker compose for macOS users (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
supercaracal committed May 10, 2024
1 parent b38c904 commit a3dc26c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
19 changes: 19 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,22 @@ services:
condition: service_healthy
node6:
condition: service_healthy
ruby:
image: "ruby:${RUBY_VERSION:-3}"
restart: always
working_dir: /client
volumes:
- .:/client
command:
- ruby
- "-e"
- 'Signal.trap(:INT, "EXIT"); Signal.trap(:TERM, "EXIT"); loop { sleep 1 }'
environment:
REDIS_HOST: node1
cap_drop:
- ALL
healthcheck:
test: ["CMD", "ruby", "-e", "'puts 1'"]
interval: "5s"
timeout: "3s"
retries: 3
24 changes: 20 additions & 4 deletions test/testing_constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

require 'redis_client'

TEST_REDIS_HOST = '127.0.0.1'
TEST_REDIS_HOST = ENV.fetch('REDIS_HOST', '127.0.0.1')
TEST_REDIS_PORT = 6379
TEST_TIMEOUT_SEC = 5.0
TEST_RECONNECT_ATTEMPTS = 3
Expand Down Expand Up @@ -56,9 +56,25 @@
TEST_NUMBER_OF_REPLICAS = TEST_REPLICA_SIZE * TEST_SHARD_SIZE
TEST_NUMBER_OF_NODES = TEST_SHARD_SIZE + TEST_NUMBER_OF_REPLICAS

TEST_REDIS_PORTS = TEST_REDIS_PORT.upto(TEST_REDIS_PORT + TEST_NUMBER_OF_NODES - 1).to_a.freeze
TEST_NODE_URIS = TEST_REDIS_PORTS.map { |v| "#{TEST_REDIS_SCHEME}://#{TEST_REDIS_HOST}:#{v}" }.freeze
TEST_NODE_OPTIONS = TEST_REDIS_PORTS.to_h { |v| ["#{TEST_REDIS_HOST}:#{v}", { host: TEST_REDIS_HOST, port: v }] }.freeze
case TEST_REDIS_HOST
when '127.0.0.1', 'localhost'
TEST_REDIS_PORTS = TEST_REDIS_PORT.upto(TEST_REDIS_PORT + TEST_NUMBER_OF_NODES - 1).to_a.freeze
TEST_NODE_URIS = TEST_REDIS_PORTS.map { |v| "#{TEST_REDIS_SCHEME}://#{TEST_REDIS_HOST}:#{v}" }.freeze
TEST_NODE_OPTIONS = TEST_REDIS_PORTS.to_h { |v| ["#{TEST_REDIS_HOST}:#{v}", { host: TEST_REDIS_HOST, port: v }] }.freeze
when 'node1'
TEST_REDIS_PORTS = Array.new(TEST_NUMBER_OF_NODES) { TEST_REDIS_PORT }.freeze
TEST_NODE_URIS = Array.new(TEST_NUMBER_OF_NODES) do |i|
host = "node#{i + 1}"
"#{TEST_REDIS_SCHEME}://#{host}:#{TEST_REDIS_PORT}"
end.freeze

TEST_NODE_OPTIONS = Array.new(TEST_NUMBER_OF_NODES) do |i|
host = "node#{format("%#{TEST_NUMBER_OF_NODES}d", i + 1)}"
["#{host}:#{TEST_REDIS_PORT}", { host: host, port: TEST_REDIS_PORT }]
end.to_h.freeze
else
raise NotImplementedError, TEST_REDIS_HOST
end

TEST_GENERIC_OPTIONS = (TEST_REDIS_SSL ? _base_opts.merge(_ssl_opts) : _base_opts).freeze

Expand Down

0 comments on commit a3dc26c

Please sign in to comment.