diff --git a/.fixtures.yml b/.fixtures.yml index acce6724b..214e11c01 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,9 +1,10 @@ fixtures: repositories: - "stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git" - "apt": "git://github.com/puppetlabs/puppetlabs-apt.git" - "archive": "https://github.com/voxpupuli/puppet-archive.git" - "erlang": "git://github.com/garethr/garethr-erlang.git" - "systemd": "https://github.com/camptocamp/puppet-systemd.git" - symlinks: - "rabbitmq": "#{source_dir}" + stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib' + apt: 'https://github.com/puppetlabs/puppetlabs-apt' + archive: 'https://github.com/voxpupuli/puppet-archive' + erlang: 'https://github.com/garethr/garethr-erlang' + systemd: 'https://github.com/camptocamp/puppet-systemd' + yumrepo_core: + repo: 'https://github.com/puppetlabs/puppetlabs-yumrepo_core' + puppet_version: '>= 6.0.0' diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 67b063cd0..832578e12 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -16,8 +16,9 @@ By participating in this project you agree to abide by its terms. runs the tests for us. You can also execute them locally. This is explained in a later section. -1. Checkout the docs we use to review a module. They provide some guidance for - new code that might help you before you submit a pull request. +1. Checkout [our docs](https://voxpupuli.org/docs/#reviewing-a-module-pr) we + use to review a module and the [official styleguide](https://puppet.com/docs/puppet/6.0/style_guide.html). + They provide some guidance for new code that might help you before you submit a pull request. 1. Add a test for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality diff --git a/.msync.yml b/.msync.yml index 45b7d7c22..1d2221fa3 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '2.0.0-rc0' +modulesync_config_version: '2.2.0' diff --git a/.sync.yml b/.sync.yml index a1a3a665b..2bc522885 100644 --- a/.sync.yml +++ b/.sync.yml @@ -13,4 +13,4 @@ appveyor.yml: spec/spec_helper.rb: allow_deprecations: true spec_overrides: "require 'spec_helper_local'" - mock_with: ':rspec' + mock_with: ':mocha' diff --git a/.travis.yml b/.travis.yml index 6ee4f92ff..945996ae5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,11 +18,11 @@ matrix: env: PUPPET_VERSION="~> 5.0" CHECK=test - rvm: 2.5.1 bundler_args: --without system_tests development release - env: PUPPET_VERSION="~> 5.0" CHECK=test_with_coveralls - - rvm: 2.4.4 - bundler_args: --without system_tests development release - env: PUPPET_VERSION="~> 5.0" CHECK=rubocop + env: PUPPET_VERSION="~> 6.0" CHECK=test_with_coveralls - rvm: 2.5.1 + bundler_args: --without system_tests development release + env: PUPPET_VERSION="~> 6.0" CHECK=rubocop + - rvm: 2.4.4 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 5.0" CHECK=build DEPLOY_TO_FORGE=yes - rvm: 2.5.1 @@ -31,6 +31,12 @@ matrix: env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian8-64{hypervisor=docker} CHECK=beaker services: docker sudo: required + - rvm: 2.5.1 + bundler_args: --without development release + dist: trusty + env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian8-64{hypervisor=docker} CHECK=beaker + services: docker + sudo: required - rvm: 2.5.1 bundler_args: --without development release dist: trusty @@ -43,6 +49,12 @@ matrix: env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian9-64{hypervisor=docker} CHECK=beaker services: docker sudo: required + - rvm: 2.5.1 + bundler_args: --without development release + dist: trusty + env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian9-64{hypervisor=docker} CHECK=beaker + services: docker + sudo: required - rvm: 2.5.1 bundler_args: --without development release dist: trusty @@ -55,6 +67,12 @@ matrix: env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1404-64{hypervisor=docker} CHECK=beaker services: docker sudo: required + - rvm: 2.5.1 + bundler_args: --without development release + dist: trusty + env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1404-64{hypervisor=docker} CHECK=beaker + services: docker + sudo: required - rvm: 2.5.1 bundler_args: --without development release dist: trusty @@ -67,6 +85,12 @@ matrix: env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64{hypervisor=docker} CHECK=beaker services: docker sudo: required + - rvm: 2.5.1 + bundler_args: --without development release + dist: trusty + env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64{hypervisor=docker} CHECK=beaker + services: docker + sudo: required - rvm: 2.5.1 bundler_args: --without development release dist: trusty @@ -79,6 +103,12 @@ matrix: env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos6-64{hypervisor=docker} CHECK=beaker services: docker sudo: required + - rvm: 2.5.1 + bundler_args: --without development release + dist: trusty + env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos6-64{hypervisor=docker} CHECK=beaker + services: docker + sudo: required - rvm: 2.5.1 bundler_args: --without development release dist: trusty @@ -91,6 +121,12 @@ matrix: env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos7-64{hypervisor=docker} CHECK=beaker services: docker sudo: required + - rvm: 2.5.1 + bundler_args: --without development release + dist: trusty + env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos7-64{hypervisor=docker} CHECK=beaker + services: docker + sudo: required - rvm: 2.5.1 bundler_args: --without development release dist: trusty diff --git a/Gemfile b/Gemfile index 20f3df025..7ed69d4e5 100644 --- a/Gemfile +++ b/Gemfile @@ -11,9 +11,8 @@ def location_for(place, fake_version = nil) end group :test do - gem 'puppetlabs_spec_helper', '~> 2.6', :require => false - gem 'rspec-puppet', '~> 2.5', :require => false - gem 'rspec-puppet-facts', :require => false + gem 'puppetlabs_spec_helper', '>= 2.11.0', :require => false + gem 'rspec-puppet-facts', '>= 1.8.0', :require => false gem 'rspec-puppet-utils', :require => false gem 'puppet-lint-leading_zero-check', :require => false gem 'puppet-lint-trailing_comma-check', :require => false diff --git a/manifests/repo/apt.pp b/manifests/repo/apt.pp index 651e4e377..6b593831b 100644 --- a/manifests/repo/apt.pp +++ b/manifests/repo/apt.pp @@ -26,7 +26,7 @@ key => { 'id' => $key, 'source' => $key_source, - 'content' => $key_content, + 'content' => $key_content, }, architecture => $architecture, } diff --git a/spec/classes/rabbitmq_spec.rb b/spec/classes/rabbitmq_spec.rb index bd00c33f9..6cbfbb06e 100644 --- a/spec/classes/rabbitmq_spec.rb +++ b/spec/classes/rabbitmq_spec.rb @@ -91,12 +91,18 @@ context 'with no pin', if: facts[:os]['family'] == 'Debian' do let(:params) { { repos_ensure: true, package_apt_pin: '' } } + if Puppet.version =~ %r{^6} # https://tickets.puppetlabs.com/browse/PUP-9112 and https://tickets.puppetlabs.com/browse/PUP-9180 + let(:expected_key_apt_source_key_content) { 'nil' } + else + let(:expected_key_apt_source_key_content) { ':undef' } + end + describe 'it sets up an apt::source' do it { is_expected.to contain_apt__source('rabbitmq').with( 'location' => "https://packagecloud.io/rabbitmq/rabbitmq-server/#{facts[:os]['name'].downcase}", 'repos' => 'main', - 'key' => '{"id"=>"418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB", "source"=>"https://packagecloud.io/gpg.key", "content"=>:undef}' + 'key' => "{\"id\"=>\"418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB\", \"source\"=>\"https://packagecloud.io/gpg.key\", \"content\"=>#{expected_key_apt_source_key_content}}" ) } end @@ -105,12 +111,18 @@ context 'with pin', if: facts[:os]['family'] == 'Debian' do let(:params) { { repos_ensure: true, package_apt_pin: '700' } } + if Puppet.version =~ %r{^6} # https://tickets.puppetlabs.com/browse/PUP-9112 and https://tickets.puppetlabs.com/browse/PUP-9180 + let(:expected_key_apt_source_key_content) { 'nil' } + else + let(:expected_key_apt_source_key_content) { ':undef' } + end + describe 'it sets up an apt::source and pin' do it { is_expected.to contain_apt__source('rabbitmq').with( 'location' => "https://packagecloud.io/rabbitmq/rabbitmq-server/#{facts[:os]['name'].downcase}", 'repos' => 'main', - 'key' => '{"id"=>"418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB", "source"=>"https://packagecloud.io/gpg.key", "content"=>:undef}' + 'key' => "{\"id\"=>\"418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB\", \"source\"=>\"https://packagecloud.io/gpg.key\", \"content\"=>#{expected_key_apt_source_key_content}}" ) } diff --git a/spec/default_facts.yml b/spec/default_facts.yml index 13c416576..2f6698d5b 100644 --- a/spec/default_facts.yml +++ b/spec/default_facts.yml @@ -8,7 +8,6 @@ # Hint if using with rspec-puppet-facts ("on_supported_os.each"): # if a same named fact exists in facterdb it will be overridden. --- -concat_basedir: "/tmp" ipaddress: "172.16.254.254" is_pe: false macaddress: "AA:AA:AA:AA:AA:AA" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a8e7cc9aa..640eb8c9f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,10 +1,13 @@ -require 'puppetlabs_spec_helper/module_spec_helper' -require 'rspec-puppet-facts' -include RspecPuppetFacts - # This file is managed via modulesync # https://github.com/voxpupuli/modulesync # https://github.com/voxpupuli/modulesync_config +RSpec.configure do |c| + c.mock_with :mocha +end + +require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet-facts' +include RspecPuppetFacts if Dir.exist?(File.expand_path('../../lib', __FILE__)) require 'coveralls' @@ -23,15 +26,15 @@ end RSpec.configure do |c| - default_facts = { - puppetversion: Puppet.version, - facterversion: Facter.version - } + default_facts = {} default_facts.merge!(YAML.load(File.read(File.expand_path('../default_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_facts.yml', __FILE__)) default_facts.merge!(YAML.load(File.read(File.expand_path('../default_module_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_module_facts.yml', __FILE__)) c.default_facts = default_facts - c.mock_with :rspec + + # Coverage generation + c.after(:suite) do + RSpec::Puppet::Coverage.report! + end end require 'spec_helper_local' -# vim: syntax=ruby diff --git a/spec/unit/facter/util/fact_erl_ssl_path_spec.rb b/spec/unit/facter/util/fact_erl_ssl_path_spec.rb index 679a90162..0717533bf 100644 --- a/spec/unit/facter/util/fact_erl_ssl_path_spec.rb +++ b/spec/unit/facter/util/fact_erl_ssl_path_spec.rb @@ -5,33 +5,24 @@ describe 'erl_ssl_path' do context 'with valid value' do - before do - allow(Facter::Util::Resolution).to receive(:which).with('erl') { true } - allow(Facter::Core::Execution).to receive(:execute).with("erl -eval 'io:format(\"~p\", [code:lib_dir(ssl, ebin)]),halt().' -noshell") { '"/usr/lib64/erlang/lib/ssl-5.3.3/ebin"' } - end - it do + Facter::Util::Resolution.expects(:which).with('erl').returns(true) + Facter::Core::Execution.expects(:execute).with("erl -eval 'io:format(\"~p\", [code:lib_dir(ssl, ebin)]),halt().' -noshell").returns('"/usr/lib64/erlang/lib/ssl-5.3.3/ebin"') expect(Facter.fact(:erl_ssl_path).value).to eq('/usr/lib64/erlang/lib/ssl-5.3.3/ebin') end end context 'with error message' do - before do - allow(Facter::Util::Resolution).to receive(:which).with('erl') { true } - allow(Facter::Core::Execution).to receive(:execute).with("erl -eval 'io:format(\"~p\", [code:lib_dir(ssl, ebin)]),halt().' -noshell") { '{error,bad_name}' } - end - it do + Facter::Util::Resolution.expects(:which).with('erl').returns(true) + Facter::Core::Execution.expects(:execute).with("erl -eval 'io:format(\"~p\", [code:lib_dir(ssl, ebin)]),halt().' -noshell").returns('{error,bad_name}') expect(Facter.fact(:erl_ssl_path).value).to be_nil end end context 'with erl not present' do - before do - allow(Facter::Util::Resolution).to receive(:which).with('erl') { false } - end - it do + Facter::Util::Resolution.expects(:which).with('erl').returns(false) expect(Facter.fact(:erl_ssl_path).value).to be_nil end end diff --git a/spec/unit/facter/util/fact_rabbitmq_nodename_spec.rb b/spec/unit/facter/util/fact_rabbitmq_nodename_spec.rb index f0ed39272..0abf83361 100644 --- a/spec/unit/facter/util/fact_rabbitmq_nodename_spec.rb +++ b/spec/unit/facter/util/fact_rabbitmq_nodename_spec.rb @@ -5,57 +5,47 @@ describe 'rabbitmq_nodename' do context 'with value' do - before do - allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl') { true } - allow(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1') { 'Status of node monty@rabbit1 ...' } - end it do + Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true) + Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns('Status of node monty@rabbit1 ...') expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit1') end end context 'with dashes in hostname' do - before do - allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl') { true } - allow(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1') { 'Status of node monty@rabbit-1 ...' } - end it do + Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true) + Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns('Status of node monty@rabbit-1 ...') expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit-1') end end context 'with dashes in nodename/hostname' do - before do - allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl') { true } - allow(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1') { 'Status of node monty-python@rabbit-1 ...' } - end it do + Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true) + Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns('Status of node monty-python@rabbit-1 ...') expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty-python@rabbit-1') end end context 'with quotes around node name' do - before do - allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl') { true } - allow(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1') { 'Status of node \'monty@rabbit-1\' ...' } - end it do + Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true) + Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns('Status of node \'monty@rabbit-1\' ...') expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit-1') end end context 'without trailing points' do - before do - allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl') { true } - allow(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1') { 'Status of node monty@rabbit-1' } - end it do + Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true) + Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns('Status of node monty@rabbit-1') expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit-1') end end context 'rabbitmq is not running' do - before do + it do error_string = <<-EOS Status of node 'monty@rabbit-1' ... Error: unable to connect to node 'monty@rabbit-1': nodedown @@ -77,19 +67,15 @@ - cookie hash: 6WdP0nl6d3HYqA5vTKMkIg== EOS - allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl') { true } - allow(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1') { error_string } - end - it do + Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true) + Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns(error_string) expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit-1') end end context 'rabbitmqctl is not in path' do - before do - allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl') { false } - end it do + Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(false) expect(Facter.fact(:rabbitmq_nodename).value).to be_nil end end diff --git a/spec/unit/facter/util/fact_rabbitmq_version_spec.rb b/spec/unit/facter/util/fact_rabbitmq_version_spec.rb index b4c4420da..26dfbae62 100644 --- a/spec/unit/facter/util/fact_rabbitmq_version_spec.rb +++ b/spec/unit/facter/util/fact_rabbitmq_version_spec.rb @@ -7,28 +7,22 @@ describe 'rabbitmq_version' do context 'with value' do - before do - allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqadmin') { true } - allow(Facter::Core::Execution).to receive(:execute).with('rabbitmqadmin --version 2>&1') { 'rabbitmqadmin 3.6.0' } - end it do + Facter::Util::Resolution.expects(:which).with('rabbitmqadmin').returns(true) + Facter::Core::Execution.expects(:execute).with('rabbitmqadmin --version 2>&1').returns('rabbitmqadmin 3.6.0') expect(Facter.fact(:rabbitmq_version).value).to eq('3.6.0') end end context 'with invalid value' do - before do - allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqadmin') { true } - allow(Facter::Core::Execution).to receive(:execute).with('rabbitmqadmin --version 2>&1') { 'rabbitmqadmin %%VSN%%' } - end it do + Facter::Util::Resolution.expects(:which).with('rabbitmqadmin').returns(true) + Facter::Core::Execution.expects(:execute).with('rabbitmqadmin --version 2>&1').returns('rabbitmqadmin %%VSN%%') expect(Facter.fact(:rabbitmq_version).value).to be_nil end end context 'rabbitmqadmin is not in path' do - before do - allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqadmin') { false } - end it do + Facter::Util::Resolution.expects(:which).with('rabbitmqadmin').returns(false) expect(Facter.fact(:rabbitmq_version).value).to be_nil end end