Skip to content
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

chore: add a ruby container to docker compose for macOS users #363

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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