2016-06-15 08:36:25 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'watcher::api' do
|
|
|
|
|
|
|
|
let :params do
|
2016-08-17 22:26:52 +00:00
|
|
|
{ :watcher_client_password => 'password',
|
2016-06-28 14:41:47 +00:00
|
|
|
:manage_service => true,
|
|
|
|
:enabled => true,
|
|
|
|
:package_ensure => 'latest',
|
|
|
|
}
|
2016-06-15 08:36:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples 'watcher-api' do
|
|
|
|
|
2016-08-17 22:26:52 +00:00
|
|
|
context 'without required parameter watcher_client_password' do
|
|
|
|
before { params.delete(:watcher_client_password) }
|
2016-06-15 08:36:25 +00:00
|
|
|
it { expect { is_expected.to raise_error(Puppet::Error) } }
|
|
|
|
end
|
|
|
|
|
2016-06-28 14:41:47 +00:00
|
|
|
it { is_expected.to contain_class('watcher::params') }
|
|
|
|
|
|
|
|
it 'installs watcher-api package' do
|
|
|
|
is_expected.to contain_package('watcher-api').with(
|
|
|
|
:ensure => 'latest',
|
|
|
|
:name => platform_params[:api_package_name],
|
|
|
|
:tag => ['openstack', 'watcher-package'],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
[{:enabled => true}, {:enabled => false}].each do |param_hash|
|
|
|
|
context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
|
|
|
|
before do
|
|
|
|
params.merge!(param_hash)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'configures watcher-api service' do
|
|
|
|
is_expected.to contain_service('watcher-api').with(
|
|
|
|
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
|
|
|
|
:name => platform_params[:api_service_name],
|
|
|
|
:enable => params[:enabled],
|
|
|
|
:hasstatus => true,
|
|
|
|
:hasrestart => true,
|
2016-07-03 17:38:21 +00:00
|
|
|
:tag => ['watcher-service',
|
|
|
|
'watcher-db-manage-create_schema',
|
|
|
|
'watcher-db-manage-upgrade'],
|
2016-06-28 14:41:47 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2016-06-15 08:36:25 +00:00
|
|
|
end
|
|
|
|
|
2016-06-28 14:41:47 +00:00
|
|
|
context 'with disabled service managing' do
|
|
|
|
before do
|
|
|
|
params.merge!({
|
|
|
|
:manage_service => false,
|
|
|
|
:enabled => false })
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'configures watcher-api service' do
|
|
|
|
is_expected.to contain_service('watcher-api').with(
|
|
|
|
:ensure => nil,
|
|
|
|
:name => platform_params[:api_service_name],
|
|
|
|
:enable => false,
|
|
|
|
:hasstatus => true,
|
|
|
|
:hasrestart => true,
|
2016-07-03 17:38:21 +00:00
|
|
|
:tag => ['watcher-service',
|
|
|
|
'watcher-db-manage-create_schema',
|
|
|
|
'watcher-db-manage-upgrade'],
|
2016-06-28 14:41:47 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-15 08:36:25 +00:00
|
|
|
context 'watcher clients auth section with default parameters' do
|
|
|
|
it 'configures watcher clients auth' do
|
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/username').with_value('watcher')
|
2016-08-17 22:26:52 +00:00
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/password').with_value( params[:watcher_client_password] )
|
2016-06-15 08:36:25 +00:00
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/auth_url').with_value('http://localhost:35357/')
|
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/auth_uri').with_value('http://localhost:5000/')
|
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/project_name').with_value('service')
|
2016-07-06 16:32:46 -06:00
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/project_domain_name').with_value('<SERVICE DEFAULT>')
|
2016-06-15 08:36:25 +00:00
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/insecure').with_value('<SERVICE DEFAULT>')
|
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/auth_type').with_value('password')
|
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/cafile').with_value('<SERVICE DEFAULT>')
|
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/certfile').with_value('<SERVICE DEFAULT>')
|
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/keyfile').with_value('<SERVICE DEFAULT>')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'watcher clients auth section with overridden parameters' do
|
|
|
|
before do
|
|
|
|
params.merge! ({
|
|
|
|
:watcher_client_username => 'watcher_user',
|
|
|
|
:watcher_client_password => 'PassWoRD',
|
2016-08-17 22:26:52 +00:00
|
|
|
:watcher_client_auth_uri => 'http://localhost:5001/',
|
|
|
|
:watcher_client_auth_url => 'http://localhost:35358/',
|
2016-06-15 08:36:25 +00:00
|
|
|
:watcher_client_project_name => 'ProjectZero',
|
|
|
|
:watcher_client_project_domain_name => 'WatcherDomain',
|
|
|
|
:watcher_client_insecure => 'true',
|
|
|
|
:watcher_client_auth_type => 'password',
|
|
|
|
:watcher_client_cafile => '/tmp/ca.crt',
|
|
|
|
:watcher_client_certfile => '/tmp/watcher.com.crt',
|
|
|
|
:watcher_client_keyfile => '/tmp/key.pm',
|
|
|
|
})
|
|
|
|
end
|
|
|
|
it 'configures watcher clients auth' do
|
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/username').with_value( params[:watcher_client_username] )
|
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/password').with_value( params[:watcher_client_password] )
|
2016-08-17 22:26:52 +00:00
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/auth_uri').with_value('http://localhost:5001/')
|
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/auth_url').with_value('http://localhost:35358/')
|
2016-06-15 08:36:25 +00:00
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/project_name').with_value( params[:watcher_client_project_name] )
|
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/project_domain_name').with_value( params[:watcher_client_project_domain_name] )
|
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/insecure').with_value( params[:watcher_client_insecure] )
|
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/auth_type').with_value( params[:watcher_client_auth_type] )
|
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/cafile').with_value( params[:watcher_client_cafile] )
|
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/certfile').with_value( params[:watcher_client_certfile] )
|
|
|
|
is_expected.to contain_watcher_config('watcher_clients_auth/keyfile').with_value( params[:watcher_client_keyfile] )
|
|
|
|
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
|
2016-06-28 14:41:47 +00:00
|
|
|
let(:platform_params) do
|
|
|
|
case facts[:osfamily]
|
|
|
|
when 'Debian'
|
|
|
|
{ :api_package_name => 'watcher-api',
|
|
|
|
:api_service_name => 'watcher-api' }
|
|
|
|
when 'RedHat'
|
|
|
|
{ :api_package_name => 'openstack-watcher-api',
|
|
|
|
:api_service_name => 'openstack-watcher-api' }
|
|
|
|
end
|
|
|
|
end
|
2016-06-15 08:36:25 +00:00
|
|
|
it_behaves_like 'watcher-api'
|
|
|
|
end
|
|
|
|
end
|
2016-06-28 14:41:47 +00:00
|
|
|
|
2016-06-15 08:36:25 +00:00
|
|
|
end
|