--- /dev/null
+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}"
--- /dev/null
+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
--- /dev/null
+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
#
-# == parameters
-# * package_ensure - ensure state for package.
-#
-class ceilometer(
+class ceilometer (
$metering_secret,
$package_ensure = 'present',
$verbose = 'False',
group { 'ceilometer':
name => $::ceilometer::params::groupname,
- require => $::ceilometer::common_package_name,
+ require => Package['ceilometer-common'],
}
user { 'ceilometer':
--- /dev/null
+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
--- /dev/null
+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
-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'