From 366deb93cb377ab160060000999f6309ed89b547 Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Thu, 18 Feb 2016 21:32:17 -0700 Subject: [PATCH] Switch zaqar to use rspec-puppet-facts This change updates the tests to use rspec-puppet-facts. Additionally this change fixes the relationship in zaqar::server_instance for Debian based systems. Change-Id: I03ce4ee17feec1f0ea7012ea116c9c12cf3bde5f --- manifests/server_instance.pp | 6 +- spec/classes/zaqar_db_mysql_spec.rb | 97 +++++---- spec/classes/zaqar_db_postgresql_spec.rb | 45 ++--- spec/classes/zaqar_init_spec.rb | 117 ++++++----- spec/classes/zaqar_keystone_auth_spec.rb | 189 +++++++++--------- spec/classes/zaqar_logging_spec.rb | 23 +-- spec/classes/zaqar_management_mongodb_spec.rb | 102 +++++----- spec/classes/zaqar_messaging_mongodb_spec.rb | 109 +++++----- spec/classes/zaqar_policy_spec.rb | 22 +- spec/classes/zaqar_server_instance_spec.rb | 26 --- spec/classes/zaqar_server_spec.rb | 42 ++-- .../classes/zaqar_transport_websocket_spec.rb | 41 ++-- spec/classes/zaqar_transport_wsgi_spec.rb | 37 ++-- spec/defines/zaqar_server_instance_spec.rb | 48 +++++ 14 files changed, 497 insertions(+), 407 deletions(-) delete mode 100644 spec/classes/zaqar_server_instance_spec.rb create mode 100644 spec/defines/zaqar_server_instance_spec.rb diff --git a/manifests/server_instance.pp b/manifests/server_instance.pp index 4ec6c6f..a27a262 100644 --- a/manifests/server_instance.pp +++ b/manifests/server_instance.pp @@ -30,13 +30,13 @@ define zaqar::server_instance( include ::zaqar include ::zaqar::params - service { "openstack-zaqar@${name}": + service { "${::zaqar::params::service_name}@${name}": ensure => $service_ensure, enable => $enabled, } - Package[$::zaqar::params::package_name] ~> Service["${::zaqar::params::service_name}@${name}"] - Package[$::zaqar::params::package_name] ~> File["/etc/zaqar/${name}.conf"] + Package['zaqar-common'] ~> Service["${::zaqar::params::service_name}@${name}"] + Package['zaqar-common'] ~> File["/etc/zaqar/${name}.conf"] File["/etc/zaqar/${name}.conf"] ~> Service["${::zaqar::params::service_name}@${name}"] Zaqar_config<||> ~> Service["${::zaqar::params::service_name}@${name}"] diff --git a/spec/classes/zaqar_db_mysql_spec.rb b/spec/classes/zaqar_db_mysql_spec.rb index 495e3e4..41627ca 100644 --- a/spec/classes/zaqar_db_mysql_spec.rb +++ b/spec/classes/zaqar_db_mysql_spec.rb @@ -2,61 +2,70 @@ require 'spec_helper' describe 'zaqar::db::mysql' do - let :pre_condition do - [ - 'include mysql::server', - 'include zaqar::db::sync' - ] - end + shared_examples_for 'zaqar::db::mysql' do + let :pre_condition do + [ + 'include mysql::server', + 'include zaqar::db::sync' + ] + end - let :facts do - { :osfamily => 'Debian' } - end - - let :params do - { - 'password' => 'fooboozoo_default_password', - } - end - - describe 'with only required params' do - it { is_expected.to contain_openstacklib__db__mysql('zaqar').with( - 'user' => 'zaqar', - 'password_hash' => '*3DDF34A86854A312A8E2C65B506E21C91800D206', - 'dbname' => 'zaqar', - 'host' => '127.0.0.1', - 'charset' => 'utf8', - :collate => 'utf8_general_ci', - )} - end - - describe "overriding allowed_hosts param to array" do let :params do { - :password => 'zaqarpass', - :allowed_hosts => ['127.0.0.1','%'] + 'password' => 'fooboozoo_default_password', } end - end - describe "overriding allowed_hosts param to string" do - let :params do - { - :password => 'zaqarpass2', - :allowed_hosts => '192.168.1.1' - } + describe 'with only required params' do + it { is_expected.to contain_openstacklib__db__mysql('zaqar').with( + 'user' => 'zaqar', + 'password_hash' => '*3DDF34A86854A312A8E2C65B506E21C91800D206', + 'dbname' => 'zaqar', + 'host' => '127.0.0.1', + 'charset' => 'utf8', + :collate => 'utf8_general_ci', + )} end - end + describe "overriding allowed_hosts param to array" do + let :params do + { + :password => 'zaqarpass', + :allowed_hosts => ['127.0.0.1','%'] + } + end + + end + describe "overriding allowed_hosts param to string" do + let :params do + { + :password => 'zaqarpass2', + :allowed_hosts => '192.168.1.1' + } + end - describe "overriding allowed_hosts param equals to host param " do - let :params do - { - :password => 'zaqarpass2', - :allowed_hosts => '127.0.0.1' - } end + describe "overriding allowed_hosts param equals to host param " do + let :params do + { + :password => 'zaqarpass2', + :allowed_hosts => '127.0.0.1' + } + 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::db::mysql' + end end end diff --git a/spec/classes/zaqar_db_postgresql_spec.rb b/spec/classes/zaqar_db_postgresql_spec.rb index 3f45600..66666fe 100644 --- a/spec/classes/zaqar_db_postgresql_spec.rb +++ b/spec/classes/zaqar_db_postgresql_spec.rb @@ -2,21 +2,13 @@ require 'spec_helper' describe 'zaqar::db::postgresql' do - let :req_params do - { :password => 'pw' } - end + shared_examples_for 'zaqar::db::postgresql' do + let :req_params do + { :password => 'pw' } + end - let :pre_condition do - 'include postgresql::server' - end - - context 'on a RedHat osfamily' do - let :facts do - { - :osfamily => 'RedHat', - :operatingsystemrelease => '7.0', - :concat_basedir => '/var/lib/puppet/concat' - } + let :pre_condition do + 'include postgresql::server' end context 'with only required parameters' do @@ -32,27 +24,16 @@ describe 'zaqar::db::postgresql' do end - context 'on a Debian osfamily' do - let :facts do - { - :operatingsystemrelease => '7.8', - :operatingsystem => 'Debian', - :osfamily => 'Debian', - :concat_basedir => '/var/lib/puppet/concat' - } - end - - context 'with only required parameters' do - let :params do - req_params + 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({ :concat_basedir => '/var/lib/puppet/concat' })) end - it { is_expected.to contain_postgresql__server__db('zaqar').with( - :user => 'zaqar', - :password => 'md52e9c9a1a01bb2fef7463b70dd24d4b25' - )} + it_configures 'zaqar::db::postgresql' end - end end diff --git a/spec/classes/zaqar_init_spec.rb b/spec/classes/zaqar_init_spec.rb index 8b3a925..b1c88fa 100644 --- a/spec/classes/zaqar_init_spec.rb +++ b/spec/classes/zaqar_init_spec.rb @@ -1,61 +1,82 @@ require 'spec_helper' describe 'zaqar' do - let :req_params do - { - :admin_password => 'foo', - } - end - - let :facts do - { :osfamily => 'RedHat' } - end - - describe 'with only required params' do - let :params do - req_params + shared_examples 'zaqar' do + let :req_params do + { + :admin_password => 'foo', + } end - it { is_expected.to contain_package('zaqar-common').with( - :ensure => 'present', - :name => 'openstack-zaqar' - )} + describe 'with only required params' do + let :params do + req_params + end - it { is_expected.to contain_class('zaqar::params') } + it { is_expected.to contain_package('zaqar-common').with( + :ensure => 'present', + :name => platform_params[:zaqar_common_package], + :tag => ['openstack', 'zaqar-package'] + )} + + it { is_expected.to contain_class('zaqar::params') } + + it 'should contain default config' do + is_expected.to contain_zaqar_config('keystone_authtoken/auth_uri').with( + :value => 'http://localhost:5000/' + ) + is_expected.to contain_zaqar_config('keystone_authtoken/identity_uri').with( + :value => 'http://localhost:35357/' + ) + is_expected.to contain_zaqar_config('keystone_authtoken/admin_tenant_name').with( + :value => 'services' + ) + is_expected.to contain_zaqar_config('keystone_authtoken/admin_user').with( + :value => 'zaqar' + ) + is_expected.to contain_zaqar_config('keystone_authtoken/admin_password').with( + :value => 'foo' + ) + is_expected.to contain_zaqar_config('DEFAULT/auth_strategy').with( + :value => 'keystone' + ) + end - it 'should contain default config' do - is_expected.to contain_zaqar_config('keystone_authtoken/auth_uri').with( - :value => 'http://localhost:5000/' - ) - is_expected.to contain_zaqar_config('keystone_authtoken/identity_uri').with( - :value => 'http://localhost:35357/' - ) - is_expected.to contain_zaqar_config('keystone_authtoken/admin_tenant_name').with( - :value => 'services' - ) - is_expected.to contain_zaqar_config('keystone_authtoken/admin_user').with( - :value => 'zaqar' - ) - is_expected.to contain_zaqar_config('keystone_authtoken/admin_password').with( - :value => 'foo' - ) end - end + describe 'with custom values' do + let :params do + req_params.merge!({ + :admin_mode => true, + :unreliable => true, + :pooling => true + }) + end - describe 'with custom values' do - let :params do - req_params.merge!({ - :admin_mode => true, - :unreliable => true, - :pooling => true - }) - end - - it do - is_expected.to contain_zaqar_config('DEFAULT/admin_mode').with_value(true) - is_expected.to contain_zaqar_config('DEFAULT/unreliable').with_value(true) - is_expected.to contain_zaqar_config('DEFAULT/pooling').with_value(true) + it do + is_expected.to contain_zaqar_config('DEFAULT/admin_mode').with_value(true) + is_expected.to contain_zaqar_config('DEFAULT/unreliable').with_value(true) + is_expected.to contain_zaqar_config('DEFAULT/pooling').with_value(true) + 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 + + let(:platform_params) do + case facts[:osfamily] + when 'Debian' + { :zaqar_common_package => 'zaqar' } + when 'RedHat' + { :zaqar_common_package => 'openstack-zaqar' } + end + end + it_behaves_like 'zaqar' + end + end end diff --git a/spec/classes/zaqar_keystone_auth_spec.rb b/spec/classes/zaqar_keystone_auth_spec.rb index 18114b8..24c3cd7 100644 --- a/spec/classes/zaqar_keystone_auth_spec.rb +++ b/spec/classes/zaqar_keystone_auth_spec.rb @@ -6,116 +6,127 @@ require 'spec_helper' describe 'zaqar::keystone::auth' do - let :facts do - { :osfamily => 'Debian' } - end - describe 'with default class parameters' do - let :params do - { :password => 'zaqar_password', - :tenant => 'foobar' } + shared_examples_for 'zaqar::keystone::auth' do + describe 'with default class parameters' do + let :params do + { :password => 'zaqar_password', + :tenant => 'foobar' } + end + + it { is_expected.to contain_keystone_user('zaqar').with( + :ensure => 'present', + :password => 'zaqar_password', + ) } + + it { is_expected.to contain_keystone_user_role('zaqar@foobar').with( + :ensure => 'present', + :roles => ['admin'] + )} + + it { is_expected.to contain_keystone_service('zaqar::messaging').with( + :ensure => 'present', + :description => 'Openstack messaging Service' + ) } + + it { is_expected.to contain_keystone_endpoint('RegionOne/zaqar::messaging').with( + :ensure => 'present', + :public_url => "http://127.0.0.1:8888", + :admin_url => "http://127.0.0.1:8888", + :internal_url => "http://127.0.0.1:8888" + ) } end - it { is_expected.to contain_keystone_user('zaqar').with( - :ensure => 'present', - :password => 'zaqar_password', - ) } + describe 'when overriding public_url, internal_url and admin_url' do + let :params do + { :password => 'zaqar_password', + :public_url => 'https://10.10.10.10:8080', + :admin_url => 'http://10.10.10.10:8080', + :internal_url => 'http://10.10.10.10:8080' + } + end - it { is_expected.to contain_keystone_user_role('zaqar@foobar').with( - :ensure => 'present', - :roles => ['admin'] - )} - - it { is_expected.to contain_keystone_service('zaqar::messaging').with( - :ensure => 'present', - :description => 'Openstack messaging Service' - ) } - - it { is_expected.to contain_keystone_endpoint('RegionOne/zaqar::messaging').with( - :ensure => 'present', - :public_url => "http://127.0.0.1:8888", - :admin_url => "http://127.0.0.1:8888", - :internal_url => "http://127.0.0.1:8888" - ) } - end - - describe 'when overriding public_url, internal_url and admin_url' do - let :params do - { :password => 'zaqar_password', - :public_url => 'https://10.10.10.10:8080', - :admin_url => 'http://10.10.10.10:8080', - :internal_url => 'http://10.10.10.10:8080' - } + it { is_expected.to contain_keystone_endpoint('RegionOne/zaqar::messaging').with( + :ensure => 'present', + :public_url => "https://10.10.10.10:8080", + :internal_url => "http://10.10.10.10:8080", + :admin_url => "http://10.10.10.10:8080" + ) } end - it { is_expected.to contain_keystone_endpoint('RegionOne/zaqar::messaging').with( - :ensure => 'present', - :public_url => "https://10.10.10.10:8080", - :internal_url => "http://10.10.10.10:8080", - :admin_url => "http://10.10.10.10:8080" - ) } - end + describe 'when overriding auth name' do + let :params do + { :password => 'foo', + :auth_name => 'zaqary' } + end - describe 'when overriding auth name' do - let :params do - { :password => 'foo', - :auth_name => 'zaqary' } + it { is_expected.to contain_keystone_user('zaqary') } + it { is_expected.to contain_keystone_user_role('zaqary@services') } + it { is_expected.to contain_keystone_service('zaqary::messaging') } + it { is_expected.to contain_keystone_endpoint('RegionOne/zaqary::messaging') } end - it { is_expected.to contain_keystone_user('zaqary') } - it { is_expected.to contain_keystone_user_role('zaqary@services') } - it { is_expected.to contain_keystone_service('zaqary::messaging') } - it { is_expected.to contain_keystone_endpoint('RegionOne/zaqary::messaging') } - end + describe 'when overriding service name' do + let :params do + { :service_name => 'zaqar_service', + :auth_name => 'zaqar', + :password => 'zaqar_password' } + end - describe 'when overriding service name' do - let :params do - { :service_name => 'zaqar_service', - :auth_name => 'zaqar', - :password => 'zaqar_password' } + it { is_expected.to contain_keystone_user('zaqar') } + it { is_expected.to contain_keystone_user_role('zaqar@services') } + it { is_expected.to contain_keystone_service('zaqar_service::messaging') } + it { is_expected.to contain_keystone_endpoint('RegionOne/zaqar_service::messaging') } end - it { is_expected.to contain_keystone_user('zaqar') } - it { is_expected.to contain_keystone_user_role('zaqar@services') } - it { is_expected.to contain_keystone_service('zaqar_service::messaging') } - it { is_expected.to contain_keystone_endpoint('RegionOne/zaqar_service::messaging') } - end + describe 'when disabling user configuration' do - describe 'when disabling user configuration' do + let :params do + { + :password => 'zaqar_password', + :configure_user => false + } + end + + it { is_expected.not_to contain_keystone_user('zaqar') } + it { is_expected.to contain_keystone_user_role('zaqar@services') } + it { is_expected.to contain_keystone_service('zaqar::messaging').with( + :ensure => 'present', + :description => 'Openstack messaging Service' + ) } - let :params do - { - :password => 'zaqar_password', - :configure_user => false - } end - it { is_expected.not_to contain_keystone_user('zaqar') } - it { is_expected.to contain_keystone_user_role('zaqar@services') } - it { is_expected.to contain_keystone_service('zaqar::messaging').with( - :ensure => 'present', - :description => 'Openstack messaging Service' - ) } + describe 'when disabling user and user role configuration' do + let :params do + { + :password => 'zaqar_password', + :configure_user => false, + :configure_user_role => false + } + end + + it { is_expected.not_to contain_keystone_user('zaqar') } + it { is_expected.not_to contain_keystone_user_role('zaqar@services') } + it { is_expected.to contain_keystone_service('zaqar::messaging').with( + :ensure => 'present', + :description => 'Openstack messaging Service' + ) } + + end end - describe 'when disabling user and user role configuration' do + 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 - let :params do - { - :password => 'zaqar_password', - :configure_user => false, - :configure_user_role => false - } + it_configures 'zaqar::keystone::auth' end - - it { is_expected.not_to contain_keystone_user('zaqar') } - it { is_expected.not_to contain_keystone_user_role('zaqar@services') } - it { is_expected.to contain_keystone_service('zaqar::messaging').with( - :ensure => 'present', - :description => 'Openstack messaging Service' - ) } - end end diff --git a/spec/classes/zaqar_logging_spec.rb b/spec/classes/zaqar_logging_spec.rb index 7eee526..8257b2d 100644 --- a/spec/classes/zaqar_logging_spec.rb +++ b/spec/classes/zaqar_logging_spec.rb @@ -88,20 +88,15 @@ describe 'zaqar::logging' do } end - context 'on Debian platforms' do - let :facts do - { :osfamily => 'Debian' } + 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-logging' end - - it_configures 'zaqar-logging' end - - context 'on RedHat platforms' do - let :facts do - { :osfamily => 'RedHat' } - end - - it_configures 'zaqar-logging' - end - end diff --git a/spec/classes/zaqar_management_mongodb_spec.rb b/spec/classes/zaqar_management_mongodb_spec.rb index 443b973..d350bf5 100644 --- a/spec/classes/zaqar_management_mongodb_spec.rb +++ b/spec/classes/zaqar_management_mongodb_spec.rb @@ -2,59 +2,69 @@ require 'spec_helper' describe 'zaqar::management::mongodb' do - let :req_params do - { - :uri => 'mongodb://127.0.0.1:27017', - } - end - - let :facts do - { :osfamily => 'RedHat' } - end - - describe 'with only required params' do - let :params do - req_params + shared_examples_for 'zaqar::management::mongodb' do + let :req_params do + { + :uri => 'mongodb://127.0.0.1:27017', + } end - it 'should config mongo management driver' do - is_expected.to contain_zaqar_config('drivers/management_store').with( - :value => 'mongodb' - ) - is_expected.to contain_zaqar_config('drivers:management_store:mongodb/uri').with( - :value => 'mongodb://127.0.0.1:27017' - ) + describe 'with only required params' do + let :params do + req_params + end + + it 'should config mongo management driver' do + is_expected.to contain_zaqar_config('drivers/management_store').with( + :value => 'mongodb' + ) + is_expected.to contain_zaqar_config('drivers:management_store:mongodb/uri').with( + :value => 'mongodb://127.0.0.1:27017' + ) + end + end + describe 'with custom values' do + let :params do + req_params.merge!({ + :ssl_keyfile => 'keyfile', + :ssl_certfile => 'certfile', + :ssl_cert_reqs => 'cert_reqs', + :ssl_ca_certs => 'ca_certs', + :database => 'zaqar_db', + :max_attempts => '1', + :max_retry_sleep => '2', + :max_retry_jitter => '3', + :max_reconnect_attempts => '4', + :reconnect_sleep => '5', + }) + end + + it 'configures custom values' do + is_expected.to contain_zaqar_config('drivers:management_store:mongodb/ssl_keyfile').with_value('keyfile') + is_expected.to contain_zaqar_config('drivers:management_store:mongodb/ssl_certfile').with_value('certfile') + is_expected.to contain_zaqar_config('drivers:management_store:mongodb/ssl_cert_reqs').with_value('cert_reqs') + is_expected.to contain_zaqar_config('drivers:management_store:mongodb/ssl_ca_certs').with_value('ca_certs') + is_expected.to contain_zaqar_config('drivers:management_store:mongodb/database').with_value('zaqar_db') + is_expected.to contain_zaqar_config('drivers:management_store:mongodb/max_attempts').with_value('1') + is_expected.to contain_zaqar_config('drivers:management_store:mongodb/max_retry_sleep').with_value('2') + is_expected.to contain_zaqar_config('drivers:management_store:mongodb/max_retry_jitter').with_value('3') + is_expected.to contain_zaqar_config('drivers:management_store:mongodb/max_reconnect_attempts').with_value('4') + is_expected.to contain_zaqar_config('drivers:management_store:mongodb/reconnect_sleep').with_value('5') + end + end end - describe 'with custom values' do - let :params do - req_params.merge!({ - :ssl_keyfile => 'keyfile', - :ssl_certfile => 'certfile', - :ssl_cert_reqs => 'cert_reqs', - :ssl_ca_certs => 'ca_certs', - :database => 'zaqar_db', - :max_attempts => '1', - :max_retry_sleep => '2', - :max_retry_jitter => '3', - :max_reconnect_attempts => '4', - :reconnect_sleep => '5', - }) - 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 custom values' do - is_expected.to contain_zaqar_config('drivers:management_store:mongodb/ssl_keyfile').with_value('keyfile') - is_expected.to contain_zaqar_config('drivers:management_store:mongodb/ssl_certfile').with_value('certfile') - is_expected.to contain_zaqar_config('drivers:management_store:mongodb/ssl_cert_reqs').with_value('cert_reqs') - is_expected.to contain_zaqar_config('drivers:management_store:mongodb/ssl_ca_certs').with_value('ca_certs') - is_expected.to contain_zaqar_config('drivers:management_store:mongodb/database').with_value('zaqar_db') - is_expected.to contain_zaqar_config('drivers:management_store:mongodb/max_attempts').with_value('1') - is_expected.to contain_zaqar_config('drivers:management_store:mongodb/max_retry_sleep').with_value('2') - is_expected.to contain_zaqar_config('drivers:management_store:mongodb/max_retry_jitter').with_value('3') - is_expected.to contain_zaqar_config('drivers:management_store:mongodb/max_reconnect_attempts').with_value('4') - is_expected.to contain_zaqar_config('drivers:management_store:mongodb/reconnect_sleep').with_value('5') + it_configures 'zaqar::management::mongodb' end end diff --git a/spec/classes/zaqar_messaging_mongodb_spec.rb b/spec/classes/zaqar_messaging_mongodb_spec.rb index e068c8e..7fb3b51 100644 --- a/spec/classes/zaqar_messaging_mongodb_spec.rb +++ b/spec/classes/zaqar_messaging_mongodb_spec.rb @@ -2,62 +2,71 @@ require 'spec_helper' describe 'zaqar::messaging::mongodb' do - let :req_params do - { - :uri => 'mongodb://127.0.0.1:27017', - } - end - - let :facts do - { :osfamily => 'RedHat' } - end - - describe 'with only required params' do - let :params do - req_params + shared_examples_for 'zaqar::messaging::mongodb' do + let :req_params do + { + :uri => 'mongodb://127.0.0.1:27017', + } end - it 'should config mongo messaging driver' do - is_expected.to contain_zaqar_config('drivers/message_store').with( - :value => 'mongodb' - ) - is_expected.to contain_zaqar_config('drivers:message_store:mongodb/uri').with( - :value => 'mongodb://127.0.0.1:27017' - ) + describe 'with only required params' do + let :params do + req_params + end + + it 'should config mongo messaging driver' do + is_expected.to contain_zaqar_config('drivers/message_store').with( + :value => 'mongodb' + ) + is_expected.to contain_zaqar_config('drivers:message_store:mongodb/uri').with( + :value => 'mongodb://127.0.0.1:27017' + ) + end + end - end + describe 'with custom values' do + let :params do + req_params.merge!({ + :ssl_keyfile => 'keyfile', + :ssl_certfile => 'certfile', + :ssl_cert_reqs => 'cert_reqs', + :ssl_ca_certs => 'ca_certs', + :database => 'zaqar_db', + :max_attempts => '1', + :max_retry_sleep => '2', + :max_retry_jitter => '3', + :max_reconnect_attempts => '4', + :reconnect_sleep => '5', + :partitions => '6', + }) + end - describe 'with custom values' do - let :params do - req_params.merge!({ - :ssl_keyfile => 'keyfile', - :ssl_certfile => 'certfile', - :ssl_cert_reqs => 'cert_reqs', - :ssl_ca_certs => 'ca_certs', - :database => 'zaqar_db', - :max_attempts => '1', - :max_retry_sleep => '2', - :max_retry_jitter => '3', - :max_reconnect_attempts => '4', - :reconnect_sleep => '5', - :partitions => '6', - }) - end - - it 'configures custom values' do - is_expected.to contain_zaqar_config('drivers:message_store:mongodb/ssl_keyfile').with_value('keyfile') - is_expected.to contain_zaqar_config('drivers:message_store:mongodb/ssl_certfile').with_value('certfile') - is_expected.to contain_zaqar_config('drivers:message_store:mongodb/ssl_cert_reqs').with_value('cert_reqs') - is_expected.to contain_zaqar_config('drivers:message_store:mongodb/ssl_ca_certs').with_value('ca_certs') - is_expected.to contain_zaqar_config('drivers:message_store:mongodb/database').with_value('zaqar_db') - is_expected.to contain_zaqar_config('drivers:message_store:mongodb/max_attempts').with_value('1') - is_expected.to contain_zaqar_config('drivers:message_store:mongodb/max_retry_sleep').with_value('2') - is_expected.to contain_zaqar_config('drivers:message_store:mongodb/max_retry_jitter').with_value('3') - is_expected.to contain_zaqar_config('drivers:message_store:mongodb/max_reconnect_attempts').with_value('4') - is_expected.to contain_zaqar_config('drivers:message_store:mongodb/reconnect_sleep').with_value('5') - is_expected.to contain_zaqar_config('drivers:message_store:mongodb/partitions').with_value('6') + it 'configures custom values' do + is_expected.to contain_zaqar_config('drivers:message_store:mongodb/ssl_keyfile').with_value('keyfile') + is_expected.to contain_zaqar_config('drivers:message_store:mongodb/ssl_certfile').with_value('certfile') + is_expected.to contain_zaqar_config('drivers:message_store:mongodb/ssl_cert_reqs').with_value('cert_reqs') + is_expected.to contain_zaqar_config('drivers:message_store:mongodb/ssl_ca_certs').with_value('ca_certs') + is_expected.to contain_zaqar_config('drivers:message_store:mongodb/database').with_value('zaqar_db') + is_expected.to contain_zaqar_config('drivers:message_store:mongodb/max_attempts').with_value('1') + is_expected.to contain_zaqar_config('drivers:message_store:mongodb/max_retry_sleep').with_value('2') + is_expected.to contain_zaqar_config('drivers:message_store:mongodb/max_retry_jitter').with_value('3') + is_expected.to contain_zaqar_config('drivers:message_store:mongodb/max_reconnect_attempts').with_value('4') + is_expected.to contain_zaqar_config('drivers:message_store:mongodb/reconnect_sleep').with_value('5') + is_expected.to contain_zaqar_config('drivers:message_store:mongodb/partitions').with_value('6') + 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::mongodb' + end + end end diff --git a/spec/classes/zaqar_policy_spec.rb b/spec/classes/zaqar_policy_spec.rb index f5bae4d..32d76a5 100644 --- a/spec/classes/zaqar_policy_spec.rb +++ b/spec/classes/zaqar_policy_spec.rb @@ -23,19 +23,15 @@ describe 'zaqar::policy' do end end - context 'on Debian platforms' do - let :facts do - { :osfamily => 'Debian' } + 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 policies' end - - it_configures 'zaqar policies' - end - - context 'on RedHat platforms' do - let :facts do - { :osfamily => 'RedHat' } - end - - it_configures 'zaqar policies' end end diff --git a/spec/classes/zaqar_server_instance_spec.rb b/spec/classes/zaqar_server_instance_spec.rb deleted file mode 100644 index b833304..0000000 --- a/spec/classes/zaqar_server_instance_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'spec_helper' -describe 'zaqar' do - - let :pre_condition do - "zaqar::server_instance{ '1': transport => 'websocket' }" - end - - let :facts do - { :osfamily => 'RedHat' } - end - - let :params do - { :admin_password => 'foo' } - end - - describe 'with a websocket server instance 1' do - - it { is_expected.to contain_service('openstack-zaqar@1').with( - :ensure => 'running', - :enable => true - )} - it {is_expected.to contain_file('/etc/zaqar/1.conf') } - - end - -end diff --git a/spec/classes/zaqar_server_spec.rb b/spec/classes/zaqar_server_spec.rb index e2d0623..df63ac7 100644 --- a/spec/classes/zaqar_server_spec.rb +++ b/spec/classes/zaqar_server_spec.rb @@ -1,20 +1,38 @@ require 'spec_helper' describe 'zaqar::server' do - let :facts do - { :osfamily => 'RedHat' } - end + shared_examples_for 'zaqar::server' do + describe 'with a zaqar server enabled' do + let :pre_condition do + "class {'::zaqar': admin_password => 'foo'}" + end + + it { is_expected.to contain_service(platform_params[:zaqar_service_name]).with( + :ensure => 'running', + :enable => true + )} - describe 'with a zaqar server enabled' do - let :pre_condition do - "class {'::zaqar': admin_password => 'foo'}" end - - it { is_expected.to contain_service('openstack-zaqar').with( - :ensure => 'running', - :enable => true - )} - 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 + + let(:platform_params) do + case facts[:osfamily] + when 'Debian' + { :zaqar_service_name => 'zaqar' } + when 'RedHat' + { :zaqar_service_name => 'openstack-zaqar' } + end + end + + it_configures 'zaqar::server' + end + end end diff --git a/spec/classes/zaqar_transport_websocket_spec.rb b/spec/classes/zaqar_transport_websocket_spec.rb index 945a3bd..def090e 100644 --- a/spec/classes/zaqar_transport_websocket_spec.rb +++ b/spec/classes/zaqar_transport_websocket_spec.rb @@ -2,24 +2,33 @@ require 'spec_helper' describe 'zaqar::transport::websocket' do - let :facts do - { :osfamily => 'RedHat' } - end + shared_examples_for 'zaqar::transport::websocket' do + describe 'with custom values' do + let :params do + { + :bind => '1', + :port => '2', + :external_port => '3', + } + end - describe 'with custom values' do - let :params do - { - :bind => '1', - :port => '2', - :external_port => '3', - } - end - - it 'configures custom values' do - is_expected.to contain_zaqar_config('drivers:transport:websocket/bind').with_value('1') - is_expected.to contain_zaqar_config('drivers:transport:websocket/port').with_value('2') - is_expected.to contain_zaqar_config('drivers:transport:websocket/external-port').with_value('3') + it 'configures custom values' do + is_expected.to contain_zaqar_config('drivers:transport:websocket/bind').with_value('1') + is_expected.to contain_zaqar_config('drivers:transport:websocket/port').with_value('2') + is_expected.to contain_zaqar_config('drivers:transport:websocket/external-port').with_value('3') + 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::transport::websocket' + end + end end diff --git a/spec/classes/zaqar_transport_wsgi_spec.rb b/spec/classes/zaqar_transport_wsgi_spec.rb index 3b46f59..84e62a4 100644 --- a/spec/classes/zaqar_transport_wsgi_spec.rb +++ b/spec/classes/zaqar_transport_wsgi_spec.rb @@ -2,22 +2,31 @@ require 'spec_helper' describe 'zaqar::transport::wsgi' do - let :facts do - { :osfamily => 'RedHat' } - end + shared_examples_for 'zaqar::transport::wsgi' do + describe 'with custom values' do + let :params do + { + :bind => '1', + :port => '2', + } + end - describe 'with custom values' do - let :params do - { - :bind => '1', - :port => '2', - } - end - - it 'configures custom values' do - is_expected.to contain_zaqar_config('drivers:transport:wsgi/bind').with_value('1') - is_expected.to contain_zaqar_config('drivers:transport:wsgi/port').with_value('2') + it 'configures custom values' do + is_expected.to contain_zaqar_config('drivers:transport:wsgi/bind').with_value('1') + is_expected.to contain_zaqar_config('drivers:transport:wsgi/port').with_value('2') + 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::transport::wsgi' + end + end end diff --git a/spec/defines/zaqar_server_instance_spec.rb b/spec/defines/zaqar_server_instance_spec.rb new file mode 100644 index 0000000..d5be950 --- /dev/null +++ b/spec/defines/zaqar_server_instance_spec.rb @@ -0,0 +1,48 @@ +require 'spec_helper' +describe 'zaqar::server_instance' do + + shared_examples_for 'zaqar::server_instance' do + let(:title) { '1' } + + let :pre_condition do + "class { 'zaqar': admin_password => 'foo' }" + end + + let :params do + { + :transport => 'websocket' + } + end + + describe 'with a websocket server instance 1' do + + it { is_expected.to contain_service("#{platform_params[:zaqar_service_name]}@1").with( + :ensure => 'running', + :enable => true + )} + it { is_expected.to contain_file('/etc/zaqar/1.conf') } + + 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 + + let(:platform_params) do + case facts[:osfamily] + when 'Debian' + { :zaqar_service_name => 'zaqar' } + when 'RedHat' + { :zaqar_service_name => 'openstack-zaqar' } + end + end + + it_configures 'zaqar::server_instance' + end + end +end