summaryrefslogtreecommitdiffstats
path: root/puppet-barometer/spec
diff options
context:
space:
mode:
Diffstat (limited to 'puppet-barometer/spec')
-rw-r--r--puppet-barometer/spec/classes/barometer_db_mysql_spec.rb73
-rw-r--r--puppet-barometer/spec/classes/barometer_db_postgresql_spec.rb37
-rw-r--r--puppet-barometer/spec/classes/barometer_db_spec.rb117
-rw-r--r--puppet-barometer/spec/classes/barometer_db_sync_spec.rb34
-rw-r--r--puppet-barometer/spec/classes/barometer_keystone_auth_spec.rb141
-rw-r--r--puppet-barometer/spec/classes/barometer_keystone_authtoken_spec.rb147
-rw-r--r--puppet-barometer/spec/classes/barometer_logging_spec.rb139
-rw-r--r--puppet-barometer/spec/classes/barometer_policy_spec.rb36
-rw-r--r--puppet-barometer/spec/shared_examples.rb5
-rw-r--r--puppet-barometer/spec/unit/provider/barometer_config/ini_setting_spec.rb68
-rw-r--r--puppet-barometer/spec/unit/type/barometer_config_spec.rb64
11 files changed, 861 insertions, 0 deletions
diff --git a/puppet-barometer/spec/classes/barometer_db_mysql_spec.rb b/puppet-barometer/spec/classes/barometer_db_mysql_spec.rb
new file mode 100644
index 00000000..be1535c4
--- /dev/null
+++ b/puppet-barometer/spec/classes/barometer_db_mysql_spec.rb
@@ -0,0 +1,73 @@
+require 'spec_helper'
+
+describe 'barometer::db::mysql' do
+
+ let :pre_condition do
+ 'include mysql::server'
+ end
+
+ let :required_params do
+ { :password => 'fooboozoo_default_password', }
+ end
+
+ shared_examples_for 'barometer-db-mysql' do
+ context 'with only required params' do
+ let :params do
+ required_params
+ end
+
+ it { is_expected.to contain_openstacklib__db__mysql('barometer').with(
+ :user => 'barometer',
+ :password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
+ :dbname => 'barometer',
+ :host => '127.0.0.1',
+ :charset => 'utf8',
+ :collate => 'utf8_general_ci',
+ )}
+ end
+
+ context 'overriding allowed_hosts param to array' do
+ let :params do
+ { :allowed_hosts => ['127.0.0.1','%'] }.merge(required_params)
+ end
+
+ it { is_expected.to contain_openstacklib__db__mysql('barometer').with(
+ :user => 'barometer',
+ :password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
+ :dbname => 'barometer',
+ :host => '127.0.0.1',
+ :charset => 'utf8',
+ :collate => 'utf8_general_ci',
+ :allowed_hosts => ['127.0.0.1','%']
+ )}
+ end
+
+ describe 'overriding allowed_hosts param to string' do
+ let :params do
+ { :allowed_hosts => '192.168.1.1' }.merge(required_params)
+ end
+
+ it { is_expected.to contain_openstacklib__db__mysql('barometer').with(
+ :user => 'barometer',
+ :password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
+ :dbname => 'barometer',
+ :host => '127.0.0.1',
+ :charset => 'utf8',
+ :collate => 'utf8_general_ci',
+ :allowed_hosts => '192.168.1.1'
+ )}
+ 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
+
+ it_behaves_like 'barometer-db-mysql'
+ end
+ end
+end
diff --git a/puppet-barometer/spec/classes/barometer_db_postgresql_spec.rb b/puppet-barometer/spec/classes/barometer_db_postgresql_spec.rb
new file mode 100644
index 00000000..eb2e9bc5
--- /dev/null
+++ b/puppet-barometer/spec/classes/barometer_db_postgresql_spec.rb
@@ -0,0 +1,37 @@
+require 'spec_helper'
+
+describe 'barometer::db::postgresql' do
+
+ let :pre_condition do
+ 'include postgresql::server'
+ end
+
+ let :required_params do
+ { :password => 'pw' }
+ end
+
+ shared_examples_for 'barometer-db-postgresql' do
+ context 'with only required parameters' do
+ let :params do
+ required_params
+ end
+
+ it { is_expected.to contain_postgresql__server__db('barometer').with(
+ :user => 'barometer',
+ :password => 'md5c530c33636c58ae83ca933f39319273e'
+ )}
+ 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({ :concat_basedir => '/var/lib/puppet/concat' }))
+ end
+
+ it_behaves_like 'barometer-db-postgresql'
+ end
+ end
+end
diff --git a/puppet-barometer/spec/classes/barometer_db_spec.rb b/puppet-barometer/spec/classes/barometer_db_spec.rb
new file mode 100644
index 00000000..c60666bb
--- /dev/null
+++ b/puppet-barometer/spec/classes/barometer_db_spec.rb
@@ -0,0 +1,117 @@
+require 'spec_helper'
+
+describe 'barometer::db' do
+
+ shared_examples 'barometer::db' do
+ context 'with default parameters' do
+ it { is_expected.to contain_barometer_config('database/connection').with_value('sqlite:////var/lib/barometer/barometer.sqlite') }
+ it { is_expected.to contain_barometer_config('database/idle_timeout').with_value('<SERVICE DEFAULT>') }
+ it { is_expected.to contain_barometer_config('database/min_pool_size').with_value('<SERVICE DEFAULT>') }
+ it { is_expected.to contain_barometer_config('database/db_max_retries').with_value('<SERVICE DEFAULT>') }
+ it { is_expected.to contain_barometer_config('database/max_retries').with_value('<SERVICE DEFAULT>') }
+ it { is_expected.to contain_barometer_config('database/retry_interval').with_value('<SERVICE DEFAULT>') }
+ it { is_expected.to contain_barometer_config('database/max_pool_size').with_value('<SERVICE DEFAULT>') }
+ it { is_expected.to contain_barometer_config('database/max_overflow').with_value('<SERVICE DEFAULT>') }
+ end
+
+ context 'with specific parameters' do
+ let :params do
+ { :database_connection => 'mysql+pymysql://barometer:barometer@localhost/barometer',
+ :database_idle_timeout => '3601',
+ :database_min_pool_size => '2',
+ :database_db_max_retries => '-1',
+ :database_max_retries => '11',
+ :database_retry_interval => '11',
+ :database_max_pool_size => '11',
+ :database_max_overflow => '21',
+ }
+ end
+
+ it { is_expected.to contain_barometer_config('database/connection').with_value('mysql+pymysql://barometer:barometer@localhost/barometer') }
+ it { is_expected.to contain_barometer_config('database/idle_timeout').with_value('3601') }
+ it { is_expected.to contain_barometer_config('database/min_pool_size').with_value('2') }
+ it { is_expected.to contain_barometer_config('database/db_max_retries').with_value('-1') }
+ it { is_expected.to contain_barometer_config('database/max_retries').with_value('11') }
+ it { is_expected.to contain_barometer_config('database/retry_interval').with_value('11') }
+ it { is_expected.to contain_barometer_config('database/max_pool_size').with_value('11') }
+ it { is_expected.to contain_barometer_config('database/max_overflow').with_value('21') }
+ end
+
+ context 'with postgresql backend' do
+ let :params do
+ { :database_connection => 'postgresql://barometer:barometer@localhost/barometer', }
+ end
+
+ it 'install the proper backend package' do
+ is_expected.to contain_package('python-psycopg2').with(:ensure => 'present')
+ end
+
+ end
+
+ context 'with MySQL-python library as backend package' do
+ let :params do
+ { :database_connection => 'mysql://barometer:barometer@localhost/barometer', }
+ end
+
+ it { is_expected.to contain_package('python-mysqldb').with(:ensure => 'present') }
+ end
+
+ context 'with incorrect database_connection string' do
+ let :params do
+ { :database_connection => 'foodb://barometer:barometer@localhost/barometer', }
+ end
+
+ it_raises 'a Puppet::Error', /validate_re/
+ end
+
+ context 'with incorrect pymysql database_connection string' do
+ let :params do
+ { :database_connection => 'foo+pymysql://barometer:barometer@localhost/barometer', }
+ end
+
+ it_raises 'a Puppet::Error', /validate_re/
+ end
+
+ end
+
+ shared_examples_for 'barometer::db on Debian' do
+ context 'using pymysql driver' do
+ let :params do
+ { :database_connection => 'mysql+pymysql://barometer:barometer@localhost/barometer', }
+ end
+
+ it 'install the proper backend package' do
+ is_expected.to contain_package('db_backend_package').with(
+ :ensure => 'present',
+ :name => 'python-pymysql',
+ :tag => 'openstack'
+ )
+ end
+ end
+ end
+
+ shared_examples_for 'barometer::db on RedHat' do
+ context 'using pymysql driver' do
+ let :params do
+ { :database_connection => 'mysql+pymysql://barometer:barometer@localhost/barometer', }
+ end
+
+ it 'install the proper backend package' do
+ is_expected.not_to contain_package('db_backend_package')
+ end
+ 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
+
+ it_configures 'barometer::db'
+ it_configures "barometer::db on #{facts[:osfamily]}"
+ end
+ end
+end
diff --git a/puppet-barometer/spec/classes/barometer_db_sync_spec.rb b/puppet-barometer/spec/classes/barometer_db_sync_spec.rb
new file mode 100644
index 00000000..8c26853b
--- /dev/null
+++ b/puppet-barometer/spec/classes/barometer_db_sync_spec.rb
@@ -0,0 +1,34 @@
+require 'spec_helper'
+
+describe 'barometer::db::sync' do
+
+ shared_examples_for 'barometer-dbsync' do
+
+ it 'runs barometer-db-sync' do
+ is_expected.to contain_exec('barometer-db-sync').with(
+ :command => 'barometer-manage db_sync ',
+ :path => [ '/bin', '/usr/bin', ],
+ :refreshonly => 'true',
+ :user => 'barometer',
+ :logoutput => 'on_failure'
+ )
+ 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({
+ :os_workers => 8,
+ :concat_basedir => '/var/lib/puppet/concat'
+ }))
+ end
+
+ it_configures 'barometer-dbsync'
+ end
+ end
+
+end
diff --git a/puppet-barometer/spec/classes/barometer_keystone_auth_spec.rb b/puppet-barometer/spec/classes/barometer_keystone_auth_spec.rb
new file mode 100644
index 00000000..b54849d6
--- /dev/null
+++ b/puppet-barometer/spec/classes/barometer_keystone_auth_spec.rb
@@ -0,0 +1,141 @@
+#
+# Unit tests for barometer::keystone::auth
+#
+
+require 'spec_helper'
+
+describe 'barometer::keystone::auth' do
+ shared_examples_for 'barometer-keystone-auth' do
+ context 'with default class parameters' do
+ let :params do
+ { :password => 'barometer_password',
+ :tenant => 'foobar' }
+ end
+
+ it { is_expected.to contain_keystone_user('barometer').with(
+ :ensure => 'present',
+ :password => 'barometer_password',
+ ) }
+
+ it { is_expected.to contain_keystone_user_role('barometer@foobar').with(
+ :ensure => 'present',
+ :roles => ['admin']
+ )}
+
+ it { is_expected.to contain_keystone_service('barometer::nfv-orchestration').with(
+ :ensure => 'present',
+ :description => 'barometer NFV orchestration Service'
+ ) }
+
+ it { is_expected.to contain_keystone_endpoint('RegionOne/barometer::nfv-orchestration').with(
+ :ensure => 'present',
+ :public_url => 'http://127.0.0.1:9890',
+ :admin_url => 'http://127.0.0.1:9890',
+ :internal_url => 'http://127.0.0.1:9890',
+ ) }
+ end
+
+ context 'when overriding URL parameters' do
+ let :params do
+ { :password => 'barometer_password',
+ :public_url => 'https://10.10.10.10:80',
+ :internal_url => 'http://10.10.10.11:81',
+ :admin_url => 'http://10.10.10.12:81', }
+ end
+
+ it { is_expected.to contain_keystone_endpoint('RegionOne/barometer::nfv-orchestration').with(
+ :ensure => 'present',
+ :public_url => 'https://10.10.10.10:80',
+ :internal_url => 'http://10.10.10.11:81',
+ :admin_url => 'http://10.10.10.12:81',
+ ) }
+ end
+
+ context 'when overriding auth name' do
+ let :params do
+ { :password => 'foo',
+ :auth_name => 'barometery' }
+ end
+
+ it { is_expected.to contain_keystone_user('barometery') }
+ it { is_expected.to contain_keystone_user_role('barometery@services') }
+ it { is_expected.to contain_keystone_service('barometer::nfv-orchestration') }
+ it { is_expected.to contain_keystone_endpoint('RegionOne/barometer::nfv-orchestration') }
+ end
+
+ context 'when overriding service name' do
+ let :params do
+ { :service_name => 'barometer_service',
+ :auth_name => 'barometer',
+ :password => 'barometer_password' }
+ end
+
+ it { is_expected.to contain_keystone_user('barometer') }
+ it { is_expected.to contain_keystone_user_role('barometer@services') }
+ it { is_expected.to contain_keystone_service('barometer_service::nfv-orchestration') }
+ it { is_expected.to contain_keystone_endpoint('RegionOne/barometer_service::nfv-orchestration') }
+ end
+
+ context 'when disabling user configuration' do
+
+ let :params do
+ {
+ :password => 'barometer_password',
+ :configure_user => false
+ }
+ end
+
+ it { is_expected.not_to contain_keystone_user('barometer') }
+ it { is_expected.to contain_keystone_user_role('barometer@services') }
+ it { is_expected.to contain_keystone_service('barometer::nfv-orchestration').with(
+ :ensure => 'present',
+ :description => 'barometer NFV orchestration Service'
+ ) }
+
+ end
+
+ context 'when disabling user and user role configuration' do
+
+ let :params do
+ {
+ :password => 'barometer_password',
+ :configure_user => false,
+ :configure_user_role => false
+ }
+ end
+
+ it { is_expected.not_to contain_keystone_user('barometer') }
+ it { is_expected.not_to contain_keystone_user_role('barometer@services') }
+ it { is_expected.to contain_keystone_service('barometer::nfv-orchestration').with(
+ :ensure => 'present',
+ :description => 'barometer NFV orchestration Service'
+ ) }
+
+ end
+
+ context 'when using ensure absent' do
+
+ let :params do
+ {
+ :password => 'barometer_password',
+ :ensure => 'absent'
+ }
+ end
+
+ it { is_expected.to contain_keystone__resource__service_identity('barometer').with_ensure('absent') }
+
+ 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
+
+ it_behaves_like 'barometer-keystone-auth'
+ end
+ end
+end
diff --git a/puppet-barometer/spec/classes/barometer_keystone_authtoken_spec.rb b/puppet-barometer/spec/classes/barometer_keystone_authtoken_spec.rb
new file mode 100644
index 00000000..8c2e4fb5
--- /dev/null
+++ b/puppet-barometer/spec/classes/barometer_keystone_authtoken_spec.rb
@@ -0,0 +1,147 @@
+require 'spec_helper'
+
+describe 'barometer::keystone::authtoken' do
+
+ let :params do
+ { :password => 'secrete', }
+ end
+
+ shared_examples 'barometer authtoken' do
+
+ context 'with default parameters' do
+
+ it 'configure keystone_authtoken' do
+ is_expected.to contain_barometer_config('keystone_authtoken/username').with_value('barometer')
+ is_expected.to contain_barometer_config('keystone_authtoken/password').with_value('secrete')
+ is_expected.to contain_barometer_config('keystone_authtoken/auth_url').with_value('http://localhost:35357')
+ is_expected.to contain_barometer_config('keystone_authtoken/project_name').with_value('services')
+ is_expected.to contain_barometer_config('keystone_authtoken/user_domain_name').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/project_domain_name').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/insecure').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/auth_section').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/auth_type').with_value('password')
+ is_expected.to contain_barometer_config('keystone_authtoken/auth_uri').with_value('http://localhost:5000')
+ is_expected.to contain_barometer_config('keystone_authtoken/auth_version').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/cache').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/cafile').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/certfile').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/check_revocations_for_cached').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/delay_auth_decision').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/enforce_token_bind').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/hash_algorithms').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/http_connect_timeout').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/http_request_max_retries').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/include_service_catalog').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/keyfile').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/memcache_pool_conn_get_timeout').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/memcache_pool_dead_retry').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/memcache_pool_maxsize').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/memcache_pool_socket_timeout').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/memcache_pool_unused_timeout').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/memcache_secret_key').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/memcache_security_strategy').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/memcache_use_advanced_pool').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/memcached_servers').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/region_name').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/revocation_cache_time').with_value('<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('keystone_authtoken/token_cache_time').with_value('<SERVICE DEFAULT>')
+ end
+ end
+
+ context 'when overriding parameters' do
+ before do
+ params.merge!({
+ :auth_uri => 'https://10.0.0.1:9999/',
+ :username => 'myuser',
+ :password => 'mypasswd',
+ :auth_url => 'https://127.0.0.1:35357',
+ :project_name => 'service_project',
+ :user_domain_name => 'domainX',
+ :project_domain_name => 'domainX',
+ :insecure => false,
+ :auth_section => 'new_section',
+ :auth_type => 'password',
+ :auth_version => 'v3',
+ :cache => 'somevalue',
+ :cafile => '/opt/stack/data/cafile.pem',
+ :certfile => 'certfile.crt',
+ :check_revocations_for_cached => false,
+ :delay_auth_decision => false,
+ :enforce_token_bind => 'permissive',
+ :hash_algorithms => 'md5',
+ :http_connect_timeout => '300',
+ :http_request_max_retries => '3',
+ :include_service_catalog => true,
+ :keyfile => 'keyfile',
+ :memcache_pool_conn_get_timeout => '9',
+ :memcache_pool_dead_retry => '302',
+ :memcache_pool_maxsize => '11',
+ :memcache_pool_socket_timeout => '2',
+ :memcache_pool_unused_timeout => '61',
+ :memcache_secret_key => 'secret_key',
+ :memcache_security_strategy => 'ENCRYPT',
+ :memcache_use_advanced_pool => true,
+ :memcached_servers => ['memcached01:11211','memcached02:11211'],
+ :manage_memcache_package => true,
+ :region_name => 'region2',
+ :revocation_cache_time => '11',
+ :token_cache_time => '301',
+ })
+ end
+
+ it 'configure keystone_authtoken' do
+ is_expected.to contain_barometer_config('keystone_authtoken/auth_uri').with_value('https://10.0.0.1:9999/')
+ is_expected.to contain_barometer_config('keystone_authtoken/username').with_value(params[:username])
+ is_expected.to contain_barometer_config('keystone_authtoken/password').with_value(params[:password]).with_secret(true)
+ is_expected.to contain_barometer_config('keystone_authtoken/auth_url').with_value(params[:auth_url])
+ is_expected.to contain_barometer_config('keystone_authtoken/project_name').with_value(params[:project_name])
+ is_expected.to contain_barometer_config('keystone_authtoken/user_domain_name').with_value(params[:user_domain_name])
+ is_expected.to contain_barometer_config('keystone_authtoken/project_domain_name').with_value(params[:project_domain_name])
+ is_expected.to contain_barometer_config('keystone_authtoken/insecure').with_value(params[:insecure])
+ is_expected.to contain_barometer_config('keystone_authtoken/auth_section').with_value(params[:auth_section])
+ is_expected.to contain_barometer_config('keystone_authtoken/auth_type').with_value(params[:auth_type])
+ is_expected.to contain_barometer_config('keystone_authtoken/auth_version').with_value(params[:auth_version])
+ is_expected.to contain_barometer_config('keystone_authtoken/cache').with_value(params[:cache])
+ is_expected.to contain_barometer_config('keystone_authtoken/cafile').with_value(params[:cafile])
+ is_expected.to contain_barometer_config('keystone_authtoken/certfile').with_value(params[:certfile])
+ is_expected.to contain_barometer_config('keystone_authtoken/check_revocations_for_cached').with_value(params[:check_revocations_for_cached])
+ is_expected.to contain_barometer_config('keystone_authtoken/delay_auth_decision').with_value(params[:delay_auth_decision])
+ is_expected.to contain_barometer_config('keystone_authtoken/enforce_token_bind').with_value(params[:enforce_token_bind])
+ is_expected.to contain_barometer_config('keystone_authtoken/hash_algorithms').with_value(params[:hash_algorithms])
+ is_expected.to contain_barometer_config('keystone_authtoken/http_connect_timeout').with_value(params[:http_connect_timeout])
+ is_expected.to contain_barometer_config('keystone_authtoken/http_request_max_retries').with_value(params[:http_request_max_retries])
+ is_expected.to contain_barometer_config('keystone_authtoken/include_service_catalog').with_value(params[:include_service_catalog])
+ is_expected.to contain_barometer_config('keystone_authtoken/keyfile').with_value(params[:keyfile])
+ is_expected.to contain_barometer_config('keystone_authtoken/memcache_pool_conn_get_timeout').with_value(params[:memcache_pool_conn_get_timeout])
+ is_expected.to contain_barometer_config('keystone_authtoken/memcache_pool_dead_retry').with_value(params[:memcache_pool_dead_retry])
+ is_expected.to contain_barometer_config('keystone_authtoken/memcache_pool_maxsize').with_value(params[:memcache_pool_maxsize])
+ is_expected.to contain_barometer_config('keystone_authtoken/memcache_pool_socket_timeout').with_value(params[:memcache_pool_socket_timeout])
+ is_expected.to contain_barometer_config('keystone_authtoken/memcache_pool_unused_timeout').with_value(params[:memcache_pool_unused_timeout])
+ is_expected.to contain_barometer_config('keystone_authtoken/memcache_secret_key').with_value(params[:memcache_secret_key])
+ is_expected.to contain_barometer_config('keystone_authtoken/memcache_security_strategy').with_value(params[:memcache_security_strategy])
+ is_expected.to contain_barometer_config('keystone_authtoken/memcache_use_advanced_pool').with_value(params[:memcache_use_advanced_pool])
+ is_expected.to contain_barometer_config('keystone_authtoken/memcached_servers').with_value('memcached01:11211,memcached02:11211')
+ is_expected.to contain_barometer_config('keystone_authtoken/region_name').with_value(params[:region_name])
+ is_expected.to contain_barometer_config('keystone_authtoken/revocation_cache_time').with_value(params[:revocation_cache_time])
+ is_expected.to contain_barometer_config('keystone_authtoken/token_cache_time').with_value(params[:token_cache_time])
+ end
+
+ it 'installs python memcache package' do
+ is_expected.to contain_package('python-memcache')
+ end
+ 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
+
+ it_configures 'barometer authtoken'
+ end
+ end
+
+end
diff --git a/puppet-barometer/spec/classes/barometer_logging_spec.rb b/puppet-barometer/spec/classes/barometer_logging_spec.rb
new file mode 100644
index 00000000..a9028dbf
--- /dev/null
+++ b/puppet-barometer/spec/classes/barometer_logging_spec.rb
@@ -0,0 +1,139 @@
+require 'spec_helper'
+
+describe 'barometer::logging' do
+
+ let :params do
+ {
+ }
+ end
+
+ let :log_params do
+ {
+ :logging_context_format_string => '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s',
+ :logging_default_format_string => '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s',
+ :logging_debug_format_suffix => '%(funcName)s %(pathname)s:%(lineno)d',
+ :logging_exception_prefix => '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s',
+ :log_config_append => '/etc/barometer/logging.conf',
+ :publish_errors => true,
+ :default_log_levels => {
+ 'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN',
+ 'qpid' => 'WARN', 'sqlalchemy' => 'WARN', 'suds' => 'INFO',
+ 'iso8601' => 'WARN',
+ 'requests.packages.urllib3.connectionpool' => 'WARN' },
+ :fatal_deprecations => true,
+ :instance_format => '[instance: %(uuid)s] ',
+ :instance_uuid_format => '[instance: %(uuid)s] ',
+ :log_date_format => '%Y-%m-%d %H:%M:%S',
+ :use_syslog => true,
+ :use_stderr => false,
+ :syslog_log_facility => 'LOG_FOO',
+ :log_dir => '/var/log',
+ :log_file => '/var/log/barometer.log',
+ :debug => true,
+ }
+ end
+
+ shared_examples_for 'barometer-logging' do
+
+ context 'with basic logging options and default settings' do
+ it_configures 'basic default logging settings'
+ end
+
+ context 'with basic logging options and non-default settings' do
+ before { params.merge!( log_params ) }
+ it_configures 'basic non-default logging settings'
+ end
+
+ context 'with extended logging options' do
+ before { params.merge!( log_params ) }
+ it_configures 'logging params set'
+ end
+
+ context 'without extended logging options' do
+ it_configures 'logging params unset'
+ end
+
+ end
+
+ shared_examples 'basic default logging settings' do
+ it 'configures barometer logging settins with default values' do
+ is_expected.to contain_barometer_config('DEFAULT/use_syslog').with(:value => '<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('DEFAULT/use_stderr').with(:value => '<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('DEFAULT/syslog_log_facility').with(:value => '<SERVICE DEFAULT>')
+ is_expected.to contain_barometer_config('DEFAULT/log_dir').with(:value => '/var/log/barometer')
+ is_expected.to contain_barometer_config('DEFAULT/log_file').with(:value => '/var/log/barometer/barometer.log')
+ is_expected.to contain_barometer_config('DEFAULT/debug').with(:value => '<SERVICE DEFAULT>')
+ end
+ end
+
+ shared_examples 'basic non-default logging settings' do
+ it 'configures barometer logging settins with non-default values' do
+ is_expected.to contain_barometer_config('DEFAULT/use_syslog').with(:value => 'true')
+ is_expected.to contain_barometer_config('DEFAULT/use_stderr').with(:value => 'false')
+ is_expected.to contain_barometer_config('DEFAULT/syslog_log_facility').with(:value => 'LOG_FOO')
+ is_expected.to contain_barometer_config('DEFAULT/log_dir').with(:value => '/var/log')
+ is_expected.to contain_barometer_config('DEFAULT/log_file').with(:value => '/var/log/barometer.log')
+ is_expected.to contain_barometer_config('DEFAULT/debug').with(:value => 'true')
+ end
+ end
+
+ shared_examples_for 'logging params set' do
+ it 'enables logging params' do
+ is_expected.to contain_barometer_config('DEFAULT/logging_context_format_string').with_value(
+ '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s')
+
+ is_expected.to contain_barometer_config('DEFAULT/logging_default_format_string').with_value(
+ '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s')
+
+ is_expected.to contain_barometer_config('DEFAULT/logging_debug_format_suffix').with_value(
+ '%(funcName)s %(pathname)s:%(lineno)d')
+
+ is_expected.to contain_barometer_config('DEFAULT/logging_exception_prefix').with_value(
+ '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s')
+
+ is_expected.to contain_barometer_config('DEFAULT/log_config_append').with_value(
+ '/etc/barometer/logging.conf')
+ is_expected.to contain_barometer_config('DEFAULT/publish_errors').with_value(
+ true)
+
+ is_expected.to contain_barometer_config('DEFAULT/default_log_levels').with_value(
+ 'amqp=WARN,amqplib=WARN,boto=WARN,iso8601=WARN,qpid=WARN,requests.packages.urllib3.connectionpool=WARN,sqlalchemy=WARN,suds=INFO')
+
+ is_expected.to contain_barometer_config('DEFAULT/fatal_deprecations').with_value(
+ true)
+
+ is_expected.to contain_barometer_config('DEFAULT/instance_format').with_value(
+ '[instance: %(uuid)s] ')
+
+ is_expected.to contain_barometer_config('DEFAULT/instance_uuid_format').with_value(
+ '[instance: %(uuid)s] ')
+
+ is_expected.to contain_barometer_config('DEFAULT/log_date_format').with_value(
+ '%Y-%m-%d %H:%M:%S')
+ end
+ end
+
+
+ shared_examples_for 'logging params unset' do
+ [ :logging_context_format_string, :logging_default_format_string,
+ :logging_debug_format_suffix, :logging_exception_prefix,
+ :log_config_append, :publish_errors,
+ :default_log_levels, :fatal_deprecations,
+ :instance_format, :instance_uuid_format,
+ :log_date_format, ].each { |param|
+ it { is_expected.to contain_barometer_config("DEFAULT/#{param}").with_value('<SERVICE DEFAULT>') }
+ }
+ 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
+
+ it_behaves_like 'barometer-logging'
+ end
+ end
+end
diff --git a/puppet-barometer/spec/classes/barometer_policy_spec.rb b/puppet-barometer/spec/classes/barometer_policy_spec.rb
new file mode 100644
index 00000000..27259f39
--- /dev/null
+++ b/puppet-barometer/spec/classes/barometer_policy_spec.rb
@@ -0,0 +1,36 @@
+require 'spec_helper'
+
+describe 'barometer::policy' do
+ shared_examples_for 'barometer-policies' do
+ let :params do
+ {
+ :policy_path => '/etc/barometer/policy.json',
+ :policies => {
+ 'context_is_admin' => {
+ 'key' => 'context_is_admin',
+ 'value' => 'foo:bar'
+ }
+ }
+ }
+ end
+
+ it 'set up the policies' do
+ is_expected.to contain_openstacklib__policy__base('context_is_admin').with({
+ :key => 'context_is_admin',
+ :value => 'foo:bar'
+ })
+ 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
+
+ it_behaves_like 'barometer-policies'
+ end
+ end
+end
diff --git a/puppet-barometer/spec/shared_examples.rb b/puppet-barometer/spec/shared_examples.rb
new file mode 100644
index 00000000..fec0eacc
--- /dev/null
+++ b/puppet-barometer/spec/shared_examples.rb
@@ -0,0 +1,5 @@
+shared_examples_for "a Puppet::Error" do |description|
+ it "with message matching #{description.inspect}" do
+ expect { is_expected.to have_class_count(1) }.to raise_error(Puppet::Error, description)
+ end
+end
diff --git a/puppet-barometer/spec/unit/provider/barometer_config/ini_setting_spec.rb b/puppet-barometer/spec/unit/provider/barometer_config/ini_setting_spec.rb
new file mode 100644
index 00000000..198406a0
--- /dev/null
+++ b/puppet-barometer/spec/unit/provider/barometer_config/ini_setting_spec.rb
@@ -0,0 +1,68 @@
+#
+# these tests are a little concerning b/c they are hacking around the
+# modulepath, so these tests will not catch issues that may eventually arise
+# related to loading these plugins.
+# I could not, for the life of me, figure out how to programatcally set the modulepath
+$LOAD_PATH.push(
+ File.join(
+ File.dirname(__FILE__),
+ '..',
+ '..',
+ '..',
+ 'fixtures',
+ 'modules',
+ 'inifile',
+ 'lib')
+)
+$LOAD_PATH.push(
+ File.join(
+ File.dirname(__FILE__),
+ '..',
+ '..',
+ '..',
+ 'fixtures',
+ 'modules',
+ 'openstacklib',
+ 'lib')
+)
+require 'spec_helper'
+provider_class = Puppet::Type.type(:barometer_config).provider(:ini_setting)
+describe provider_class do
+
+ it 'should default to the default setting when no other one is specified' do
+ resource = Puppet::Type::Barometer_config.new(
+ {:name => 'DEFAULT/foo', :value => 'bar'}
+ )
+ provider = provider_class.new(resource)
+ expect(provider.section).to eq('DEFAULT')
+ expect(provider.setting).to eq('foo')
+ end
+
+ it 'should allow setting to be set explicitly' do
+ resource = Puppet::Type::Barometer_config.new(
+ {:name => 'dude/foo', :value => 'bar'}
+ )
+ provider = provider_class.new(resource)
+ expect(provider.section).to eq('dude')
+ expect(provider.setting).to eq('foo')
+ end
+
+ it 'should ensure absent when <SERVICE DEFAULT> is specified as a value' do
+ resource = Puppet::Type::Barometer_config.new(
+ {:name => 'dude/foo', :value => '<SERVICE DEFAULT>'}
+ )
+ provider = provider_class.new(resource)
+ provider.exists?
+ expect(resource[:ensure]).to eq :absent
+ end
+
+ it 'should ensure absent when value matches ensure_absent_val' do
+ resource = Puppet::Type::Barometer_config.new(
+ {:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' }
+ )
+ provider = provider_class.new(resource)
+ provider.exists?
+ expect(resource[:ensure]).to eq :absent
+ end
+
+end
diff --git a/puppet-barometer/spec/unit/type/barometer_config_spec.rb b/puppet-barometer/spec/unit/type/barometer_config_spec.rb
new file mode 100644
index 00000000..fbc70fa9
--- /dev/null
+++ b/puppet-barometer/spec/unit/type/barometer_config_spec.rb
@@ -0,0 +1,64 @@
+require 'puppet'
+require 'puppet/type/barometer_config'
+describe 'Puppet::Type.type(:barometer_config)' do
+ before :each do
+ @barometer_config = Puppet::Type.type(:barometer_config).new(:name => 'DEFAULT/foo', :value => 'bar')
+ end
+
+ it 'should require a name' do
+ expect {
+ Puppet::Type.type(:barometer_config).new({})
+ }.to raise_error(Puppet::Error, 'Title or name must be provided')
+ end
+
+ it 'should not expect a name with whitespace' do
+ expect {
+ Puppet::Type.type(:barometer_config).new(:name => 'f oo')
+ }.to raise_error(Puppet::Error, /Parameter name failed/)
+ end
+
+ it 'should fail when there is no section' do
+ expect {
+ Puppet::Type.type(:barometer_config).new(:name => 'foo')
+ }.to raise_error(Puppet::Error, /Parameter name failed/)
+ end
+
+ it 'should not require a value when ensure is absent' do
+ Puppet::Type.type(:barometer_config).new(:name => 'DEFAULT/foo', :ensure => :absent)
+ end
+
+ it 'should accept a valid value' do
+ @barometer_config[:value] = 'bar'
+ expect(@barometer_config[:value]).to eq('bar')
+ end
+
+ it 'should not accept a value with whitespace' do
+ @barometer_config[:value] = 'b ar'
+ expect(@barometer_config[:value]).to eq('b ar')
+ end
+
+ it 'should accept valid ensure values' do
+ @barometer_config[:ensure] = :present
+ expect(@barometer_config[:ensure]).to eq(:present)
+ @barometer_config[:ensure] = :absent
+ expect(@barometer_config[:ensure]).to eq(:absent)
+ end
+
+ it 'should not accept invalid ensure values' do
+ expect {
+ @barometer_config[:ensure] = :latest
+ }.to raise_error(Puppet::Error, /Invalid value/)
+ end
+
+ it 'should autorequire the package that install the file' do
+ catalog = Puppet::Resource::Catalog.new
+ package = Puppet::Type.type(:package).new(:name => 'barometer')
+ catalog.add_resource package, @barometer_config
+ dependency = @barometer_config.autorequire
+ expect(dependency.size).to eq(1)
+ expect(dependency[0].target).to eq(@barometer_config)
+ expect(dependency[0].source).to eq(package)
+ end
+
+
+end