From bcc2e678e0548fb9262be45220ce461bf4f5045b Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sat, 9 Jul 2022 11:50:17 +0900 Subject: [PATCH] Add acceptance tests for config management resources Change-Id: I3516381afe6bae49a78ed9ab2c98b23a7cb6e258 --- ...cinder_spec.rb => 10_basic_cinder_spec.rb} | 0 spec/acceptance/99_cinder_config_spec.rb | 134 ++++++++++++++++++ 2 files changed, 134 insertions(+) rename spec/acceptance/{basic_cinder_spec.rb => 10_basic_cinder_spec.rb} (100%) create mode 100644 spec/acceptance/99_cinder_config_spec.rb diff --git a/spec/acceptance/basic_cinder_spec.rb b/spec/acceptance/10_basic_cinder_spec.rb similarity index 100% rename from spec/acceptance/basic_cinder_spec.rb rename to spec/acceptance/10_basic_cinder_spec.rb diff --git a/spec/acceptance/99_cinder_config_spec.rb b/spec/acceptance/99_cinder_config_spec.rb new file mode 100644 index 00000000..aa0d2893 --- /dev/null +++ b/spec/acceptance/99_cinder_config_spec.rb @@ -0,0 +1,134 @@ +require 'spec_helper_acceptance' + +describe 'basic cinder_config resource' do + + context 'default parameters' do + + it 'should work with no errors' do + pp= <<-EOS + Exec { logoutput => 'on_failure' } + + File <||> -> Cinder_config <||> + File <||> -> Cinder_api_paste_ini <||> + File <||> -> Cinder_rootwrap_config <||> + + file { '/etc/cinder' : + ensure => directory, + } + file { '/etc/cinder/cinder.conf' : + ensure => file, + } + file { '/etc/cinder/api-paste.ini' : + ensure => file, + } + file { '/etc/cinder/rootwrap.conf' : + ensure => file, + } + + cinder_config { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + cinder_config { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + cinder_config { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + cinder_config { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + cinder_config { 'DEFAULT/thisshouldexist3' : + value => ['foo', 'bar'], + } + + cinder_api_paste_ini { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + cinder_api_paste_ini { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + cinder_api_paste_ini { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + cinder_api_paste_ini { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + + cinder_api_paste_ini { 'DEFAULT/thisshouldexist3' : + value => 'foo', + key_val_separator => ':' + } + + cinder_rootwrap_config { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + cinder_rootwrap_config { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + cinder_rootwrap_config { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + cinder_rootwrap_config { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } + EOS + + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file('/etc/cinder/cinder.conf') do + it { is_expected.to exist } + it { is_expected.to contain('thisshouldexist=foo') } + it { is_expected.to contain('thisshouldexist2=') } + it { is_expected.to contain('thisshouldexist3=foo') } + it { is_expected.to contain('thisshouldexist3=bar') } + + describe '#content' do + subject { super().content } + it { is_expected.to_not match /thisshouldnotexist/ } + end + end + + describe file('/etc/cinder/api-paste.ini') do + it { is_expected.to exist } + it { is_expected.to contain('thisshouldexist=foo') } + it { is_expected.to contain('thisshouldexist2=') } + it { is_expected.to contain('thisshouldexist3:foo') } + + describe '#content' do + subject { super().content } + it { is_expected.to_not match /thisshouldnotexist/ } + end + end + + describe file('/etc/cinder/rootwrap.conf') do + it { is_expected.to exist } + it { is_expected.to contain('thisshouldexist=foo') } + it { is_expected.to contain('thisshouldexist2=') } + + describe '#content' do + subject { super().content } + it { is_expected.to_not match /thisshouldnotexist/ } + end + end + end +end