Fixed swift::proxy::cache requirement on memcached
Fixed the incorrect inclusion of a requirement for the memcached class to be in the catalog for swift::proxy::cache due to a bad grep of the memcached server list. The grep command will return an array of matching values. Unfortunately this includes if nothing is found so the if condition was always matching. Now if you are not using a local memcache server on 127.0.0.1, the memcached class is not required to be in the catalog. Change-Id: I79b92dc67e46dfa0b62ba07b00633de6fb17bf1e Closes-Bug: #1628967
This commit is contained in:
parent
5e5aa7fa88
commit
fbbcd89235
@ -25,8 +25,8 @@ class swift::proxy::cache(
|
|||||||
include ::swift::deps
|
include ::swift::deps
|
||||||
|
|
||||||
# require the memcached class if its on the same machine
|
# require the memcached class if its on the same machine
|
||||||
if grep(any2array($memcache_servers), '^127\.0\.0\.1') {
|
if !empty(grep(any2array($memcache_servers), '127.0.0.1')) {
|
||||||
Class['memcached'] -> Class['swift::proxy::cache']
|
Class['::memcached'] -> Class['::swift::proxy::cache']
|
||||||
}
|
}
|
||||||
|
|
||||||
concat::fragment { 'swift_cache':
|
concat::fragment { 'swift_cache':
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- Fixed the incorrect inclusion of a requirement for the memcached class
|
||||||
|
to be in the catalog for swift::proxy::cache due to a bad grep of the
|
||||||
|
memcached server list. LP#1628967
|
@ -10,37 +10,47 @@ describe 'swift::proxy::cache' do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'with defaults' do
|
||||||
let :pre_condition do
|
let :pre_condition do
|
||||||
'class { "memcached": max_memory => 1 }'
|
'class { "memcached": max_memory => 1 }'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should have the required classes' do
|
||||||
|
is_expected.to contain_class('swift::deps')
|
||||||
|
is_expected.to contain_class('swift::proxy::cache')
|
||||||
|
end
|
||||||
|
it 'should properly configure the swift_cache fragment' do
|
||||||
|
is_expected.to contain_concat_fragment('swift_cache').with_content(/\[filter:cache\]\nuse = egg:swift#memcache/)
|
||||||
|
is_expected.to contain_concat_fragment('swift_cache').with_content(/memcache_servers = 127\.0\.0\.1:11211/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it { is_expected.to contain_concat_fragment('swift_cache').with_content(/\[filter:cache\]\nuse = egg:swift#memcache/) }
|
describe 'without memcached being included' do
|
||||||
|
it 'should raise an error' do
|
||||||
describe 'with defaults' do
|
expect { catalogue }.to raise_error(Puppet::Error)
|
||||||
|
end
|
||||||
it { is_expected.to contain_concat_fragment('swift_cache').with_content(/memcache_servers = 127\.0\.0\.1:11211/) }
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'with overridden memcache server' do
|
describe 'with overridden memcache server' do
|
||||||
|
|
||||||
let :params do
|
let :params do
|
||||||
{:memcache_servers => '10.0.0.1:1'}
|
{:memcache_servers => '10.0.0.1:1'}
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to contain_concat_fragment('swift_cache').with_content(/memcache_servers = 10\.0\.0\.1:1/) }
|
it 'should properly configure the swift_cache fragment' do
|
||||||
|
is_expected.to contain_concat_fragment('swift_cache').with_content(/\[filter:cache\]\nuse = egg:swift#memcache/)
|
||||||
|
is_expected.to contain_concat_fragment('swift_cache').with_content(/memcache_servers = 10\.0\.0\.1:1/)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'with overridden memcache server array' do
|
describe 'with overridden memcache server array' do
|
||||||
|
|
||||||
let :params do
|
let :params do
|
||||||
{:memcache_servers => ['10.0.0.1:1', '10.0.0.2:2']}
|
{:memcache_servers => ['10.0.0.1:1', '10.0.0.2:2']}
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to contain_concat_fragment('swift_cache').with_content(/memcache_servers = 10\.0\.0\.1:1,10\.0\.0\.2:2/) }
|
it 'should properly configure the swift_cache fragment' do
|
||||||
|
is_expected.to contain_concat_fragment('swift_cache').with_content(/\[filter:cache\]\nuse = egg:swift#memcache/)
|
||||||
|
is_expected.to contain_concat_fragment('swift_cache').with_content(/memcache_servers = 10\.0\.0\.1:1,10\.0\.0\.2:2/)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user