Add rspec tests for ceilometer and ceilometer::api
This commit is contained in:
parent
938d647ac7
commit
49a63ed390
7
.fixtures.yml
Normal file
7
.fixtures.yml
Normal file
@ -0,0 +1,7 @@
|
||||
fixtures:
|
||||
repositories:
|
||||
"stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
|
||||
"inifile": "git://github.com/cprice-puppet/puppetlabs-inifile"
|
||||
"mysql": "git://github.com/puppetlabs/puppetlabs-mysql.git"
|
||||
symlinks:
|
||||
"ceilometer": "#{source_dir}"
|
28
.travis.yml
Normal file
28
.travis.yml
Normal file
@ -0,0 +1,28 @@
|
||||
language: ruby
|
||||
bundler_args: --without development
|
||||
before_script:
|
||||
- echo $PUPPET_GEM_VERSION | grep '2.6' && git clone git://github.com/puppetlabs/puppetlabs-create_resources.git spec/fixtures/modules/create_resources || true
|
||||
script: "bundle exec rake spec SPEC_OPTS='--format documentation'"
|
||||
rvm:
|
||||
- 1.8.7
|
||||
- 1.9.3
|
||||
- ruby-head
|
||||
env:
|
||||
- PUPPET_GEM_VERSION="~> 2.6"
|
||||
- PUPPET_GEM_VERSION="~> 2.7"
|
||||
- PUPPET_GEM_VERSION="~> 3.0"
|
||||
- PUPPET_GEM_VERSION="~> 3.1"
|
||||
matrix:
|
||||
allow_failures:
|
||||
- rvm: ruby-head
|
||||
exclude:
|
||||
- rvm: 1.9.3
|
||||
env: PUPPET_GEM_VERSION="~> 2.7"
|
||||
- rvm: ruby-head
|
||||
env: PUPPET_GEM_VERSION="~> 2.7"
|
||||
- rvm: 1.9.3
|
||||
env: PUPPET_GEM_VERSION="~> 2.6"
|
||||
- rvm: ruby-head
|
||||
env: PUPPET_GEM_VERSION="~> 2.6"
|
||||
notifications:
|
||||
email: false
|
13
Gemfile
Normal file
13
Gemfile
Normal file
@ -0,0 +1,13 @@
|
||||
source :rubygems
|
||||
|
||||
group :development, :test do
|
||||
gem 'puppetlabs_spec_helper', :require => false
|
||||
end
|
||||
|
||||
if puppetversion = ENV['PUPPET_GEM_VERSION']
|
||||
gem 'puppet', puppetversion, :require => false
|
||||
else
|
||||
gem 'puppet', :require => false
|
||||
end
|
||||
|
||||
# vim:ft=ruby
|
@ -1,8 +1,5 @@
|
||||
#
|
||||
# == parameters
|
||||
# * package_ensure - ensure state for package.
|
||||
#
|
||||
class ceilometer(
|
||||
class ceilometer (
|
||||
$metering_secret,
|
||||
$package_ensure = 'present',
|
||||
$verbose = 'False',
|
||||
@ -18,7 +15,7 @@ class ceilometer(
|
||||
|
||||
group { 'ceilometer':
|
||||
name => $::ceilometer::params::groupname,
|
||||
require => $::ceilometer::common_package_name,
|
||||
require => Package['ceilometer-common'],
|
||||
}
|
||||
|
||||
user { 'ceilometer':
|
||||
|
50
spec/classes/ceilometer_api_spec.rb
Normal file
50
spec/classes/ceilometer_api_spec.rb
Normal file
@ -0,0 +1,50 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'ceilometer::api' do
|
||||
|
||||
let :pre_condition do
|
||||
"class { 'ceilometer': metering_secret => 's3cr3t' }"
|
||||
end
|
||||
|
||||
let :params do
|
||||
{ :enabled => true,
|
||||
:keystone_host => '127.0.0.1',
|
||||
:keystone_port => '35357',
|
||||
:keystone_protocol => 'http',
|
||||
:keystone_user => 'ceilometer',
|
||||
:keystone_password => 'ceilometer-passw0rd'
|
||||
}
|
||||
end
|
||||
|
||||
context 'with all parameters' do
|
||||
|
||||
it { should include_class('ceilometer::params') }
|
||||
|
||||
it 'installs ceilometer-api package' do
|
||||
should contain_package('ceilometer-api').with(
|
||||
:ensure => 'installed'
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures ceilometer-api service' do
|
||||
should contain_service('ceilometer-api').with(
|
||||
:ensure => 'running',
|
||||
:name => 'ceilometer-api',
|
||||
:enable => true,
|
||||
:hasstatus => true,
|
||||
:hasrestart => true,
|
||||
:require => ['Package[ceilometer-api]', 'Class[Ceilometer::Db]'],
|
||||
:subscribe => 'Exec[ceilometer-dbsync]'
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures ceilometer with keystone' do
|
||||
should contain_ceilometer_config('keystone_authtoken/auth_host').with_value( params[:keystone_host] )
|
||||
should contain_ceilometer_config('keystone_authtoken/auth_port').with_value( params[:keystone_port] )
|
||||
should contain_ceilometer_config('keystone_authtoken/auth_protocol').with_value( params[:keystone_protocol] )
|
||||
should contain_ceilometer_config('keystone_authtoken/admin_tenant_name').with_value('services')
|
||||
should contain_ceilometer_config('keystone_authtoken/admin_user').with_value( params[:keystone_user] )
|
||||
should contain_ceilometer_config('keystone_authtoken/admin_password').with_value( params[:keystone_password] )
|
||||
end
|
||||
end
|
||||
end
|
91
spec/classes/ceilometer_init_spec.rb
Normal file
91
spec/classes/ceilometer_init_spec.rb
Normal file
@ -0,0 +1,91 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'ceilometer' do
|
||||
|
||||
let :params do
|
||||
{ :metering_secret => 'metering-s3cr3t',
|
||||
:package_ensure => 'present',
|
||||
:verbose => 'False',
|
||||
:debug => 'False',
|
||||
:rabbit_host => '127.0.0.1',
|
||||
:rabbit_port => 5672,
|
||||
:rabbit_userid => 'guest',
|
||||
:rabbit_password => '',
|
||||
:rabbit_virtualhost => '/',
|
||||
}
|
||||
end
|
||||
|
||||
context 'with all parameters' do
|
||||
|
||||
it { should include_class('ceilometer::params') }
|
||||
|
||||
it 'configures ceilometer group' do
|
||||
should contain_group('ceilometer').with(
|
||||
:name => 'ceilometer',
|
||||
:require => 'Package[ceilometer-common]'
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures ceilometer user' do
|
||||
should contain_user('ceilometer').with(
|
||||
:name => 'ceilometer',
|
||||
:gid => 'ceilometer',
|
||||
:groups => ['nova'],
|
||||
:system => true,
|
||||
:require => ['Group[ceilometer]', 'Package[ceilometer-common]']
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures ceilometer configuration folder' do
|
||||
should contain_file('/etc/ceilometer/').with(
|
||||
:ensure => 'directory',
|
||||
:owner => 'ceilometer',
|
||||
:group => 'ceilometer',
|
||||
:mode => '0750',
|
||||
:require => ['Package[ceilometer-common]', 'User[ceilometer]']
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures ceilometer configuration file' do
|
||||
should contain_file('/etc/ceilometer/ceilometer.conf').with(
|
||||
:ensure => 'file',
|
||||
:owner => 'ceilometer',
|
||||
:group => 'ceilometer',
|
||||
:mode => '0640',
|
||||
:require => ['File[/etc/ceilometer]', 'User[ceilometer]']
|
||||
)
|
||||
end
|
||||
|
||||
it 'installs ceilometer common package' do
|
||||
should contain_package('ceilometer-common').with(
|
||||
:ensure => 'present',
|
||||
:name => 'ceilometer-common'
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures required metering_secret' do
|
||||
should contain_ceilometer_config('DEFAULT/metering_secret').with_value('metering-s3cr3t')
|
||||
end
|
||||
|
||||
it 'configures rabbit' do
|
||||
should contain_ceilometer_config('DEFAULT/rabbit_host').with_value( params[:rabbit_host] )
|
||||
should contain_ceilometer_config('DEFAULT/rabbit_port').with_value( params[:rabbit_port] )
|
||||
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] )
|
||||
end
|
||||
|
||||
it 'fixes a bad value in ceilometer (glance_control_exchange)' do
|
||||
should contain_ceilometer_config('DEFAULT/glance_control_exchange').with_value('glance')
|
||||
end
|
||||
|
||||
it 'adds glance-notifications topic' do
|
||||
should contain_ceilometer_config('DEFAULT/notification_topics').with_value('notifications,glance_notifications')
|
||||
end
|
||||
end
|
||||
end
|
@ -1,17 +1 @@
|
||||
dir = File.expand_path(File.dirname(__FILE__))
|
||||
$LOAD_PATH.unshift File.join(dir, 'lib')
|
||||
|
||||
require 'mocha'
|
||||
require 'puppet'
|
||||
require 'rspec'
|
||||
require 'spec/autorun'
|
||||
|
||||
Spec::Runner.configure do |config|
|
||||
config.mock_with :mocha
|
||||
end
|
||||
|
||||
# We need this because the RAL uses 'should' as a method. This
|
||||
# allows us the same behaviour but with a different method name.
|
||||
class Object
|
||||
alias :must :should
|
||||
end
|
||||
require 'puppetlabs_spec_helper/module_spec_helper'
|
||||
|
Loading…
Reference in New Issue
Block a user