diff --git a/Gemfile b/Gemfile index 16052af..f10111f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,86 +1,86 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' def location_for(place_or_version, fake_version = nil) git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} file_url_regex = %r{\Afile:\/\/(?.*)} if place_or_version && (git_url = place_or_version.match(git_url_regex)) [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact elsif place_or_version && (file_url = place_or_version.match(file_url_regex)) ['>= 0', { path: File.expand_path(file_url[:path]), require: false }] else [place_or_version, { require: false }] end end ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments minor_version = ruby_version_segments[0..1].join('.') group :development do gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] gem "puppet-module-posix-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby] gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby] gem "puppet-module-win-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw] gem "puppet-module-win-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw] end puppet_version = ENV['PUPPET_GEM_VERSION'] facter_version = ENV['FACTER_GEM_VERSION'] hiera_version = ENV['HIERA_GEM_VERSION'] gems = {} gems['puppet'] = location_for(puppet_version) # If facter or hiera versions have been specified via the environment # variables gems['facter'] = location_for(facter_version) if facter_version gems['hiera'] = location_for(hiera_version) if hiera_version if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)} # If we're using a Puppet gem on Windows which handles its own win32-xxx gem # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445). gems['win32-dir'] = ['<= 0.4.9', require: false] gems['win32-eventlog'] = ['<= 0.6.5', require: false] gems['win32-process'] = ['<= 0.7.5', require: false] gems['win32-security'] = ['<= 0.2.5', require: false] gems['win32-service'] = ['0.8.8', require: false] end gems.each do |gem_name, gem_params| gem gem_name, *gem_params end # Evaluate Gemfile.local and ~/.gemfile if they exist extra_gemfiles = [ "#{__FILE__}.local", File.join(Dir.home, '.gemfile'), ] extra_gemfiles.each do |gemfile| if File.file?(gemfile) && File.readable?(gemfile) eval(File.read(gemfile), binding) end end #move to .sync.yaml in the future gem 'puppetlabs_spec_helper', '>= 2.0' gem 'puppet-lint', '>= 2.0.0' gem 'facter', '>= 2.4.0' gem 'facterdb', '>= 1.0.0' gem 'rspec-puppet-facts', '>= 1.6.0' gem 'serverspec' -gem 'r10k' +#gem 'r10k' gem 'parallel_tests', '>= 2.10.0' gem 'metadata-json-lint' gem 'beaker-rspec' gem 'beaker-vagrant' gem 'beaker-puppet_install_helper' # vim: syntax=ruby diff --git a/TESTING.md b/TESTING.md index 5c8a160..2e6a08e 100644 --- a/TESTING.md +++ b/TESTING.md @@ -1,87 +1,85 @@ # TESTING ## Prerequisites -Before starting any test, you should make sure you have installed all dependent puppet modules. Find a list of all -dependencies in [README.md] or [metadata.json]. +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-icingaweb2 -bundle install +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-icingaweb2 -rake validate +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-icingaweb2 -rake lint +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-icingaweb2 -rake spec +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 ``` -## Integration tests +## 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: ``` -bundle exec rake acceptance +pdk bundle exec rake beaker ``` Run a single test: ``` -bundle exec rake beaker:ubuntu-server-1604-x64 +cd puppet-icingaweb2 +pdk 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 +pdk bundle exec rake beaker:ubuntu-server-1604-x64 ``` ### Run tests All available ServerSpec tests are listed in the `spec/acceptance/` directory. -Run all integraion tests: - -``` -cd puppet-icingaweb2 -rake beaker -``` - List all available tasks/platforms: ``` cd puppet-icingaweb2 -rake --task -``` - -Run integration tests for a single platform: -``` -cd puppet-icingaweb2 -rake beaker:centos-7 +pdk exec rake --task ``` -[README.md]: README.md [puppet-lint]: http://puppet-lint.com/ -[metadata.json]: metadata.json [RSpec]: http://rspec-puppet.com/ [Serverspec]: http://serverspec.org/ -[Beaker]: https://github.com/puppetlabs/beaker \ No newline at end of file +[Beaker]: https://github.com/puppetlabs/beaker