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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
|
require 'spec_helper'
describe 'ceilometer' do
let :params do
{
:http_timeout => '600',
:max_parallel_requests => 64,
:telemetry_secret => 'metering-s3cr3t',
:package_ensure => 'present',
:purge_config => false,
:host => 'foo.domain'
}
end
shared_examples_for 'ceilometer' do
it 'configures timeout for HTTP requests' do
is_expected.to contain_ceilometer_config('DEFAULT/http_timeout').with_value(params[:http_timeout])
end
it 'configures max_parallel_requests' do
is_expected.to contain_ceilometer_config('DEFAULT/max_parallel_requests').with_value(params[:max_parallel_requests])
end
it 'configures host name' do
is_expected.to contain_ceilometer_config('DEFAULT/host').with_value(params[:host])
end
context 'with rabbit parameters' do
it_configures 'a ceilometer base installation'
it_configures 'rabbit with SSL support'
it_configures 'rabbit without HA support'
it_configures 'rabbit with connection heartbeats'
context 'with rabbit_ha_queues' do
before { params.merge!( :rabbit_ha_queues => true ) }
it_configures 'rabbit with rabbit_ha_queues'
end
end
context 'with rabbit parameters' do
context 'with one server' do
it_configures 'a ceilometer base installation'
it_configures 'rabbit with SSL support'
it_configures 'rabbit without HA support'
end
end
end
shared_examples_for 'a ceilometer base installation' do
it { is_expected.to contain_class('ceilometer::params') }
it 'installs ceilometer common package' do
is_expected.to contain_package('ceilometer-common').with(
:ensure => 'present',
:name => platform_params[:common_package_name],
:tag => ['openstack', 'ceilometer-package'],
)
end
it 'passes purge to resource' do
is_expected.to contain_resources('ceilometer_config').with({
:purge => false
})
end
it 'configures required telemetry_secret' do
is_expected.to contain_ceilometer_config('publisher/telemetry_secret').with_value(params[:telemetry_secret]).with_secret(true)
end
context 'without the required telemetry_secret' do
before { params.delete(:telemetry_secret) }
it { is_expected.to raise_error(Puppet::Error) }
end
it 'configures default transport_url' do
is_expected.to contain_oslo__messaging__default('ceilometer_config').with(
:executor_thread_pool_size => '<SERVICE DEFAULT>',
:transport_url => '<SERVICE DEFAULT>',
:rpc_response_timeout => '<SERVICE DEFAULT>',
:control_exchange => '<SERVICE DEFAULT>'
)
end
it 'configures notifications' do
is_expected.to contain_oslo__messaging__notifications('ceilometer_config').with(
:transport_url => '<SERVICE DEFAULT>',
:driver => '<SERVICE DEFAULT>',
:topics => '<SERVICE DEFAULT>',
:retry => '<SERVICE DEFAULT>',
)
end
context 'with rabbitmq durable queues configured' do
before { params.merge!( :amqp_durable_queues => true ) }
it_configures 'rabbit with durable queues'
end
context 'with overridden transport_url parameter' do
before {
params.merge!(
:executor_thread_pool_size => '128',
:default_transport_url => 'rabbit://rabbit_user:password@localhost:5673',
:rpc_response_timeout => '120',
:control_exchange => 'ceilometer',
)
}
it 'configures transport_url' do
is_expected.to contain_oslo__messaging__default('ceilometer_config').with(
:executor_thread_pool_size => '128',
:transport_url => 'rabbit://rabbit_user:password@localhost:5673',
:rpc_response_timeout => '120',
:control_exchange => 'ceilometer'
)
end
end
context 'with overridden notification parameters' do
before {
params.merge!(
:notification_topics => ['notifications', 'custom'],
:notification_driver => 'messagingv2',
:notification_transport_url => 'rabbit://rabbit_user:password@localhost:5673',
:notification_retry => 10,
)
}
it 'configures notifications' do
is_expected.to contain_oslo__messaging__notifications('ceilometer_config').with(
:transport_url => 'rabbit://rabbit_user:password@localhost:5673',
:driver => 'messagingv2',
:topics => ['notifications', 'custom'],
:retry => 10,
)
end
end
end
shared_examples_for 'rabbit without HA support' do
it 'configures rabbit' do
is_expected.to contain_oslo__messaging__rabbit('ceilometer_config').with(
:rabbit_ha_queues => '<SERVICE DEFAULT>',
:heartbeat_timeout_threshold => '<SERVICE DEFAULT>',
:heartbeat_rate => '<SERVICE DEFAULT>',
:rabbit_qos_prefetch_count => '<SERVICE DEFAULT>',
:amqp_durable_queues => '<SERVICE DEFAULT>',
:amqp_auto_delete => '<SERVICE DEFAULT>',
:kombu_reconnect_delay => '<SERVICE DEFAULT>',
:kombu_failover_strategy => '<SERVICE DEFAULT>',
:kombu_compression => '<SERVICE DEFAULT>',
:rabbit_quorum_queue => '<SERVICE DEFAULT>',
:rabbit_transient_quorum_queue => '<SERVICE DEFAULT>',
:rabbit_transient_queues_ttl => '<SERVICE DEFAULT>',
:rabbit_quorum_delivery_limit => '<SERVICE DEFAULT>',
:rabbit_quorum_max_memory_length => '<SERVICE DEFAULT>',
:rabbit_quorum_max_memory_bytes => '<SERVICE DEFAULT>',
:use_queue_manager => '<SERVICE DEFAULT>',
:rabbit_stream_fanout => '<SERVICE DEFAULT>',
:enable_cancel_on_failover => '<SERVICE DEFAULT>',
)
end
end
shared_examples_for 'rabbit with rabbit_ha_queues' do
it 'configures rabbit' do
is_expected.to contain_oslo__messaging__rabbit('ceilometer_config').with(
:rabbit_ha_queues => params[:rabbit_ha_queues]
)
end
end
shared_examples_for 'rabbit with durable queues' do
it 'in ceilometer' do
is_expected.to contain_oslo__messaging__rabbit('ceilometer_config').with(
:amqp_durable_queues => params[:amqp_durable_queues]
)
end
end
shared_examples_for 'rabbit with connection heartbeats' do
context "with heartbeat configuration" do
before { params.merge!(
:rabbit_heartbeat_timeout_threshold => '60',
:rabbit_heartbeat_rate => '10',
) }
it { is_expected.to contain_oslo__messaging__rabbit('ceilometer_config').with(
:heartbeat_timeout_threshold => '60',
:heartbeat_rate => '10',
) }
end
end
shared_examples_for 'rabbit with SSL support' do
context "with default parameters" do
it { is_expected.to contain_oslo__messaging__rabbit('ceilometer_config').with(
:rabbit_use_ssl => '<SERVICE DEFAULT>',
:kombu_ssl_ca_certs => '<SERVICE DEFAULT>',
:kombu_ssl_certfile => '<SERVICE DEFAULT>',
:kombu_ssl_keyfile => '<SERVICE DEFAULT>',
:kombu_ssl_version => '<SERVICE DEFAULT>',
)}
end
context "with SSL enabled with kombu" do
before { params.merge!(
:rabbit_use_ssl => true,
:kombu_ssl_ca_certs => '/path/to/ca.crt',
:kombu_ssl_certfile => '/path/to/cert.crt',
:kombu_ssl_keyfile => '/path/to/cert.key',
:kombu_ssl_version => 'TLSv1'
) }
it { is_expected.to contain_oslo__messaging__rabbit('ceilometer_config').with(
:rabbit_use_ssl => true,
:kombu_ssl_ca_certs => '/path/to/ca.crt',
:kombu_ssl_certfile => '/path/to/cert.crt',
:kombu_ssl_keyfile => '/path/to/cert.key',
:kombu_ssl_version => 'TLSv1'
)}
end
context "with SSL enabled without kombu" do
before { params.merge!(
:rabbit_use_ssl => true
) }
it { is_expected.to contain_oslo__messaging__rabbit('ceilometer_config').with(
:rabbit_use_ssl => true,
)}
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
let :platform_params do
case facts[:os]['family']
when 'Debian'
{ :common_package_name => 'ceilometer-common' }
when 'RedHat'
{ :common_package_name => 'openstack-ceilometer-common' }
end
end
it_behaves_like 'ceilometer'
end
end
end
|