From 005f06f3dde8198fac2ca1a0206e05157e927d3c Mon Sep 17 00:00:00 2001 From: varac <varacanero@zeromail.org> Date: Sun, 20 Dec 2015 01:57:04 +0100 Subject: [tests] Use beaker+docker for acceptance tests Beaker together with docker is a very fast way to do acceptance testing. This commit adds basic beaker/docker support: - Add a debian jessie nodeset - Test if the module applies idempotentially, so it doesn't change resources on a second run with the same parameters. https://github.com/puppetlabs/beaker/blob/master/docs/Docker-Support.md --- .gitignore | 1 + Gemfile | 7 +++++++ README | 24 ++++++++++++++++++++++ spec/acceptance/apt_spec.rb | 21 +++++++++++++++++++ .../acceptance/nodesets/debian-8-x86_64-docker.yml | 19 +++++++++++++++++ spec/acceptance/nodesets/default.yml | 1 + spec/spec_helper_acceptance.rb | 18 ++++++++++++++++ 7 files changed, 91 insertions(+) create mode 100644 spec/acceptance/apt_spec.rb create mode 100644 spec/acceptance/nodesets/debian-8-x86_64-docker.yml create mode 120000 spec/acceptance/nodesets/default.yml create mode 100644 spec/spec_helper_acceptance.rb diff --git a/.gitignore b/.gitignore index a54aa97..3b626b8 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /spec/fixtures/modules/* !/spec/fixtures/modules/apt !/spec/fixtures/modules/apt/* +/log /.vagrant/ /.bundle/ /coverage/ diff --git a/Gemfile b/Gemfile index 8925a90..a2756c4 100644 --- a/Gemfile +++ b/Gemfile @@ -11,3 +11,10 @@ group :test do gem "rspec-puppet-facts" gem "mocha" end + +group :system_tests do + gem 'beaker', :require => false + gem 'beaker-rspec', :require => false + gem 'beaker_spec_helper', :require => false + gem 'serverspec', :require => false +end diff --git a/README b/README index 410201d..1d63af2 100644 --- a/README +++ b/README @@ -576,11 +576,35 @@ To run pupept rspec tests: bundle install --path vendor/bundle bundle exec rake spec +Verbose Output: + + bundle exec rake spec SPEC_OPTS='--format documentation' + Using different facter/puppet versions: FACTER_GEM_VERSION=1.6.10 PUPPET_GEM_VERSION=2.7.23 bundle install --path vendor/bundle bundle exec rake spec +Acceptance Tests +---------------- + +At the moment, we use [beaker together with docker](https://github.com/puppetlabs/beaker/blob/master/docs/Docker-Support.md) +to do acceptance testing. +Be sure to have a recent docker version installed. + +List configured nodesets: + + bundle exec rake beaker_nodes + +Run tests on default node (Debian Jessie): + + bundle exec rake beaker + +Run different nodeset: + + BEAKER_set="debian-8-x86_64-docker" bundle exec rspec spec/acceptance/*_spec.rb + + Licensing ========= diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb new file mode 100644 index 0000000..a976a56 --- /dev/null +++ b/spec/acceptance/apt_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper_acceptance' + +describe 'apt class' do + + context 'default parameters' do + it 'should work idempotently with no errors' do + pp = <<-EOS + class { 'apt': } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe package('apt') do + it { is_expected.to be_installed } + end + + end +end diff --git a/spec/acceptance/nodesets/debian-8-x86_64-docker.yml b/spec/acceptance/nodesets/debian-8-x86_64-docker.yml new file mode 100644 index 0000000..f09ad62 --- /dev/null +++ b/spec/acceptance/nodesets/debian-8-x86_64-docker.yml @@ -0,0 +1,19 @@ +HOSTS: + debian-8-x64: + platform: debian-8-amd64 + image: debian:8 + hypervisor: docker + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y wget locales-all puppet git' + - 'rm -f /usr/sbin/policy-rc.d' + +CONFIG: + type: foss + #log_level: verbose + #log_level: debug + +ssh: + password: root + auth_methods: ["password"] diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml new file mode 120000 index 0000000..b125a96 --- /dev/null +++ b/spec/acceptance/nodesets/default.yml @@ -0,0 +1 @@ +debian-8-x86_64-docker.yml \ No newline at end of file diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb new file mode 100644 index 0000000..1ccd84d --- /dev/null +++ b/spec/spec_helper_acceptance.rb @@ -0,0 +1,18 @@ +require 'beaker-rspec' + +RSpec.configure do |c| + module_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + module_name = module_root.split('-').last + + # Readable test descriptions + c.formatter = :documentation + + # Configure all nodes in nodeset + c.before :suite do + # Install module and dependencies + puppet_module_install(:source => module_root, :module_name => module_name) + hosts.each do |host| + shell('git clone https://gitlab.com/shared-puppet-modules-group/common.git /etc/puppet/modules/common') + end + end +end -- cgit v1.2.3 From 2bbfe8cab9ba8125feb9f54865e3025bf4d355ee Mon Sep 17 00:00:00 2001 From: Gabriel Filion <gabster@lelutin.ca> Date: Wed, 29 Jun 2016 17:31:14 +0200 Subject: Fix some minor lint issues This was shown by the testing that was added in merge request !34 --- manifests/preseeded_package.pp | 5 ++++- manifests/sources_list.pp | 5 ++++- manifests/upgrade_package.pp | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/manifests/preseeded_package.pp b/manifests/preseeded_package.pp index 3ef0687..162ade7 100644 --- a/manifests/preseeded_package.pp +++ b/manifests/preseeded_package.pp @@ -1,3 +1,4 @@ +# Install a package with a preseed file to automatically answer some questions. define apt::preseeded_package ( $ensure = 'installed', $content = '' @@ -10,7 +11,9 @@ define apt::preseeded_package ( file { $seedfile: content => $real_content, - mode => '0600', owner => root, group => root, + mode => '0600', + owner => 'root', + group => 0, } package { $name: diff --git a/manifests/sources_list.pp b/manifests/sources_list.pp index 0ee068d..7565bce 100644 --- a/manifests/sources_list.pp +++ b/manifests/sources_list.pp @@ -1,3 +1,4 @@ +# Configure an apt source define apt::sources_list ( $ensure = 'present', $source = '', @@ -22,7 +23,9 @@ define apt::sources_list ( # apparently doesn't. file { "/etc/apt/sources.list.d/${realname}.list": ensure => $ensure, - owner => root, group => 0, mode => '0644', + mode => '0644', + owner => 'root', + group => 0, notify => Exec['apt_updated'], } diff --git a/manifests/upgrade_package.pp b/manifests/upgrade_package.pp index 30572c9..e61b15d 100644 --- a/manifests/upgrade_package.pp +++ b/manifests/upgrade_package.pp @@ -1,3 +1,5 @@ +# Install a package either to a certain version, or while making sure that it's +# always the latest version that's installed. define apt::upgrade_package ( $version = '' ) { @@ -23,7 +25,7 @@ define apt::upgrade_package ( } exec { "apt-get -q -y -o 'DPkg::Options::=--force-confold' install ${name}${version_suffix}": - onlyif => [ "grep-status -F Status installed -a -P $name -q", "apt-show-versions -u $name | grep -q upgradeable" ], + onlyif => [ "grep-status -F Status installed -a -P ${name} -q", "apt-show-versions -u ${name} | grep -q upgradeable" ], require => Package['apt-show-versions', 'dctrl-tools'], before => Exec['apt_updated'] } -- cgit v1.2.3 From 0250f57b821619bba2cb25fdc16f90ac34cab2f0 Mon Sep 17 00:00:00 2001 From: Tech SOGEECOM <tech@sogeecom.org> Date: Wed, 29 Jun 2016 12:00:21 -0400 Subject: use the same style for all the examples --- README.md | 56 +++++++++++++------------------------------------------- 1 file changed, 13 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 41a9aeb..695a824 100644 --- a/README.md +++ b/README.md @@ -49,10 +49,6 @@ Ubuntu support is lagging behind but not absent either. ## Upgrade Notice<a name="upgrade-notice"></a> - * The default value of the `$repos` parameter was removed since the logic is - now in the `apt::params` class. If you have explicitly set `$repos` to - 'auto' in your manifests, you should remove this. - * The `disable_update` parameter has been removed. The main apt class defaults to *not* run an `apt-get update` on every run anyway so this parameter seems useless. @@ -83,10 +79,9 @@ Ubuntu support is lagging behind but not absent either. you will need to remove the variables, and the include and instead do the following: - class { - 'apt': - debian_url => 'http://localhost:9999/debian/', - use_next_release => true; + class { 'apt': + debian_url => 'http://localhost:9999/debian/', + use_next_release => true; } previously, you could manually set `$lsbdistcodename` which would enable forced @@ -98,10 +93,9 @@ Ubuntu support is lagging behind but not absent either. you to trigger upgrades: include apt::dist_upgrade - class { - 'apt': - codename => 'wheezy', - notify => Exec['apt_dist-upgrade']; + class { 'apt': + codename => 'wheezy', + notify => Exec['apt_dist-upgrade']; } * the `apticron` class has been moved to a parameterized class. if you were @@ -116,8 +110,7 @@ Ubuntu support is lagging behind but not absent either. you will need to remove the variables, and the include and instead do the following: - class { - 'apt::apticron': + class { 'apt::apticron': email => 'foo@example.com', notifynew => '1'; } @@ -134,9 +127,8 @@ Ubuntu support is lagging behind but not absent either. you will need to remove the variables, and the include and instead do the following: - class { - 'apt::listchanges': - email => 'foo@example.com'; + class { 'apt::listchanges': + email => 'foo@example.com'; } * the `apt::proxy_client` class has been moved to a paramterized class. if you @@ -151,10 +143,9 @@ Ubuntu support is lagging behind but not absent either. you will need to remove the variables, and the include and instead do the following: - class { - 'apt::proxy_client': - proxy => 'http://proxy.domain', - port => '666'; + class { 'apt::proxy_client': + proxy => 'http://proxy.domain', + port => '666'; } @@ -644,33 +635,11 @@ To run pupept rspec tests: bundle install --path vendor/bundle bundle exec rake spec -Verbose Output: - - bundle exec rake spec SPEC_OPTS='--format documentation' - Using different facter/puppet versions: FACTER_GEM_VERSION=1.6.10 PUPPET_GEM_VERSION=2.7.23 bundle install --path vendor/bundle bundle exec rake spec -## Acceptance Tests<a name="acceptance-tests"></a> - -At the moment, we use [beaker together with docker](https://github.com/puppetlabs/beaker/blob/master/docs/Docker-Support.md) -to do acceptance testing. -Be sure to have a recent docker version installed. - -List configured nodesets: - - bundle exec rake beaker_nodes - -Run tests on default node (Debian Jessie): - - bundle exec rake beaker - -Run different nodeset: - - BEAKER_set="debian-8-x86_64-docker" bundle exec rspec spec/acceptance/*_spec.rb - # Licensing<a name="licensing"></a> @@ -681,3 +650,4 @@ The GPL version 3 license text can be found in the "LICENSE" file accompanying this puppet module, or at the following URL: http://www.gnu.org/licenses/gpl-3.0.html + -- cgit v1.2.3 From eedc5eef88f19e83581742d305af82ae27a6fad5 Mon Sep 17 00:00:00 2001 From: Tech SOGEECOM <tech@sogeecom.org> Date: Wed, 29 Jun 2016 12:01:18 -0400 Subject: fix :key: in Gitlab markdown --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 695a824..6ad05de 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ * [apt::preseeded_package](#apt-preseeded_package) * [apt::sources_list](#apt-sources_list) * [apt::key](#apt-key) - * [apt::key::plain](#apt-key-plain) + * [`apt::key::plain`](#apt-key-plain) * [apt::upgrade_package](#apt-upgrade_package) * [Resources](#ressources) * [File\['apt_config'\]](#fileapt_config) @@ -558,7 +558,7 @@ use `apt::key::plain`. The `.gpg` extension is compulsory for `apt` to pickup the key properly. -## apt::key::plain<a name="apt-key-plain"></a> +## `apt::key::plain`<a name="apt-key-plain"></a> Deploys a secure apt OpenPGP key. This usually accompanies the sources.list snippets above for third party repositories. For example, -- cgit v1.2.3 From 419f9e460113d31e0d3d7c95ede5e41e7918d2bf Mon Sep 17 00:00:00 2001 From: Tech SOGEECOM <tech@sogeecom.org> Date: Wed, 29 Jun 2016 13:42:41 -0400 Subject: add back the parts of the README that were lost --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index 6ad05de..940e533 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ * [File\['apt_config'\]](#fileapt_config) * [Exec\['apt_updated'\]](#execapt_updated) * [Tests](#tests) + * [Acceptance Tests](#acceptance-tests) * [Licensing](#licensing) @@ -49,6 +50,10 @@ Ubuntu support is lagging behind but not absent either. ## Upgrade Notice<a name="upgrade-notice"></a> + * The default value of the `$repos` parameter was removed since the logic is + now in the `apt::params` class. If you have explicitly set `$repos` to + 'auto' in your manifests, you should remove this. + * The `disable_update` parameter has been removed. The main apt class defaults to *not* run an `apt-get update` on every run anyway so this parameter seems useless. @@ -635,11 +640,33 @@ To run pupept rspec tests: bundle install --path vendor/bundle bundle exec rake spec +Verbose Output: + + bundle exec rake spec SPEC_OPTS='--format documentation' + Using different facter/puppet versions: FACTER_GEM_VERSION=1.6.10 PUPPET_GEM_VERSION=2.7.23 bundle install --path vendor/bundle bundle exec rake spec +## Acceptance Tests<a name="acceptance-tests"></a> + +At the moment, we use [beaker together with docker](https://github.com/puppetlabs/beaker/blob/master/docs/Docker-Support.md) +to do acceptance testing. +Be sure to have a recent docker version installed. + +List configured nodesets: + + bundle exec rake beaker_nodes + +Run tests on default node (Debian Jessie): + + bundle exec rake beaker + +Run different nodeset: + + BEAKER_set="debian-8-x86_64-docker" bundle exec rspec spec/acceptance/*_spec.rb + # Licensing<a name="licensing"></a> -- cgit v1.2.3 From 5a7336ad479ce98877b80f901863f253c0b74a1d Mon Sep 17 00:00:00 2001 From: Tech SOGEECOM <tech@sogeecom.org> Date: Wed, 29 Jun 2016 13:55:29 -0400 Subject: fix formatting errors --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 940e533..a77026f 100644 --- a/README.md +++ b/README.md @@ -642,7 +642,7 @@ To run pupept rspec tests: Verbose Output: - bundle exec rake spec SPEC_OPTS='--format documentation' + bundle exec rake spec SPEC_OPTS='--format documentation' Using different facter/puppet versions: @@ -657,15 +657,15 @@ Be sure to have a recent docker version installed. List configured nodesets: - bundle exec rake beaker_nodes + bundle exec rake beaker_nodes Run tests on default node (Debian Jessie): - bundle exec rake beaker + bundle exec rake beaker Run different nodeset: - BEAKER_set="debian-8-x86_64-docker" bundle exec rspec spec/acceptance/*_spec.rb + BEAKER_set="debian-8-x86_64-docker" bundle exec rspec spec/acceptance/*_spec.rb # Licensing<a name="licensing"></a> @@ -677,4 +677,3 @@ The GPL version 3 license text can be found in the "LICENSE" file accompanying this puppet module, or at the following URL: http://www.gnu.org/licenses/gpl-3.0.html - -- cgit v1.2.3 From 05ca5b0a05d1ac38bb61d42f06b61a230060520f Mon Sep 17 00:00:00 2001 From: Tech SOGEECOM <tech@sogeecom.org> Date: Wed, 29 Jun 2016 13:59:51 -0400 Subject: ident the upgrade notices correctly --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a77026f..83a7ec9 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ Ubuntu support is lagging behind but not absent either. ## Upgrade Notice<a name="upgrade-notice"></a> - * The default value of the `$repos` parameter was removed since the logic is + * The default value of the `$repos` parameter was removed since the logic is now in the `apt::params` class. If you have explicitly set `$repos` to 'auto' in your manifests, you should remove this. @@ -77,8 +77,8 @@ Ubuntu support is lagging behind but not absent either. instantiating the class with those variables instead. For example, if you had the following in your manifests: - $apt_debian_url = 'http://localhost:9999/debian/' - $apt_use_next_release = true + $ apt_debian_url = 'http://localhost:9999/debian/' + $ apt_use_next_release = true include apt you will need to remove the variables, and the include and instead do -- cgit v1.2.3 From 8723519f0fec46fb39a99ae7c57581271e532322 Mon Sep 17 00:00:00 2001 From: intrigeri <intrigeri@boum.org> Date: Wed, 29 Jun 2016 18:21:19 +0000 Subject: Fix newly introduced white-space issues. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 83a7ec9..41194e1 100644 --- a/README.md +++ b/README.md @@ -51,8 +51,8 @@ Ubuntu support is lagging behind but not absent either. ## Upgrade Notice<a name="upgrade-notice"></a> * The default value of the `$repos` parameter was removed since the logic is - now in the `apt::params` class. If you have explicitly set `$repos` to - 'auto' in your manifests, you should remove this. + now in the `apt::params` class. If you have explicitly set `$repos` to + 'auto' in your manifests, you should remove this. * The `disable_update` parameter has been removed. The main apt class defaults to *not* run an `apt-get update` on every run anyway so this @@ -77,8 +77,8 @@ Ubuntu support is lagging behind but not absent either. instantiating the class with those variables instead. For example, if you had the following in your manifests: - $ apt_debian_url = 'http://localhost:9999/debian/' - $ apt_use_next_release = true + $apt_debian_url = 'http://localhost:9999/debian/' + $apt_use_next_release = true include apt you will need to remove the variables, and the include and instead do -- cgit v1.2.3 From bc73809d7b33541b50ba9f38cb3bf1dd2237b98f Mon Sep 17 00:00:00 2001 From: intrigeri <intrigeri@boum.org> Date: Wed, 29 Jun 2016 18:21:30 +0000 Subject: Try to fix rendering of Markdown pre-formatted sections in bullet lists. --- README.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 41194e1..c0d5f85 100644 --- a/README.md +++ b/README.md @@ -77,9 +77,9 @@ Ubuntu support is lagging behind but not absent either. instantiating the class with those variables instead. For example, if you had the following in your manifests: - $apt_debian_url = 'http://localhost:9999/debian/' - $apt_use_next_release = true - include apt + $apt_debian_url = 'http://localhost:9999/debian/' + $apt_use_next_release = true + include apt you will need to remove the variables, and the include and instead do the following: @@ -107,10 +107,10 @@ Ubuntu support is lagging behind but not absent either. including this class before, you will need to move to instantiating the class instead. For example, if you had the following in your manifests: - $apticron_email = 'foo@example.com' - $apticron_notifynew = '1' - ... any $apticron_* variables - include apticron + $apticron_email = 'foo@example.com' + $apticron_notifynew = '1' + ... any $apticron_* variables + include apticron you will need to remove the variables, and the include and instead do the following: @@ -125,9 +125,9 @@ Ubuntu support is lagging behind but not absent either. to move to instantiating the class with those variables instead. For example, if you had the following in your manifests: - $apt_listchanges_email = 'foo@example.com' - ... any $apt_listchanges_* variables - include apt::listchanges + $apt_listchanges_email = 'foo@example.com' + ... any $apt_listchanges_* variables + include apt::listchanges you will need to remove the variables, and the include and instead do the following: @@ -141,17 +141,17 @@ Ubuntu support is lagging behind but not absent either. to move to instantiating the class with those variables instead. For example, if you had the following in your manifests: - $apt_proxy = 'http://proxy.domain' - $apt_proxy_port = 666 - include apt::proxy_client + $apt_proxy = 'http://proxy.domain' + $apt_proxy_port = 666 + include apt::proxy_client you will need to remove the variables, and the include and instead do the following: - class { 'apt::proxy_client': - proxy => 'http://proxy.domain', - port => '666'; - } + class { 'apt::proxy_client': + proxy => 'http://proxy.domain', + port => '666'; + } # Requirements<a name="requirements"></a> -- cgit v1.2.3