From 70bb91c97583db653e5f060c9c104e65d0342f26 Mon Sep 17 00:00:00 2001 From: Xingchao Yu Date: Thu, 3 Nov 2016 21:13:55 +0800 Subject: [PATCH] Fix db sync command Cloudkitty uses cloudkitty-dbsync command for executing DB schema operations instead of cloudkitty-manage, and add rspec test for cloudkitty::db::sync Change-Id: Ifec20dd417778b537170e0b226ca0eee06b0105d --- manifests/db/sync.pp | 3 ++- spec/classes/cloudkitty_db_sync_spec.rb | 34 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 spec/classes/cloudkitty_db_sync_spec.rb diff --git a/manifests/db/sync.pp b/manifests/db/sync.pp index 31f963f..7a270ae 100644 --- a/manifests/db/sync.pp +++ b/manifests/db/sync.pp @@ -12,12 +12,13 @@ class cloudkitty::db::sync( $extra_params = undef, ) { exec { 'cloudkitty-db-sync': - command => "cloudkitty-manage db_sync ${extra_params}", + command => "cloudkitty-dbsync upgrade ${extra_params}", path => [ '/bin', '/usr/bin', ], user => 'cloudkitty', refreshonly => true, try_sleep => 5, tries => 10, + logoutput => on_failure, subscribe => [Package['cloudkitty'], Cloudkitty_config['database/connection']], } diff --git a/spec/classes/cloudkitty_db_sync_spec.rb b/spec/classes/cloudkitty_db_sync_spec.rb new file mode 100644 index 0000000..ce70129 --- /dev/null +++ b/spec/classes/cloudkitty_db_sync_spec.rb @@ -0,0 +1,34 @@ +require 'spec_helper' + +describe 'cloudkitty::db::sync' do + + shared_examples_for 'cloudkitty-dbsync' do + + it 'runs cloudkitty-db-sync' do + is_expected.to contain_exec('cloudkitty-db-sync').with( + :command => 'cloudkitty-dbsync upgrade ', + :path => [ '/bin', '/usr/bin', ], + :refreshonly => 'true', + :user => 'cloudkitty', + :logoutput => 'on_failure' + ) + 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({ + :os_workers => 8, + :concat_basedir => '/var/lib/puppet/concat' + })) + end + + it_configures 'cloudkitty-dbsync' + end + end + +end