diff options
author | blsaws <bs3131@att.com> | 2016-05-16 07:40:31 -0700 |
---|---|---|
committer | blsaws <bs3131@att.com> | 2016-05-16 07:40:31 -0700 |
commit | 8dcfe1a692815ee3a34dca32fd427471dfd0046a (patch) | |
tree | 5619e2c7b7113fe6ec68c98064895f7d8723e5bb /components/congress/install/puppet/spec/classes | |
parent | e50f20b9c29fd6282025b4ccb87fedacb013ef66 (diff) |
Refactor installer code folders.
JIRA: COPPER-2
Add initial centos7 bash scripts in development.
Change-Id: I112aa43c231dac035f0d1bc2ae416fabf6b8b650
Signed-off-by: blsaws <bs3131@att.com>
Diffstat (limited to 'components/congress/install/puppet/spec/classes')
6 files changed, 506 insertions, 0 deletions
diff --git a/components/congress/install/puppet/spec/classes/congress_db_mysql_spec.rb b/components/congress/install/puppet/spec/classes/congress_db_mysql_spec.rb new file mode 100644 index 0000000..6370bac --- /dev/null +++ b/components/congress/install/puppet/spec/classes/congress_db_mysql_spec.rb @@ -0,0 +1,62 @@ +require 'spec_helper' + +describe 'congress::db::mysql' do + + let :pre_condition do + [ + 'include mysql::server', + 'include congress::db::sync' + ] + end + + let :facts do + { :osfamily => 'Debian' } + end + + let :params do + { + 'password' => 'fooboozoo_default_password', + } + end + + describe 'with only required params' do + it { is_expected.to contain_openstacklib__db__mysql('congress').with( + 'user' => 'congress', + 'password_hash' => '*3DDF34A86854A312A8E2C65B506E21C91800D206', + 'dbname' => 'congress', + 'host' => '127.0.0.1', + 'charset' => 'utf8', + :collate => 'utf8_general_ci', + )} + end + + describe "overriding allowed_hosts param to array" do + let :params do + { + :password => 'congresspass', + :allowed_hosts => ['127.0.0.1','%'] + } + end + + end + describe "overriding allowed_hosts param to string" do + let :params do + { + :password => 'congresspass2', + :allowed_hosts => '192.168.1.1' + } + end + + end + + describe "overriding allowed_hosts param equals to host param " do + let :params do + { + :password => 'congresspass2', + :allowed_hosts => '127.0.0.1' + } + end + + end + +end diff --git a/components/congress/install/puppet/spec/classes/congress_db_postgresql_spec.rb b/components/congress/install/puppet/spec/classes/congress_db_postgresql_spec.rb new file mode 100644 index 0000000..74abbdb --- /dev/null +++ b/components/congress/install/puppet/spec/classes/congress_db_postgresql_spec.rb @@ -0,0 +1,58 @@ +require 'spec_helper' + +describe 'congress::db::postgresql' do + + let :req_params do + { :password => 'pw' } + end + + let :pre_condition do + 'include postgresql::server' + end + + context 'on a RedHat osfamily' do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '7.0', + :concat_basedir => '/var/lib/puppet/concat' + } + end + + context 'with only required parameters' do + let :params do + req_params + end + + it { is_expected.to contain_postgresql__server__db('congress').with( + :user => 'congress', + :password => 'md5c530c33636c58ae83ca933f39319273e' + )} + end + + end + + context 'on a Debian osfamily' do + let :facts do + { + :operatingsystemrelease => '7.8', + :operatingsystem => 'Debian', + :osfamily => 'Debian', + :concat_basedir => '/var/lib/puppet/concat' + } + end + + context 'with only required parameters' do + let :params do + req_params + end + + it { is_expected.to contain_postgresql__server__db('congress').with( + :user => 'congress', + :password => 'md5c530c33636c58ae83ca933f39319273e' + )} + end + + end + +end diff --git a/components/congress/install/puppet/spec/classes/congress_db_spec.rb b/components/congress/install/puppet/spec/classes/congress_db_spec.rb new file mode 100644 index 0000000..3b84993 --- /dev/null +++ b/components/congress/install/puppet/spec/classes/congress_db_spec.rb @@ -0,0 +1,78 @@ +require 'spec_helper' + +describe 'congress::db' do + + shared_examples 'congress::db' do + context 'with default parameters' do + it { is_expected.to contain_congress_config('database/connection').with_value('mysql://congress:secrete@localhost:3306/congress') } + it { is_expected.to contain_congress_config('database/idle_timeout').with_value('3600') } + it { is_expected.to contain_congress_config('database/min_pool_size').with_value('1') } + it { is_expected.to contain_congress_config('database/max_retries').with_value('10') } + it { is_expected.to contain_congress_config('database/retry_interval').with_value('10') } + it { is_expected.to contain_congress_config('database/max_pool_size').with_value('10') } + it { is_expected.to contain_congress_config('database/max_overflow').with_value('20') } + end + + context 'with specific parameters' do + let :params do + { :database_connection => 'mysql://congress:congress@localhost/congress', + :database_idle_timeout => '3601', + :database_min_pool_size => '2', + :database_max_retries => '11', + :database_retry_interval => '11', + :database_max_pool_size => '11', + :database_max_overflow => '21', + } + end + + it { is_expected.to contain_congress_config('database/connection').with_value('mysql://congress:congress@localhost/congress') } + it { is_expected.to contain_congress_config('database/idle_timeout').with_value('3601') } + it { is_expected.to contain_congress_config('database/min_pool_size').with_value('2') } + it { is_expected.to contain_congress_config('database/max_retries').with_value('11') } + it { is_expected.to contain_congress_config('database/retry_interval').with_value('11') } + it { is_expected.to contain_congress_config('database/max_pool_size').with_value('11') } + it { is_expected.to contain_congress_config('database/max_overflow').with_value('21') } + end + + context 'with postgresql backend' do + let :params do + { :database_connection => 'postgresql://congress:congress@localhost/congress', } + end + + it 'install the proper backend package' do + is_expected.to contain_package('python-psycopg2').with(:ensure => 'present') + end + + end + + context 'with incorrect database_connection string' do + let :params do + { :database_connection => 'sqlite://congress:congress@localhost/congress', } + end + + it_raises 'a Puppet::Error', /validate_re/ + end + end + + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian', + :operatingsystem => 'Debian', + :operatingsystemrelease => 'jessie', + } + end + + it_configures 'congress::db' + end + + context 'on Redhat platforms' do + let :facts do + { :osfamily => 'RedHat', + :operatingsystemrelease => '7.1', + } + end + + it_configures 'congress::db' + end + +end diff --git a/components/congress/install/puppet/spec/classes/congress_keystone_auth_spec.rb b/components/congress/install/puppet/spec/classes/congress_keystone_auth_spec.rb new file mode 100644 index 0000000..3cb7e59 --- /dev/null +++ b/components/congress/install/puppet/spec/classes/congress_keystone_auth_spec.rb @@ -0,0 +1,123 @@ +# +# Unit tests for congress::keystone::auth +# + +require 'spec_helper' + +describe 'congress::keystone::auth' do + + let :facts do + { :osfamily => 'Debian' } + end + + describe 'with default class parameters' do + let :params do + { :password => 'congress_password', + :tenant => 'foobar' } + end + + it { is_expected.to contain_keystone_user('congress').with( + :ensure => 'present', + :password => 'congress_password', + ) } + + it { is_expected.to contain_keystone_user_role('congress@foobar').with( + :ensure => 'present', + :roles => ['admin'] + )} + + it { is_expected.to contain_keystone_service('congress').with( + :ensure => 'present', + :type => 'FIXME', + :description => 'congress FIXME Service' + ) } + + it { is_expected.to contain_keystone_endpoint('RegionOne/congress').with( + :ensure => 'present', + :public_url => 'http://127.0.0.1:FIXME', + :admin_url => 'http://127.0.0.1:FIXME', + :internal_url => 'http://127.0.0.1:FIXME', + ) } + end + + describe 'when overriding URL paramaters' do + let :params do + { :password => 'congress_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/congress').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 + + describe 'when overriding auth name' do + let :params do + { :password => 'foo', + :auth_name => 'congressy' } + end + + it { is_expected.to contain_keystone_user('congressy') } + it { is_expected.to contain_keystone_user_role('congressy@services') } + it { is_expected.to contain_keystone_service('congressy') } + it { is_expected.to contain_keystone_endpoint('RegionOne/congressy') } + end + + describe 'when overriding service name' do + let :params do + { :service_name => 'congress_service', + :auth_name => 'congress', + :password => 'congress_password' } + end + + it { is_expected.to contain_keystone_user('congress') } + it { is_expected.to contain_keystone_user_role('congress@services') } + it { is_expected.to contain_keystone_service('congress_service') } + it { is_expected.to contain_keystone_endpoint('RegionOne/congress_service') } + end + + describe 'when disabling user configuration' do + + let :params do + { + :password => 'congress_password', + :configure_user => false + } + end + + it { is_expected.not_to contain_keystone_user('congress') } + it { is_expected.to contain_keystone_user_role('congress@services') } + it { is_expected.to contain_keystone_service('congress').with( + :ensure => 'present', + :type => 'FIXME', + :description => 'congress FIXME Service' + ) } + + end + + describe 'when disabling user and user role configuration' do + + let :params do + { + :password => 'congress_password', + :configure_user => false, + :configure_user_role => false + } + end + + it { is_expected.not_to contain_keystone_user('congress') } + it { is_expected.not_to contain_keystone_user_role('congress@services') } + it { is_expected.to contain_keystone_service('congress').with( + :ensure => 'present', + :type => 'FIXME', + :description => 'congress FIXME Service' + ) } + + end + +end diff --git a/components/congress/install/puppet/spec/classes/congress_logging_spec.rb b/components/congress/install/puppet/spec/classes/congress_logging_spec.rb new file mode 100644 index 0000000..0bfb994 --- /dev/null +++ b/components/congress/install/puppet/spec/classes/congress_logging_spec.rb @@ -0,0 +1,144 @@ +require 'spec_helper' + +describe 'congress::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/congress/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, + :log_facility => 'LOG_FOO', + :log_dir => '/var/log', + :verbose => true, + :debug => true, + } + end + + shared_examples_for 'congress-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 ceilometer logging settins with default values' do + is_expected.to contain_ceilometer_config('DEFAULT/use_syslog').with(:value => 'false') + is_expected.to contain_ceilometer_config('DEFAULT/use_stderr').with(:value => 'true') + is_expected.to contain_ceilometer_config('DEFAULT/syslog_log_facility').with(:value => 'LOG_USER') + is_expected.to contain_ceilometer_config('DEFAULT/log_dir').with(:value => '/var/log/congress') + is_expected.to contain_ceilometer_config('DEFAULT/verbose').with(:value => 'false') + is_expected.to contain_ceilometer_config('DEFAULT/debug').with(:value => 'false') + end + end + + shared_examples 'basic non-default logging settings' do + it 'configures ceilometer logging settins with non-default values' do + is_expected.to contain_ceilometer_config('DEFAULT/use_syslog').with(:value => 'true') + is_expected.to contain_ceilometer_config('DEFAULT/use_stderr').with(:value => 'false') + is_expected.to contain_ceilometer_config('DEFAULT/syslog_log_facility').with(:value => 'LOG_FOO') + is_expected.to contain_ceilometer_config('DEFAULT/log_dir').with(:value => '/var/log') + is_expected.to contain_ceilometer_config('DEFAULT/verbose').with(:value => 'true') + is_expected.to contain_ceilometer_config('DEFAULT/debug').with(:value => 'true') + end + end + + shared_examples_for 'logging params set' do + it 'enables logging params' do + is_expected.to contain_congress_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_congress_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_congress_config('DEFAULT/logging_debug_format_suffix').with_value( + '%(funcName)s %(pathname)s:%(lineno)d') + + is_expected.to contain_congress_config('DEFAULT/logging_exception_prefix').with_value( + '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s') + + is_expected.to contain_congress_config('DEFAULT/log_config_append').with_value( + '/etc/congress/logging.conf') + is_expected.to contain_congress_config('DEFAULT/publish_errors').with_value( + true) + + is_expected.to contain_congress_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_congress_config('DEFAULT/fatal_deprecations').with_value( + true) + + is_expected.to contain_congress_config('DEFAULT/instance_format').with_value( + '[instance: %(uuid)s] ') + + is_expected.to contain_congress_config('DEFAULT/instance_uuid_format').with_value( + '[instance: %(uuid)s] ') + + is_expected.to contain_congress_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_congress_config("DEFAULT/#{param}").with_ensure('absent') } + } + end + + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian' } + end + + it_configures 'congress-logging' + end + + context 'on RedHat platforms' do + let :facts do + { :osfamily => 'RedHat' } + end + + it_configures 'congress-logging' + end + +end diff --git a/components/congress/install/puppet/spec/classes/congress_policy_spec.rb b/components/congress/install/puppet/spec/classes/congress_policy_spec.rb new file mode 100644 index 0000000..d4e08ca --- /dev/null +++ b/components/congress/install/puppet/spec/classes/congress_policy_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe 'congress::policy' do + + shared_examples_for 'congress policies' do + let :params do + { + :policy_path => '/etc/congress/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 + + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian' } + end + + it_configures 'congress policies' + end + + context 'on RedHat platforms' do + let :facts do + { :osfamily => 'RedHat' } + end + + it_configures 'congress policies' + end +end |