simp-beaker-helpers 1.10.5 → 1.10.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ef2969b67b01c0674df80bbea3c16889381922bbfdb08505c491a88c125e523
4
- data.tar.gz: a86092fd607ad2b35e87c3242af394dc57f69441f2bca2d5c86adbf204a4bacd
3
+ metadata.gz: 32a8dc49acbd2983aba94a4ba0807a14c38067db0919405ea998fb2a60fe68c0
4
+ data.tar.gz: 8c85f102e7dc4dce934303d76885b4cfed21c42cf47cdbbc843497b377477d23
5
5
  SHA512:
6
- metadata.gz: ebf14936b15e19407abe6471a6b4fa0fee9c8b64db9a1e36c52922132e65fba63d29f99a1f9f1c10993bbfbfc334f77b1ec0531f67ef9780e732bc53f7e2a012
7
- data.tar.gz: c30f517d4e108c4d7d5a4dfc5d8bb6a1399094bee4f454dcee4ed5b8b37667e596a020d4e370d1353a76375ae0259cf3fec13e0c01eb0c4fa513797606f49b60
6
+ metadata.gz: 92206a3fd881f98bcd574189c3090459048bfb0c813b08381f7ceeb65d0def201d963616eb08df4ebfa080309bdffd65e8c5a9d010a9f0764ccc3ea8a50f6f14
7
+ data.tar.gz: 615c5b9a61816772adc6cf6503be7db15ae71ae629fd7f7e4ca63db3e7b10948b983da44260faa8604d7ee8a980cfa3abc95f4d9d6d799f1dc5e89a1d344e4a1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ### 1.10.7 / 2018-05-11
2
+ * Updated README
3
+ * Changed acceptance tests to use `beaker:suites`
4
+ * Removed all Puppet 5+ mappings and updated the install method to figure out
5
+ what to use based on the available gems so that everything is now consistent
6
+
7
+ ### 1.10.6 / 2018-05-07
8
+ * Added Simp::BeakerHelpers.tmpname method to work around the removal of
9
+ Dir::Tmpname in Ruby 2.5
10
+
1
11
  ### 1.10.5 / 2018-04-27
2
12
  * Fix issue with direct copy to/from docker containers
3
13
  * Add necessary package for SSG builds
data/README.md CHANGED
@@ -3,38 +3,48 @@
3
3
  Methods to assist beaker acceptance tests for SIMP.
4
4
 
5
5
  #### Table of Contents
