diff --git a/AUTHORS b/AUTHORS index 21a77c0..b6b1b17 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,46 +1,50 @@ Alexandre Beche Alexandre R Gomes Andrew Choo Benjamin Krein Bill Scheidegger Blerim Sheqa Bram Vogelaar Bram Vogelaar CV Dennis Hoppe Devin Christensen Eric Lippmann Eric Zounes Florian Baumann James Weakly Jan Collijs Johan Fleury +Jonas Verhofsté Josh Beard Joshua Hoblitt Khanh Ngo Lennart Betz Leo Antunes Lorenz Bischof Markus Frosch +Martin Jansen Matthias Baur Michael Friedrich Nicolas Dandrimont Ott, Jörn WI (Fa. Goetzfried) Paolo Schiro +Pavel Pulec Peter Souter Robert Waffen Rudy Gevaert Sebastian Brückner Stefan Kleindl +Steffen Zieger Steven Bambling Tim Bishop Timo Goebel Tokynet Tom De Vylder Tomislav Dukaric Vladimir Smirnov XnS Zach Leslie david.leib@barzahlen.de marco.fretz plarivee diff --git a/TESTING.md b/TESTING.md index 2e6a08e..0c06c01 100644 --- a/TESTING.md +++ b/TESTING.md @@ -1,85 +1,84 @@ # TESTING ## Prerequisites Before starting any test, you should make sure you have installed the Puppet PDK and Bolt, also Vagrant and VirtualBox have to be installed for acceptance tests. Required gems are installed with `bundler`: ``` cd puppet-icinga2 pdk bundle install ``` Or just do an update: ``` cd puppet-icinga2 pdk bundle update ``` ## Validation tests Validation tests will check all manifests, templates and ruby files against syntax violations and style guides . Run validation tests: ``` cd puppet-icinga2 pdk bundle exec rake validate ``` ## Puppet lint With puppet-lint we test if our manifests conform to the recommended style guides from Puppet. Run lint tests: ``` cd puppet-icinga2 pdk bundle exec rake lint ``` ## Unit tests For unit testing we use [RSpec]. All classes, defined resource types and functions should have appropriate unit tests. Run unit tests: ``` cd puppet-icinga2 pdk test unit -pdk test unit --tests=repos ``` Or dedicated tests: ``` -pdk test unit --tests=spec/classes/repos_spec.rb,spec/classes/redis_spec.rb +pdk test unit --tests=spec/classes/vspheredb_spec.rb,spec/classes/vspeheredb_service_spec.rb ``` ## Acceptance tests 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: ``` pdk bundle exec rake beaker ``` Run a single test: ``` cd puppet-icingaweb2 pdk bundle exec rake beaker:ubuntu-server-1604-x64 ``` Don't destroy VM after tests: ``` export BEAKER_destroy=no pdk bundle exec rake beaker:ubuntu-server-1604-x64 ``` ### Run tests All available ServerSpec tests are listed in the `spec/acceptance/` directory. List all available tasks/platforms: ``` cd puppet-icingaweb2 pdk exec rake --task ``` [puppet-lint]: http://puppet-lint.com/ [RSpec]: http://rspec-puppet.com/ [Serverspec]: http://serverspec.org/ [Beaker]: https://github.com/puppetlabs/beaker diff --git a/spec/classes/director_servicespec.rb b/spec/classes/director_servicespec.rb deleted file mode 100644 index c7198fa..0000000 --- a/spec/classes/director_servicespec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'spec_helper' - -describe('icingaweb2::module::director::service', type: :class) do - let(:pre_condition) do - [ - "class { 'icingaweb2': }", - "class { 'icingaweb2::module::director': }", - ] - end - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - context "#{os} with defaults" do - it { - is_expected.to contain_user('icingadirector') - .with('ensure' => 'present', 'gid' => 'icingaweb2', 'shell' => '/bin/false').that_comes_before('Systemd::Unit_file[icinga-director.service]') - } - it { is_expected.to contain_systemd__unit_file('icinga-director.service').that_notifies('Service[icinga-director]') } - it { - is_expected.to contain_service('icinga-director') - .with('ensure' => 'running', - 'enable' => true) - } - end - end - end -end diff --git a/spec/classes/director_spec.rb b/spec/classes/director_spec.rb index 34909c8..8241fc3 100644 --- a/spec/classes/director_spec.rb +++ b/spec/classes/director_spec.rb @@ -1,112 +1,110 @@ require 'spec_helper' describe('icingaweb2::module::director', type: :class) do let(:pre_condition) do [ "class { 'icingaweb2': }", ] end on_supported_os.each do |os, facts| context "on #{os}" do let :facts do facts end context "#{os} with kickstart 'true'" do let(:params) do { git_revision: 'foobar', db_host: 'localhost', db_name: 'director', db_username: 'director', db_password: 'director', import_schema: true, kickstart: true, endpoint: 'foobar', api_username: 'root', api_password: 'secret' } end it { is_expected.to contain_icingaweb2__config__resource('icingaweb2-module-director') .with_type('db') .with_db_type('mysql') .with_host('localhost') - .with_port('3306') .with_db_name('director') .with_db_username('director') .with_db_password('director') .with_db_charset('utf8') } it { is_expected.to contain_icingaweb2__module('director') .with_install_method('git') .with_git_revision('foobar') .with_module_dir('/usr/share/icingaweb2/modules/director') .with_settings('module-director-db' => { 'section_name' => 'db', 'target' => '/etc/icingaweb2/modules/director/config.ini', 'settings' => { 'resource' => 'icingaweb2-module-director', }, }, 'module-director-config' => { 'section_name' => 'config', 'target' => '/etc/icingaweb2/modules/director/kickstart.ini', 'settings' => { 'endpoint' => 'foobar', 'host' => 'localhost', 'port' => '5665', 'username' => 'root', 'password' => 'secret', }, }) } it { is_expected.to contain_exec('director-migration') } it { is_expected.to contain_exec('director-kickstart') } end context "#{os} with import_schema 'false'" do let(:params) do { git_revision: 'foobar', db_host: 'localhost', db_name: 'director', db_username: 'director', db_password: 'director', import_schema: false } end it { is_expected.to contain_icingaweb2__config__resource('icingaweb2-module-director') .with_type('db') .with_db_type('mysql') .with_host('localhost') - .with_port('3306') .with_db_name('director') .with_db_username('director') .with_db_password('director') .with_db_charset('utf8') } it { is_expected.to contain_icingaweb2__module('director') .with_install_method('git') .with_git_revision('foobar') .with_module_dir('/usr/share/icingaweb2/modules/director') .with_settings('module-director-db' => { 'section_name' => 'db', 'target' => '/etc/icingaweb2/modules/director/config.ini', 'settings' => { 'resource' => 'icingaweb2-module-director', }, }) } it { is_expected.not_to contain_exec('director-migration') } it { is_expected.not_to contain_exec('director-kickstart') } end end end end diff --git a/spec/classes/vspheredb_spec.rb b/spec/classes/vspheredb_spec.rb index 9d8badf..314a89b 100644 --- a/spec/classes/vspheredb_spec.rb +++ b/spec/classes/vspheredb_spec.rb @@ -1,52 +1,53 @@ require 'spec_helper' describe('icingaweb2::module::vspheredb', type: :class) do let(:pre_condition) do [ "class { 'icingaweb2': }", ] end on_supported_os.each do |os, facts| context "on #{os}" do let :facts do facts end context "#{os} with git_revision 'v1.1.0'" do let(:params) do { git_revision: 'v1.1.0', db_host: 'localhost', db_name: 'vspheredb', db_username: 'vspheredb', db_password: 'vspheredb' } end it { is_expected.to contain_icingaweb2__config__resource('icingaweb2-module-vspheredb') .with_type('db') .with_db_type('mysql') .with_host('localhost') .with_port('3306') .with_db_name('vspheredb') .with_db_username('vspheredb') .with_db_password('vspheredb') .with_db_charset('utf8mb4') } it { is_expected.to contain_icingaweb2__module('vspheredb') .with_install_method('git') .with_git_revision('v1.1.0') + .with_package_name('icingaweb2-module-vspheredb') .with_settings('icingaweb2-module-vspheredb' => { 'section_name' => 'db', - 'target' => '/etc/icingaweb2/modules/vspheredb', + 'target' => '/etc/icingaweb2/modules/vspheredb/config.ini', 'settings' => { 'resource' => 'icingaweb2-module-vspheredb', }, }) } end end end end