diff --git a/manifests/init.pp b/manifests/init.pp index 132a653..4e3cd1a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -46,6 +46,14 @@ # Defines the maximum size of message posts. (integer value) # Defaults to $::os_service_default. # +# [*message_store*] +# Backend driver for message storage. +# Defaults to $::os_service_default. +# +# [*management_store*] +# Backend driver for management storage. +# Defaults to $::os_service_default. +# # [*unreliable*] # Disable all reliability constraints. (boolean value) # Default false @@ -73,6 +81,8 @@ class zaqar( $claim_pipeline = $::os_service_default, $subscription_pipeline = $::os_service_default, $max_messages_post_size = $::os_service_default, + $message_store = 'mongodb', + $management_store = 'mongodb', $package_name = $::zaqar::params::package_name, $package_ensure = 'present', $purge_config = false, @@ -104,6 +114,8 @@ class zaqar( 'storage/claim_pipeline': value => $claim_pipeline; 'storage/subscription_pipeline': value => $subscription_pipeline; 'transport/max_messages_post_size': value => $max_messages_post_size; + 'drivers/message_store': value => $message_store; + 'drivers/management_store': value => $management_store; } } diff --git a/manifests/management/mongodb.pp b/manifests/management/mongodb.pp index 4294ac0..2e5710b 100644 --- a/manifests/management/mongodb.pp +++ b/manifests/management/mongodb.pp @@ -74,7 +74,6 @@ class zaqar::management::mongodb( include ::zaqar::deps zaqar_config { - 'drivers/management_store': value => 'mongodb'; 'drivers:management_store:mongodb/uri': value => $uri, secret => true; 'drivers:management_store:mongodb/ssl_keyfile': value => $ssl_keyfile; 'drivers:management_store:mongodb/ssl_certfile': value => $ssl_certfile; diff --git a/manifests/management/sqlalchemy.pp b/manifests/management/sqlalchemy.pp new file mode 100644 index 0000000..16c512d --- /dev/null +++ b/manifests/management/sqlalchemy.pp @@ -0,0 +1,16 @@ +# == class: zaqar::management::sqlalchemy +# +# [*uri*] +# SQLAlchemy Connection URI. Required. +# +class zaqar::management::sqlalchemy( + $uri, +) { + + include ::zaqar::deps + + zaqar_config { + 'drivers:management_store:sqlalchemy/uri': value => $uri, secret => true; + } + +} diff --git a/manifests/messaging/mongodb.pp b/manifests/messaging/mongodb.pp index d51bb8c..0e82aed 100644 --- a/manifests/messaging/mongodb.pp +++ b/manifests/messaging/mongodb.pp @@ -81,7 +81,6 @@ class zaqar::messaging::mongodb( include ::zaqar::deps zaqar_config { - 'drivers/message_store': value => 'mongodb'; 'drivers:message_store:mongodb/uri': value => $uri, secret => true; 'drivers:message_store:mongodb/ssl_keyfile': value => $ssl_keyfile; 'drivers:message_store:mongodb/ssl_certfile': value => $ssl_certfile; diff --git a/manifests/messaging/swift.pp b/manifests/messaging/swift.pp new file mode 100644 index 0000000..281a907 --- /dev/null +++ b/manifests/messaging/swift.pp @@ -0,0 +1,21 @@ +# == class: zaqar::messaging::swift +# +# [*uri*] +# Swift Connection URI. Required. +# +# [*auth_url*] +# URL to the KeyStone service. Default $::os_service_default +# +class zaqar::messaging::swift( + $uri, + $auth_url = $::os_service_default, +) { + + include ::zaqar::deps + + zaqar_config { + 'drivers:message_store:swift/uri': value => $uri, secret => true; + 'drivers:message_store:swift/auth_url': value => $auth_url; + } + +} diff --git a/spec/acceptance/zaqar_swift_spec.rb b/spec/acceptance/zaqar_swift_spec.rb new file mode 100644 index 0000000..b302f6a --- /dev/null +++ b/spec/acceptance/zaqar_swift_spec.rb @@ -0,0 +1,62 @@ +require 'spec_helper_acceptance' + +describe 'swift zaqar' do + + context 'default parameters' do + + it 'zaqar with swift should work with no errors' do + pp= <<-EOS + include ::openstack_integration + include ::openstack_integration::repos + include ::openstack_integration::mysql + include ::openstack_integration::keystone + include ::openstack_integration::swift + + class { '::memcached': + listen_ip => '127.0.0.1', + } + + class { '::zaqar::keystone::auth': + password => 'a_big_secret', + } + + class { '::zaqar::keystone::auth_websocket': + password => 'a_big_secret', + } + + class {'::zaqar::management::sqlalchemy': + uri => 'mysql+pymysql://zaqar:a_big_secret@127.0.0.1/zaqar?charset=utf8', + } + class {'::zaqar::messaging::swift': + uri => 'swift://zaqar:a_big_secret:/service' + } + class {'::zaqar::keystone::authtoken': + password => 'a_big_secret', + } + class {'::zaqar': + unreliable => true, + } + include ::zaqar::server + # run a second instance using websockets, the Debian system does + # not support the use of services to run a second instance. + if $::osfamily == 'RedHat' { + zaqar::server_instance{ '1': + transport => 'websocket' + } + } + EOS + + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe port(8888) do + it { is_expected.to be_listening.with('tcp') } + end + + end + +end + diff --git a/spec/classes/zaqar_init_spec.rb b/spec/classes/zaqar_init_spec.rb index a8615b7..b155557 100644 --- a/spec/classes/zaqar_init_spec.rb +++ b/spec/classes/zaqar_init_spec.rb @@ -49,6 +49,8 @@ describe 'zaqar' do :claim_pipeline => 'zaqar_pipeline3', :subscription_pipeline => 'zaqar_pipeline4', :max_messages_post_size => '1234', + :message_store => 'swift', + :management_store => 'sqlalchemy', }) end @@ -61,6 +63,8 @@ describe 'zaqar' do is_expected.to contain_zaqar_config('storage/claim_pipeline').with_value('zaqar_pipeline3') is_expected.to contain_zaqar_config('storage/subscription_pipeline').with_value('zaqar_pipeline4') is_expected.to contain_zaqar_config('transport/max_messages_post_size').with_value('1234') + is_expected.to contain_zaqar_config('drivers/message_store').with_value('swift') + is_expected.to contain_zaqar_config('drivers/management_store').with_value('sqlalchemy') end end end diff --git a/spec/classes/zaqar_management_mongodb_spec.rb b/spec/classes/zaqar_management_mongodb_spec.rb index d350bf5..0e40009 100644 --- a/spec/classes/zaqar_management_mongodb_spec.rb +++ b/spec/classes/zaqar_management_mongodb_spec.rb @@ -3,6 +3,14 @@ require 'spec_helper' describe 'zaqar::management::mongodb' do shared_examples_for 'zaqar::management::mongodb' do + let :pre_condition do + "class { '::zaqar::keystone::authtoken': + password =>'foo', + } + class { '::zaqar': + }" + + end let :req_params do { :uri => 'mongodb://127.0.0.1:27017', diff --git a/spec/classes/zaqar_management_sqlalchemy_spec.rb b/spec/classes/zaqar_management_sqlalchemy_spec.rb new file mode 100644 index 0000000..88b5809 --- /dev/null +++ b/spec/classes/zaqar_management_sqlalchemy_spec.rb @@ -0,0 +1,51 @@ +require 'spec_helper' + +describe 'zaqar::management::sqlalchemy' do + + shared_examples_for 'zaqar::management::sqlalchemy' do + let :pre_condition do + "class { '::zaqar::keystone::authtoken': + password =>'foo', + } + class { '::zaqar': + management_store =>'sqlalchemy', + }" + + end + let :req_params do + { + :uri => 'mysql://user:pass@127.0.0.1/zaqar', + } + end + + describe 'with only required params' do + let :params do + req_params + end + + it 'should config sqlalchemy management driver' do + is_expected.to contain_zaqar_config('drivers/management_store').with( + :value => 'sqlalchemy' + ) + is_expected.to contain_zaqar_config('drivers:management_store:sqlalchemy/uri').with( + :value => 'mysql://user:pass@127.0.0.1/zaqar', + ) + 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_configures 'zaqar::management::sqlalchemy' + end + end + +end + diff --git a/spec/classes/zaqar_messaging_mongodb_spec.rb b/spec/classes/zaqar_messaging_mongodb_spec.rb index 7fb3b51..47aef4a 100644 --- a/spec/classes/zaqar_messaging_mongodb_spec.rb +++ b/spec/classes/zaqar_messaging_mongodb_spec.rb @@ -3,6 +3,14 @@ require 'spec_helper' describe 'zaqar::messaging::mongodb' do shared_examples_for 'zaqar::messaging::mongodb' do + let :pre_condition do + "class { '::zaqar::keystone::authtoken': + password =>'foo', + } + class { '::zaqar': + }" + + end let :req_params do { :uri => 'mongodb://127.0.0.1:27017', diff --git a/spec/classes/zaqar_messaging_swift_spec.rb b/spec/classes/zaqar_messaging_swift_spec.rb new file mode 100644 index 0000000..d39e6ab --- /dev/null +++ b/spec/classes/zaqar_messaging_swift_spec.rb @@ -0,0 +1,61 @@ +require 'spec_helper' + +describe 'zaqar::messaging::swift' do + + shared_examples_for 'zaqar::messaging::swift' do + let :pre_condition do + "class { '::zaqar::keystone::authtoken': + password =>'foo', + } + class { '::zaqar': + message_store =>'swift', + }" + end + let :req_params do + { + :uri => 'swift://user:pass@/zaqar', + } + end + + describe 'with only required params' do + let :params do + req_params + end + + it 'should config swift messaging driver' do + is_expected.to contain_zaqar_config('drivers/message_store').with( + :value => 'swift' + ) + is_expected.to contain_zaqar_config('drivers:message_store:swift/uri').with( + :value => 'swift://user:pass@/zaqar', + ) + end + + end + + describe 'with custom values' do + let :params do + req_params.merge!({ + :auth_url => 'http://foo', + }) + end + + it 'configures custom values' do + is_expected.to contain_zaqar_config('drivers:message_store:swift/auth_url').with_value('http://foo') + 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_configures 'zaqar::messaging::swift' + end + end +end +