-
Notifications
You must be signed in to change notification settings - Fork 30
/
glance_api_spec.rb
97 lines (86 loc) · 2.73 KB
/
glance_api_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
require 'spec_helper'
describe 'glance::api' do
let :facts do
{
:osfamily => 'Debian',
:concat_basedir => '/var/lib/puppet/concat'
}
end
let :default_params do
{
:log_verbose => 'False',
:log_debug => 'False',
:bind_host => '0.0.0.0',
:bind_port => '9292',
:registry_host => '0.0.0.0',
:registry_port => '9191',
:log_file => '/var/log/glance/api.log',
:auth_type => 'keystone',
:auth_uri => 'http://127.0.0.1:5000/',
:enabled => true
}
end
[{},
{
:log_verbose => 'true',
:log_debug => 'true',
:bind_host => '127.0.0.1',
:bind_port => '9222',
:registry_host => '127.0.0.1',
:registry_port => '9111',
:log_file => '/var/log/glance-api.log',
:auth_type => 'not_keystone',
:auth_uri => 'http://192.168.56.210:5000/',
:enabled => false
}
].each do |param_set|
describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
let :param_hash do
default_params.merge(param_set)
end
let :params do
param_set
end
it { should contain_class 'glance' }
it { should contain_service('glance-api').with(
'ensure' => param_hash[:enabled] ? 'running': 'stopped',
'enable' => param_hash[:enabled],
'hasstatus' => 'true',
'hasrestart' => 'true',
'subscribe' => 'Concat[/etc/glance/glance-api.conf]'
) }
it 'should compile the template based on the class parameters' do
verify_contents(
subject,
'/var/lib/puppet/concat/_etc_glance_glance-api.conf/fragments/01_glance-api-header',
[
"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,
'/var/lib/puppet/concat/_etc_glance_glance-api.conf/fragments/99_glance-api-footer',
expected_lines
)
end
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
end
end
end