From a94df7b02a8db29e0f7fadd96ce3538787d236ef Mon Sep 17 00:00:00 2001 From: Sergii Golovatiuk Date: Fri, 20 May 2016 11:07:54 +0200 Subject: [PATCH] Fix tests for concat 2.1.0 Depends-On: I8e3cd60fa50e04221aedf5c153c1ecb8a5bd97b5 Change-Id: I920479f9d5f0d94151c63a5fdc1445edf984a01a Signed-off-by: Sergii Golovatiuk --- .../swift_proxy_account_quotas_spec.rb | 16 +- spec/classes/swift_proxy_authtoken_spec.rb | 131 ++++--------- spec/classes/swift_proxy_bulk_spec.rb | 48 ++--- spec/classes/swift_proxy_cache_spec.rb | 15 +- spec/classes/swift_proxy_catch_errors_spec.rb | 8 +- spec/classes/swift_proxy_ceilometer_spec.rb | 40 ++-- .../swift_proxy_container_quotas_spec.rb | 12 +- spec/classes/swift_proxy_crossdomain_spec.rb | 34 ++-- spec/classes/swift_proxy_dlo_spec.rb | 32 +--- spec/classes/swift_proxy_formpost_spec.rb | 12 +- spec/classes/swift_proxy_gatekeeper_spec.rb | 40 ++-- spec/classes/swift_proxy_healthcheck_spec.rb | 12 +- spec/classes/swift_proxy_keystone_spec.rb | 20 +- spec/classes/swift_proxy_ratelimit_spec.rb | 44 ++--- spec/classes/swift_proxy_s3token_spec.rb | 36 +--- spec/classes/swift_proxy_slo_spec.rb | 44 ++--- spec/classes/swift_proxy_spec.rb | 180 ++++++++++-------- spec/classes/swift_proxy_staticweb_spec.rb | 12 +- spec/classes/swift_proxy_swauth_spec.rb | 20 +- spec/classes/swift_proxy_swift3_spec.rb | 4 +- spec/classes/swift_proxy_tempauth_spec.rb | 35 ++-- spec/classes/swift_proxy_tempurl_spec.rb | 17 +- .../swift_storage_filter_healthcheck_spec.rb | 18 +- .../swift_storage_filter_recon_spec.rb | 28 +-- spec/defines/swift_storage_server_spec.rb | 58 +++--- 25 files changed, 332 insertions(+), 584 deletions(-) diff --git a/spec/classes/swift_proxy_account_quotas_spec.rb b/spec/classes/swift_proxy_account_quotas_spec.rb index 955996e2..6db109c2 100644 --- a/spec/classes/swift_proxy_account_quotas_spec.rb +++ b/spec/classes/swift_proxy_account_quotas_spec.rb @@ -22,19 +22,7 @@ require 'spec_helper' describe 'swift::proxy::account_quotas' do - let :facts do - {} + it do + is_expected.to contain_concat_fragment('swift_account_quotas').with_content("\n[filter:account_quotas]\nuse = egg:swift#account_quotas\n") end - - let :pre_condition do - 'concat { "/etc/swift/proxy-server.conf": }' - end - - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/80_swift_account_quotas" - end - - it { is_expected.to contain_file(fragment_file).with_content(/\[filter:account_quotas\]/) } - it { is_expected.to contain_file(fragment_file).with_content(/use = egg:swift#account_quotas/) } - end diff --git a/spec/classes/swift_proxy_authtoken_spec.rb b/spec/classes/swift_proxy_authtoken_spec.rb index 44ca437c..56aa7c1b 100644 --- a/spec/classes/swift_proxy_authtoken_spec.rb +++ b/spec/classes/swift_proxy_authtoken_spec.rb @@ -24,30 +24,25 @@ describe 'swift::proxy::authtoken' do )} end - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/22_swift_authtoken" - end - describe "when using default parameters" do it 'should build the fragment with correct parameters' do - verify_contents(catalogue, fragment_file, - [ - '[filter:authtoken]', - 'log_name = swift', - 'signing_dir = /var/cache/swift', - 'paste.filter_factory = keystonemiddleware.auth_token:filter_factory', - 'auth_host = 127.0.0.1', - 'auth_port = 35357', - 'auth_protocol = http', - 'auth_uri = http://127.0.0.1:5000', - 'admin_tenant_name = services', - 'admin_user = swift', - 'admin_password = password', - 'delay_auth_decision = 1', - 'cache = swift.cache', - 'include_service_catalog = False' - ] - ) + is_expected.to contain_concat_fragment('swift_authtoken').with_content(' +[filter:authtoken] +log_name = swift +signing_dir = /var/cache/swift +paste.filter_factory = keystonemiddleware.auth_token:filter_factory + +auth_host = 127.0.0.1 +auth_port = 35357 +auth_protocol = http +auth_uri = http://127.0.0.1:5000 +admin_tenant_name = services +admin_user = swift +admin_password = password +delay_auth_decision = 1 +cache = swift.cache +include_service_catalog = False +') end end @@ -59,22 +54,7 @@ describe 'swift::proxy::authtoken' do end it 'should build the fragment with correct parameters' do - verify_contents(catalogue, fragment_file, - [ - '[filter:authtoken]', - 'log_name = swift', - 'signing_dir = /var/cache/swift', - 'paste.filter_factory = keystonemiddleware.auth_token:filter_factory', - 'auth_host = 127.0.0.1', - 'auth_port = 35357', - 'auth_protocol = http', - 'auth_uri = http://127.0.0.1:5000', - 'admin_token = ADMINTOKEN', - 'delay_auth_decision = 1', - 'cache = swift.cache', - 'include_service_catalog = False' - ] - ) + is_expected.to contain_concat_fragment('swift_authtoken').with_content(/admin_token = ADMINTOKEN/) end end @@ -95,25 +75,24 @@ describe 'swift::proxy::authtoken' do end it 'should build the fragment with correct parameters' do - verify_contents(catalogue, fragment_file, - [ - '[filter:authtoken]', - 'log_name = swift', - 'signing_dir = /home/swift/keystone-signing', - 'paste.filter_factory = keystonemiddleware.auth_token:filter_factory', - 'auth_host = some.host', - 'auth_port = 443', - 'auth_protocol = https', - 'auth_admin_prefix = /keystone/admin', - 'auth_uri = https://some.host:5000', - 'admin_tenant_name = admin', - 'admin_user = swiftuser', - 'admin_password = swiftpassword', - 'delay_auth_decision = 0', - 'cache = foo', - 'include_service_catalog = False' - ] - ) + is_expected.to contain_concat_fragment('swift_authtoken').with_content(' +[filter:authtoken] +log_name = swift +signing_dir = /home/swift/keystone-signing +paste.filter_factory = keystonemiddleware.auth_token:filter_factory + +auth_host = some.host +auth_port = 443 +auth_protocol = https +auth_admin_prefix = /keystone/admin +auth_uri = https://some.host:5000 +admin_tenant_name = admin +admin_user = swiftuser +admin_password = swiftpassword +delay_auth_decision = 0 +cache = foo +include_service_catalog = False +') end end @@ -122,7 +101,7 @@ describe 'swift::proxy::authtoken' do { :auth_uri => 'http://public.host/keystone/main' } end - it { is_expected.to contain_file(fragment_file).with_content(/auth_uri = http:\/\/public.host\/keystone\/main/)} + it { is_expected.to contain_concat_fragment('swift_authtoken').with_content(/auth_uri = http:\/\/public\.host\/keystone\/main/)} end [ @@ -138,7 +117,7 @@ describe 'swift::proxy::authtoken' do { :auth_admin_prefix => auth_admin_prefix } end - it { expect { is_expected.to contain_file(fragment_file).with_content(/auth_admin_prefix = #{auth_admin_prefix}/) }.to \ + it { expect { is_expected.to contain_concat_fragment('swift_authtoken').with_content(/auth_admin_prefix = #{auth_admin_prefix}/) }.to \ raise_error(Puppet::Error, /validate_re\(\): "#{auth_admin_prefix}" does not match/) } end end @@ -151,27 +130,10 @@ describe 'swift::proxy::authtoken' do end it 'should build the fragment with correct parameters' do - verify_contents(catalogue, fragment_file, - [ - '[filter:authtoken]', - 'log_name = swift', - 'signing_dir = /var/cache/swift', - 'paste.filter_factory = keystonemiddleware.auth_token:filter_factory', - 'auth_host = 127.0.0.1', - 'auth_port = 35357', - 'auth_protocol = http', - 'auth_uri = http://127.0.0.1:5000', - 'identity_uri = https://foo.bar:35357/', - 'delay_auth_decision = 1', - 'cache = swift.cache', - 'include_service_catalog = False' - ] - ) + is_expected.to contain_concat_fragment('swift_authtoken').with_content(/identity_uri = https:\/\/foo\.bar:35357\//) end end - - describe "when both auth_uri and identity_uri are set" do let :params do { @@ -181,19 +143,8 @@ describe 'swift::proxy::authtoken' do end it 'should build the fragment with correct parameters' do - verify_contents(catalogue, fragment_file, - [ - '[filter:authtoken]', - 'log_name = swift', - 'signing_dir = /var/cache/swift', - 'paste.filter_factory = keystonemiddleware.auth_token:filter_factory', - 'auth_uri = https://foo.bar:5000/v2.0/', - 'identity_uri = https://foo.bar:35357/', - 'delay_auth_decision = 1', - 'cache = swift.cache', - 'include_service_catalog = False' - ] - ) + is_expected.to contain_concat_fragment('swift_authtoken').with_content(/auth_uri = https:\/\/foo\.bar:5000\/v2\.0\//) + is_expected.to contain_concat_fragment('swift_authtoken').with_content(/identity_uri = https:\/\/foo\.bar:35357\//) end end diff --git a/spec/classes/swift_proxy_bulk_spec.rb b/spec/classes/swift_proxy_bulk_spec.rb index a34c8383..30e92256 100644 --- a/spec/classes/swift_proxy_bulk_spec.rb +++ b/spec/classes/swift_proxy_bulk_spec.rb @@ -22,30 +22,16 @@ require 'spec_helper' describe 'swift::proxy::bulk' do - let :facts do - {} - end - - let :pre_condition do - 'concat { "/etc/swift/proxy-server.conf": }' - end - - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/21_swift_bulk" - end - describe "when using default parameters" do it 'should build the fragment with correct parameters' do - verify_contents(catalogue, fragment_file, - [ - '[filter:bulk]', - 'use = egg:swift#bulk', - 'max_containers_per_extraction = 10000', - 'max_failed_extractions = 1000', - 'max_deletes_per_request = 10000', - 'yield_frequency = 60', - ] - ) + is_expected.to contain_concat_fragment('swift_bulk').with_content(' +[filter:bulk] +use = egg:swift#bulk +max_containers_per_extraction = 10000 +max_failed_extractions = 1000 +max_deletes_per_request = 10000 +yield_frequency = 60 +') end end @@ -59,16 +45,14 @@ describe 'swift::proxy::bulk' do } end it 'should build the fragment with correct parameters' do - verify_contents(catalogue, fragment_file, - [ - '[filter:bulk]', - 'use = egg:swift#bulk', - 'max_containers_per_extraction = 5000', - 'max_failed_extractions = 500', - 'max_deletes_per_request = 5000', - 'yield_frequency = 10', - ] - ) + is_expected.to contain_concat_fragment('swift_bulk').with_content(' +[filter:bulk] +use = egg:swift#bulk +max_containers_per_extraction = 5000 +max_failed_extractions = 500 +max_deletes_per_request = 5000 +yield_frequency = 10 +') end end diff --git a/spec/classes/swift_proxy_cache_spec.rb b/spec/classes/swift_proxy_cache_spec.rb index 4d77a924..30b29073 100644 --- a/spec/classes/swift_proxy_cache_spec.rb +++ b/spec/classes/swift_proxy_cache_spec.rb @@ -11,20 +11,15 @@ describe 'swift::proxy::cache' do end let :pre_condition do - 'concat { "/etc/swift/proxy-server.conf": } - class { "memcached": max_memory => 1 }' + 'class { "memcached": max_memory => 1 }' end - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/23_swift_cache" - end - it { is_expected.to contain_file(fragment_file).with_content(/[filter:cache]/) } - it { is_expected.to contain_file(fragment_file).with_content(/use = egg:swift#memcache/) } + it { is_expected.to contain_concat_fragment('swift_cache').with_content(/\[filter:cache\]\nuse = egg:swift#memcache/) } describe 'with defaults' do - it { is_expected.to contain_file(fragment_file).with_content(/memcache_servers = 127\.0\.0\.1:11211/) } + it { is_expected.to contain_concat_fragment('swift_cache').with_content(/memcache_servers = 127\.0\.0\.1:11211/) } end @@ -34,7 +29,7 @@ describe 'swift::proxy::cache' do {:memcache_servers => '10.0.0.1:1'} end - it { is_expected.to contain_file(fragment_file).with_content(/memcache_servers = 10\.0\.0\.1:1/) } + it { is_expected.to contain_concat_fragment('swift_cache').with_content(/memcache_servers = 10\.0\.0\.1:1/) } end @@ -44,7 +39,7 @@ describe 'swift::proxy::cache' do {:memcache_servers => ['10.0.0.1:1', '10.0.0.2:2']} end - it { is_expected.to contain_file(fragment_file).with_content(/memcache_servers = 10\.0\.0\.1:1,10\.0\.0\.2:2/) } + it { is_expected.to contain_concat_fragment('swift_cache').with_content(/memcache_servers = 10\.0\.0\.1:1,10\.0\.0\.2:2/) } end diff --git a/spec/classes/swift_proxy_catch_errors_spec.rb b/spec/classes/swift_proxy_catch_errors_spec.rb index 80b8c033..b0937abc 100644 --- a/spec/classes/swift_proxy_catch_errors_spec.rb +++ b/spec/classes/swift_proxy_catch_errors_spec.rb @@ -10,11 +10,7 @@ describe 'swift::proxy::catch_errors' do 'concat { "/etc/swift/proxy-server.conf": }' end - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/24_swift_catch_errors" - end - - it { is_expected.to contain_file(fragment_file).with_content(/[filter:catch_errors]/) } - it { is_expected.to contain_file(fragment_file).with_content(/use = egg:swift#catch_errors/) } + it { is_expected.to contain_concat_fragment('swift_catch_errors').with_content(/[filter:catch_errors]/) } + it { is_expected.to contain_concat_fragment('swift_catch_errors').with_content(/use = egg:swift#catch_errors/) } end diff --git a/spec/classes/swift_proxy_ceilometer_spec.rb b/spec/classes/swift_proxy_ceilometer_spec.rb index edc0f68c..f225c47b 100644 --- a/spec/classes/swift_proxy_ceilometer_spec.rb +++ b/spec/classes/swift_proxy_ceilometer_spec.rb @@ -15,19 +15,11 @@ describe 'swift::proxy::ceilometer' do }' end - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/33_swift_ceilometer" - end - describe "when using default parameters" do - it { is_expected.to contain_file(fragment_file).with_content(/[filter:ceilometer]/) } - it { is_expected.to contain_file(fragment_file).with_content(/paste.filter_factory = ceilometermiddleware.swift:filter_factory/) } - it { is_expected.to contain_file(fragment_file).with_content(/url = rabbit:\/\/guest:guest@127.0.0.1:5672\//) } - if Puppet.version.to_f < 4.0 - it { is_expected.to contain_concat__fragment('swift_ceilometer').with_require('Class[Ceilometer]')} - else - it { is_expected.to contain_concat__fragment('swift_ceilometer').with_require('Class[Ceilometer]')} - end + it { is_expected.to contain_concat_fragment('swift_ceilometer').with_content(/[filter:ceilometer]/) } + it { is_expected.to contain_concat_fragment('swift_ceilometer').with_content(/paste.filter_factory = ceilometermiddleware.swift:filter_factory/) } + it { is_expected.to contain_concat_fragment('swift_ceilometer').with_content(/url = rabbit:\/\/guest:guest@127.0.0.1:5672\//) } + it { is_expected.to contain_concat__fragment('swift_ceilometer').with_require('Class[Ceilometer]')} it { is_expected.to contain_user('swift').with_groups('ceilometer') } it { is_expected.to contain_file('/var/log/ceilometer/swift-proxy-server.log').with(:owner => 'swift', :group => 'swift', :mode => '0664') } end @@ -48,12 +40,12 @@ describe 'swift::proxy::ceilometer' do context 'with single rabbit host' do it { is_expected.to contain_user('swift').with_groups('www-data') } - it { is_expected.to contain_file(fragment_file).with_content(/[filter:ceilometer]/) } - it { is_expected.to contain_file(fragment_file).with_content(/paste.filter_factory = ceilometermiddleware.swift:filter_factory/) } - it { is_expected.to contain_file(fragment_file).with_content(/url = rabbit:\/\/user_1:user_1_passw@1.1.1.1:5673\/rabbit/) } - it { is_expected.to contain_file(fragment_file).with_content(/driver = messagingv2/) } - it { is_expected.to contain_file(fragment_file).with_content(/topic = notifications/) } - it { is_expected.to contain_file(fragment_file).with_content(/control_exchange = swift/) } + it { is_expected.to contain_concat_fragment('swift_ceilometer').with_content(/[filter:ceilometer]/) } + it { is_expected.to contain_concat_fragment('swift_ceilometer').with_content(/paste.filter_factory = ceilometermiddleware.swift:filter_factory/) } + it { is_expected.to contain_concat_fragment('swift_ceilometer').with_content(/url = rabbit:\/\/user_1:user_1_passw@1.1.1.1:5673\/rabbit/) } + it { is_expected.to contain_concat_fragment('swift_ceilometer').with_content(/driver = messagingv2/) } + it { is_expected.to contain_concat_fragment('swift_ceilometer').with_content(/topic = notifications/) } + it { is_expected.to contain_concat_fragment('swift_ceilometer').with_content(/control_exchange = swift/) } end context 'with multiple rabbit hosts' do @@ -62,12 +54,12 @@ describe 'swift::proxy::ceilometer' do end it { is_expected.to contain_user('swift').with_groups('www-data') } - it { is_expected.to contain_file(fragment_file).with_content(/[filter:ceilometer]/) } - it { is_expected.to contain_file(fragment_file).with_content(/paste.filter_factory = ceilometermiddleware.swift:filter_factory/) } - it { is_expected.to contain_file(fragment_file).with_content(/url = rabbit:\/\/user_1:user_1_passw@127.0.0.1:5672,user_1:user_1_passw@127.0.0.2:5672\/rabbit/) } - it { is_expected.to contain_file(fragment_file).with_content(/driver = messagingv2/) } - it { is_expected.to contain_file(fragment_file).with_content(/topic = notifications/) } - it { is_expected.to contain_file(fragment_file).with_content(/control_exchange = swift/) } + it { is_expected.to contain_concat_fragment('swift_ceilometer').with_content(/[filter:ceilometer]/) } + it { is_expected.to contain_concat_fragment('swift_ceilometer').with_content(/paste.filter_factory = ceilometermiddleware.swift:filter_factory/) } + it { is_expected.to contain_concat_fragment('swift_ceilometer').with_content(/url = rabbit:\/\/user_1:user_1_passw@127.0.0.1:5672,user_1:user_1_passw@127.0.0.2:5672\/rabbit/) } + it { is_expected.to contain_concat_fragment('swift_ceilometer').with_content(/driver = messagingv2/) } + it { is_expected.to contain_concat_fragment('swift_ceilometer').with_content(/topic = notifications/) } + it { is_expected.to contain_concat_fragment('swift_ceilometer').with_content(/control_exchange = swift/) } end end diff --git a/spec/classes/swift_proxy_container_quotas_spec.rb b/spec/classes/swift_proxy_container_quotas_spec.rb index 3233da4c..d2480527 100644 --- a/spec/classes/swift_proxy_container_quotas_spec.rb +++ b/spec/classes/swift_proxy_container_quotas_spec.rb @@ -26,15 +26,7 @@ describe 'swift::proxy::container_quotas' do {} end - let :pre_condition do - 'concat { "/etc/swift/proxy-server.conf": }' - end - - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/81_swift_container_quotas" - end - - it { is_expected.to contain_file(fragment_file).with_content(/\[filter:container_quotas\]/) } - it { is_expected.to contain_file(fragment_file).with_content(/use = egg:swift#container_quotas/) } + it { is_expected.to contain_concat_fragment('swift_container_quotas').with_content(/\[filter:container_quotas\]/) } + it { is_expected.to contain_concat_fragment('swift_container_quotas').with_content(/use = egg:swift#container_quotas/) } end diff --git a/spec/classes/swift_proxy_crossdomain_spec.rb b/spec/classes/swift_proxy_crossdomain_spec.rb index 14ee3b70..a186aa9f 100644 --- a/spec/classes/swift_proxy_crossdomain_spec.rb +++ b/spec/classes/swift_proxy_crossdomain_spec.rb @@ -6,23 +6,13 @@ describe 'swift::proxy::crossdomain' do {} end - let :pre_condition do - 'concat { "/etc/swift/proxy-server.conf": }' - end - - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/35_swift_crossdomain" - end - describe "when using default parameters" do it 'should build the fragment with correct parameters' do - verify_contents(catalogue, fragment_file, - [ - '[filter:crossdomain]', - 'use = egg:swift#crossdomain', - 'cross_domain_policy = ', - ] - ) + is_expected.to contain_concat_fragment('swift_crossdomain').with_content(' +[filter:crossdomain] +use = egg:swift#crossdomain +cross_domain_policy = +') end end @@ -34,14 +24,12 @@ describe 'swift::proxy::crossdomain' do } end it 'should build the fragment with correct parameters' do - verify_contents(catalogue, fragment_file, - [ - '[filter:crossdomain]', - 'use = egg:swift#crossdomain', - 'cross_domain_policy = ', - '', - ] - ) + is_expected.to contain_concat_fragment('swift_crossdomain').with_content(' +[filter:crossdomain] +use = egg:swift#crossdomain +cross_domain_policy = + +') end end diff --git a/spec/classes/swift_proxy_dlo_spec.rb b/spec/classes/swift_proxy_dlo_spec.rb index 930388b8..4f1ef92d 100644 --- a/spec/classes/swift_proxy_dlo_spec.rb +++ b/spec/classes/swift_proxy_dlo_spec.rb @@ -6,21 +6,15 @@ describe 'swift::proxy::dlo' do {} end - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/36_swift_dlo" - end - describe "when using default parameters" do it 'should build the fragment with correct parameters' do - verify_contents(catalogue, fragment_file, - [ - '[filter:dlo]', - 'use = egg:swift#dlo', - 'rate_limit_after_segment = 10', - 'rate_limit_segments_per_sec = 1', - 'max_get_time = 86400', - ] - ) + is_expected.to contain_concat_fragment('swift_dlo').with_content(' +[filter:dlo] +use = egg:swift#dlo +rate_limit_after_segment = 10 +rate_limit_segments_per_sec = 1 +max_get_time = 86400 +') end end @@ -33,15 +27,9 @@ describe 'swift::proxy::dlo' do } end it 'should build the fragment with correct parameters' do - verify_contents(catalogue, fragment_file, - [ - '[filter:dlo]', - 'use = egg:swift#dlo', - 'rate_limit_after_segment = 30', - 'rate_limit_segments_per_sec = 5', - 'max_get_time = 6400', - ] - ) + is_expected.to contain_concat_fragment('swift_dlo').with_content(/rate_limit_after_segment = 30/) + is_expected.to contain_concat_fragment('swift_dlo').with_content(/rate_limit_segments_per_sec = 5/) + is_expected.to contain_concat_fragment('swift_dlo').with_content(/max_get_time = 6400/) end end diff --git a/spec/classes/swift_proxy_formpost_spec.rb b/spec/classes/swift_proxy_formpost_spec.rb index d2386f37..e16e6463 100644 --- a/spec/classes/swift_proxy_formpost_spec.rb +++ b/spec/classes/swift_proxy_formpost_spec.rb @@ -6,15 +6,7 @@ describe 'swift::proxy::formpost' do {} end - let :pre_condition do - 'concat { "/etc/swift/proxy-server.conf": }' - end - - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/31_swift-proxy-formpost" - end - - it { is_expected.to contain_file(fragment_file).with_content(/[filter:formpost]/) } - it { is_expected.to contain_file(fragment_file).with_content(/use = egg:swift#formpost/) } + it { is_expected.to contain_concat_fragment('swift-proxy-formpost').with_content(/[filter:formpost]/) } + it { is_expected.to contain_concat_fragment('swift-proxy-formpost').with_content(/use = egg:swift#formpost/) } end diff --git a/spec/classes/swift_proxy_gatekeeper_spec.rb b/spec/classes/swift_proxy_gatekeeper_spec.rb index 70015a72..619a6372 100644 --- a/spec/classes/swift_proxy_gatekeeper_spec.rb +++ b/spec/classes/swift_proxy_gatekeeper_spec.rb @@ -6,27 +6,17 @@ describe 'swift::proxy::gatekeeper' do {} end - let :pre_condition do - 'concat { "/etc/swift/proxy-server.conf": }' - end - - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/34_swift_gatekeeper" - end - describe "when using default parameters" do it 'should build the fragment with correct parameters' do - verify_contents(catalogue, fragment_file, - [ - '[filter:gatekeeper]', - 'use = egg:swift#gatekeeper', - 'set log_name = gatekeeper', - 'set log_facility = LOG_LOCAL0', - 'set log_level = INFO', - 'set log_headers = false', - 'set log_address = /dev/log', - ] - ) + is_expected.to contain_concat_fragment('swift_gatekeeper').with_content(' +[filter:gatekeeper] +use = egg:swift#gatekeeper +set log_name = gatekeeper +set log_facility = LOG_LOCAL0 +set log_level = INFO +set log_headers = false +set log_address = /dev/log +') end end @@ -39,15 +29,9 @@ describe 'swift::proxy::gatekeeper' do } end it 'should build the fragment with correct parameters' do - verify_contents(catalogue, fragment_file, - [ - '[filter:gatekeeper]', - 'use = egg:swift#gatekeeper', - 'set log_name = newgatekeeper', - 'set log_facility = LOG_LOCAL2', - 'set log_level = WARN', - ] - ) + is_expected.to contain_concat_fragment('swift_gatekeeper').with_content(/set log_name = newgatekeeper/) + is_expected.to contain_concat_fragment('swift_gatekeeper').with_content(/set log_facility = LOG_LOCAL2/) + is_expected.to contain_concat_fragment('swift_gatekeeper').with_content(/set log_level = WARN/) end end diff --git a/spec/classes/swift_proxy_healthcheck_spec.rb b/spec/classes/swift_proxy_healthcheck_spec.rb index 0e1776a7..c28bb6f3 100644 --- a/spec/classes/swift_proxy_healthcheck_spec.rb +++ b/spec/classes/swift_proxy_healthcheck_spec.rb @@ -6,15 +6,7 @@ describe 'swift::proxy::healthcheck' do {} end - let :pre_condition do - 'concat { "/etc/swift/proxy-server.conf": }' - end - - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/25_swift_healthcheck" - end - - it { is_expected.to contain_file(fragment_file).with_content(/[filter:healthcheck]/) } - it { is_expected.to contain_file(fragment_file).with_content(/use = egg:swift#healthcheck/) } + it { is_expected.to contain_concat_fragment('swift_healthcheck').with_content(/[filter:healthcheck]/) } + it { is_expected.to contain_concat_fragment('swift_healthcheck').with_content(/use = egg:swift#healthcheck/) } end diff --git a/spec/classes/swift_proxy_keystone_spec.rb b/spec/classes/swift_proxy_keystone_spec.rb index 5f6762ca..79e26465 100644 --- a/spec/classes/swift_proxy_keystone_spec.rb +++ b/spec/classes/swift_proxy_keystone_spec.rb @@ -6,23 +6,17 @@ describe 'swift::proxy::keystone' do {} end - let :fragment_file do - '/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/79_swift_keystone' - end - let :pre_condition do 'concat { "/etc/swift/proxy-server.conf": }' end - it { is_expected.to contain_file(fragment_file).with_content(/[filter:keystone]/) } - - it { is_expected.to contain_file(fragment_file).with_content(/use = egg:swift#keystoneauth/) } + it { is_expected.to contain_concat_fragment('swift_keystone').with_content(/\[filter:keystone\]\nuse = egg:swift#keystoneauth/) } describe 'with defaults' do - it { is_expected.to contain_file(fragment_file).with_content(/operator_roles = admin, SwiftOperator/) } - it { is_expected.to contain_file(fragment_file).with_content(/is_admin = true/) } - it { is_expected.to contain_file(fragment_file).with_content(/reseller_prefix = AUTH_/) } + it { is_expected.to contain_concat_fragment('swift_keystone').with_content(/operator_roles = admin, SwiftOperator/) } + it { is_expected.to contain_concat_fragment('swift_keystone').with_content(/is_admin = true/) } + it { is_expected.to contain_concat_fragment('swift_keystone').with_content(/reseller_prefix = AUTH_/) } end @@ -35,9 +29,9 @@ describe 'swift::proxy::keystone' do :reseller_prefix => 'SWIFT_' } - it { is_expected.to contain_file(fragment_file).with_content(/operator_roles = foo/) } - it { is_expected.to contain_file(fragment_file).with_content(/is_admin = false/) } - it { is_expected.to contain_file(fragment_file).with_content(/reseller_prefix = SWIFT_/) } + it { is_expected.to contain_concat_fragment('swift_keystone').with_content(/operator_roles = foo/) } + it { is_expected.to contain_concat_fragment('swift_keystone').with_content(/is_admin = false/) } + it { is_expected.to contain_concat_fragment('swift_keystone').with_content(/reseller_prefix = SWIFT_/) } end diff --git a/spec/classes/swift_proxy_ratelimit_spec.rb b/spec/classes/swift_proxy_ratelimit_spec.rb index 5b848ef8..59c5cd48 100644 --- a/spec/classes/swift_proxy_ratelimit_spec.rb +++ b/spec/classes/swift_proxy_ratelimit_spec.rb @@ -6,27 +6,17 @@ describe 'swift::proxy::ratelimit' do {} end - let :pre_condition do - 'concat { "/etc/swift/proxy-server.conf": }' - end - - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/26_swift_ratelimit" - end - describe "when using default parameters" do it 'should build the fragment with correct parameters' do - verify_contents(catalogue, fragment_file, - [ - '[filter:ratelimit]', - 'use = egg:swift#ratelimit', - 'clock_accuracy = 1000', - 'max_sleep_time_seconds = 60', - 'log_sleep_time_seconds = 0', - 'rate_buffer_seconds = 5', - 'account_ratelimit = 0', - ] - ) + is_expected.to contain_concat_fragment('swift_ratelimit').with_content(' +[filter:ratelimit] +use = egg:swift#ratelimit +clock_accuracy = 1000 +max_sleep_time_seconds = 60 +log_sleep_time_seconds = 0 +rate_buffer_seconds = 5 +account_ratelimit = 0 +') end end @@ -41,17 +31,11 @@ describe 'swift::proxy::ratelimit' do } end it 'should build the fragment with correct parameters' do - verify_contents(catalogue, fragment_file, - [ - '[filter:ratelimit]', - 'use = egg:swift#ratelimit', - 'clock_accuracy = 9436', - 'max_sleep_time_seconds = 3600', - 'log_sleep_time_seconds = 42', - 'rate_buffer_seconds = 51', - 'account_ratelimit = 69', - ] - ) + is_expected.to contain_concat_fragment('swift_ratelimit').with_content(/clock_accuracy = 9436/) + is_expected.to contain_concat_fragment('swift_ratelimit').with_content(/max_sleep_time_seconds = 3600/) + is_expected.to contain_concat_fragment('swift_ratelimit').with_content(/log_sleep_time_seconds = 42/) + is_expected.to contain_concat_fragment('swift_ratelimit').with_content(/rate_buffer_seconds = 51/) + is_expected.to contain_concat_fragment('swift_ratelimit').with_content(/account_ratelimit = 69/) end end diff --git a/spec/classes/swift_proxy_s3token_spec.rb b/spec/classes/swift_proxy_s3token_spec.rb index e2ceac26..b91538f3 100644 --- a/spec/classes/swift_proxy_s3token_spec.rb +++ b/spec/classes/swift_proxy_s3token_spec.rb @@ -6,25 +6,15 @@ describe 'swift::proxy::s3token' do {} end - let :pre_condition do - 'concat { "/etc/swift/proxy-server.conf": }' - end - - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/28_swift_s3token" - end - describe "when using default parameters" do it 'should build the fragment with correct parameters' do - verify_contents(catalogue, fragment_file, - [ - '[filter:s3token]', - 'paste.filter_factory = keystonemiddleware.s3_token:filter_factory', - 'auth_port = 35357', - 'auth_protocol = http', - 'auth_host = 127.0.0.1' - ] - ) + is_expected.to contain_concat_fragment('swift_s3token').with_content(' +[filter:s3token] +paste.filter_factory = keystonemiddleware.s3_token:filter_factory +auth_port = 35357 +auth_protocol = http +auth_host = 127.0.0.1 +') end end @@ -37,15 +27,9 @@ describe 'swift::proxy::s3token' do } end it 'should build the fragment with correct parameters' do - verify_contents(catalogue, fragment_file, - [ - '[filter:s3token]', - 'paste.filter_factory = keystonemiddleware.s3_token:filter_factory', - 'auth_port = 4212', - 'auth_protocol = https', - 'auth_host = 1.2.3.4' - ] - ) + is_expected.to contain_concat_fragment('swift_s3token').with_content(/auth_port = 4212/) + is_expected.to contain_concat_fragment('swift_s3token').with_content(/auth_protocol = https/) + is_expected.to contain_concat_fragment('swift_s3token').with_content(/auth_host = 1.2.3.4/) end end diff --git a/spec/classes/swift_proxy_slo_spec.rb b/spec/classes/swift_proxy_slo_spec.rb index 97d2be72..dccf1c8b 100644 --- a/spec/classes/swift_proxy_slo_spec.rb +++ b/spec/classes/swift_proxy_slo_spec.rb @@ -6,28 +6,18 @@ describe 'swift::proxy::slo' do {} end - let :pre_condition do - 'concat { "/etc/swift/proxy-server.conf": }' - end - - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/35_swift_slo" - end - describe "when using default parameters" do it 'should build the fragment with correct parameters' do - verify_contents(catalogue, fragment_file, - [ - '[filter:slo]', - 'use = egg:swift#slo', - 'max_manifest_segments = 1000', - 'max_manifest_size = 2097152', - 'min_segment_size = 1048576', - 'rate_limit_after_segment = 10', - 'rate_limit_segments_per_sec = 0', - 'max_get_time = 86400', - ] - ) + is_expected.to contain_concat_fragment('swift_slo').with_content(' +[filter:slo] +use = egg:swift#slo +max_manifest_segments = 1000 +max_manifest_size = 2097152 +min_segment_size = 1048576 +rate_limit_after_segment = 10 +rate_limit_segments_per_sec = 0 +max_get_time = 86400 +') end end @@ -41,16 +31,10 @@ describe 'swift::proxy::slo' do } end it 'should build the fragment with correct parameters' do - verify_contents(catalogue, fragment_file, - [ - '[filter:slo]', - 'use = egg:swift#slo', - 'max_manifest_segments = 2000', - 'max_manifest_size = 500000', - 'rate_limit_after_segment = 30', - 'max_get_time = 6400', - ] - ) + is_expected.to contain_concat_fragment('swift_slo').with_content(/max_manifest_segments = 2000/) + is_expected.to contain_concat_fragment('swift_slo').with_content(/max_manifest_size = 500000/) + is_expected.to contain_concat_fragment('swift_slo').with_content(/rate_limit_after_segment = 30/) + is_expected.to contain_concat_fragment('swift_slo').with_content(/max_get_time = 6400/) end end diff --git a/spec/classes/swift_proxy_spec.rb b/spec/classes/swift_proxy_spec.rb index aa7b9791..e0aa3d55 100644 --- a/spec/classes/swift_proxy_spec.rb +++ b/spec/classes/swift_proxy_spec.rb @@ -16,10 +16,6 @@ describe 'swift::proxy' do } end - let :fragment_path do - "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/00_swift_proxy" - end - describe 'with proper dependencies' do let :pre_condition do @@ -50,37 +46,42 @@ describe 'swift::proxy' do :tag => 'swift-service', } )} - it { is_expected.to contain_file('/etc/swift/proxy-server.conf').with( - {:ensure => 'present', - :owner => 'swift', - :group => 'swift', - } - )} it 'should build the header file with all of the default contents' do - verify_contents(catalogue, fragment_path, - [ - '[DEFAULT]', - 'bind_port = 8080', - "workers = #{facts[:processorcount]}", - 'user = swift', - 'log_name = proxy-server', - 'log_level = INFO', - 'log_headers = False', - 'log_address = /dev/log', - '[pipeline:main]', - 'pipeline = healthcheck cache tempauth proxy-server', - '[app:proxy-server]', - 'use = egg:swift#proxy', - 'set log_name = proxy-server', - 'set log_facility = LOG_LOCAL1', - 'set log_level = INFO', - 'set log_address = /dev/log', - 'log_handoffs = true', - 'allow_account_management = true', - 'account_autocreate = true' - ] - ) + is_expected.to contain_concat_fragment('swift_proxy').with_content('# This file is managed by puppet. Do not edit +# +[DEFAULT] +bind_port = 8080 + +bind_ip = 127.0.0.1 + +workers = 1 +user = swift +log_name = proxy-server +log_facility = LOG_LOCAL1 +log_level = INFO +log_headers = False +log_address = /dev/log + + + +[pipeline:main] +pipeline = healthcheck cache tempauth proxy-server + +[app:proxy-server] +use = egg:swift#proxy +set log_name = proxy-server +set log_facility = LOG_LOCAL1 +set log_level = INFO +set log_address = /dev/log +log_handoffs = true +allow_account_management = true +account_autocreate = true + + + + +') end it { is_expected.to contain_concat__fragment('swift_proxy').with_before( @@ -120,26 +121,41 @@ describe 'swift::proxy' do } end it 'should build the header file with provided values' do - verify_contents(catalogue, fragment_path, - [ - '[DEFAULT]', - 'bind_port = 80', - "workers = 3", - 'user = swift', - 'log_level = DEBUG', - '[pipeline:main]', - 'pipeline = swauth proxy-server', - '[app:proxy-server]', - 'use = egg:swift#proxy', - 'set log_name = swift-proxy-server', - 'allow_account_management = false', - 'account_autocreate = false', - 'read_affinity = r1z1=100, r1=200', - 'write_affinity = r1', - 'write_affinity_node_count = 2 * replicas', - 'node_timeout = 20' - ] - ) + is_expected.to contain_concat_fragment('swift_proxy').with_content('# This file is managed by puppet. Do not edit +# +[DEFAULT] +bind_port = 80 + +bind_ip = 10.0.0.2 + +workers = 3 +user = swift +log_name = swift-proxy-server +log_facility = LOG_LOCAL1 +log_level = DEBUG +log_headers = False +log_address = /dev/log + + + +[pipeline:main] +pipeline = swauth proxy-server + +[app:proxy-server] +use = egg:swift#proxy +set log_name = swift-proxy-server +set log_facility = LOG_LOCAL1 +set log_level = DEBUG +set log_address = /dev/log +log_handoffs = true +allow_account_management = false +account_autocreate = false +sorting_method = affinity +read_affinity = r1z1=100, r1=200 +write_affinity = r1 +write_affinity_node_count = 2 * replicas +node_timeout = 20 +') end if Puppet.version.to_f < 4.0 it { is_expected.to contain_concat__fragment('swift_proxy').with_before('Class[Swift::Proxy::Swauth]')} @@ -188,28 +204,42 @@ describe 'swift::proxy' do } end it 'should build the header file with provided values' do - verify_contents(catalogue, fragment_path, - [ - '[DEFAULT]', - 'bind_port = 80', - "workers = 3", - 'user = swift', - 'log_level = DEBUG', - 'log_udp_host = 127.0.0.1', - 'log_udp_port = 514', - '[pipeline:main]', - 'pipeline = swauth proxy-server', - '[app:proxy-server]', - 'use = egg:swift#proxy', - 'set log_name = swift-proxy-server', - 'allow_account_management = false', - 'account_autocreate = false', - 'read_affinity = r1z1=100, r1=200', - 'write_affinity = r1', - 'write_affinity_node_count = 2 * replicas', - 'node_timeout = 20' - ] - ) + is_expected.to contain_concat_fragment('swift_proxy').with_content('# This file is managed by puppet. Do not edit +# +[DEFAULT] +bind_port = 80 + +bind_ip = 10.0.0.2 + +workers = 3 +user = swift +log_name = swift-proxy-server +log_facility = LOG_LOCAL1 +log_level = DEBUG +log_headers = False +log_address = /dev/log +# If set, log_udp_host will override log_address +log_udp_host = 127.0.0.1 +log_udp_port = 514 + +[pipeline:main] +pipeline = swauth proxy-server + +[app:proxy-server] +use = egg:swift#proxy +set log_name = swift-proxy-server +set log_facility = LOG_LOCAL1 +set log_level = DEBUG +set log_address = /dev/log +log_handoffs = true +allow_account_management = false +account_autocreate = false +sorting_method = affinity +read_affinity = r1z1=100, r1=200 +write_affinity = r1 +write_affinity_node_count = 2 * replicas +node_timeout = 20 +') end end end diff --git a/spec/classes/swift_proxy_staticweb_spec.rb b/spec/classes/swift_proxy_staticweb_spec.rb index 66001788..eb714271 100644 --- a/spec/classes/swift_proxy_staticweb_spec.rb +++ b/spec/classes/swift_proxy_staticweb_spec.rb @@ -6,15 +6,7 @@ describe 'swift::proxy::staticweb' do {} end - let :pre_condition do - 'concat { "/etc/swift/proxy-server.conf": }' - end - - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/32_swift-proxy-staticweb" - end - - it { is_expected.to contain_file(fragment_file).with_content(/[filter:staticweb]/) } - it { is_expected.to contain_file(fragment_file).with_content(/use = egg:swift#staticweb/) } + it { is_expected.to contain_concat_fragment('swift-proxy-staticweb').with_content(/[filter:staticweb]/) } + it { is_expected.to contain_concat_fragment('swift-proxy-staticweb').with_content(/use = egg:swift#staticweb/) } end diff --git a/spec/classes/swift_proxy_swauth_spec.rb b/spec/classes/swift_proxy_swauth_spec.rb index 4bfd7ff1..fd0bd180 100644 --- a/spec/classes/swift_proxy_swauth_spec.rb +++ b/spec/classes/swift_proxy_swauth_spec.rb @@ -6,23 +6,15 @@ describe 'swift::proxy::swauth' do {} end - let :pre_condition do - 'concat { "/etc/swift/proxy-server.conf": }' - end - - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/20_swift_proxy_swauth" - end - it { is_expected.to contain_package('python-swauth').with_ensure('present') } - it { is_expected.to contain_file(fragment_file).with_content(/[filter:swauth]/) } - it { is_expected.to contain_file(fragment_file).with_content(/use = egg:swauth#swauth/) } + it { is_expected.to contain_concat_fragment('swift_proxy_swauth').with_content(/[filter:swauth]/) } + it { is_expected.to contain_concat_fragment('swift_proxy_swauth').with_content(/use = egg:swauth#swauth/) } describe 'with defaults' do - it { is_expected.to contain_file(fragment_file).with_content(/default_swift_cluster = local#127\.0\.0\.1/) } - it { is_expected.to contain_file(fragment_file).with_content(/super_admin_key = swauthkey/) } + it { is_expected.to contain_concat_fragment('swift_proxy_swauth').with_content(/default_swift_cluster = local#127\.0\.0\.1/) } + it { is_expected.to contain_concat_fragment('swift_proxy_swauth').with_content(/super_admin_key = swauthkey/) } end @@ -34,8 +26,8 @@ describe 'swift::proxy::swauth' do :package_ensure => 'latest' } end - it { is_expected.to contain_file(fragment_file).with_content(/default_swift_cluster = local#10\.0\.0\.1/) } - it { is_expected.to contain_file(fragment_file).with_content(/super_admin_key = foo/) } + it { is_expected.to contain_concat_fragment('swift_proxy_swauth').with_content(/default_swift_cluster = local#10\.0\.0\.1/) } + it { is_expected.to contain_concat_fragment('swift_proxy_swauth').with_content(/super_admin_key = foo/) } it { is_expected.to contain_package('python-swauth').with_ensure('latest') } end diff --git a/spec/classes/swift_proxy_swift3_spec.rb b/spec/classes/swift_proxy_swift3_spec.rb index 0bd2f9ec..0fffe005 100644 --- a/spec/classes/swift_proxy_swift3_spec.rb +++ b/spec/classes/swift_proxy_swift3_spec.rb @@ -15,7 +15,7 @@ describe 'swift::proxy::swift3' do "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/27_swift_swift3" end - it { is_expected.to contain_file(fragment_file).with_content(/[filter:swift3]/) } - it { is_expected.to contain_file(fragment_file).with_content(/use = egg:swift3#swift3/) } + it { is_expected.to contain_concat_fragment('swift_swift3').with_content(/[filter:swift3]/) } + it { is_expected.to contain_concat_fragment('swift_swift3').with_content(/use = egg:swift3#swift3/) } end diff --git a/spec/classes/swift_proxy_tempauth_spec.rb b/spec/classes/swift_proxy_tempauth_spec.rb index b7eec3ba..8ba239b1 100644 --- a/spec/classes/swift_proxy_tempauth_spec.rb +++ b/spec/classes/swift_proxy_tempauth_spec.rb @@ -19,20 +19,13 @@ describe 'swift::proxy::tempauth' do 'concat { "/etc/swift/proxy-server.conf": }' end - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/01_swift-proxy-swauth" - end + it { is_expected.to contain_concat_fragment('swift-proxy-swauth').with_content(/\[filter:tempauth\]\nuse = egg:swift#tempauth/) } - it { is_expected.to contain_file(fragment_file).with_content(/[filter:tempauth]/) } - it { is_expected.to contain_file(fragment_file).with_content(/use = egg:swift#tempauth/) } - - it { is_expected.to_not contain_file(fragment_file).with_content(/reseller_prefix/) } - it { is_expected.to_not contain_file(fragment_file).with_content(/token_life/) } - it { is_expected.to_not contain_file(fragment_file).with_content(/auth_prefix/) } - it { is_expected.to_not contain_file(fragment_file).with_content(/storage_url_scheme/) } - it { is_expected.to contain_file(fragment_file).with_content( - /user_admin_admin = admin \.admin \.reseller_admin/ - ) } + it { is_expected.to_not contain_concat_fragment('swift-proxy-swauth').with_content(/reseller_prefix/) } + it { is_expected.to_not contain_concat_fragment('swift-proxy-swauth').with_content(/token_life/) } + it { is_expected.to_not contain_concat_fragment('swift-proxy-swauth').with_content(/auth_prefix/) } + it { is_expected.to_not contain_concat_fragment('swift-proxy-swauth').with_content(/storage_url_scheme/) } + it { is_expected.to contain_concat_fragment('swift-proxy-swauth').with_content(/user_admin_admin = admin \.admin \.reseller_admin/) } context 'declaring two users' do let :params do { @@ -51,10 +44,10 @@ describe 'swift::proxy::tempauth' do }, ] } end - it { is_expected.to contain_file(fragment_file).with_content( + it { is_expected.to contain_concat_fragment('swift-proxy-swauth').with_content( /user_admin_admin = admin \.admin \.reseller_admin/ ) } - it { is_expected.to contain_file(fragment_file).with_content( + it { is_expected.to contain_concat_fragment('swift-proxy-swauth').with_content( /user_bar_foo = pass \.reseller_admin/ ) } end @@ -70,9 +63,7 @@ describe 'swift::proxy::tempauth' do }, ] } end - it { is_expected.to contain_file(fragment_file).with_content( - /user_admin_admin = admin $/ - ) } + it { is_expected.to contain_concat_fragment('swift-proxy-swauth').with_content(/user_admin_admin = admin $/) } end @@ -85,10 +76,10 @@ describe 'swift::proxy::tempauth' do }.merge(default_params) end - it { is_expected.to contain_file(fragment_file).with_content(/reseller_prefix = AUTH/) } - it { is_expected.to contain_file(fragment_file).with_content(/token_life = 81600/) } - it { is_expected.to contain_file(fragment_file).with_content(/auth_prefix = \/auth\//) } - it { is_expected.to contain_file(fragment_file).with_content(/storage_url_scheme = http/) } + it { is_expected.to contain_concat_fragment('swift-proxy-swauth').with_content(/reseller_prefix = AUTH/) } + it { is_expected.to contain_concat_fragment('swift-proxy-swauth').with_content(/token_life = 81600/) } + it { is_expected.to contain_concat_fragment('swift-proxy-swauth').with_content(/auth_prefix = \/auth\//) } + it { is_expected.to contain_concat_fragment('swift-proxy-swauth').with_content(/storage_url_scheme = http/) } describe "invalid params" do ['account_user_list', 'token_life', 'auth_prefix', 'storage_url_scheme'].each do |param| diff --git a/spec/classes/swift_proxy_tempurl_spec.rb b/spec/classes/swift_proxy_tempurl_spec.rb index 1f05cf58..7cfa6e0f 100644 --- a/spec/classes/swift_proxy_tempurl_spec.rb +++ b/spec/classes/swift_proxy_tempurl_spec.rb @@ -10,19 +10,14 @@ describe 'swift::proxy::tempurl' do 'concat { "/etc/swift/proxy-server.conf": }' end - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/29_swift-proxy-tempurl" - end - - it { is_expected.to contain_file(fragment_file).with_content(/[filter:tempurl]/) } - it { is_expected.to contain_file(fragment_file).with_content(/use = egg:swift#tempurl/) } + it { is_expected.to contain_concat_fragment('swift-proxy-tempurl').with_content(/\[filter:tempurl\]\nuse = egg:swift#tempurl/) } ['methods', 'incoming_remove_headers', 'incoming_allow_headers', 'outgoing_remove_headers', 'outgoing_allow_headers' ].each do |h| - it { is_expected.to_not contain_file(fragment_file).with_content(/#{h}/) } + it { is_expected.to_not contain_concat_fragment('swift-proxy-tempurl').with_content(/#{h}/) } end context "when params are set" do @@ -34,12 +29,12 @@ describe 'swift::proxy::tempurl' do 'outgoing_allow_headers' => ['x-foo','x-bar-*'], } end - it { is_expected.to contain_file(fragment_file).with_content(/methods = GET HEAD PUT/) } + it { is_expected.to contain_concat_fragment('swift-proxy-tempurl').with_content(/methods = GET HEAD PUT/) } ['incoming_remove_headers', 'incoming_allow_headers', 'outgoing_remove_headers', 'outgoing_allow_headers' ].each do |h| - it { is_expected.to contain_file(fragment_file).with_content(/#{h} = x-foo x-bar-*/) } + it { is_expected.to contain_concat_fragment('swift-proxy-tempurl').with_content(/#{h} = x-foo x-bar-*/) } end describe 'when params are not array' do @@ -51,12 +46,12 @@ describe 'swift::proxy::tempurl' do 'outgoing_allow_headers' => 'x-foo x-bar-*', } end - it { is_expected.to contain_file(fragment_file).with_content(/methods = GET HEAD PUT/) } + it { is_expected.to contain_concat_fragment('swift-proxy-tempurl').with_content(/methods = GET HEAD PUT/) } ['incoming_remove_headers', 'incoming_allow_headers', 'outgoing_remove_headers', 'outgoing_allow_headers' ].each do |h| - it { is_expected.to contain_file(fragment_file).with_content(/#{h} = x-foo x-bar-*/) } + it { is_expected.to contain_concat_fragment('swift-proxy-tempurl').with_content(/#{h} = x-foo x-bar-*/) } end end end diff --git a/spec/defines/swift_storage_filter_healthcheck_spec.rb b/spec/defines/swift_storage_filter_healthcheck_spec.rb index d8f78a80..3c866ab2 100644 --- a/spec/defines/swift_storage_filter_healthcheck_spec.rb +++ b/spec/defines/swift_storage_filter_healthcheck_spec.rb @@ -9,21 +9,11 @@ describe 'swift::storage::filter::healthcheck' do {} end - let :pre_condition do - 'concat { "/etc/swift/dummy-server.conf": }' - end - - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_dummy-server.conf/fragments/25_swift_healthcheck_dummy" - end - it 'should build the fragment with correct content' do - verify_contents(catalogue, fragment_file, - [ - '[filter:healthcheck]', - 'use = egg:swift#healthcheck' - ] - ) + is_expected.to contain_concat_fragment('swift_healthcheck_dummy').with_content(' +[filter:healthcheck] +use = egg:swift#healthcheck +') end end diff --git a/spec/defines/swift_storage_filter_recon_spec.rb b/spec/defines/swift_storage_filter_recon_spec.rb index e95a36bc..1eaaa59e 100644 --- a/spec/defines/swift_storage_filter_recon_spec.rb +++ b/spec/defines/swift_storage_filter_recon_spec.rb @@ -9,23 +9,13 @@ describe 'swift::storage::filter::recon' do {} end - let :pre_condition do - 'concat { "/etc/swift/dummy-server.conf": }' - end - - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_dummy-server.conf/fragments/35_swift_recon_dummy" - end - describe 'when passing default parameters' do it 'should build the fragment with correct content' do - verify_contents(catalogue, fragment_file, - [ - '[filter:recon]', - 'use = egg:swift#recon', - 'recon_cache_path = /var/cache/swift' - ] - ) + is_expected.to contain_concat_fragment('swift_recon_dummy').with_content(' +[filter:recon] +use = egg:swift#recon +recon_cache_path = /var/cache/swift +') end end @@ -36,13 +26,7 @@ describe 'swift::storage::filter::recon' do } end it 'should build the fragment with correct content' do - verify_contents(catalogue, fragment_file, - [ - '[filter:recon]', - 'use = egg:swift#recon', - 'recon_cache_path = /some/other/path' - ] - ) + is_expected.to contain_concat_fragment('swift_recon_dummy').with_content(/recon_cache_path = \/some\/other\/path/) end end diff --git a/spec/defines/swift_storage_server_spec.rb b/spec/defines/swift_storage_server_spec.rb index 7a755797..e979b469 100644 --- a/spec/defines/swift_storage_server_spec.rb +++ b/spec/defines/swift_storage_server_spec.rb @@ -58,9 +58,6 @@ describe 'swift::storage::server' do :enable => true, :hasstatus => true, )} - let :fragment_file do - "/var/lib/puppet/concat/_etc_swift_#{t}-server.conf/fragments/00_swift-#{t}-#{title}" - end describe 'when parameters are overridden' do { @@ -72,11 +69,7 @@ describe 'swift::storage::server' do }.each do |k,v| describe "when #{k} is set" do let :params do req_params.merge({k => v}) end - it { is_expected.to contain_file(fragment_file) \ - .with_content( - /^#{k.to_s}\s*=\s*#{v.is_a?(Array) ? v.join(' ') : v}\s*$/ - ) - } + it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^#{k.to_s}\s*=\s*#{v.is_a?(Array) ? v.join(' ') : v}\s*$/) } end end describe "when pipeline is passed an array" do @@ -93,29 +86,23 @@ describe 'swift::storage::server' do describe "when replicator_concurrency is set" do let :params do req_params.merge({:replicator_concurrency => 42}) end - it { is_expected.to contain_file(fragment_file) \ - .with_content(/\[#{t}-replicator\]\nconcurrency\s*=\s*42\s*$/m) - } + it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/\[#{t}-replicator\]\nconcurrency\s*=\s*42\s*$/m) } end if t != 'account' describe "when updater_concurrency is set" do let :params do req_params.merge({:updater_concurrency => 73}) end - it { is_expected.to contain_file(fragment_file) \ - .with_content(/\[#{t}-updater\]\nconcurrency\s*=\s*73\s*$/m) - } + it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/\[#{t}-updater\]\nconcurrency\s*=\s*73\s*$/m) } end else describe "when reaper_concurrency is set" do let :params do req_params.merge({:reaper_concurrency => 4682}) end - it { is_expected.to contain_file(fragment_file) \ - .with_content(/\[#{t}-reaper\]\nconcurrency\s*=\s*4682\s*$/m) - } + it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/\[#{t}-reaper\]\nconcurrency\s*=\s*4682\s*$/m) } end end if t == 'container' describe "when allow_versioning is set" do let :params do req_params.merge({ :allow_versions => false, }) end - it { is_expected.to contain_file(fragment_file).with_content(/\[app:container-server\]\nallow_versions\s*=\s*false\s*$/m)} + it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/\[app:container-server\]\nallow_versions\s*=\s*false\s*$/m) } end end describe "when log_udp_port is set" do @@ -128,8 +115,8 @@ describe 'swift::storage::server' do { :log_udp_host => '127.0.0.1', :log_udp_port => '514'}) end - it { is_expected.to contain_file(fragment_file).with_content(/^log_udp_host\s*=\s*127\.0\.0\.1\s*$/) } - it { is_expected.to contain_file(fragment_file).with_content(/^log_udp_port\s*=\s*514\s*$/) } + it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^log_udp_host\s*=\s*127\.0\.0\.1\s*$/) } + it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^log_udp_port\s*=\s*514\s*$/) } end end @@ -145,9 +132,7 @@ describe 'swift::storage::server' do end describe "when log_requests is turned off" do let :params do req_params.merge({:log_requests => false}) end - it { is_expected.to contain_file(fragment_file) \ - .with_content(/^set log_requests\s*=\s*false\s*$/) - } + it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^set log_requests\s*=\s*false\s*$/) } end end @@ -168,19 +153,20 @@ describe 'swift::storage::server' do )} # verify template lines - it { is_expected.to contain_file(fragment_file).with_content(/^devices\s*=\s*\/srv\/node\s*$/) } - it { is_expected.to contain_file(fragment_file).with_content(/^bind_ip\s*=\s*10\.0\.0\.1\s*$/) } - it { is_expected.to contain_file(fragment_file).with_content(/^bind_port\s*=\s*#{title}\s*$/) } - it { is_expected.to contain_file(fragment_file).with_content(/^mount_check\s*=\s*true\s*$/) } - it { is_expected.to contain_file(fragment_file).with_content(/^user\s*=\s*swift\s*$/) } - it { is_expected.to contain_file(fragment_file).with_content(/^set log_name\s*=\s*#{t}-server\s*$/) } - it { is_expected.to contain_file(fragment_file).with_content(/^set log_facility\s*=\s*LOG_LOCAL2\s*$/) } - it { is_expected.to contain_file(fragment_file).with_content(/^set log_level\s*=\s*INFO\s*$/) } - it { is_expected.to contain_file(fragment_file).with_content(/^set log_address\s*=\s*\/dev\/log\s*$/) } - it { is_expected.to contain_file(fragment_file).with_content(/^set log_requests\s*=\s*true\s*$/) } - it { is_expected.to contain_file(fragment_file).with_content(/^workers\s*=\s*1\s*$/) } - it { is_expected.to contain_file(fragment_file).with_content(/^concurrency\s*=\s*1\s*$/) } - it { is_expected.to contain_file(fragment_file).with_content(/^pipeline\s*=\s*#{t}-server\s*$/) } + it { is_expected.to contain_concat("/etc/swift/#{t}-server.conf") } + it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^devices\s*=\s*\/srv\/node\s*$/) } + it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^bind_ip\s*=\s*10\.0\.0\.1\s*$/) } + it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^bind_port\s*=\s*#{title}\s*$/) } + it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^mount_check\s*=\s*true\s*$/) } + it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^user\s*=\s*swift\s*$/) } + it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^set log_name\s*=\s*#{t}-server\s*$/) } + it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^set log_facility\s*=\s*LOG_LOCAL2\s*$/) } + it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^set log_level\s*=\s*INFO\s*$/) } + it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^set log_address\s*=\s*\/dev\/log\s*$/) } + it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^set log_requests\s*=\s*true\s*$/) } + it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^workers\s*=\s*1\s*$/) } + it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^concurrency\s*=\s*1\s*$/) } + it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^pipeline\s*=\s*#{t}-server\s*$/) } end end end