From 5c302c1a31ef425d05a753806fe8cb5cfe010b48 Mon Sep 17 00:00:00 2001 From: Blerim Sheqa Date: Mon, 25 Sep 2017 15:40:54 +0200 Subject: [PATCH] Cleanup and extend acceptance tests --- Gemfile | 1 + TESTING.md | 16 +++ examples/apache2.pp | 21 ++-- examples/authmethod.pp | 2 +- examples/import_schema.pp | 2 +- examples/module_director.pp | 11 +- examples/module_monitoring.pp | 2 +- spec/acceptance/1_init_spec.rb | 26 ----- spec/acceptance/apache2_spec.rb | 56 +++++++++ spec/acceptance/class_spec.rb | 25 ++++ spec/acceptance/icingaweb2_director_spec.rb | 95 +++++++++++++++ spec/acceptance/icingaweb2_monitoring_spec.rb | 110 ++++++++++++++++++ spec/acceptance/nodesets/centos-6-x64.yml | 10 ++ spec/acceptance/nodesets/centos-6.yml | 13 --- spec/acceptance/nodesets/centos-7-x64.yml | 10 ++ spec/acceptance/nodesets/centos-7.yml | 12 -- spec/acceptance/nodesets/debian-7.yml | 11 -- spec/acceptance/nodesets/debian-78-x64.yml | 10 ++ spec/acceptance/nodesets/debian-8.yml | 11 -- spec/acceptance/nodesets/debian-82-x64.yml | 10 ++ spec/acceptance/nodesets/ubuntu-14.04.yml | 11 -- spec/acceptance/nodesets/ubuntu-16.04.yml | 11 -- .../nodesets/ubuntu-server-1404-x64.yml | 10 ++ .../nodesets/ubuntu-server-1604-x64.yml | 10 ++ spec/spec_helper_acceptance.rb | 60 ++-------- 25 files changed, 398 insertions(+), 158 deletions(-) delete mode 100644 spec/acceptance/1_init_spec.rb create mode 100644 spec/acceptance/apache2_spec.rb create mode 100644 spec/acceptance/class_spec.rb create mode 100644 spec/acceptance/icingaweb2_director_spec.rb create mode 100644 spec/acceptance/icingaweb2_monitoring_spec.rb create mode 100644 spec/acceptance/nodesets/centos-6-x64.yml delete mode 100644 spec/acceptance/nodesets/centos-6.yml create mode 100644 spec/acceptance/nodesets/centos-7-x64.yml delete mode 100644 spec/acceptance/nodesets/centos-7.yml delete mode 100644 spec/acceptance/nodesets/debian-7.yml create mode 100644 spec/acceptance/nodesets/debian-78-x64.yml delete mode 100644 spec/acceptance/nodesets/debian-8.yml create mode 100644 spec/acceptance/nodesets/debian-82-x64.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-14.04.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-16.04.yml create mode 100644 spec/acceptance/nodesets/ubuntu-server-1404-x64.yml create mode 100644 spec/acceptance/nodesets/ubuntu-server-1604-x64.yml diff --git a/Gemfile b/Gemfile index 8e208467..e58dfcd2 100644 --- a/Gemfile +++ b/Gemfile @@ -21,5 +21,6 @@ unless RUBY_VERSION < '2.0.0' end gem 'serverspec', :require => false gem 'beaker-puppet_install_helper', :require => false + gem 'beaker-module_install_helper', :require => false end end diff --git a/TESTING.md b/TESTING.md index d680935a..5c8a1600 100644 --- a/TESTING.md +++ b/TESTING.md @@ -41,6 +41,22 @@ rake spec With integration tests this module is tested on multiple platforms to check the complete installation process. We define these tests with [ServerSpec] and run them on VMs by using [Beaker]. +Run all tests: +``` +bundle exec rake acceptance +``` + +Run a single test: +``` +bundle exec rake beaker:ubuntu-server-1604-x64 +``` + +Don't destroy VM after tests: +``` +export BEAKER_destroy=no +bundle exec rake beaker:ubuntu-server-1604-x64 +``` + ### Run tests All available ServerSpec tests are listed in the `spec/acceptance/` directory. diff --git a/examples/apache2.pp b/examples/apache2.pp index 7cbd06fd..b2f612f5 100644 --- a/examples/apache2.pp +++ b/examples/apache2.pp @@ -25,21 +25,22 @@ import_schema => true, db_type => 'mysql', db_host => 'localhost', - db_port => '3306', + db_port => 3306, db_username => 'icingaweb2', db_password => 'icingaweb2', require => Mysql::Db['icingaweb2'], } class {'icingaweb2::module::monitoring': - ido_host => 'localhost', - ido_db_name => 'icinga2', - ido_db_username => 'icinga2', - ido_db_password => 'supersecret', - icinga2 => { - transport => 'api', - username => 'root', - password => 'icinga', + ido_host => 'localhost', + ido_db_name => 'icinga2', + ido_db_username => 'icinga2', + ido_db_password => 'supersecret', + commandtransports => { + icinga2 => { + transport => 'api', + username => 'root', + password => 'icinga', + } } -} } \ No newline at end of file diff --git a/examples/authmethod.pp b/examples/authmethod.pp index 950cb715..240bf49b 100644 --- a/examples/authmethod.pp +++ b/examples/authmethod.pp @@ -9,7 +9,7 @@ type => 'db', db_type => 'mysql', host => 'localhost', - port => '3306', + port => 3306, db_name => 'icingaweb2', db_username => 'root', db_password => 'supersecret', diff --git a/examples/import_schema.pp b/examples/import_schema.pp index e3a4e273..f98921bb 100644 --- a/examples/import_schema.pp +++ b/examples/import_schema.pp @@ -19,7 +19,7 @@ import_schema => true, db_type => 'pgsql', db_host => 'localhost', - db_port => '5432', + db_port => 5432, db_username => 'icingaweb2', db_password => 'icingaweb2', require => [ Postgresql::Server::Db['icingaweb2'], Mysql::Db['icingaweb2'] ] diff --git a/examples/module_director.pp b/examples/module_director.pp index 7c600aad..4c4634f0 100644 --- a/examples/module_director.pp +++ b/examples/module_director.pp @@ -1,3 +1,5 @@ +package { 'git': } + include ::mysql::server mysql::db { 'director': @@ -13,7 +15,7 @@ import_schema => true, db_type => 'mysql', db_host => 'localhost', - db_port => '3306', + db_port => 3306, db_username => 'icingaweb2', db_password => 'icingaweb2', } @@ -23,6 +25,13 @@ ido_db_name => 'icinga2', ido_db_username => 'icinga2', ido_db_password => 'supersecret', + commandtransports => { + icinga2 => { + transport => 'api', + username => 'root', + password => 'icinga', + } + } } class {'icingaweb2::module::director': diff --git a/examples/module_monitoring.pp b/examples/module_monitoring.pp index e251c6ec..2e904f5c 100644 --- a/examples/module_monitoring.pp +++ b/examples/module_monitoring.pp @@ -13,7 +13,7 @@ import_schema => true, db_type => 'mysql', db_host => 'localhost', - db_port => '3306', + db_port => 3306, db_username => 'icingaweb2', db_password => 'icingaweb2', require => Mysql::Db['icingaweb2'], diff --git a/spec/acceptance/1_init_spec.rb b/spec/acceptance/1_init_spec.rb deleted file mode 100644 index d6e2098b..00000000 --- a/spec/acceptance/1_init_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -# These tests are designed to ensure that the module, when ran with defaults, -# sets up everything correctly. -describe 'icingaweb2' do - it 'with basic settings for package installation' do - pp = <<-EOS - class { '::icingaweb2': - manage_repo => true, - } - EOS - apply_manifest(pp, catch_failures: true, debug: false, trace: true) - apply_manifest(pp, catch_changes: true, debug: false, trace: true) - end - - describe package('icingaweb2') do - it { is_expected.to be_installed } - end - - if fact('osfamily') == 'Debian' - describe service('apache2') do - it { is_expected.to be_running } - end - end -end diff --git a/spec/acceptance/apache2_spec.rb b/spec/acceptance/apache2_spec.rb new file mode 100644 index 00000000..1a1497ce --- /dev/null +++ b/spec/acceptance/apache2_spec.rb @@ -0,0 +1,56 @@ +#! /usr/bin/env ruby -S rspec +require 'spec_helper_acceptance' + +describe 'icingaweb2 with apache2' do + it 'with basic settings and apache2' do + pp = " + class { 'apache': + mpm_module => 'prefork' + } + + class { 'apache::mod::php': } + + case $::osfamily { + 'redhat': { + package { 'php-mysql': } + file {'/etc/httpd/conf.d/icingaweb2.conf': + source => 'puppet:///modules/icingaweb2/examples/apache2/icingaweb2.conf', + require => Class['apache'], + notify => Service['httpd'], + } + } + 'debian': { + class { 'apache::mod::rewrite': } + + file {'/etc/apache2/conf.d/icingaweb2.conf': + source => 'puppet:///modules/icingaweb2/examples/apache2/icingaweb2.conf', + require => Class['apache'], + notify => Service['apache2'], + } + } + } + + class {'icingaweb2': + manage_repo => true, + } + " + + apply_manifest(pp, catch_failures: true) + end + + if fact('osfamily') == 'Debian' + describe service('apache2') do + it { is_expected.to be_running } + end + end + + if fact('osfamily') == 'RedHat' + describe service('httpd') do + it { is_expected.to be_running } + end + end + + describe command('curl -I http://localhost/icingaweb2/') do + its(:stdout) { should match(%r{302 Found}) } + end +end diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb new file mode 100644 index 00000000..d0059d09 --- /dev/null +++ b/spec/acceptance/class_spec.rb @@ -0,0 +1,25 @@ +#! /usr/bin/env ruby -S rspec +require 'spec_helper_acceptance' + +describe 'icingaweb2 class:' do + it 'runs successfully' do + pp = " + class { '::icingaweb2': + manage_repo => true, + } + " + + apply_manifest(pp, catch_failures: true) + end + + describe package('icingaweb2') do + it { is_expected.to be_installed } + end + + describe file('/etc/icingaweb2/config.ini') do + it { is_expected.to be_file } + it { is_expected.to contain '[global]' } + it { is_expected.to contain '[logging]' } + end + +end diff --git a/spec/acceptance/icingaweb2_director_spec.rb b/spec/acceptance/icingaweb2_director_spec.rb new file mode 100644 index 00000000..cadeebdd --- /dev/null +++ b/spec/acceptance/icingaweb2_director_spec.rb @@ -0,0 +1,95 @@ +#! /usr/bin/env ruby -S rspec +require 'spec_helper_acceptance' + +describe 'icingaweb2::module::director class:' do + it 'runs successfully' do + pp = " + package { 'git': } + + include ::mysql::server + + mysql::db { 'icingaweb2': + user => 'icingaweb2', + password => 'icingaweb2', + host => 'localhost', + grant => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'DROP', 'CREATE VIEW', 'CREATE', 'INDEX', 'EXECUTE', 'ALTER', 'REFERENCES'], + } + + mysql::db { 'director': + user => 'director', + password => 'director', + host => 'localhost', + charset => 'utf8', + grant => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'DROP', 'CREATE VIEW', 'CREATE', 'INDEX', 'EXECUTE', 'ALTER', 'REFERENCES'], + } + + class {'icingaweb2': + manage_repo => true, + import_schema => true, + db_type => 'mysql', + db_host => 'localhost', + db_port => 3306, + db_username => 'icingaweb2', + db_password => 'icingaweb2', + require => Mysql::Db['icingaweb2'], + } + + class {'icingaweb2::module::monitoring': + ido_host => 'localhost', + ido_db_name => 'icinga2', + ido_db_username => 'icinga2', + ido_db_password => 'supersecret', + commandtransports => { + icinga2 => { + transport => 'api', + username => 'root', + password => 'icinga', + } + } + } + + class {'icingaweb2::module::director': + git_revision => 'v1.3.2', + db_host => 'localhost', + db_name => 'director', + db_username => 'director', + db_password => 'director', + import_schema => true, + kickstart => false, + endpoint => 'puppet-icingaweb2.localdomain', + api_username => 'root', + api_password => 'icinga', + require => Mysql::Db['director'] + } + " + + apply_manifest(pp, catch_failures: true) + end + + describe file('/etc/icingaweb2/enabledModules/director') do + it { is_expected.to be_symlink } + end + + describe file('/etc/icingaweb2/modules/director/config.ini') do + it { is_expected.to be_file } + it { is_expected.to contain '[db]' } + it { is_expected.to contain 'resource = "icingaweb2-module-director"' } + end + + describe file('/etc/icingaweb2/resources.ini') do + it { is_expected.to be_file } + it { is_expected.to contain '[icingaweb2-module-director]' } + it { is_expected.to contain 'type = "db"' } + it { is_expected.to contain 'db = "mysql"' } + it { is_expected.to contain 'host = "localhost"' } + it { is_expected.to contain 'port = "3306"' } + it { is_expected.to contain 'dbname = "director"' } + it { is_expected.to contain 'username = "director"' } + it { is_expected.to contain 'password = "director"' } + it { is_expected.to contain 'charset = "utf8"' } + end + + #describe command('mysql -e "select object_name from director.icinga_apiuser"') do + # its(:stdout) { should match(%r{root}) } + #end +end diff --git a/spec/acceptance/icingaweb2_monitoring_spec.rb b/spec/acceptance/icingaweb2_monitoring_spec.rb new file mode 100644 index 00000000..27e5f91e --- /dev/null +++ b/spec/acceptance/icingaweb2_monitoring_spec.rb @@ -0,0 +1,110 @@ +#! /usr/bin/env ruby -S rspec +require 'spec_helper_acceptance' + +describe 'icingaweb2::module::monitoring class:' do + it 'runs successfully' do + pp = " + include ::mysql::server + + mysql::db { 'icingaweb2': + user => 'icingaweb2', + password => 'icingaweb2', + host => 'localhost', + grant => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'DROP', 'CREATE VIEW', 'CREATE', 'INDEX', 'EXECUTE', 'ALTER', 'REFERENCES'], + } + + class {'icingaweb2': + manage_repo => true, + import_schema => true, + db_type => 'mysql', + db_host => 'localhost', + db_port => 3306, + db_username => 'icingaweb2', + db_password => 'icingaweb2', + require => Mysql::Db['icingaweb2'], + } + + class {'icingaweb2::module::monitoring': + ido_host => 'localhost', + ido_db_name => 'icinga2', + ido_db_username => 'icinga2', + ido_db_password => 'supersecret', + commandtransports => { + icinga2 => { + transport => 'api', + username => 'root', + password => 'icinga', + } + } + } + " + + apply_manifest(pp, catch_failures: true) + end + + describe file('/etc/icingaweb2/enabledModules/monitoring') do + it { is_expected.to be_symlink } + end + + describe file('/etc/icingaweb2/modules/monitoring/config.ini') do + it { is_expected.to be_file } + it { is_expected.to contain '[config]' } + it { is_expected.to contain 'protected_customvars = "*pw*, *pass*, community"' } + end + + describe file('/etc/icingaweb2/modules/monitoring/backends.ini') do + it { is_expected.to be_file } + it { is_expected.to contain '[backends]' } + it { is_expected.to contain 'type = "ido"' } + it { is_expected.to contain 'resource = "icingaweb2-module-monitoring"' } + end + + describe file('/etc/icingaweb2/modules/monitoring/commandtransports.ini') do + it { is_expected.to be_file } + it { is_expected.to contain '[icinga2]' } + it { is_expected.to contain 'transport = "api"' } + it { is_expected.to contain 'host = "localhost"' } + it { is_expected.to contain 'port = "5665"' } + it { is_expected.to contain 'username = "root"' } + it { is_expected.to contain 'password = "icinga"' } + end + + describe file('/etc/icingaweb2/resources.ini') do + it { is_expected.to be_file } + it { is_expected.to contain '[icingaweb2-module-monitoring]' } + it { is_expected.to contain 'type = "db"' } + it { is_expected.to contain 'db = "mysql"' } + it { is_expected.to contain 'host = "localhost"' } + it { is_expected.to contain 'port = "3306"' } + it { is_expected.to contain 'dbname = "icinga2"' } + it { is_expected.to contain 'username = "icinga2"' } + it { is_expected.to contain 'password = "supersecret"' } + it { is_expected.to contain '[mysql-icingaweb2]' } + it { is_expected.to contain 'type = "db"' } + it { is_expected.to contain 'db = "mysql"' } + it { is_expected.to contain 'host = "localhost"' } + it { is_expected.to contain 'port = "3306"' } + it { is_expected.to contain 'dbname = "icingaweb2"' } + it { is_expected.to contain 'username = "icingaweb2"' } + it { is_expected.to contain 'password = "icingaweb2"' } + end + + describe file('/etc/icingaweb2/authentication.ini') do + it { is_expected.to be_file } + it { is_expected.to contain '[mysql-auth]' } + it { is_expected.to contain 'backend = "db"' } + it { is_expected.to contain 'resource = "mysql-icingaweb2"' } + + end + + describe file('/etc/icingaweb2/roles.ini') do + it { is_expected.to be_file } + it { is_expected.to contain '[default admin user]' } + it { is_expected.to contain 'users = "icinga"' } + it { is_expected.to contain 'permissions = "*"' } + end + + describe command('mysql -e "select name from icingaweb2.icingaweb_user"') do + its(:stdout) { should match(%r{icinga}) } + end +end diff --git a/spec/acceptance/nodesets/centos-6-x64.yml b/spec/acceptance/nodesets/centos-6-x64.yml new file mode 100644 index 00000000..fd7d010d --- /dev/null +++ b/spec/acceptance/nodesets/centos-6-x64.yml @@ -0,0 +1,10 @@ +--- +HOSTS: + centos-6-x64: + roles: + - master + platform: el-6-x86_64 + box: centos/6 + hypervisor: vagrant +CONFIG: + type: aio \ No newline at end of file diff --git a/spec/acceptance/nodesets/centos-6.yml b/spec/acceptance/nodesets/centos-6.yml deleted file mode 100644 index 041bce39..00000000 --- a/spec/acceptance/nodesets/centos-6.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -HOSTS: - centos-6-x64: - platform: centos-6-x86_64 - box: centos/6 - hypervisor: vagrant -CONFIG: - type: foss - type: foss - preserve_hosts: always - trace_limit: 200 - masterless: true - add_el_extras: true \ No newline at end of file diff --git a/spec/acceptance/nodesets/centos-7-x64.yml b/spec/acceptance/nodesets/centos-7-x64.yml new file mode 100644 index 00000000..d51ca205 --- /dev/null +++ b/spec/acceptance/nodesets/centos-7-x64.yml @@ -0,0 +1,10 @@ +--- +HOSTS: + centos-7-x64: + roles: + - master + platform: el-7-x86_64 + box: centos/7 + hypervisor: vagrant +CONFIG: + type: aio diff --git a/spec/acceptance/nodesets/centos-7.yml b/spec/acceptance/nodesets/centos-7.yml deleted file mode 100644 index 8ab326ea..00000000 --- a/spec/acceptance/nodesets/centos-7.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -HOSTS: - centos-7-x64: - platform: centos-7-x86_64 - box: centos/7 - hypervisor: vagrant -CONFIG: - type: foss - preserve_hosts: always - trace_limit: 200 - masterless: true - add_el_extras: true \ No newline at end of file diff --git a/spec/acceptance/nodesets/debian-7.yml b/spec/acceptance/nodesets/debian-7.yml deleted file mode 100644 index 2fcfbdda..00000000 --- a/spec/acceptance/nodesets/debian-7.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -HOSTS: - debian-8-x64: - platform: debian-7-amd64 - box: debian/wheezy64 - hypervisor: vagrant -CONFIG: - type: foss - preserve_hosts: always - trace_limit: 200 - masterless: true \ No newline at end of file diff --git a/spec/acceptance/nodesets/debian-78-x64.yml b/spec/acceptance/nodesets/debian-78-x64.yml new file mode 100644 index 00000000..f9700e64 --- /dev/null +++ b/spec/acceptance/nodesets/debian-78-x64.yml @@ -0,0 +1,10 @@ +--- +HOSTS: + debian-78-x64: + roles: + - master + platform: debian-7-amd64 + box: puppetlabs/debian-7.8-64-nocm + hypervisor: vagrant +CONFIG: + type: foss \ No newline at end of file diff --git a/spec/acceptance/nodesets/debian-8.yml b/spec/acceptance/nodesets/debian-8.yml deleted file mode 100644 index 5b06792c..00000000 --- a/spec/acceptance/nodesets/debian-8.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -HOSTS: - debian-8-x64: - platform: debian-8-amd64 - box: debian/jessie64 - hypervisor: vagrant -CONFIG: - type: foss - preserve_hosts: always - trace_limit: 200 - masterless: true \ No newline at end of file diff --git a/spec/acceptance/nodesets/debian-82-x64.yml b/spec/acceptance/nodesets/debian-82-x64.yml new file mode 100644 index 00000000..c6c837b2 --- /dev/null +++ b/spec/acceptance/nodesets/debian-82-x64.yml @@ -0,0 +1,10 @@ +--- +HOSTS: + debian-82-x64: + roles: + - master + platform: debian-8-amd64 + box: puppetlabs/debian-8.2-64-nocm + hypervisor: vagrant +CONFIG: + type: foss \ No newline at end of file diff --git a/spec/acceptance/nodesets/ubuntu-14.04.yml b/spec/acceptance/nodesets/ubuntu-14.04.yml deleted file mode 100644 index 168e02cc..00000000 --- a/spec/acceptance/nodesets/ubuntu-14.04.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -HOSTS: - ubuntu-1404-x64: - platform: ubuntu-14.04-amd64 - box: ubuntu/trusty64 - hypervisor: vagrant -CONFIG: - type: foss - preserve_hosts: always - trace_limit: 200 - masterless: true diff --git a/spec/acceptance/nodesets/ubuntu-16.04.yml b/spec/acceptance/nodesets/ubuntu-16.04.yml deleted file mode 100644 index 1c4b828f..00000000 --- a/spec/acceptance/nodesets/ubuntu-16.04.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -HOSTS: - ubuntu-1404-x64: - platform: ubuntu-16.04-amd64 - box: ubuntu/xenial64 - hypervisor: vagrant -CONFIG: - type: foss - preserve_hosts: always - trace_limit: 200 - masterless: true diff --git a/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml b/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml new file mode 100644 index 00000000..9e5ce56e --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml @@ -0,0 +1,10 @@ +--- +HOSTS: + ubuntu-server-1404-x64: + roles: + - master + platform: ubuntu-14.04-amd64 + box: puppetlabs/ubuntu-14.04-64-nocm + hypervisor: vagrant +CONFIG: + type: foss \ No newline at end of file diff --git a/spec/acceptance/nodesets/ubuntu-server-1604-x64.yml b/spec/acceptance/nodesets/ubuntu-server-1604-x64.yml new file mode 100644 index 00000000..441fe0ad --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-1604-x64.yml @@ -0,0 +1,10 @@ +--- +HOSTS: + ubuntu-server-1604-x64: + roles: + - master + platform: ubuntu-16.04-amd64 + box: puppetlabs/ubuntu-16.04-64-nocm + hypervisor: vagrant +CONFIG: + type: foss \ No newline at end of file diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index b9ac9b46..da0bf6bc 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,65 +1,27 @@ -#! /usr/bin/env ruby -S rspec - -# This file comes from puppetlabs-stdlib -# which is licensed under the Apache-2.0 License. -# https://github.com/puppetlabs/puppetlabs-stdlib -# (c) 2015-2015 Puppetlabs and puppetlabs-stdlib contributors - -require 'puppet' -require 'puppet/util/package' require 'beaker-rspec' require 'beaker/puppet_install_helper' - -UNSUPPORTED_PLATFORMS = [].freeze +require 'beaker/module_install_helper' run_puppet_install_helper RSpec.configure do |c| - # Project root proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) - # Readable test descriptions c.formatter = :documentation - # Configure all nodes in nodeset - c.before :suite do - if ENV['FUTURE_PARSER'] == 'yes' - default[:default_apply_opts] ||= {} - default[:default_apply_opts][:parser] = 'future' - end - - puppet_version = get_puppet_version - if Puppet::Util::Package.versioncmp(puppet_version, '4.0.0') < 0 - copy_root_module_to(default, source: proj_root, module_name: 'icingaweb2', target_module_path: '/etc/puppet/modules') - else - copy_root_module_to(default, source: proj_root, module_name: 'icingaweb2') - end + install_module_from_forge('puppetlabs-vcsrepo', '>= 1.3.0 <= 3.0.0') + install_module_from_forge('puppetlabs-mysql', '>= 2.2.0 <= 5.0.0') + install_module_from_forge('puppetlabs-apache', '>= 1.11.0 <= 3.0.0') + install_module_from_forge('puppet-zypprepo', '>= 2.0.0 <= 3.0.0') + install_module_from_forge('puppetlabs-apt', '>= 2.0.0 <= 3.0.0') + c.before :suite do hosts.each do |host| - %w(puppetlabs-apt - puppetlabs-concat - puppetlabs-stdlib - puppetlabs-vcsrepo - ).each do |mod| - on host, puppet('module', 'install', mod), acceptable_exit_codes: [0, 1] + copy_module_to(host, source: proj_root, module_name: 'icingaweb2') + if fact('osfamily') == 'RedHat' + # Soft dep on epel for Passenger + install_package(host, 'epel-release') end end end end - -def is_future_parser_enabled? - # rubocop:disable Style/GuardClause - if default[:type] == 'aio' - # rubocop:enable Style/GuardClause - return true - elsif default[:default_apply_opts] - return default[:default_apply_opts][:parser] == 'future' - end - false -end - -# rubocop:disable Style/AccessorMethodName -def get_puppet_version - (on default, puppet('--version')).output.chomp -end -# rubocop:enable Style/AccessorMethodName