From: Mykyta Karpin Date: Thu, 22 Oct 2015 13:38:25 +0000 (+0300) Subject: add mongodb_replica_set option to ceilometer module X-Git-Tag: 7.0.0~6^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=1c651fe9870aaa218c52fc66ab244f009c239a0d;p=puppet-modules%2Fpuppet-ceilometer.git add mongodb_replica_set option to ceilometer module This option sets name of the replica set which is used to connect to MongoDB database. Change-Id: I6e5149d4f830677fc4bf3e363f7b999c0b06e399 --- diff --git a/manifests/db.pp b/manifests/db.pp index dc01e26..6ac0218 100644 --- a/manifests/db.pp +++ b/manifests/db.pp @@ -35,6 +35,12 @@ # If set, use this value for max_overflow with sqlalchemy. # (Optional) Defaults to 20. # +# [*mongodb_replica_set*] +# The name of the replica set which is used to connect to MongoDB +# database. If it is set, MongoReplicaSetClient will be used instead +# of MongoClient. +# (Optional) Defaults to undef (string value). +# # [*sync_db*] # enable dbsync. # @@ -47,6 +53,7 @@ class ceilometer::db ( $database_retry_interval = 10, $database_max_overflow = 20, $sync_db = true, + $mongodb_replica_set = undef, ) { include ::ceilometer::params @@ -68,6 +75,11 @@ class ceilometer::db ( } /^mongodb:\/\//: { $backend_package = $::ceilometer::params::pymongo_package_name + if $mongodb_replica_set { + ceilometer_config { 'database/mongodb_replica_set': value => $mongodb_replica_set; } + } else { + ceilometer_config { 'database/mongodb_replica_set': ensure => absent; } + } } /^sqlite:\/\//: { $backend_package = $::ceilometer::params::sqlite_package_name diff --git a/spec/classes/ceilometer_db_spec.rb b/spec/classes/ceilometer_db_spec.rb index 552ca0b..ab35203 100644 --- a/spec/classes/ceilometer_db_spec.rb +++ b/spec/classes/ceilometer_db_spec.rb @@ -13,6 +13,7 @@ describe 'ceilometer::db' do it { is_expected.to contain_ceilometer_config('database/min_pool_size').with_value('1') } it { is_expected.to contain_ceilometer_config('database/max_retries').with_value('10') } it { is_expected.to contain_ceilometer_config('database/retry_interval').with_value('10') } + it { is_expected.not_to contain_ceilometer_config('database/mongodb_replica_set') } end @@ -33,12 +34,14 @@ describe 'ceilometer::db' do it { is_expected.to contain_ceilometer_config('database/min_pool_size').with_value('2') } it { is_expected.to contain_ceilometer_config('database/max_retries').with_value('11') } it { is_expected.to contain_ceilometer_config('database/retry_interval').with_value('11') } + it { is_expected.to contain_ceilometer_config('database/mongodb_replica_set').with_ensure( 'absent' ) } end - context 'with mongodb backend' do + context 'with mongodb backend and replica set' do let :params do - { :database_connection => 'mongodb://localhost:1234/ceilometer', } + { :database_connection => 'mongodb://localhost:1234/ceilometer', + :mongodb_replica_set => 'foobar' } end it 'install the proper backend package' do @@ -49,6 +52,8 @@ describe 'ceilometer::db' do ) end + it { is_expected.to contain_ceilometer_config('database/mongodb_replica_set').with_value( 'foobar' ) } + end