6
- 1. [Overview](#overview)
7
- 2. [Setup](#setup)
8
- * [Beginning with simp-beaker-helpers](#beginning-with-simp-beaker-helpers)
9
- 3. [General Enhancements](#general-enhancements)
10
- * [Suites](#suites)
11
- 4. [Nodeset Enhancements](#nodeset-enhancements)
12
- * [YUM Repo Support](#yum_repo_support)
13
- 5. [Methods](#methods)
14
- * [`copy_fixture_modules_to`](#copy_fixture_modules_to)
6
+
7
+ <!-- vim-markdown-toc GFM -->
8
+
9
+ * [Overview](#overview)
10
+ * [Setup](#setup)
11
+ * [Beginning with simp-beaker-helpers](#beginning-with-simp-beaker-helpers)
12
+ * [Rake Tasks](#rake-tasks)
13
+ * [`rake beaker:suites`](#rake-beakersuites)
14
+ * [Suite Execution](#suite-execution)
15
+ * [Environment Variables](#environment-variables)
16
+ * [Global Suite Configuration](#global-suite-configuration)
17
+ * [Supported Config:](#supported-config)
18
+ * [Individual Suite Configuration](#individual-suite-configuration)
19
+ * [Supported Config:](#supported-config-1)
20
+ * [Nodeset Enhancements](#nodeset-enhancements)
21
+ * [YUM Repo Support](#yum-repo-support)
22
+ * [Methods](#methods)
15
23
  * [`copy_to`](#copy_to)
24
+ * [`copy_fixture_modules_to`](#copy_fixture_modules_to)
16
25
  * [`fix_errata_on`](#fix_errata_on)
17
- * PKI
18
- * [`run_fake_pki_ca_on`](#run_fake_pki_ca_on)
19
- * [`copy_pki_to`](#copy_pki_to)
20
- * [`copy_keydist_to`](#copy_keydist_to)
21
- * Custom facts
22
- * [`pfact_on`](#pfact_on)
23
- * [`pluginsync_on`](#pluginsync_on)
24
- * Hiera
25
- * [`write_hieradata_to`](#write_hieradata_to)
26
- * [`set_hieradata_on`](#set_hieradata_on)
27
- * [`clear_temp_hieradata`](#clear_temp_hieradata)
28
- 6. [Environment variables](#environment-variables)
26
+ * [`run_fake_pki_ca_on`](#run_fake_pki_ca_on)
27
+ * [`copy_pki_to`](#copy_pki_to)
28
+ * [`copy_keydist_to`](#copy_keydist_to)
29
+ * [`pfact_on`](#pfact_on)
30
+ * [`pluginsync_on`](#pluginsync_on)
31
+ * [`write_hieradata_to`](#write_hieradata_to)
32
+ * [`set_hieradata_on`](#set_hieradata_on)
33
+ * [`clear_temp_hieradata`](#clear_temp_hieradata)
34
+ * [`latest_puppet_agent_version_for(puppet_version)`](#latest_puppet_agent_version_forpuppet_version)
35
+ * [`install_puppet`](#install_puppet)
36
+ * [Environment variables](#environment-variables-1)
29
37
  * [`BEAKER_fips`](#beaker_fips)
30
38
  * [`BEAKER_spec_prep`](#beaker_spec_prep)
31
39
  * [`BEAKER_stringify_facts`](#beaker_stringify_facts)
32
40
  * [`BEAKER_use_fixtures_dir_for_modules`](#beaker_use_fixtures_dir_for_modules)
33
- * [`PUPPET_VERSION`](#puppet_version)
34
- 7. [Examples](#examples)
35
- * [Prep OS, Generate and copy PKI certs to each SUT](#prep-os-generate-and-copy-pki-certs-to-each-sut)
36
- * [Specify the version of Puppet to run in the SUTs](#specify-the-version-of-puppet-to-run-in-the-suts)
37
- 8. [License](#license)
41
+ * [PUPPET_VERSION](#puppet_version)
42
+ * [Examples](#examples)
43
+ * [Prep OS, Generate and copy PKI certs to each SUT](#prep-os-generate-and-copy-pki-certs-to-each-sut)
44
+ * [Specify the version of Puppet to run in the SUTs](#specify-the-version-of-puppet-to-run-in-the-suts)
45
+ * [License](#license)
46
+
47
+ <!-- vim-markdown-toc -->
38
48
 
39
49
  ## Overview
40
50
 
@@ -53,9 +63,19 @@ Add this to your project's `spec/spec_helper_acceptance.rb`:
53
63
  require 'simp/beaker_helpers'
54
64
  include Simp::BeakerHelpers
55
65
  ```
56
- ## General Enhancements
57
66
 
58
- ### Suites
67
+ ## Rake Tasks
68
+
69
+ New `rake` tasks are available to help you use `beaker` more effectively.
70
+
71
+ These can be included in your `Rakefile` by adding the following:
72
+
73
+ ```
74
+ require 'simp/rake/beaker'
75
+ Simp::Rake::Beaker.new(File.dirname(__FILE__))
76
+ ```
77
+
78
+ ### `rake beaker:suites`
59
79
 
60
80
  The 'beaker:suites' rake task provides the ability to run isolated test sets
61
81
  with a full reset of the Beaker environment.
@@ -64,7 +84,7 @@ These are entirely isolated runs of Beaker and have been designed to be used
64
84
  for situations where you need to eliminate all of the cruft from your previous
65
85
  runs to perform a new type of test.
66
86
 
67
- #### Suite Execution
87
+ ### Suite Execution
68
88
 
69
89
  By default the only suite that will be executed is `default`. Since each suite
70
90
  is executed in a new environment, spin up can take a lot of time. Therefore,
@@ -278,8 +298,33 @@ Clean up all temporary hiera data files; meant to be called from `after(:all)`
278
298
 
279
299
  `clear_temp_hieradata`
280
300
 
301
+ #### `latest_puppet_agent_version_for(puppet_version)`
302
+
303
+ Finds the latest `puppet-agent` version based on the passed gem version and can
304
+ accept the usual Gem comparison syntax (e.g., '4.0', '=4.2', '~> 4.3.1', '5')
305
+
306
+ Returns the `puppet-agent` package version or `nil` if not found.
307
+
308
+ #### `install_puppet`
309
+
310
+ Performs an assessment of all set parameters and installs the correct
311
+ `puppet-agent` based on those parameters based on the following logic.
312
+
313
+ If the environment variable `BEAKER_PUPPET_AGENT_VERSION` or
314
+ `PUPPET_INSTALL_VERSION` or `PUPPET_VERSION` is set, it will use that value
315
+ to determine the `puppet-agent` version to install.
316
+
317
+ If it is unable to determine the `puppet-agent` version from any `*VERSION`
318
+ environment variables and the environment variable `BEAKER_PUPPET_COLLECTION`
319
+ is set, it will use this to determine which puppet collection to install from.
320
+ (Presently, this only works with Puppet 5.x and is set as `puppet5`.)
321
+
322
+ If it cannot determinte the `puppet-agent` version from any environment
323
+ variables, it will default the version to the value of
324
+ Simp::BeakerHelpers::DEFAULT_PUPPET_AGENT_VERSION, which is currently '1.10.4'.
281
325
 
282
326
  ## Environment variables
327
+
283
328
  #### `BEAKER_fips`
284
329
 
285
330
  _(Default: `no`)_ When set to `yes`, Beaker will enable [FIPS mode](https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security_Guide/sect-Security_Guide-Federal_Standards_And_Regulations-Federal_Information_Processing_Standard.html) on all SUTs before running tests.
@@ -304,6 +349,9 @@ The `PUPPET_VERSION` environment variable will install the latest
304
349
  `puppet-agent` package that provides that version of Puppet. This honors
305
350
  `Gemfile`-style expressions like `"~> 4.8.0"`
306
351
 
352
+ `BEAKER_PUPPET_AGENT_VERSION` and `PUPPET_INSTALL_VERSION` are synonyms of
353
+ `PUPPET_VERSION`.
354
+
307
355
  ## Examples
308
356
 
309
357
 
@@ -361,7 +409,10 @@ PUPPET_VERSION="~> 4.8.0" bundle exec rake beaker:suites
361
409
  # puppet-agent 1.9.2 will be installed in VMs
362
410
  PUPPET_INSTALL_VERSION=1.9.2 bundle exec rake beaker:suites
363
411
 
364
- # puppet-agent 1.8.3 will be installed in VMs
412
+ # The latest puppet 5 will be installed in VMs
413
+ PUPPET_VERSION="5" bundle exec rake beaker:suites
414
+
415
+ # puppet-agent 1.10.4 will be installed in VMs
365
416
  bundle exec rake beaker:suites
366
417
  ```
367
418
 
data/Rakefile CHANGED
@@ -5,17 +5,17 @@ require 'rake/clean'
5
5
  require 'fileutils'
6
6
  require 'find'
7
7
  require 'rspec/core/rake_task'
8
- require 'puppetlabs_spec_helper/rake_tasks'
8
+ require 'simp/rake/beaker'
9
9
 
10
+ @package='simp-beaker-helpers'
11
+ @rakefile_dir=File.dirname(__FILE__)
12
+
13
+ Simp::Rake::Beaker.new(@rakefile_dir)
10
14
 
11
15
  ['spec','syntax','syntax:hiera','syntax:manifests','syntax:templates','lint','metadata'].each do |task|
12
16
  Rake::Task[task].clear
13
17
  end
14
18
 
15
- @package='simp-beaker-helpers'
16
- @rakefile_dir=File.dirname(__FILE__)
17
-
18
-
19
19
  CLEAN.include "#{@package}-*.gem"
20
20
  CLEAN.include 'pkg'
21
21
  CLEAN.include 'dist'
@@ -46,6 +46,12 @@ SIMP_RPM_BUILD when set, alters the gem produced by pkg:gem to be RPM-safe.
46
46
  }
47
47
  end
48
48
 
49
+ desc "Run spec tests"
50
+ RSpec::Core::RakeTask.new(:spec) do |t|
51
+ t.rspec_opts = ['--color']
52
+ t.pattern = 'spec/lib/**/*_spec.rb'
53
+ end
54
+
49
55
  desc %q{run all RSpec tests (alias of 'spec')}
50
56
  task :test => :spec
51
57
 
@@ -4,17 +4,10 @@
4
4
  # - https://docs.puppet.com/puppet/latest/about_agent.html
5
5
  #
6
6
  version_mappings:
7
- '5.4.0': '5.4.0'
8
- '5.3.5': '5.3.5'
9
- '5.3.4': '5.3.4'
10
- '5.3.3': '5.3.3'
11
- '5.3.2': '5.3.2'
12
- '5.3.1': '5.3.1'
13
- '5.3.0': '5.3.0'
14
- '5.2.0': '5.2.0'
15
- '5.1.0': '5.1.0'
16
- '5.0.1': '5.0.1'
17
- '5.0.0': '5.0.0'
7
+ '4.10.11': '1.10.12'
8
+ '4.10.10': '1.10.10'
9
+ '4.10.9': '1.10.9'
10
+ '4.10.8': '1.10.8'
18
11
  '4.10.7': '1.10.7'
19
12
  '4.10.6': '1.10.6'
20
13
  '4.10.5': '1.10.5'
@@ -5,11 +5,17 @@ module Simp::BeakerHelpers
5
5
  require 'simp/beaker_helpers/inspec'
6
6
  require 'simp/beaker_helpers/ssg'
7
7
 
8
+ # Stealing this from the Ruby 2.5 Dir::Tmpname workaround from Rails
9
+ def self.tmpname
10
+ t = Time.new.strftime("%Y%m%d")
11
+ "simp-beaker-helpers-#{t}-#{$$}-#{rand(0x100000000).to_s(36)}.tmp"
12
+ end
13
+
8
14
  # This is the *oldest* version that the latest release of SIMP supports
9
15
  #
10
16
  # This is done so that we know if some new thing that we're using breaks the
11
17
  # oldest system that we support.
12
- DEFAULT_PUPPET_AGENT_VERSION = '1.7.1'
18
+ DEFAULT_PUPPET_AGENT_VERSION = '1.10.4'
13
19
 
14
20
  # We can't cache this because it may change during a run
15
21
  def fips_enabled(sut)
@@ -175,7 +181,7 @@ module Simp::BeakerHelpers
175
181
 
176
182
  Dir.chdir(mod_root) do
177
183
  begin
178
- tarfile = Dir::Tmpname.make_tmpname(['beaker','.tar'],nil)
184
+ tarfile = "#{Simp::BeakerHelpers.tmpname}.tar"
179
185
 
180
186
  excludes = PUPPET_MODULE_INSTALL_IGNORE.map do |x|
181
187
  x = "--exclude '*/#{x}'"
@@ -681,48 +687,119 @@ done
681
687
  # Looks up latest `puppet-agent` version by the version of its `puppet` gem
682
688
  #
683
689
  # @param puppet_version [String] target Puppet gem version. Works with
684
- # Gemfile comparison syntax (e.g., '4.0', '= 4.2', '~> 4.3.1')
690
+ # Gemfile comparison syntax (e.g., '4.0', '= 4.2', '~> 4.3.1', '> 5.1, < 5.5')
685
691
  #
686
692
  # @return [String,Nil] the `puppet-agent` version or nil
687
693
  #
688
694
  def latest_puppet_agent_version_for( puppet_version )
689
695
  return nil if puppet_version.nil?
696
+
690
697
  require 'rubygems/requirement'
691
698
  require 'rubygems/version'
692
699
  require 'yaml'
700
+
701
+ _puppet_version = puppet_version.strip.split(',')
702
+
703
+
693
704
  @agent_version_table ||= YAML.load_file(
694
705
  File.expand_path(
695
706
  '../../files/puppet-agent-versions.yaml',
696
707
  File.dirname(__FILE__)
697
708
  )).fetch('version_mappings')
698
709
  _pair = @agent_version_table.find do |k,v|
699
- Gem::Requirement.new(puppet_version).satisfied_by?(Gem::Version.new(k))
710
+ Gem::Requirement.new(_puppet_version).satisfied_by?(Gem::Version.new(k))
700
711
  end
701
712
  result = _pair ? _pair.last : nil
702
713
 
714
+ # If we didn't get a match, go look for published rubygems
715
+ unless result
716
+ puppet_gems = nil
717
+
718
+ Bundler.with_clean_env do
719
+ puppet_gems = %x(gem search -ra -e puppet).match(/\((.+)\)/)
720
+ end
721
+
722
+ if puppet_gems
723
+ puppet_gems = puppet_gems[1].split(/,?\s+/).select{|x| x =~ /^\d/}
724
+
725
+ # If we don't have a full version string, we need to massage it for the
726
+ # match.
727
+ begin
728
+ if _puppet_version.size == 1
729
+ Gem::Version.new(_puppet_version[0])
730
+ if _puppet_version[0].count('.') < 2
731
+ _puppet_version = "~> #{_puppet_version[0]}"
732
+ end
733
+ end
734
+ rescue ArgumentError
735
+ # this means _puppet_version is not just a version, but a version
736
+ # specifier such as "= 5.2.3", "<= 5.1", "> 4", "~> 4.10.7"
737
+ end
738
+
739
+ result = puppet_gems.find do |ver|
740
+ Gem::Requirement.new(_puppet_version).satisfied_by?(Gem::Version.new(ver))
741
+ end
742
+ end
743
+ end
744
+
703
745
  return result
704
746
  end
705
747
 
748
+ # returns hash with :puppet_install_version, :beaker_puppet_collection,
749
+ # and :puppet_install_type keys determined from environment variables,
750
+ # host settings, and/or defaults
751
+ #
752
+ # NOTE: BEAKER_PUPPET_AGENT_VERSION or PUPPET_INSTALL_VERSION or
753
+ # PUPPET_VERSION takes precedence over BEAKER_PUPPET_COLLECTION
754
+ # or host.options['puppet_collection'], when both a puppet
755
+ # install version and a puppet collection are specified. This is
756
+ # because the puppet install version can specify more precise
757
+ # version information than is available from a puppet collection.
758
+ def get_puppet_install_info
759
+ # The first match is internal Beaker and the second is legacy SIMP
760
+ puppet_install_version = ENV['BEAKER_PUPPET_AGENT_VERSION'] || ENV['PUPPET_INSTALL_VERSION'] || ENV['PUPPET_VERSION']
761
+
762
+ if puppet_install_version and !puppet_install_version.strip.empty?
763
+ puppet_agent_version = latest_puppet_agent_version_for(puppet_install_version.strip)
764
+ end
765
+
766
+ if puppet_agent_version.nil?
767
+ if puppet_collection = (ENV['BEAKER_PUPPET_COLLECTION'] || host.options['puppet_collection'])
768
+ if puppet_collection =~ /puppet(\d+)/
769
+ puppet_install_version = "~> #{$1}"
770
+ puppet_agent_version = latest_puppet_agent_version_for(puppet_install_version)
771
+ else
772
+ raise("Error: Puppet Collection '#{puppet_collection}' must match /puppet(\\d+)/")
773
+ end
774
+ else
775
+ puppet_agent_version = DEFAULT_PUPPET_AGENT_VERSION
776
+ end
777
+ end
778
+
779
+ if puppet_collection.nil?
780
+ base_version = puppet_agent_version.to_i
781
+ puppet_collection = "puppet#{base_version}" if base_version >= 5
782
+ end
783
+
784
+ { :puppet_install_version => puppet_agent_version,
785
+ :beaker_puppet_collection => puppet_collection,
786
+ :puppet_install_type => ENV.fetch('PUPPET_INSTALL_TYPE', 'agent')
787
+ }
788
+ end
789
+
706
790
 
707
791
  # Replacement for `install_puppet` in spec_helper_acceptance.rb
708
792
  def install_puppet
709
- puppet_install_type = ENV.fetch('PUPPET_INSTALL_TYPE', 'agent')
710
-
711
- puppet_agent_version = ENV.fetch('PUPPET_INSTALL_VERSION', nil)
793
+ install_info = get_puppet_install_info
712
794
 
713
- unless puppet_agent_version
714
- if host.options['puppet_collection'] && host.options['puppet_collection'] =~ /puppet(\d+)/
715
- puppet_agent_version = latest_puppet_agent_version_for("~> #{$1}")
716
- else
717
- puppet_agent_version = (
718
- latest_puppet_agent_version_for(ENV.fetch('PUPPET_VERSION',nil)) ||
719
- DEFAULT_PUPPET_AGENT_VERSION
720
- )
721
- end
795
+ # In case Beaker needs this info internally
796
+ ENV['PUPPET_INSTALL_VERSION'] = install_info[:puppet_install_version]
797
+ unless install_info[:puppet_collection].nil?
798
+ ENV['BEAKER_PUPPET_COLLECTION'] = install_info[:puppet_collection]
722
799
  end
723
800
 
724
801
  require 'beaker/puppet_install_helper'
725
802
 
726
- run_puppet_install_helper(puppet_install_type, puppet_agent_version)
803
+ run_puppet_install_helper(install_info[:puppet_install_type], install_info[:puppet_install_version])
727
804
  end
728
805
  end
@@ -1,5 +1,5 @@
1
1
  module Simp; end
2
2
 
3
3
  module Simp::BeakerHelpers
4
- VERSION = '1.10.5'
4
+ VERSION = '1.10.7'
5
5
  end
@@ -0,0 +1 @@
1
+ spec/acceptance/suites/default/../../nodesets
@@ -0,0 +1,21 @@
1
+ # This needs to be done so that we actually bring in a collection at the start
2
+ # of the run
3
+ #
4
+ # Choosing an arbitrary number in the middle of 5 so that we're not fooled by
5
+ # edge cases
6
+ #
7
+ ENV['PUPPET_VERSION'] = '5.1'
8
+
9
+ require 'spec_helper_acceptance'
10
+
11
+ hosts.each do |host|
12
+ describe 'make sure puppet version is valid' do
13
+ context "on #{host}" do
14
+ client_puppet_version = on(host, 'puppet --version').output.strip
15
+
16
+ it "should be running puppet version #{ENV['PUPPET_VERSION']}}" do
17
+ expect(Gem::Version.new(client_puppet_version)).to be >= Gem::Version.new(ENV['PUPPET_VERSION'])
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,2 @@
1
+ ---
2
+ 'default_run': true
@@ -0,0 +1,221 @@
1
+ require 'spec_helper'
2
+ require 'simp/beaker_helpers'
3
+
4
+ # redefine methods used in RSpec.configure withing Simp::BeakerHelpers
5
+ def hosts; end
6
+ def activate_interfaces(hosts); end
7
+ def clear_temp_hieradata; end
8
+
9
+ class MyTestClass
10
+ class FakeHost
11
+ attr_accessor :options
12
+ def initialize(opts = {})
13
+ @options = opts
14
+ end
15
+ end
16
+
17
+ include Simp::BeakerHelpers
18
+
19
+ attr_accessor :host
20
+
21
+ def initialize
22
+ @host = FakeHost.new
23
+ end
24
+ end
25
+
26
+ describe 'Simp::BeakerHelpers' do
27
+ before :each do
28
+ @helper = MyTestClass.new
29
+ end
30
+
31
+ let(:gem_search_results) {
32
+ # subset of results, but still exercises code
33
+ "puppet (5.5.1 ruby universal-darwin x64-mingw32 x86-mingw32, 5.5.0 ruby universal-darwin x64-mingw32 x86-mingw32, 5.4.0 ruby universal-darwin x64-mingw32 x86-mingw32, 5.3.6 ruby universal-darwin x64-mingw32 x86-mingw32, 5.3.5 ruby universal-darwin x64-mingw32 x86-mingw32, 5.3.4 ruby universal-darwin x64-mingw32 x86-mingw32, 5.3.3 ruby universal-darwin x64-mingw32 x86-mingw32, 5.3.2 ruby universal-darwin x64-mingw32 x86-mingw32, 5.3.1 ruby universal-darwin x64-mingw32 x86-mingw32, 5.2.0 ruby universal-darwin x64-mingw32 x86-mingw32, 5.1.0 ruby universal-darwin x64-mingw32 x86-mingw32, 5.0.1 ruby universal-darwin x64-mingw32 x86-mingw32, 5.0.0 ruby universal-darwin x64-mingw32 x86-mingw32, 4.10.11 ruby universal-darwin x64-mingw32 x86-mingw32, 4.10.10 ruby universal-darwin x64-mingw32 x86-mingw32, 4.10.9 ruby universal-darwin x64-mingw32 x86-mingw32, 4.10.8 ruby universal-darwin x64-mingw32 x86-mingw32, 4.10.7 ruby universal-darwin x64-mingw32 x86-mingw32, 4.10.6 ruby universal-darwin x64-mingw32 x86-mingw32, 4.10.5 ruby universal-darwin x64-mingw32 x86-mingw32, 4.10.4 ruby universal-darwin x64-mingw32 x86-mingw32, 4.10.1 ruby universal-darwin x64-mingw32 x86-mingw32, 4.10.0 ruby universal-darwin x64-mingw32 x86-mingw32, 4.9.4 ruby universal-darwin x64-mingw32 x86-mingw32, 4.9.3 ruby universal-darwin x64-mingw32 x86-mingw32, 4.9.2 ruby universal-darwin x64-mingw32 x86-mingw32, 4.9.1 ruby universal-darwin x64-mingw32 x86-mingw32, 4.9.0 ruby universal-darwin x64-mingw32 x86-mingw32, 4.8.2 ruby universal-darwin x64-mingw32 x86-mingw32, 4.8.1 ruby universal-darwin x64-mingw32 x86-mingw32, 4.8.0 ruby universal-darwin x64-mingw32 x86-mingw32)\n"
34
+ }
35
+
36
+ context '#latest_puppet_agent_version_for' do
37
+ context 'using table' do
38
+ it 'maps exact Puppet version' do
39
+ expect( @helper.latest_puppet_agent_version_for('4.10.4') ).to eq '1.10.4'
40
+ end
41
+
42
+ # remaining tests are only for a sampling of version specifictions with
43
+ # operators, because we are really only testing that the version specification
44
+ # is proper;ly handed off to Gem::Requirement(), not that Gem::Requirement works.
45
+ it "maps to appropriate Puppet version when '=' operator specified in version" do
46
+ expect( @helper.latest_puppet_agent_version_for('= 4.8') ).to eq '1.8.0'
47
+ end
48
+
49
+ it "maps to appropriate Puppet version when '~>' operator specified in version" do
50
+ expect( @helper.latest_puppet_agent_version_for('~> 4.8.0') ).to eq '1.8.3'
51
+ end
52
+
53
+ it "maps to appropriate Puppet version when '<' operator specified in version" do
54
+ expect( @helper.latest_puppet_agent_version_for('< 4.9') ).to match /1.8.3/
55
+ end
56
+
57
+ it "maps to appropriate Puppet version when comma-separated operators specified in version" do
58
+ expect( @helper.latest_puppet_agent_version_for('>= 4.7, < 4.9') ).to match /1.8.3/
59
+ end
60
+ end
61
+
62
+ context 'using gem lookup' do
63
+ it 'maps exact Puppet version' do
64
+ allow(@helper).to receive(:`).with('gem search -ra -e puppet').and_return(gem_search_results)
65
+ expect( @helper.latest_puppet_agent_version_for('5.3.1') ).to eq '5.3.1'
66
+ end
67
+
68
+ # remaining tests are only for a sampling of version specifictions with
69
+ # operators, because we are really only testing that the version specification
70
+ # is proper;ly handed off to Gem::Requirement(), not that Gem::Requirement works.
71
+ it "maps to appropriate Puppet version when '=' operator specified in version" do
72
+ allow(@helper).to receive(:`).with('gem search -ra -e puppet').and_return(gem_search_results)
73
+ expect( @helper.latest_puppet_agent_version_for('= 5.5') ).to eq '5.5.0'
74
+ end
75
+
76
+ it "maps to appropriate Puppet version when '~>' operator specified in version" do
77
+ allow(@helper).to receive(:`).with('gem search -ra -e puppet').and_return(gem_search_results)
78
+ expect( @helper.latest_puppet_agent_version_for('~> 5.3.0') ).to eq '5.3.6'
79
+ end
80
+
81
+ # this logic won't work properly without code changes that just aren't worth it because
82
+ # Puppet 4 is MD soon....
83
+ it "maps to appropriate Puppet version when '<' operator specified in version" do
84
+ pending 'fails because matches 4.x table'
85
+ allow(@helper).to receive(:`).with('gem search -ra -e puppet').and_return(gem_search_results)
86
+ expect( @helper.latest_puppet_agent_version_for('< 5.5') ).to match /5.4.0/
87
+ end
88
+
89
+ it "maps to appropriate Puppet version when comma-separated operators specified in version" do
90
+ allow(@helper).to receive(:`).with('gem search -ra -e puppet').and_return(gem_search_results)
91
+ expect( @helper.latest_puppet_agent_version_for('>= 5, < 5.5') ).to match /5.4.0/
92
+ end
93
+ end
94
+ end
95
+
96
+ context '#get_puppet_install_info' do
97
+ after (:each) do
98
+ ENV['BEAKER_PUPPET_AGENT_VERSION'] = nil
99
+ ENV['PUPPET_INSTALL_VERSION'] = nil
100
+ ENV['PUPPET_VERSION'] = nil
101
+ ENV['BEAKER_PUPPET_COLLECTION'] = nil
102
+ ENV['PUPPET_INSTALL_TYPE'] = nil
103
+ end
104
+
105
+ it 'uses defaults when no environment variables are set' do
106
+ expected = {
107
+ :puppet_install_version => Simp::BeakerHelpers::DEFAULT_PUPPET_AGENT_VERSION,
108
+ :beaker_puppet_collection => nil,
109
+ :puppet_install_type => 'agent'
110
+ }
111
+ expect( @helper.get_puppet_install_info ).to eq expected
112
+ end
113
+
114
+ it 'extracts info from PUPPET_INSTALL_VERSION for Puppet 4' do
115
+ ENV['PUPPET_INSTALL_VERSION']= '4.10.5'
116
+ expected = {
117
+ :puppet_install_version => '1.10.5',
118
+ :beaker_puppet_collection => nil,
119
+ :puppet_install_type => 'agent'
120
+ }
121
+ expect( @helper.get_puppet_install_info ).to eq expected
122
+ end
123
+
124
+ it 'extracts info from PUPPET_INSTALL_VERSION for Puppet 5' do
125
+ allow(@helper).to receive(:`).with('gem search -ra -e puppet').and_return(gem_search_results)
126
+ ENV['PUPPET_INSTALL_VERSION']= '5.5.0'
127
+ expected = {
128
+ :puppet_install_version => '5.5.0',
129
+ :beaker_puppet_collection => 'puppet5',
130
+ :puppet_install_type => 'agent'
131
+ }
132
+ expect( @helper.get_puppet_install_info ).to eq expected
133
+ end
134
+
135
+ it 'extracts info from PUPPET_INSTALL_VERSION even when BEAKER_PUPPET_COLLECTION is set' do
136
+ allow(@helper).to receive(:`).with('gem search -ra -e puppet').and_return(gem_search_results)
137
+ ENV['PUPPET_INSTALL_VERSION']= '5.5.0'
138
+ ENV['BEAKER_PUPPET_COLLECTION']= 'puppet6'
139
+ expected = {
140
+ :puppet_install_version => '5.5.0',
141
+ :beaker_puppet_collection => 'puppet5',
142
+ :puppet_install_type => 'agent'
143
+ }
144
+ expect( @helper.get_puppet_install_info ).to eq expected
145
+ end
146
+
147
+ it 'extracts info from PUPPET_INSTALL_VERSION even when host puppet_collection option is set' do
148
+ allow(@helper).to receive(:`).with('gem search -ra -e puppet').and_return(gem_search_results)
149
+ ENV['PUPPET_INSTALL_VERSION']= '5.5.0'
150
+ @helper.host.options = {'puppet_collection' => 'puppet6'}
151
+ expected = {
152
+ :puppet_install_version => '5.5.0',
153
+ :beaker_puppet_collection => 'puppet5',
154
+ :puppet_install_type => 'agent'
155
+ }
156
+ expect( @helper.get_puppet_install_info ).to eq expected
157
+ end
158
+
159
+ it 'extracts info from BEAKER_PUPPET_AGENT_VERSION' do
160
+ ENV['BEAKER_PUPPET_AGENT_VERSION']= '4.10.5'
161
+ expected = {
162
+ :puppet_install_version => '1.10.5',
163
+ :beaker_puppet_collection => nil,
164
+ :puppet_install_type => 'agent'
165
+ }
166
+ expect( @helper.get_puppet_install_info ).to eq expected
167
+ end
168
+
169
+ it 'extracts info from PUPPET_VERSION' do
170
+ ENV['PUPPET_VERSION']= '4.10.5'
171
+ expected = {
172
+ :puppet_install_version => '1.10.5',
173
+ :beaker_puppet_collection => nil,
174
+ :puppet_install_type => 'agent'
175
+ }
176
+ expect( @helper.get_puppet_install_info ).to eq expected
177
+ end
178
+
179
+ it 'extracts info from BEAKER_PUPPET_COLLECTION' do
180
+ allow(@helper).to receive(:`).with('gem search -ra -e puppet').and_return(gem_search_results)
181
+ ENV['BEAKER_PUPPET_COLLECTION']= 'puppet5'
182
+ expected = {
183
+ :puppet_install_version => '5.5.1',
184
+ :beaker_puppet_collection => 'puppet5',
185
+ :puppet_install_type => 'agent'
186
+ }
187
+ expect( @helper.get_puppet_install_info ).to eq expected
188
+ end
189
+
190
+ it 'extracts info from BEAKER_PUPPET_COLLECTION' do
191
+ allow(@helper).to receive(:`).with('gem search -ra -e puppet').and_return(gem_search_results)
192
+ @helper.host.options = {'puppet_collection' => 'puppet5'}
193
+ expected = {
194
+ :puppet_install_version => '5.5.1',
195
+ :beaker_puppet_collection => 'puppet5',
196
+ :puppet_install_type => 'agent'
197
+ }
198
+ expect( @helper.get_puppet_install_info ).to eq expected
199
+ end
200
+
201
+ it 'extracts info from PUPPET_INSTALL_TYPE' do
202
+ ENV['PUPPET_INSTALL_TYPE'] = 'pe'
203
+ expected = {
204
+ :puppet_install_version => Simp::BeakerHelpers::DEFAULT_PUPPET_AGENT_VERSION,
205
+ :beaker_puppet_collection => nil,
206
+ :puppet_install_type => 'pe'
207
+ }
208
+ expect( @helper.get_puppet_install_info ).to eq expected
209
+ end
210
+
211
+ it 'fails when BEAKER_PUPPET_COLLECTION is invalid' do
212
+ ENV['BEAKER_PUPPET_COLLECTION'] = 'PUPPET5'
213
+ expect{ @helper.get_puppet_install_info }.to raise_error(/Error: Puppet Collection 'PUPPET5' must match/)
214
+ end
215
+
216
+ it 'fails when host options puppet_collection is invalid' do
217
+ @helper.host.options = {'puppet_collection' => 'PUPPET5'}
218
+ expect{ @helper.get_puppet_install_info }.to raise_error(/Error: Puppet Collection 'PUPPET5' must match/)
219
+ end
220
+ end
221
+ end
@@ -0,0 +1,100 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16
+ RSpec.configure do |config|
17
+ # rspec-expectations config goes here. You can use an alternate
18
+ # assertion/expectation library such as wrong or the stdlib/minitest
19
+ # assertions if you prefer.
20
+ config.expect_with :rspec do |expectations|
21
+ # This option will default to `true` in RSpec 4. It makes the `description`
22
+ # and `failure_message` of custom matchers include text for helper methods
23
+ # defined using `chain`, e.g.:
24
+ # be_bigger_than(2).and_smaller_than(4).description
25
+ # # => "be bigger than 2 and smaller than 4"
26
+ # ...rather than:
27
+ # # => "be bigger than 2"
28
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
29
+ end
30
+
31
+ # rspec-mocks config goes here. You can use an alternate test double
32
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
33
+ config.mock_with :rspec do |mocks|
34
+ # Prevents you from mocking or stubbing a method that does not exist on
35
+ # a real object. This is generally recommended, and will default to
36
+ # `true` in RSpec 4.
37
+ mocks.verify_partial_doubles = true
38
+ end
39
+
40
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
41
+ # have no way to turn it off -- the option exists only for backwards
42
+ # compatibility in RSpec 3). It causes shared context metadata to be
43
+ # inherited by the metadata hash of host groups and examples, rather than
44
+ # triggering implicit auto-inclusion in groups with matching metadata.
45
+ config.shared_context_metadata_behavior = :apply_to_host_groups
46
+
47
+ # The settings below are suggested to provide a good initial experience
48
+ # with RSpec, but feel free to customize to your heart's content.
49
+ =begin
50
+ # This allows you to limit a spec run to individual examples or groups
51
+ # you care about by tagging them with `:focus` metadata. When nothing
52
+ # is tagged with `:focus`, all examples get run. RSpec also provides
53
+ # aliases for `it`, `describe`, and `context` that include `:focus`
54
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
55
+ config.filter_run_when_matching :focus
56
+
57
+ # Allows RSpec to persist some state between runs in order to support
58
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
59
+ # you configure your source control system to ignore this file.
60
+ config.example_status_persistence_file_path = "spec/examples.txt"
61
+
62
+ # Limits the available syntax to the non-monkey patched syntax that is
63
+ # recommended. For more details, see:
64
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
65
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
66
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
67
+ config.disable_monkey_patching!
68
+
69
+ # This setting enables warnings. It's recommended, but in some cases may
70
+ # be too noisy due to issues in dependencies.
71
+ config.warnings = true
72
+
73
+ # Many RSpec users commonly either run the entire suite or an individual
74
+ # file, and it's useful to allow more verbose output when running an
75
+ # individual spec file.
76
+ if config.files_to_run.one?
77
+ # Use the documentation formatter for detailed output,
78
+ # unless a formatter has already been configured
79
+ # (e.g. via a command-line flag).
80
+ config.default_formatter = "doc"
81
+ end
82
+
83
+ # Print the 10 slowest examples and example groups at the
84
+ # end of the spec run, to help surface which specs are running
85
+ # particularly slow.
86
+ config.profile_examples = 10
87
+
88
+ # Run specs in random order to surface order dependencies. If you find an
89
+ # order dependency and want to debug it, you can fix the order by providing
90
+ # the seed, which is printed after each run.
91
+ # --seed 1234
92
+ config.order = :random
93
+
94
+ # Seed global randomization in this process using the `--seed` CLI option.
95
+ # Setting this allows you to use `--seed` to deterministically reproduce
96
+ # test failures related to randomization by passing the same `--seed` value
97
+ # as the one that triggered the failure.
98
+ Kernel.srand config.seed
99
+ =end
100
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simp-beaker-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.5
4
+ version: 1.10.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Tessmer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-04-28 00:00:00.000000000 Z
12
+ date: 2018-05-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: beaker
@@ -81,14 +81,19 @@ files:
81
81
  - lib/simp/beaker_helpers/version.rb
82
82
  - lib/simp/rake/beaker.rb
83
83
  - simp-beaker-helpers.gemspec
84
- - spec/acceptance/check_puppet_version_spec.rb
85
- - spec/acceptance/enable_fips_spec.rb
86
- - spec/acceptance/fixture_modules_spec.rb
87
84
  - spec/acceptance/nodesets/default.yml
88
- - spec/acceptance/nodesets/puppet5.yml
89
- - spec/acceptance/pki_tests_spec.rb
90
- - spec/acceptance/set_hieradata_on_spec.rb
91
- - spec/acceptance/write_hieradata_to_spec.rb
85
+ - spec/acceptance/suites/default/check_puppet_version_spec.rb
86
+ - spec/acceptance/suites/default/enable_fips_spec.rb
87
+ - spec/acceptance/suites/default/fixture_modules_spec.rb
88
+ - spec/acceptance/suites/default/nodesets
89
+ - spec/acceptance/suites/default/pki_tests_spec.rb
90
+ - spec/acceptance/suites/default/set_hieradata_on_spec.rb
91
+ - spec/acceptance/suites/default/write_hieradata_to_spec.rb
92
+ - spec/acceptance/suites/puppet_collections/00_default_spec.rb
93
+ - spec/acceptance/suites/puppet_collections/metadata.yml
94
+ - spec/acceptance/suites/puppet_collections/nodesets/default.yml
95
+ - spec/lib/simp/beaker_helpers_spec.rb
96
+ - spec/spec_helper.rb
92
97
  - spec/spec_helper_acceptance.rb
93
98
  homepage: https://github.com/simp/rubygem-simp-beaker-helpers
94
99
  licenses: