From 0cce118d52ee30ba1cbc76ec33e425febc8b51d5 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 22 Aug 2022 11:36:41 +0900 Subject: [PATCH] Ensure swift_hash_path_prefix/suffix are cleared ... instead of leaving these options unmanaged. Otherwise old values can be left in swift.conf. Change-Id: Ia8698c3f590570e06182f6c5322f68c565bb68ef --- manifests/init.pp | 8 +++--- spec/classes/swift_spec.rb | 52 ++++++++++++++++++++++++++------------ 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 01924336..c904ecb3 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -45,17 +45,17 @@ # Copyright 2011 Puppetlabs Inc, unless otherwise noted. # class swift( - $swift_hash_path_suffix = undef, - $swift_hash_path_prefix = undef, + $swift_hash_path_suffix = $::os_service_default, + $swift_hash_path_prefix = $::os_service_default, $package_ensure = 'present', - $max_header_size = '8192', + $max_header_size = 8192, ) { include swift::deps include swift::params include swift::client - if ($swift_hash_path_prefix == undef and $swift_hash_path_suffix == undef) { + if is_service_default($swift_hash_path_prefix) and is_service_default($swift_hash_path_suffix) { fail('You must specify at least swift_hash_path_prefix or swift_hash_path_suffix') } diff --git a/spec/classes/swift_spec.rb b/spec/classes/swift_spec.rb index b416c425..15510d9d 100644 --- a/spec/classes/swift_spec.rb +++ b/spec/classes/swift_spec.rb @@ -5,11 +5,10 @@ describe 'swift' do let :params do { :swift_hash_path_suffix => 'string', - :max_header_size => '16384', } end - describe 'when no swift hash is specified' do + context 'when no swift hash is specified' do let :params do {} end @@ -19,20 +18,14 @@ describe 'swift' do end end - describe 'when using the default value for package_ensure' do - let :file_defaults do - { - :owner => 'swift', - :group => 'swift', - :tag => 'swift-file', - } - end - - it 'configures swift.conf' do + context 'when using defaults' do + it 'should configure swift.conf' do is_expected.to contain_swift_config( 'swift-hash/swift_hash_path_suffix').with_value('string') is_expected.to contain_swift_config( - 'swift-constraints/max_header_size').with_value('16384') + 'swift-hash/swift_hash_path_prefix').with_value('') + is_expected.to contain_swift_config( + 'swift-constraints/max_header_size').with_value(8192) end it { @@ -42,14 +35,41 @@ describe 'swift' do } end - describe 'when overriding package_ensure parameter' do + context 'when overriding package_ensure parameter' do + before do + params.merge!({:package_ensure => '1.12.0-1'}) + end + it 'should effect ensure state of swift package' do - params[:package_ensure] = '1.12.0-1' is_expected.to contain_package('swift').with_ensure(params[:package_ensure]) end end - describe 'when providing swift_hash_path_prefix and swift_hash_path_suffix' do + context 'with max_header_size' do + before do + params.merge!({:max_header_size => 16384}) + end + + it 'should configure swift.conf' do + is_expected.to contain_swift_config( + 'swift-constraints/max_header_size').with_value(16384) + end + end + + context 'with only swift_hash_path_prefix' do + let :params do + { :swift_hash_path_prefix => 'string' } + end + + it 'should configure swift.conf' do + is_expected.to contain_swift_config( + 'swift-hash/swift_hash_path_suffix').with_value('') + is_expected.to contain_swift_config( + 'swift-hash/swift_hash_path_prefix').with_value('string') + end + end + + context 'when providing swift_hash_path_prefix and swift_hash_path_suffix' do let (:params) do { :swift_hash_path_suffix => 'mysuffix',