Accept array for cache_server_url

... so that we can specify multiple backend servers.

Change-Id: Iea01d1c5202890110c33341cedee4b5bc1ba324c
This commit is contained in:
Takashi Kajinami 2022-07-31 00:08:36 +09:00
parent e3735943a3
commit 8b268d75ce
2 changed files with 22 additions and 1 deletions

View File

@ -254,7 +254,7 @@ describe 'horizon' do
it { is_expected.to contain_exec('refresh_horizon_django_compress') }
end
context 'with overridden parameters and cache_server_url' do
context 'with overridden parameters and cache_server_url (string)' do
before do
params.merge!({
:cache_server_url => 'redis://:password@10.0.0.1:6379/1',
@ -271,6 +271,23 @@ describe 'horizon' do
it { is_expected.to contain_exec('refresh_horizon_django_compress') }
end
context 'with overridden parameters and cache_server_url (array)' do
before do
params.merge!({
:cache_server_url => ['192.0.2.1:11211', '192.0.2.2:11211'],
})
end
it 'generates local_settings.py' do
verify_concat_fragment_contents(catalogue, 'local_settings.py', [
" 'LOCATION': ['192.0.2.1:11211','192.0.2.2:11211'],",
])
end
it { is_expected.to contain_exec('refresh_horizon_django_cache') }
it { is_expected.to contain_exec('refresh_horizon_django_compress') }
end
context 'installs python memcache library when cache_backend is set to memcache' do
before do
params.merge!({

View File

@ -243,7 +243,11 @@ CACHES = {
<%- end -%>
<%- end -%>
<%- if @cache_server_url -%>
<%- if @cache_server_url.kind_of?(Array) -%>
'LOCATION': ['<%= @cache_server_url.join("','") %>'],
<%- else -%>
'LOCATION': '<%= @cache_server_url %>',
<%- end -%>
<%- end -%>
}
}