Imporve unit test coverage for cinder manifects

Add some missing tests to assert module import to improve test
coverage for cinder manifests.

Change-Id: Iad5d55d0679c1cbb5bac3c9f737eef89cfc86f39
This commit is contained in:
Takashi Kajinami 2019-09-11 19:30:10 +09:00
parent bbef575f01
commit 44cedb08a7
2 changed files with 62 additions and 14 deletions

View File

@ -32,7 +32,9 @@ describe 'tripleo::profile::base::cinder::api' do
it 'should do nothing' do
is_expected.to contain_class('tripleo::profile::base::cinder::api')
is_expected.to contain_class('tripleo::profile::base::cinder')
is_expected.to contain_class('tripleo::profile::base::cinder::authtoken')
is_expected.to_not contain_class('cinder::api')
is_expected.to_not contain_class('tripleo::profile::base::apache')
is_expected.to_not contain_class('cinder::ceilometer')
end
end
@ -44,11 +46,15 @@ describe 'tripleo::profile::base::cinder::api' do
} }
it 'should trigger complete configuration' do
is_expected.to contain_class('tripleo::profile::base::cinder::api')
is_expected.to contain_class('tripleo::profile::base::cinder')
is_expected.to contain_class('tripleo::profile::base::cinder::authtoken')
is_expected.to contain_class('cinder::api').with(
:sync_db => true,
# Verify legacy key manager is enabled when none is set in hiera.
:keymgr_backend => 'cinder.keymgr.conf_key_mgr.ConfKeyManager',
)
is_expected.to contain_class('tripleo::profile::base::apache')
is_expected.to contain_class('cinder::ceilometer')
end
end
@ -60,7 +66,11 @@ describe 'tripleo::profile::base::cinder::api' do
} }
it 'should not trigger any configuration' do
is_expected.to contain_class('tripleo::profile::base::cinder::api')
is_expected.to contain_class('tripleo::profile::base::cinder')
is_expected.to contain_class('tripleo::profile::base::cinder::authtoken')
is_expected.to_not contain_class('cinder::api')
is_expected.to_not contain_class('tripleo::profile::base::apache')
is_expected.to_not contain_class('cinder::ceilometer')
end
end
@ -72,10 +82,14 @@ describe 'tripleo::profile::base::cinder::api' do
} }
it 'should trigger complete configuration' do
is_expected.to contain_class('tripleo::profile::base::cinder::api')
is_expected.to contain_class('tripleo::profile::base::cinder')
is_expected.to contain_class('tripleo::profile::base::cinder::authtoken')
is_expected.to contain_class('cinder::api').with(
:sync_db => true,
:keymgr_backend => 'castellan.key_manager.barbican_key_manager.BarbicanKeyManager',
)
is_expected.to contain_class('tripleo::profile::base::apache')
is_expected.to contain_class('cinder::ceilometer')
is_expected.to contain_cinder__type('tripleo')
end
@ -88,10 +102,14 @@ describe 'tripleo::profile::base::cinder::api' do
} }
it 'should trigger complete configuration but with no db sync or default volume type' do
is_expected.to contain_class('tripleo::profile::base::cinder::api')
is_expected.to contain_class('tripleo::profile::base::cinder')
is_expected.to contain_class('tripleo::profile::base::cinder::authtoken')
is_expected.to contain_class('cinder::api').with(
:sync_db => false,
:keymgr_backend => 'castellan.key_manager.barbican_key_manager.BarbicanKeyManager',
)
is_expected.to contain_class('tripleo::profile::base::apache')
is_expected.to contain_class('cinder::ceilometer')
is_expected.to_not contain_cinder__type('tripleo')
end

View File

