From 2a6175e2f7b1300ef26e0c12172a53a81cdeb166 Mon Sep 17 00:00:00 2001 From: Simeon Gourlin Date: Fri, 8 Nov 2019 10:58:54 +0100 Subject: [PATCH] Add parameter memcache_max_connections This add parameter memcache_max_connections as new parameter for class proxy::cache. Change-Id: Ifbedd1b48f45f2d8970d4f6a787d0da4e442d693 --- manifests/proxy/cache.pp | 11 +++- ...ache-max-connections-50876054c14dbdd5.yaml | 6 ++ spec/classes/swift_proxy_cache_spec.rb | 61 +++++++++++-------- 3 files changed, 51 insertions(+), 27 deletions(-) create mode 100644 releasenotes/notes/swift-memcache-max-connections-50876054c14dbdd5.yaml diff --git a/manifests/proxy/cache.pp b/manifests/proxy/cache.pp index 89048f34..8dac5eca 100644 --- a/manifests/proxy/cache.pp +++ b/manifests/proxy/cache.pp @@ -4,6 +4,9 @@ # [*memcache_servers*] A list of the memcache servers to be used. Entries # should be in the form host:port. # +# [*memcache_max_connections*] Sets the maximum number of connections to +# each memcached server per worker +# # == Dependencies # # Class['memcached'] @@ -19,7 +22,8 @@ # Copyright 2011 Puppetlabs Inc, unless otherwise noted. # class swift::proxy::cache( - $memcache_servers = ['127.0.0.1:11211'] + $memcache_servers = ['127.0.0.1:11211'], + $memcache_max_connections = '2' ) { include ::swift::deps @@ -30,8 +34,9 @@ class swift::proxy::cache( } swift_proxy_config { - 'filter:cache/use': value => 'egg:swift#memcache'; - 'filter:cache/memcache_servers': value => join(any2array($memcache_servers), ','); + 'filter:cache/use': value => 'egg:swift#memcache'; + 'filter:cache/memcache_servers': value => join(any2array($memcache_servers), ','); + 'filter:cache/memcache_max_connections': value => $memcache_max_connections; } } diff --git a/releasenotes/notes/swift-memcache-max-connections-50876054c14dbdd5.yaml b/releasenotes/notes/swift-memcache-max-connections-50876054c14dbdd5.yaml new file mode 100644 index 00000000..90455bb8 --- /dev/null +++ b/releasenotes/notes/swift-memcache-max-connections-50876054c14dbdd5.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Added new parameter memcache_max_connections to proxy::cache class that + can be used to configure the maximum number of connections to each + memcached server per worker. diff --git a/spec/classes/swift_proxy_cache_spec.rb b/spec/classes/swift_proxy_cache_spec.rb index 5ddd4798..6d836745 100644 --- a/spec/classes/swift_proxy_cache_spec.rb +++ b/spec/classes/swift_proxy_cache_spec.rb @@ -2,19 +2,6 @@ require 'spec_helper' describe 'swift::proxy::cache' do shared_examples 'swift::proxy::cache' do - describe 'with defaults' do - let :pre_condition do - 'class { "memcached": max_memory => 1 }' - 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 { is_expected.to contain_swift_proxy_config('filter:cache/use').with_value('egg:swift#memcache') } - it { is_expected.to contain_swift_proxy_config('filter:cache/memcache_servers').with_value('127.0.0.1:11211') } - end describe 'without memcached being included' do it 'should raise an error' do @@ -22,22 +9,48 @@ describe 'swift::proxy::cache' do end end - describe 'with overridden memcache server' do - let :params do - {:memcache_servers => '10.0.0.1:1'} + describe 'with memcached dependency' do + let :pre_condition do + 'class { "memcached": max_memory => 1 }' end - it { is_expected.to contain_swift_proxy_config('filter:cache/use').with_value('egg:swift#memcache') } - it { is_expected.to contain_swift_proxy_config('filter:cache/memcache_servers').with_value('10.0.0.1:1') } - end + describe 'with defaults' do + it 'should have the required classes' do + is_expected.to contain_class('swift::deps') + is_expected.to contain_class('swift::proxy::cache') + end - describe 'with overridden memcache server array' do - let :params do - {:memcache_servers => ['10.0.0.1:1', '10.0.0.2:2']} + it { is_expected.to contain_swift_proxy_config('filter:cache/use').with_value('egg:swift#memcache') } + it { is_expected.to contain_swift_proxy_config('filter:cache/memcache_servers').with_value('127.0.0.1:11211') } + it { is_expected.to contain_swift_proxy_config('filter:cache/memcache_max_connections').with_value(2) } end - it { is_expected.to contain_swift_proxy_config('filter:cache/use').with_value('egg:swift#memcache') } - it { is_expected.to contain_swift_proxy_config('filter:cache/memcache_servers').with_value('10.0.0.1:1,10.0.0.2:2') } + describe 'with overridden memcache server' do + let :params do + {:memcache_servers => '10.0.0.1:1'} + end + + it { is_expected.to contain_swift_proxy_config('filter:cache/use').with_value('egg:swift#memcache') } + it { is_expected.to contain_swift_proxy_config('filter:cache/memcache_servers').with_value('10.0.0.1:1') } + end + + describe 'with overridden memcache server array' do + let :params do + {:memcache_servers => ['10.0.0.1:1', '10.0.0.2:2']} + end + + it { is_expected.to contain_swift_proxy_config('filter:cache/use').with_value('egg:swift#memcache') } + it { is_expected.to contain_swift_proxy_config('filter:cache/memcache_servers').with_value('10.0.0.1:1,10.0.0.2:2') } + end + + describe 'with overridden memcache max connections' do + let :params do + {:memcache_max_connections => 4} + end + + it { is_expected.to contain_swift_proxy_config('filter:cache/use').with_value('egg:swift#memcache') } + it { is_expected.to contain_swift_proxy_config('filter:cache/memcache_max_connections').with_value(4) } + end end end