2012-01-02 15:01:50 -08:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'glance::api' do
|
|
|
|
|
2012-03-19 22:57:23 -07:00
|
|
|
let :facts do
|
|
|
|
{
|
2012-05-08 14:38:55 -07:00
|
|
|
:osfamily => 'Debian',
|
|
|
|
:concat_basedir => '/var/lib/puppet/concat'
|
2012-03-19 22:57:23 -07:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2012-01-02 15:01:50 -08:00
|
|
|
let :default_params do
|
|
|
|
{
|
2012-03-31 16:09:29 -07:00
|
|
|
:log_verbose => 'False',
|
|
|
|
:log_debug => 'False',
|
|
|
|
:bind_host => '0.0.0.0',
|
|
|
|
:bind_port => '9292',
|
2012-01-02 15:01:50 -08:00
|
|
|
:registry_host => '0.0.0.0',
|
|
|
|
:registry_port => '9191',
|
2012-03-31 16:09:29 -07:00
|
|
|
:log_file => '/var/log/glance/api.log',
|
2012-06-18 10:14:53 -07:00
|
|
|
:auth_type => 'keystone',
|
2012-08-21 12:39:23 -07:00
|
|
|
:auth_uri => 'http://127.0.0.1:5000/',
|
2012-06-18 10:14:53 -07:00
|
|
|
:enabled => true
|
2012-01-02 15:01:50 -08:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
[{},
|
|
|
|
{
|
2012-03-31 16:09:29 -07:00
|
|
|
:log_verbose => 'true',
|
|
|
|
:log_debug => 'true',
|
|
|
|
:bind_host => '127.0.0.1',
|
|
|
|
:bind_port => '9222',
|
2012-01-02 15:01:50 -08:00
|
|
|
:registry_host => '127.0.0.1',
|
|
|
|
:registry_port => '9111',
|
2012-03-31 16:09:29 -07:00
|
|
|
:log_file => '/var/log/glance-api.log',
|
2012-06-18 10:14:53 -07:00
|
|
|
:auth_type => 'not_keystone',
|
2012-08-21 12:39:23 -07:00
|
|
|
:auth_uri => 'http://192.168.56.210:5000/',
|
2012-06-18 10:14:53 -07:00
|
|
|
:enabled => false
|
2012-01-02 15:01:50 -08:00
|
|
|
}
|
|
|
|
].each do |param_set|
|
|
|
|
|
|
|
|
describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
|
2012-03-13 15:09:58 -07:00
|
|
|
|
2012-01-02 15:01:50 -08:00
|
|
|
let :param_hash do
|
2012-03-13 15:09:58 -07:00
|
|
|
default_params.merge(param_set)
|
2012-01-02 15:01:50 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
let :params do
|
|
|
|
param_set
|
|
|
|
end
|
|
|
|
|
|
|
|
it { should contain_class 'glance' }
|
|
|
|
|
2012-03-31 16:09:29 -07:00
|
|
|
it { should contain_service('glance-api').with(
|
2012-06-18 10:14:53 -07:00
|
|
|
'ensure' => param_hash[:enabled] ? 'running': 'stopped',
|
|
|
|
'enable' => param_hash[:enabled],
|
2012-01-02 15:01:50 -08:00
|
|
|
'hasstatus' => 'true',
|
|
|
|
'hasrestart' => 'true',
|
2012-03-31 16:09:29 -07:00
|
|
|
'subscribe' => 'Concat[/etc/glance/glance-api.conf]'
|
|
|
|
) }
|
2012-01-02 15:01:50 -08:00
|
|
|
|
|
|
|
it 'should compile the template based on the class parameters' do
|
2012-03-31 16:09:29 -07:00
|
|
|
verify_contents(
|
|
|
|
subject,
|
2012-04-03 10:03:08 -07:00
|
|
|
'/var/lib/puppet/concat/_etc_glance_glance-api.conf/fragments/01_glance-api-header',
|
2012-03-31 16:09:29 -07:00
|
|
|
[
|
|
|
|
"verbose = #{param_hash[:log_verbose]}",
|
|
|
|
"debug = #{param_hash[:log_debug]}",
|
|
|
|
"bind_host = #{param_hash[:bind_host]}",
|
|
|
|
"bind_port = #{param_hash[:bind_port]}",
|
|
|
|
"log_file = #{param_hash[:log_file]}",
|
|
|
|
"registry_host = #{param_hash[:registry_host]}",
|
|
|
|
"registry_port = #{param_hash[:registry_port]}",
|
|
|
|
]
|
|
|
|
)
|
|
|
|
end
|
|
|
|
it 'should add paste deploy footers' do
|
|
|
|
expected_lines = ['[paste_deploy]', 'flavor = keystone'] if params[:auth_type] = 'keystone'
|
|
|
|
verify_contents(
|
|
|
|
subject,
|
2012-04-03 10:03:08 -07:00
|
|
|
'/var/lib/puppet/concat/_etc_glance_glance-api.conf/fragments/99_glance-api-footer',
|
2012-03-31 16:09:29 -07:00
|
|
|
expected_lines
|
|
|
|
)
|
|
|
|
|
2012-01-02 15:01:50 -08:00
|
|
|
end
|
2012-08-21 12:39:23 -07:00
|
|
|
it 'should use the proper auth_uri for glance-cache' do
|
|
|
|
verify_contents(
|
|
|
|
subject,
|
|
|
|
'/etc/glance/glance-cache.conf',
|
|
|
|
[
|
|
|
|
"auth_url = #{param_hash[:auth_uri]}"
|
|
|
|
]
|
|
|
|
)
|
|
|
|
end
|
2012-01-02 15:01:50 -08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|