@ -23,30 +23,42 @@ describe 'tripleo::profile::base::cinder' do
it 'should do nothing' do
is_expected.to contain_class('tripleo::profile::base::cinder')
is_expected.to_not contain_class('cinder')
is_expected.to_not contain_class('cinder::ceilometer')
is_expected.to_not contain_class('cinder::config')
is_expected.to_not contain_class('cinder::glance')
is_expected.to_not contain_class('cinder::nova')
is_expected.to_not contain_class('cinder::logging')
is_expected.to_not contain_class('cinder::keystone::service_user')
is_expected.to_not contain_class('cinder:::cron::db_purge')
end
end
context 'with step 3 on bootstrap node' do
let(:params) { {
:step => 3,
:bootstrap_node => 'node.example.com',
:oslomsg_rpc_hosts => [ '127.0.0.1' ],
:oslomsg_rpc_username => 'cinder',
:oslomsg_rpc_password => 'foo',
:oslomsg_rpc_port => '1234'
:step => 3,
:bootstrap_node => 'node.example.com',
:oslomsg_rpc_hosts => [ '192.168.0.1' ],
:oslomsg_rpc_username => 'cinder1',
:oslomsg_rpc_password => 'foo',
:oslomsg_rpc_port => '1234',
:oslomsg_notify_hosts => [ '192.168.0.2' ],
:oslomsg_notify_username => 'cinder2',
:oslomsg_notify_password => 'baa',
:oslomsg_notify_port => '5678'
} }
it 'should trigger complete configuration' do
is_expected.to contain_class('cinder').with(
:default_transport_url => 'rabbit://cinder:foo@127.0.0.1:1234/?ssl=0'
:default_transport_url => 'rabbit://cinder1:foo@192.168.0.1:1234/?ssl=0'
)
is_expected.to contain_class('cinder::ceilometer').with(
:notification_transport_url => 'rabbit://cinder2:baa@192.168.0.2:5678/?ssl=0'
)
is_expected.to contain_class('cinder::config')
is_expected.to contain_class('cinder::glance')
is_expected.to contain_class('cinder::nova')
is_expected.to contain_class('cinder::logging')
is_expected.to contain_class('cinder::keystone::service_user')
is_expected.to_not contain_class('cinder::cron::db_purge')
end
end
@ -59,30 +71,42 @@ describe 'tripleo::profile::base::cinder' do
it 'should not trigger any configuration' do
is_expected.to_not contain_class('cinder')
is_expected.to_not contain_class('cinder::ceilometer')
is_expected.to_not contain_class('cinder::config')
is_expected.to_not contain_class('cinder::glance')
is_expected.to_not contain_class('cinder::nova')
is_expected.to_not contain_class('cinder::logging')
is_expected.to_not contain_class('cinder::keystone::service_user')
is_expected.to_not contain_class('cinder:::cron::db_purge')
end
end
context 'with step 4 on other node' do
let(:params) { {
:step => 4,
:bootstrap_node => 'somethingelse.example.com',
:oslomsg_rpc_hosts => [ '127.0.0.1' ],
:oslomsg_rpc_username => 'cinder',
:oslomsg_rpc_password => 'foo',
:oslomsg_rpc_port => '5672',
:step => 4,
:bootstrap_node => 'somethingelse.example.com',
:oslomsg_rpc_hosts => [ '192.168.0.1' ],
:oslomsg_rpc_username => 'cinder1',
:oslomsg_rpc_password => 'foo',
:oslomsg_rpc_port => '1234',
:oslomsg_notify_hosts => [ '192.168.0.2' ],
:oslomsg_notify_username => 'cinder2',
:oslomsg_notify_password => 'baa',
:oslomsg_notify_port => '5678'
} }
it 'should trigger cinder configuration without mysql grant' do
is_expected.to contain_class('cinder').with(
:default_transport_url => 'rabbit://cinder:foo@127.0.0.1:5672/?ssl=0'
:default_transport_url => 'rabbit://cinder1:foo@192.168.0.1:1234/?ssl=0'
)
is_expected.to contain_class('cinder::ceilometer').with(
:notification_transport_url => 'rabbit://cinder2:baa@192.168.0.2:5678/?ssl=0'
)
is_expected.to contain_class('cinder::config')
is_expected.to contain_class('cinder::glance')
is_expected.to contain_class('cinder::nova')
is_expected.to contain_class('cinder::logging')
is_expected.to contain_class('cinder::keystone::service_user')
is_expected.to_not contain_class('cinder:::cron::db_purge')
end
end
@ -100,9 +124,12 @@ describe 'tripleo::profile::base::cinder' do
is_expected.to contain_class('cinder').with(
:default_transport_url => 'rabbit://cinder:foo@127.0.0.1:5672/?ssl=0'
)
is_expected.to contain_class('cinder::ceilometer')
is_expected.to contain_class('cinder::config')
is_expected.to contain_class('cinder::glance')
is_expected.to contain_class('cinder::nova')
is_expected.to contain_class('cinder::logging')
is_expected.to contain_class('cinder::keystone::service_user')
is_expected.to contain_class('cinder::cron::db_purge')
end
end
@ -121,9 +148,12 @@ describe 'tripleo::profile::base::cinder' do
is_expected.to contain_class('cinder').with(
:default_transport_url => 'rabbit://cinder:foo@127.0.0.1:5672/?ssl=0'
)
is_expected.to contain_class('cinder::ceilometer')
is_expected.to contain_class('cinder::config')
is_expected.to contain_class('cinder::glance')
is_expected.to contain_class('cinder::nova')
is_expected.to contain_class('cinder::logging')
is_expected.to contain_class('cinder::keystone::service_user')
is_expected.to_not contain_class('cinder::cron::db_purge')
end
end