From 5321163380bf3087bd8ad058860f56236439295d Mon Sep 17 00:00:00 2001 From: dmburmistrov Date: Mon, 4 Apr 2016 14:28:13 +0300 Subject: [PATCH] Update oslo::concurrency define * Fix docs for parameters * Use only one call of "create_resources" * Prepare unit tests Change-Id: I6d57d0ddc18dc92caad6fe311617a71a7faa13dd --- manifests/concurrency.pp | 13 +++++---- spec/defines/oslo_concurrency_spec.rb | 42 +++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 spec/defines/oslo_concurrency_spec.rb diff --git a/manifests/concurrency.pp b/manifests/concurrency.pp index 563274c..3d63299 100644 --- a/manifests/concurrency.pp +++ b/manifests/concurrency.pp @@ -8,20 +8,23 @@ # === Parameters: # # [*disable_process_locking*] -# (Optional) Enables or disables inter-process locks. +# (Optional) Enables or disables inter-process locks. (boolean value) # Defaults to $::os_service_default. # # [*lock_path*] # (Optional) Directory to use for lock files. For security, the specified directory # should only be writable by the user running the processes that need locking. -# If external locks are used, a lock path must be set. +# If external locks are used, a lock path must be set. (string value) # Defaults to $::os_service_default. # define oslo::concurrency( $disable_process_locking = $::os_service_default, $lock_path = $::os_service_default, ) { - create_resources($name, {'oslo_concurrency/disable_process_locking' => { value => $disable_process_locking }}) - create_resources($name, {'oslo_concurrency/lock_path' => { value => $lock_path }}) -} + $concurrency_options = { + 'oslo_concurrency/disable_process_locking' => { value => $disable_process_locking }, + 'oslo_concurrency/lock_path' => { value => $lock_path } + } + create_resources($name, $concurrency_options) +} diff --git a/spec/defines/oslo_concurrency_spec.rb b/spec/defines/oslo_concurrency_spec.rb new file mode 100644 index 0000000..6b3d7dc --- /dev/null +++ b/spec/defines/oslo_concurrency_spec.rb @@ -0,0 +1,42 @@ +require 'spec_helper' + +describe 'oslo::concurrency' do + + let (:title) { 'keystone_config' } + + shared_examples 'shared examples' do + + context 'with default parameters' do + it 'configures oslo_concurrency default params' do + is_expected.to contain_keystone_config('oslo_concurrency/disable_process_locking').with_value('') + is_expected.to contain_keystone_config('oslo_concurrency/lock_path').with_value('') + end + end + + context 'with overridden parameters' do + let :params do + { + :disable_process_locking => 'true', + :lock_path => '/lock/dir/', + } + end + + it 'configures oslo_concurrency section' do + is_expected.to contain_keystone_config('oslo_concurrency/disable_process_locking').with_value('true') + is_expected.to contain_keystone_config('oslo_concurrency/lock_path').with_value('/lock/dir/') + end + end + end + + on_supported_os({ + :supported_os => OSDefaults.get_supported_os + }).each do |os,facts| + context "on #{os}" do + let (:facts) do + facts.merge!(OSDefaults.get_facts()) + end + + it_behaves_like 'shared examples' + end + end +end