Merge "Adding support for qpid in ceilometer, rspec for qpid part in ceilometer"

This commit is contained in:
Jenkins 2013-08-08 14:34:31 +00:00 committed by Gerrit Code Review
commit 755e53b2cf
2 changed files with 155 additions and 26 deletions

View File

@ -11,6 +11,10 @@
# should the daemons log verbose messages. Optional. Defaults to 'False'
# [*debug*]
# should the daemons log debug messages. Optional. Defaults to 'False'
# [*rpc_backend*]
# (optional) what rpc/queuing service to use
# Defaults to impl_kombu (rabbitmq)
#
# [*rabbit_host*]
# ip or hostname of the rabbit server. Optional. Defaults to '127.0.0.1'
# [*rabbit_port*]
@ -25,21 +29,52 @@
# [*rabbit_virtualhost*]
# virtualhost to use. Optional. Defaults to '/'
#
# [*qpid_hostname*]
# [*qpid_port*]
# [*qpid_username*]
# [*qpid_password*]
# [*qpid_heartbeat*]
# [*qpid_protocol*]
# [*qpid_tcp_nodelay*]
# [*qpid_reconnect*]
# [*qpid_reconnect_timeout*]
# [*qpid_reconnect_limit*]
# [*qpid_reconnect_interval*]
# [*qpid_reconnect_interval_min*]
# [*qpid_reconnect_interval_max*]
# (optional) various QPID options
#
class ceilometer(
$metering_secret = false,
$package_ensure = 'present',
$verbose = 'False',
$debug = 'False',
$rpc_backend = 'ceilometer.openstack.common.rpc.impl_kombu',
$rabbit_host = '127.0.0.1',
$rabbit_port = 5672,
$rabbit_hosts = undef,
$rabbit_userid = 'guest',
$rabbit_password = '',
$rabbit_virtualhost = '/',
$qpid_hostname = 'localhost',
$qpid_port = 5672,
$qpid_username = 'guest',
$qpid_password = 'guest',
$qpid_heartbeat = 60,
$qpid_protocol = 'tcp',
$qpid_tcp_nodelay = true,
$qpid_reconnect = true,
$qpid_reconnect_timeout = 0,
$qpid_reconnect_limit = 0,
$qpid_reconnect_interval_min = 0,
$qpid_reconnect_interval_max = 0,
$qpid_reconnect_interval = 0
) {
validate_string($metering_secret)
include ceilometer::params
File {
@ -79,31 +114,60 @@ class ceilometer(
Package['ceilometer-common'] -> Ceilometer_config<||>
if $rabbit_hosts {
ceilometer_config { 'DEFAULT/rabbit_host': ensure => absent }
ceilometer_config { 'DEFAULT/rabbit_port': ensure => absent }
ceilometer_config { 'DEFAULT/rabbit_hosts':
value => join($rabbit_hosts, ',')
}
} else {
ceilometer_config { 'DEFAULT/rabbit_host': value => $rabbit_host }
ceilometer_config { 'DEFAULT/rabbit_port': value => $rabbit_port }
ceilometer_config { 'DEFAULT/rabbit_hosts':
value => "${rabbit_host}:${rabbit_port}"
if $rpc_backend == 'ceilometer.openstack.common.rpc.impl_kombu' {
if $rabbit_hosts {
ceilometer_config { 'DEFAULT/rabbit_host': ensure => absent }
ceilometer_config { 'DEFAULT/rabbit_port': ensure => absent }
ceilometer_config { 'DEFAULT/rabbit_hosts':
value => join($rabbit_hosts, ',')
}
} else {
ceilometer_config { 'DEFAULT/rabbit_host': value => $rabbit_host }
ceilometer_config { 'DEFAULT/rabbit_port': value => $rabbit_port }
ceilometer_config { 'DEFAULT/rabbit_hosts':
value => "${rabbit_host}:${rabbit_port}"
}
}
if size($rabbit_hosts) > 1 {
ceilometer_config { 'DEFAULT/rabbit_ha_queues': value => true }
} else {
ceilometer_config { 'DEFAULT/rabbit_ha_queues': value => false }
}
ceilometer_config {
'DEFAULT/rabbit_userid' : value => $rabbit_userid;
'DEFAULT/rabbit_password' : value => $rabbit_password;
'DEFAULT/rabbit_virtualhost' : value => $rabbit_virtualhost;
}
}
if size($rabbit_hosts) > 1 {
ceilometer_config { 'DEFAULT/rabbit_ha_queues': value => true }
} else {
ceilometer_config { 'DEFAULT/rabbit_ha_queues': value => false }
if $rpc_backend == 'ceilometer.openstack.common.rpc.impl_qpid' {
ceilometer_config {
'DEFAULT/qpid_hostname': value => $qpid_hostname;
'DEFAULT/qpid_port': value => $qpid_port;
'DEFAULT/qpid_username': value => $qpid_username;
'DEFAULT/qpid_password': value => $qpid_password;
'DEFAULT/qpid_heartbeat': value => $qpid_heartbeat;
'DEFAULT/qpid_protocol': value => $qpid_protocol;
'DEFAULT/qpid_tcp_nodelay': value => $qpid_tcp_nodelay;
'DEFAULT/qpid_reconnect': value => $qpid_reconnect;
'DEFAULT/qpid_reconnect_timeout': value => $qpid_reconnect_timeout;
'DEFAULT/qpid_reconnect_limit': value => $qpid_reconnect_limit;
'DEFAULT/qpid_reconnect_interval_min': value => $qpid_reconnect_interval_min;
'DEFAULT/qpid_reconnect_interval_max': value => $qpid_reconnect_interval_max;
'DEFAULT/qpid_reconnect_interval': value => $qpid_reconnect_interval;
}
}
# Once we got here, we can act as an honey badger on the rpc used.
ceilometer_config {
'DEFAULT/rpc_backend' : value => $rpc_backend;
'DEFAULT/metering_secret' : value => $metering_secret;
'DEFAULT/rabbit_userid' : value => $rabbit_userid;
'DEFAULT/rabbit_password' : value => $rabbit_password;
'DEFAULT/rabbit_virtualhost' : value => $rabbit_virtualhost;
'DEFAULT/debug' : value => $debug;
'DEFAULT/verbose' : value => $verbose;
'DEFAULT/log_dir' : value => $::ceilometer::params::log_dir;

View File

@ -8,6 +8,11 @@ describe 'ceilometer' do
:package_ensure => 'present',
:verbose => 'False',
:debug => 'False',
}
end
let :rabbit_params do
{
:rabbit_host => '127.0.0.1',
:rabbit_port => 5672,
:rabbit_userid => 'guest',
@ -16,26 +21,44 @@ describe 'ceilometer' do
}
end
let :qpid_params do
{
:rpc_backend => "ceilometer.openstack.common.rpc.impl_qpid",
:qpid_hostname => 'localhost',
:qpid_port => 5672,
:qpid_username => 'guest',
:qpid_password => 'guest',
}
end
shared_examples_for 'ceilometer' do
context 'with rabbit_host parameter' do
before { params.merge!( rabbit_params ) }
it_configures 'a ceilometer base installation'
it_configures 'rabbit without HA support (with backward compatibility)'
end
context 'with rabbit_hosts parameter' do
context 'with one server' do
before { params.merge!( :rabbit_hosts => ['127.0.0.1:5672'] ) }
before { params.merge!( rabbit_params ).merge!( :rabbit_hosts => ['127.0.0.1:5672'] ) }
it_configures 'a ceilometer base installation'
it_configures 'rabbit without HA support (without backward compatibility)'
end
context 'with multiple servers' do
before { params.merge!( :rabbit_hosts => ['rabbit1:5672', 'rabbit2:5672'] ) }
before { params.merge!( rabbit_params ).merge!( :rabbit_hosts => ['rabbit1:5672', 'rabbit2:5672'] ) }
it_configures 'a ceilometer base installation'
it_configures 'rabbit with HA support'
end
end
context 'with qpid' do
before {params.merge!( qpid_params ) }
it_configures 'a ceilometer base installation'
it_configures 'qpid support'
end
end
shared_examples_for 'a ceilometer base installation' do
@ -94,12 +117,6 @@ describe 'ceilometer' do
it { expect { should raise_error(Puppet::Error) } }
end
it 'configures rabbit' do
should contain_ceilometer_config('DEFAULT/rabbit_userid').with_value( params[:rabbit_userid] )
should contain_ceilometer_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] )
should contain_ceilometer_config('DEFAULT/rabbit_virtualhost').with_value( params[:rabbit_virtualhost] )
end
it 'configures debug and verbose' do
should contain_ceilometer_config('DEFAULT/debug').with_value( params[:debug] )
should contain_ceilometer_config('DEFAULT/verbose').with_value( params[:verbose] )
@ -115,6 +132,13 @@ describe 'ceilometer' do
end
shared_examples_for 'rabbit without HA support (with backward compatibility)' do
it 'configures rabbit' do
should contain_ceilometer_config('DEFAULT/rabbit_userid').with_value( params[:rabbit_userid] )
should contain_ceilometer_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] )
should contain_ceilometer_config('DEFAULT/rabbit_virtualhost').with_value( params[:rabbit_virtualhost] )
end
it { should contain_ceilometer_config('DEFAULT/rabbit_host').with_value( params[:rabbit_host] ) }
it { should contain_ceilometer_config('DEFAULT/rabbit_port').with_value( params[:rabbit_port] ) }
it { should contain_ceilometer_config('DEFAULT/rabbit_hosts').with_value( "#{params[:rabbit_host]}:#{params[:rabbit_port]}" ) }
@ -122,6 +146,13 @@ describe 'ceilometer' do
end
shared_examples_for 'rabbit without HA support (without backward compatibility)' do
it 'configures rabbit' do
should contain_ceilometer_config('DEFAULT/rabbit_userid').with_value( params[:rabbit_userid] )
should contain_ceilometer_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] )
should contain_ceilometer_config('DEFAULT/rabbit_virtualhost').with_value( params[:rabbit_virtualhost] )
end
it { should contain_ceilometer_config('DEFAULT/rabbit_host').with_ensure('absent') }
it { should contain_ceilometer_config('DEFAULT/rabbit_port').with_ensure('absent') }
it { should contain_ceilometer_config('DEFAULT/rabbit_hosts').with_value( params[:rabbit_hosts].join(',') ) }
@ -129,12 +160,46 @@ describe 'ceilometer' do
end
shared_examples_for 'rabbit with HA support' do
it 'configures rabbit' do
should contain_ceilometer_config('DEFAULT/rabbit_userid').with_value( params[:rabbit_userid] )
should contain_ceilometer_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] )
should contain_ceilometer_config('DEFAULT/rabbit_virtualhost').with_value( params[:rabbit_virtualhost] )
end
it { should contain_ceilometer_config('DEFAULT/rabbit_host').with_ensure('absent') }
it { should contain_ceilometer_config('DEFAULT/rabbit_port').with_ensure('absent') }
it { should contain_ceilometer_config('DEFAULT/rabbit_hosts').with_value( params[:rabbit_hosts].join(',') ) }
it { should contain_ceilometer_config('DEFAULT/rabbit_ha_queues').with_value('true') }
end
shared_examples_for 'qpid support' do
context("with default parameters") do
it { should contain_ceilometer_config('DEFAULT/qpid_reconnect').with_value(true) }
it { should contain_ceilometer_config('DEFAULT/qpid_reconnect_timeout').with_value('0') }
it { should contain_ceilometer_config('DEFAULT/qpid_reconnect_limit').with_value('0') }
it { should contain_ceilometer_config('DEFAULT/qpid_reconnect_interval_min').with_value('0') }
it { should contain_ceilometer_config('DEFAULT/qpid_reconnect_interval_max').with_value('0') }
it { should contain_ceilometer_config('DEFAULT/qpid_reconnect_interval').with_value('0') }
it { should contain_ceilometer_config('DEFAULT/qpid_heartbeat').with_value('60') }
it { should contain_ceilometer_config('DEFAULT/qpid_protocol').with_value('tcp') }
it { should contain_ceilometer_config('DEFAULT/qpid_tcp_nodelay').with_value(true) }
end
context("with mandatory parameters set") do
it { should contain_ceilometer_config('DEFAULT/rpc_backend').with_value('ceilometer.openstack.common.rpc.impl_qpid') }
it { should contain_ceilometer_config('DEFAULT/qpid_hostname').with_value( params[:qpid_hostname] ) }
it { should contain_ceilometer_config('DEFAULT/qpid_port').with_value( params[:qpid_port] ) }
it { should contain_ceilometer_config('DEFAULT/qpid_username').with_value( params[:qpid_username]) }
it { should contain_ceilometer_config('DEFAULT/qpid_password').with_value(params[:qpid_password]) }
end
context("failing if the rpc_backend is not present") do
before { params.delete( :rpc_backend) }
it { expect { should raise_error(Puppet::Error) } }
end
end
context 'on Debian platforms' do
let :facts do
{ :osfamily => 'Debian' }