| 1 |
require 'spec_helper' |
| 2 |
|
| 3 |
describe 'cloudkitty' do |
| 4 |
|
| 5 |
shared_examples 'cloudkitty' do |
| 6 |
|
| 7 |
context 'with default parameters' do |
| 8 |
|
| 9 |
it 'contains related class' do |
| 10 |
is_expected.to contain_class('cloudkitty::params') |
| 11 |
is_expected.to contain_class('cloudkitty::deps') |
| 12 |
is_expected.to contain_class('cloudkitty::db') |
| 13 |
is_expected.to contain_class('cloudkitty::storage') |
| 14 |
end |
| 15 |
|
| 16 |
it 'installs packages' do |
| 17 |
is_expected.to contain_package('cloudkitty-common').with( |
| 18 |
:name => platform_params[:cloudkitty_common_package], |
| 19 |
:ensure => 'present', |
| 20 |
:tag => ['openstack', 'cloudkitty-package'] |
| 21 |
) |
| 22 |
end |
| 23 |
|
| 24 |
it 'configures rabbit' do |
| 25 |
is_expected.to contain_oslo__messaging__default('cloudkitty_config').with( |
| 26 |
:transport_url => '<SERVICE DEFAULT>', |
| 27 |
:rpc_response_timeout => '<SERVICE DEFAULT>', |
| 28 |
:control_exchange => '<SERVICE DEFAULT>' |
| 29 |
) |
| 30 |
is_expected.to contain_oslo__messaging__rabbit('cloudkitty_config').with( |
| 31 |
:rabbit_use_ssl => '<SERVICE DEFAULT>', |
| 32 |
:heartbeat_timeout_threshold => '<SERVICE DEFAULT>', |
| 33 |
:heartbeat_rate => '<SERVICE DEFAULT>', |
| 34 |
:kombu_reconnect_delay => '<SERVICE DEFAULT>', |
| 35 |
:kombu_failover_strategy => '<SERVICE DEFAULT>', |
| 36 |
:amqp_durable_queues => '<SERVICE DEFAULT>', |
| 37 |
:amqp_auto_delete => '<SERVICE DEFAULT>', |
| 38 |
:kombu_compression => '<SERVICE DEFAULT>', |
| 39 |
:kombu_ssl_ca_certs => '<SERVICE DEFAULT>', |
| 40 |
:kombu_ssl_certfile => '<SERVICE DEFAULT>', |
| 41 |
:kombu_ssl_keyfile => '<SERVICE DEFAULT>', |
| 42 |
:kombu_ssl_version => '<SERVICE DEFAULT>', |
| 43 |
:rabbit_ha_queues => '<SERVICE DEFAULT>', |
| 44 |
:rabbit_retry_interval => '<SERVICE DEFAULT>', |
| 45 |
:rabbit_quorum_queue => '<SERVICE DEFAULT>', |
| 46 |
:rabbit_qos_prefetch_count => '<SERVICE DEFAULT>', |
| 47 |
:rabbit_transient_quorum_queue => '<SERVICE DEFAULT>', |
| 48 |
:rabbit_transient_queues_ttl => '<SERVICE DEFAULT>', |
| 49 |
:rabbit_quorum_delivery_limit => '<SERVICE DEFAULT>', |
| 50 |
:rabbit_quorum_max_memory_length => '<SERVICE DEFAULT>', |
| 51 |
:rabbit_quorum_max_memory_bytes => '<SERVICE DEFAULT>', |
| 52 |
:use_queue_manager => '<SERVICE DEFAULT>', |
| 53 |
:rabbit_stream_fanout => '<SERVICE DEFAULT>', |
| 54 |
:enable_cancel_on_failover => '<SERVICE DEFAULT>', |
| 55 |
) |
| 56 |
is_expected.to contain_oslo__messaging__notifications('cloudkitty_config').with( |
| 57 |
:transport_url => '<SERVICE DEFAULT>', |
| 58 |
:driver => '<SERVICE DEFAULT>', |
| 59 |
:topics => '<SERVICE DEFAULT>', |
| 60 |
:retry => '<SERVICE DEFAULT>', |
| 61 |
) |
| 62 |
end |
| 63 |
|
| 64 |
it 'configures storage' do |
| 65 |
is_expected.to contain_cloudkitty_config('storage/backend').with_value('<SERVICE DEFAULT>') |
| 66 |
is_expected.to contain_cloudkitty_config('storage/version').with_value('<SERVICE DEFAULT>') |
| 67 |
end |
| 68 |
|
| 69 |
it 'passes purge to resource' do |
| 70 |
is_expected.to contain_resources('cloudkitty_config').with({ |
| 71 |
:purge => false |
| 72 |
}) |
| 73 |
end |
| 74 |
|
| 75 |
end |
| 76 |
|
| 77 |
context 'with overridden parameters' do |
| 78 |
let :params do |
| 79 |
{ |
| 80 |
:rabbit_ha_queues => true, |
| 81 |
:rabbit_heartbeat_timeout_threshold => 60, |
| 82 |
:rabbit_heartbeat_rate => 10, |
| 83 |
:rabbit_quorum_queue => true, |
| 84 |
:rabbit_qos_prefetch_count => 10, |
| 85 |
:rabbit_transient_quorum_queue => false, |
| 86 |
:rabbit_transient_queues_ttl => 60, |
| 87 |
:rabbit_quorum_delivery_limit => 3, |
| 88 |
:rabbit_quorum_max_memory_length => 5, |
| 89 |
:rabbit_quorum_max_memory_bytes => 1073741824, |
| 90 |
:rabbit_use_queue_manager => true, |
| 91 |
:rabbit_stream_fanout => true, |
| 92 |
:rabbit_enable_cancel_on_failover => false, |
| 93 |
:kombu_reconnect_delay => 5.0, |
| 94 |
:amqp_durable_queues => true, |
| 95 |
:amqp_auto_delete => true, |
| 96 |
:kombu_compression => 'gzip', |
| 97 |
:package_ensure => '2012.1.1-15.el6', |
| 98 |
:default_transport_url => 'rabbit://rabbit_user:password@localhost:5673', |
| 99 |
:rpc_response_timeout => '120', |
| 100 |
:control_exchange => 'cloudkitty', |
| 101 |
:notification_transport_url => 'rabbit://rabbit_user:password@localhost:5673', |
| 102 |
:notification_driver => 'messagingv1', |
| 103 |
:notification_topics => 'openstack', |
| 104 |
:notification_retry => 10, |
| 105 |
:storage_backend => 'gnocchi', |
| 106 |
:storage_version => '1', |
| 107 |
} |
| 108 |
end |
| 109 |
|
| 110 |
it 'configures rabbit' do |
| 111 |
is_expected.to contain_oslo__messaging__default('cloudkitty_config').with( |
| 112 |
:transport_url => 'rabbit://rabbit_user:password@localhost:5673', |
| 113 |
:rpc_response_timeout => '120', |
| 114 |
:control_exchange => 'cloudkitty' |
| 115 |
) |
| 116 |
is_expected.to contain_oslo__messaging__rabbit('cloudkitty_config').with( |
| 117 |
:heartbeat_timeout_threshold => 60, |
| 118 |
:heartbeat_rate => 10, |
| 119 |
:kombu_reconnect_delay => 5.0, |
| 120 |
:amqp_durable_queues => true, |
| 121 |
:amqp_auto_delete => true, |
| 122 |
:kombu_compression => 'gzip', |
| 123 |
:rabbit_ha_queues => true, |
| 124 |
:rabbit_quorum_queue => true, |
| 125 |
:rabbit_qos_prefetch_count => 10, |
| 126 |
:rabbit_transient_quorum_queue => false, |
| 127 |
:rabbit_transient_queues_ttl => 60, |
| 128 |
:rabbit_quorum_delivery_limit => 3, |
| 129 |
:rabbit_quorum_max_memory_length => 5, |
| 130 |
:rabbit_quorum_max_memory_bytes => 1073741824, |
| 131 |
:use_queue_manager => true, |
| 132 |
:rabbit_stream_fanout => true, |
| 133 |
:enable_cancel_on_failover => false, |
| 134 |
) |
| 135 |
is_expected.to contain_oslo__messaging__notifications('cloudkitty_config').with( |
| 136 |
:transport_url => 'rabbit://rabbit_user:password@localhost:5673', |
| 137 |
:driver => 'messagingv1', |
| 138 |
:topics => 'openstack', |
| 139 |
:retry => 10, |
| 140 |
) |
| 141 |
end |
| 142 |
|
| 143 |
it 'configures various things' do |
| 144 |
is_expected.to contain_cloudkitty_config('storage/backend').with_value('gnocchi') |
| 145 |
is_expected.to contain_cloudkitty_config('storage/version').with_value('1') |
| 146 |
end |
| 147 |
|
| 148 |
end |
| 149 |
|
| 150 |
context 'with rabbit ssl enabled with kombu' do |
| 151 |
let :params do |
| 152 |
{ :rabbit_use_ssl => true, |
| 153 |
:kombu_ssl_ca_certs => '/etc/ca.cert', |
| 154 |
:kombu_ssl_certfile => '/etc/certfile', |
| 155 |
:kombu_ssl_keyfile => '/etc/key', |
| 156 |
:kombu_ssl_version => 'TLSv1', } |
| 157 |
end |
| 158 |
|
| 159 |
it 'configures rabbit' do |
| 160 |
is_expected.to contain_oslo__messaging__rabbit('cloudkitty_config').with( |
| 161 |
:rabbit_use_ssl => true, |
| 162 |
:kombu_ssl_ca_certs => '/etc/ca.cert', |
| 163 |
:kombu_ssl_certfile => '/etc/certfile', |
| 164 |
:kombu_ssl_keyfile => '/etc/key', |
| 165 |
:kombu_ssl_version => 'TLSv1', |
| 166 |
) |
| 167 |
end |
| 168 |
end |
| 169 |
|
| 170 |
context 'with rabbit ssl enabled without kombu' do |
| 171 |
let :params do |
| 172 |
{ :rabbit_use_ssl => true, } |
| 173 |
end |
| 174 |
|
| 175 |
it 'configures rabbit' do |
| 176 |
is_expected.to contain_oslo__messaging__rabbit('cloudkitty_config').with( |
| 177 |
:rabbit_use_ssl => true, |
| 178 |
:kombu_ssl_ca_certs => '<SERVICE DEFAULT>', |
| 179 |
:kombu_ssl_certfile => '<SERVICE DEFAULT>', |
| 180 |
:kombu_ssl_keyfile => '<SERVICE DEFAULT>', |
| 181 |
:kombu_ssl_version => '<SERVICE DEFAULT>', |
| 182 |
) |
| 183 |
end |
| 184 |
end |
| 185 |
|
| 186 |
context 'with metrics_config' do |
| 187 |
let :params do |
| 188 |
{ :metrics_config => {'metrics' => {}}, |
| 189 |
} |
| 190 |
end |
| 191 |
|
| 192 |
it 'configures metrics.yml' do |
| 193 |
is_expected.to contain_file('metrics.yml').with( |
| 194 |
:ensure => 'file', |
| 195 |
:path => '/etc/cloudkitty/metrics.yml', |
| 196 |
:mode => '0640', |
| 197 |
:owner => 'root', |
| 198 |
:group => 'cloudkitty', |
| 199 |
:tag => 'cloudkitty-yamls' |
| 200 |
) |
| 201 |
end |
| 202 |
end |
| 203 |
end |
| 204 |
|
| 205 |
on_supported_os({ |
| 206 |
:supported_os => OSDefaults.get_supported_os |
| 207 |
}).each do |os,facts| |
| 208 |
context "on #{os}" do |
| 209 |
let (:facts) do |
| 210 |
facts.merge!(OSDefaults.get_facts()) |
| 211 |
end |
| 212 |
|
| 213 |
let(:platform_params) do |
| 214 |
case facts[:os]['family'] |
| 215 |
when 'Debian' |
| 216 |
{ :cloudkitty_common_package => 'cloudkitty-common' } |
| 217 |
when 'RedHat' |
| 218 |
{ :cloudkitty_common_package => 'openstack-cloudkitty-common' } |
| 219 |
end |
| 220 |
end |
| 221 |
it_behaves_like 'cloudkitty' |
| 222 |
end |
| 223 |
end |
| 224 |
|
| 225 |
|
| 226 |
end |