0
0
Fork 0

Support REDIS_SENTINEL_PORT variables (#31767)

This commit is contained in:
David Roetzel 2024-09-05 11:26:49 +02:00 committed by GitHub
parent 4d5c91e99a
commit 7d91723f05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 44 additions and 15 deletions

View file

@ -107,14 +107,40 @@ RSpec.describe Mastodon::RedisConfiguration do
end
context 'when giving sentinels without port numbers' do
around do |example|
ClimateControl.modify "#{prefix}REDIS_SENTINELS": '192.168.0.1,192.168.0.2', "#{prefix}REDIS_SENTINEL_MASTER": 'mainsentinel' do
example.run
context "when no default port is given via `#{prefix}REDIS_SENTINEL_PORT`" do
around do |example|
ClimateControl.modify "#{prefix}REDIS_SENTINELS": '192.168.0.1,192.168.0.2', "#{prefix}REDIS_SENTINEL_MASTER": 'mainsentinel' do
example.run
end
end
it 'uses the default sentinel port' do
expect(subject[:sentinels]).to contain_exactly({ host: '192.168.0.1', port: 26_379 }, { host: '192.168.0.2', port: 26_379 })
end
end
it 'uses the default sentinel port' do
expect(subject[:sentinels]).to contain_exactly({ host: '192.168.0.1', port: 26_379 }, { host: '192.168.0.2', port: 26_379 })
context 'when adding port numbers to some, but not all sentinels' do
around do |example|
ClimateControl.modify "#{prefix}REDIS_SENTINELS": '192.168.0.1:5678,192.168.0.2', "#{prefix}REDIS_SENTINEL_MASTER": 'mainsentinel' do
example.run
end
end
it 'uses the given port number when available and the default otherwise' do
expect(subject[:sentinels]).to contain_exactly({ host: '192.168.0.1', port: 5678 }, { host: '192.168.0.2', port: 26_379 })
end
end
context "when a default port is given via `#{prefix}REDIS_SENTINEL_PORT`" do
around do |example|
ClimateControl.modify "#{prefix}REDIS_SENTINEL_PORT": '1234', "#{prefix}REDIS_SENTINELS": '192.168.0.1,192.168.0.2', "#{prefix}REDIS_SENTINEL_MASTER": 'mainsentinel' do
example.run
end
end
it 'uses the given port number' do
expect(subject[:sentinels]).to contain_exactly({ host: '192.168.0.1', port: 1234 }, { host: '192.168.0.2', port: 1234 })
end
end
end
end