Commit 0b1b1de1 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Merge branch 'jv-redis-default-url-legacy' into 'master'

Make clear Redis "default_url" is not an example to be followed

See merge request gitlab-org/gitlab!63208
parents 87303215 badb2298
...@@ -5,10 +5,10 @@ module Gitlab ...@@ -5,10 +5,10 @@ module Gitlab
class Cache < ::Gitlab::Redis::Wrapper class Cache < ::Gitlab::Redis::Wrapper
CACHE_NAMESPACE = 'cache:gitlab' CACHE_NAMESPACE = 'cache:gitlab'
class << self private
def default_url
'redis://localhost:6380' def raw_config_hash
end super || { url: 'redis://localhost:6380' }
end end
end end
end end
......
...@@ -9,10 +9,10 @@ module Gitlab ...@@ -9,10 +9,10 @@ module Gitlab
SIDEKIQ_NAMESPACE = 'resque:gitlab' SIDEKIQ_NAMESPACE = 'resque:gitlab'
MAILROOM_NAMESPACE = 'mail_room:gitlab' MAILROOM_NAMESPACE = 'mail_room:gitlab'
class << self private
def default_url
'redis://localhost:6381' def raw_config_hash
end super || { url: 'redis://localhost:6381' }
end end
end end
end end
......
...@@ -8,10 +8,10 @@ module Gitlab ...@@ -8,10 +8,10 @@ module Gitlab
USER_SESSIONS_LOOKUP_NAMESPACE = 'session:lookup:user:gitlab' USER_SESSIONS_LOOKUP_NAMESPACE = 'session:lookup:user:gitlab'
IP_SESSIONS_LOOKUP_NAMESPACE = 'session:lookup:ip:gitlab2' IP_SESSIONS_LOOKUP_NAMESPACE = 'session:lookup:ip:gitlab2'
class << self private
def default_url
'redis://localhost:6382' def raw_config_hash
end super || { url: 'redis://localhost:6382' }
end end
end end
end end
......
...@@ -51,10 +51,6 @@ module Gitlab ...@@ -51,10 +51,6 @@ module Gitlab
end end
end end
def default_url
raise NotImplementedError
end
def config_file_path(filename) def config_file_path(filename)
path = File.join(rails_root, 'config', filename) path = File.join(rails_root, 'config', filename)
return path if File.file?(path) return path if File.file?(path)
...@@ -137,8 +133,6 @@ module Gitlab ...@@ -137,8 +133,6 @@ module Gitlab
if config_data if config_data
config_data.is_a?(String) ? { url: config_data } : config_data.deep_symbolize_keys config_data.is_a?(String) ? { url: config_data } : config_data.deep_symbolize_keys
else
{ url: self.class.default_url }
end end
end end
......
...@@ -5,7 +5,14 @@ require 'spec_helper' ...@@ -5,7 +5,14 @@ require 'spec_helper'
RSpec.describe Gitlab::Redis::Cache do RSpec.describe Gitlab::Redis::Cache do
let(:instance_specific_config_file) { "config/redis.cache.yml" } let(:instance_specific_config_file) { "config/redis.cache.yml" }
let(:environment_config_file_name) { "GITLAB_REDIS_CACHE_CONFIG_FILE" } let(:environment_config_file_name) { "GITLAB_REDIS_CACHE_CONFIG_FILE" }
let(:class_redis_url) { 'redis://localhost:6380' }
include_examples "redis_shared_examples" include_examples "redis_shared_examples"
describe '#raw_config_hash' do
it 'has a legacy default URL' do
expect(subject).to receive(:fetch_config) { false }
expect(subject.send(:raw_config_hash)).to eq(url: 'redis://localhost:6380' )
end
end
end end
...@@ -5,7 +5,14 @@ require 'spec_helper' ...@@ -5,7 +5,14 @@ require 'spec_helper'
RSpec.describe Gitlab::Redis::Queues do RSpec.describe Gitlab::Redis::Queues do
let(:instance_specific_config_file) { "config/redis.queues.yml" } let(:instance_specific_config_file) { "config/redis.queues.yml" }
let(:environment_config_file_name) { "GITLAB_REDIS_QUEUES_CONFIG_FILE" } let(:environment_config_file_name) { "GITLAB_REDIS_QUEUES_CONFIG_FILE" }
let(:class_redis_url) { 'redis://localhost:6381' }
include_examples "redis_shared_examples" include_examples "redis_shared_examples"
describe '#raw_config_hash' do
it 'has a legacy default URL' do
expect(subject).to receive(:fetch_config) { false }
expect(subject.send(:raw_config_hash)).to eq(url: 'redis://localhost:6381' )
end
end
end end
...@@ -5,7 +5,14 @@ require 'spec_helper' ...@@ -5,7 +5,14 @@ require 'spec_helper'
RSpec.describe Gitlab::Redis::SharedState do RSpec.describe Gitlab::Redis::SharedState do
let(:instance_specific_config_file) { "config/redis.shared_state.yml" } let(:instance_specific_config_file) { "config/redis.shared_state.yml" }
let(:environment_config_file_name) { "GITLAB_REDIS_SHARED_STATE_CONFIG_FILE" } let(:environment_config_file_name) { "GITLAB_REDIS_SHARED_STATE_CONFIG_FILE" }
let(:class_redis_url) { 'redis://localhost:6382' }
include_examples "redis_shared_examples" include_examples "redis_shared_examples"
describe '#raw_config_hash' do
it 'has a legacy default URL' do
expect(subject).to receive(:fetch_config) { false }
expect(subject.send(:raw_config_hash)).to eq(url: 'redis://localhost:6382' )
end
end
end end
...@@ -8,10 +8,4 @@ RSpec.describe Gitlab::Redis::Wrapper do ...@@ -8,10 +8,4 @@ RSpec.describe Gitlab::Redis::Wrapper do
expect { described_class.instrumentation_class }.to raise_error(NameError) expect { described_class.instrumentation_class }.to raise_error(NameError)
end end
end end
describe '.default_url' do
it 'is not implemented' do
expect { described_class.default_url }.to raise_error(NotImplementedError)
end
end
end end
...@@ -92,6 +92,7 @@ RSpec.shared_examples "redis_shared_examples" do ...@@ -92,6 +92,7 @@ RSpec.shared_examples "redis_shared_examples" do
subject { described_class.new(rails_env).params } subject { described_class.new(rails_env).params }
let(:rails_env) { 'development' } let(:rails_env) { 'development' }
let(:config_file_name) { config_old_format_socket }
it 'withstands mutation' do it 'withstands mutation' do
params1 = described_class.params params1 = described_class.params
...@@ -153,6 +154,8 @@ RSpec.shared_examples "redis_shared_examples" do ...@@ -153,6 +154,8 @@ RSpec.shared_examples "redis_shared_examples" do
end end
describe '.url' do describe '.url' do
let(:config_file_name) { config_old_format_socket }
it 'withstands mutation' do it 'withstands mutation' do
url1 = described_class.url url1 = described_class.url
url2 = described_class.url url2 = described_class.url
...@@ -201,6 +204,8 @@ RSpec.shared_examples "redis_shared_examples" do ...@@ -201,6 +204,8 @@ RSpec.shared_examples "redis_shared_examples" do
end end
describe '.with' do describe '.with' do
let(:config_file_name) { config_old_format_socket }
before do before do
clear_pool clear_pool
end end
...@@ -288,12 +293,6 @@ RSpec.shared_examples "redis_shared_examples" do ...@@ -288,12 +293,6 @@ RSpec.shared_examples "redis_shared_examples" do
end end
describe '#raw_config_hash' do describe '#raw_config_hash' do
it 'returns default redis url when no config file is present' do
expect(subject).to receive(:fetch_config) { false }
expect(subject.send(:raw_config_hash)).to eq(url: class_redis_url )
end
it 'returns old-style single url config in a hash' do it 'returns old-style single url config in a hash' do
expect(subject).to receive(:fetch_config) { test_redis_url } expect(subject).to receive(:fetch_config) { test_redis_url }
expect(subject.send(:raw_config_hash)).to eq(url: test_redis_url) expect(subject.send(:raw_config_hash)).to eq(url: test_redis_url)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment