|
3 | 3 | describe 'heat::api_cfn' do |
4 | 4 |
|
5 | 5 | let :params do |
6 | | - { |
7 | | - :bind_host => '127.0.0.1', |
8 | | - :bind_port => '1234', |
9 | | - :workers => '0' |
10 | | - } |
| 6 | + { :enabled => true, |
| 7 | + :manage_service => true, |
| 8 | + :bind_host => '127.0.0.1', |
| 9 | + :bind_port => '1234', |
| 10 | + :workers => '0' } |
11 | 11 | end |
12 | 12 |
|
13 | | - let :facts do |
14 | | - { :osfamily => 'Debian' } |
15 | | - end |
| 13 | + shared_examples_for 'heat-api-cfn' do |
16 | 14 |
|
17 | | - context 'config params' do |
| 15 | + context 'config params' do |
18 | 16 |
|
19 | | - it { should contain_class('heat') } |
20 | | - it { should contain_class('heat::params') } |
| 17 | + it { should contain_class('heat') } |
| 18 | + it { should contain_class('heat::params') } |
21 | 19 |
|
22 | | - it { should contain_heat_config('heat_api_cfn/bind_host').with_value( params[:bind_host] ) } |
23 | | - it { should contain_heat_config('heat_api_cfn/bind_port').with_value( params[:bind_port] ) } |
24 | | - it { should contain_heat_config('heat_api_cfn/workers').with_value( params[:workers] ) } |
| 20 | + it { should contain_heat_config('heat_api_cfn/bind_host').with_value( params[:bind_host] ) } |
| 21 | + it { should contain_heat_config('heat_api_cfn/bind_port').with_value( params[:bind_port] ) } |
| 22 | + it { should contain_heat_config('heat_api_cfn/workers').with_value( params[:workers] ) } |
25 | 23 |
|
26 | | - end |
| 24 | + end |
| 25 | + |
| 26 | + context 'with SSL socket options set' do |
| 27 | + let :params do |
| 28 | + { |
| 29 | + :use_ssl => true, |
| 30 | + :cert_file => '/path/to/cert', |
| 31 | + :key_file => '/path/to/key' |
| 32 | + } |
| 33 | + end |
| 34 | + |
| 35 | + it { should contain_heat_config('heat_api_cfn/cert_file').with_value('/path/to/cert') } |
| 36 | + it { should contain_heat_config('heat_api_cfn/key_file').with_value('/path/to/key') } |
| 37 | + end |
| 38 | + |
| 39 | + context 'with SSL socket options set with wrong parameters' do |
| 40 | + let :params do |
| 41 | + { |
| 42 | + :use_ssl => true, |
| 43 | + :key_file => '/path/to/key' |
| 44 | + } |
| 45 | + end |
| 46 | + |
| 47 | + it_raises 'a Puppet::Error', /The cert_file parameter is required when use_ssl is set to true/ |
| 48 | + end |
| 49 | + |
| 50 | + context 'with SSL socket options set to false' do |
| 51 | + let :params do |
| 52 | + { |
| 53 | + :use_ssl => false, |
| 54 | + :cert_file => false, |
| 55 | + :key_file => false |
| 56 | + } |
| 57 | + end |
| 58 | + |
| 59 | + it { should contain_heat_config('heat_api_cfn/cert_file').with_ensure('absent') } |
| 60 | + it { should contain_heat_config('heat_api_cfn/key_file').with_ensure('absent') } |
| 61 | + end |
| 62 | + |
| 63 | + [{:enabled => true}, {:enabled => false}].each do |param_hash| |
| 64 | + context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do |
| 65 | + before do |
| 66 | + params.merge!(param_hash) |
| 67 | + end |
| 68 | + |
| 69 | + it 'configures heat-api-cfn service' do |
27 | 70 |
|
28 | | - context 'with SSL socket options set' do |
29 | | - let :params do |
30 | | - { |
31 | | - :use_ssl => true, |
32 | | - :cert_file => '/path/to/cert', |
33 | | - :key_file => '/path/to/key' |
34 | | - } |
| 71 | + should contain_service('heat-api-cfn').with( |
| 72 | + :ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped', |
| 73 | + :name => platform_params[:api_service_name], |
| 74 | + :enable => params[:enabled], |
| 75 | + :hasstatus => true, |
| 76 | + :hasrestart => true, |
| 77 | + :subscribe => ['Exec[heat-dbsync]'] |
| 78 | + ) |
| 79 | + end |
| 80 | + end |
35 | 81 | end |
36 | 82 |
|
37 | | - it { should contain_heat_config('heat_api_cfn/cert_file').with_value('/path/to/cert') } |
38 | | - it { should contain_heat_config('heat_api_cfn/key_file').with_value('/path/to/key') } |
| 83 | + context 'with disabled service managing' do |
| 84 | + before do |
| 85 | + params.merge!({ |
| 86 | + :manage_service => false, |
| 87 | + :enabled => false }) |
| 88 | + end |
| 89 | + |
| 90 | + it 'configures heat-api-cfn service' do |
| 91 | + |
| 92 | + should contain_service('heat-api-cfn').with( |
| 93 | + :ensure => nil, |
| 94 | + :name => platform_params[:api_service_name], |
| 95 | + :enable => false, |
| 96 | + :hasstatus => true, |
| 97 | + :hasrestart => true, |
| 98 | + :subscribe => ['Exec[heat-dbsync]'] |
| 99 | + ) |
| 100 | + end |
| 101 | + end |
39 | 102 | end |
40 | 103 |
|
41 | | - context 'with SSL socket options set with wrong parameters' do |
42 | | - let :params do |
43 | | - { |
44 | | - :use_ssl => true, |
45 | | - :key_file => '/path/to/key' |
46 | | - } |
| 104 | + |
| 105 | + context 'on Debian platforms' do |
| 106 | + let :facts do |
| 107 | + { :osfamily => 'Debian' } |
| 108 | + end |
| 109 | + |
| 110 | + let :platform_params do |
| 111 | + { :api_service_name => 'heat-api-cfn' } |
47 | 112 | end |
48 | 113 |
|
49 | | - it_raises 'a Puppet::Error', /The cert_file parameter is required when use_ssl is set to true/ |
| 114 | + it_configures 'heat-api-cfn' |
50 | 115 | end |
51 | 116 |
|
52 | | - context 'with SSL socket options set to false' do |
53 | | - let :params do |
54 | | - { |
55 | | - :use_ssl => false, |
56 | | - :cert_file => false, |
57 | | - :key_file => false |
58 | | - } |
| 117 | + context 'on RedHat platforms' do |
| 118 | + let :facts do |
| 119 | + { :osfamily => 'RedHat' } |
| 120 | + end |
| 121 | + |
| 122 | + let :platform_params do |
| 123 | + { :api_service_name => 'openstack-heat-api-cfn' } |
59 | 124 | end |
60 | 125 |
|
61 | | - it { should contain_heat_config('heat_api_cfn/cert_file').with_ensure('absent') } |
62 | | - it { should contain_heat_config('heat_api_cfn/key_file').with_ensure('absent') } |
| 126 | + it_configures 'heat-api-cfn' |
63 | 127 | end |
64 | 128 |
|
65 | 129 | end |
0 commit comments