simp-beaker-helpers 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MDAxZjY1OTM4ZjRlYjZlM2RjMDNhM2MwNjFkMDgxYTdlYmFlYmZmMw==
5
- data.tar.gz: !binary |-
6
- YTdmN2U2ZTMxMGQ2MTYzZGUzODJjNDAyYTFkZWUwOTBjOWIxNGE4Zg==
2
+ SHA1:
3
+ metadata.gz: 9a867ae9f1b572aab3ab4c9cc5b31a9e36b006d5
4
+ data.tar.gz: 7f057b0c8985000cee0f7a64ca55b44cb6fe6bdb
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZDU4NTI0YTMyMGNhYTVjYTg2ODIyMjEyNzBiMzcwOTAxZDcwMTc3YTM0MWM5
10
- M2U1NWFmYWMzMTUyNjIyOTMwZmZhNzM4MmM4MDM1M2QxNzU3MmNlN2U1YmVi
11
- Mjg4NTliZTY1ZDBmNWYzYTdlMTJmMWI0YmJmNzcxMWM2YzcyYWM=
12
- data.tar.gz: !binary |-
13
- MDdmNmE2YmVmNzk2NjA4ZTg1MjE5NWMzNzViZTZhZGE0MzM1ZmNhYzY4NGNi
14
- YzRhNGM0MzIwYjI3MmVkZDU3ZmYxMWY5NmNlOTQ0YjRmODA3NTA0N2YwMjQz
15
- NmZmMWE0ZWJhZWFjNWEwMjhhYjNmNGRkODNiMzM4ODI1OTJkZjc=
6
+ metadata.gz: 1c6ddedd94aebe0539e7ff54afdd6378f4ebc7523527dd3398f9db95709ed6dbc5fc49c931c9cb84fa049fb3baca6e781b8a1c004fe25f1d3026d1a007709ab0
7
+ data.tar.gz: 7993446042b193c5131100fb9379a394399ecbf3b8ce433d71ad8d7d4f27d91e98e2ca12bd605ceb7e7b3ce212d9c2d1098b591e3010e4bc1a63c86a84b49357
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ Gemfile.lock
5
5
  *.old
6
6
  .vagrant
7
7
  /log
8
+ /spec/fixtures
data/Gemfile CHANGED
@@ -17,6 +17,7 @@ group :system_tests do
17
17
  gem 'pry'
18
18
  gem 'beaker'
19
19
  gem 'beaker-rspec'
20
+ gem 'vagrant-wrapper'
20
21
  # NOTE: Workaround because net-ssh 2.10 is busting beaker
21
22
  # lib/ruby/1.9.1/socket.rb:251:in `tcp': wrong number of arguments (5 for 4) (ArgumentError)
22
23
  gem 'net-ssh', '~> 2.9.0'
data/README.md CHANGED
@@ -6,9 +6,11 @@ Methods to assist beaker acceptance tests for SIMP.
6
6
  1. [Overview](#overview)
7
7
  2. [Setup](#setup)
8
8
  * [Beginning with simp-beaker-helpers](#beginning-with-simp-beaker-helpers)
9
- 3. [Nodeset Enhancements](#nodeset-enhancements)
9
+ 3. [General Enhancements](#general-enhancements)
10
+ * [Suites](#suites)
11
+ 4. [Nodeset Enhancements](#nodeset-enhancements)
10
12
  * [YUM Repo Support](#yum_repo_support)
11
- 4. [Methods](#methods)
13
+ 5. [Methods](#methods)
12
14
  * [`copy_fixture_modules_to`](#copy_fixture_modules_to)
13
15
  * [`fix_errata_on`](#fix_errata_on)
14
16
  * PKI
@@ -21,14 +23,14 @@ Methods to assist beaker acceptance tests for SIMP.
21
23
  * Hiera
22
24
  * [`set_hieradata_on`](#set_hieradata_on)
23
25
  * [`clear_temp_hieradata`](#clear_temp_hieradata)
24
- 5. [Environment variables](#environment-variables)
26
+ 6. [Environment variables](#environment-variables)
25
27
  * [`BEAKER_fips`](#beaker_fips)
26
28
  * [`BEAKER_spec_prep`](#beaker_spec_prep)
27
29
  * [`BEAKER_stringify_facts`](#beaker_stringify_facts)
28
30
  * [`BEAKER_use_fixtures_dir_for_modules`](#beaker_use_fixtures_dir_for_modules)
29
- 6. [Examples](#examples)
31
+ 7. [Examples](#examples)
30
32
  * [Prep OS, Generate and copy PKI certs to each SUT](#prep-os-generate-and-copy-pki-certs-to-each-sut)
31
- 7. [License](#license)
33
+ 8. [License](#license)
32
34
 
33
35
  ## Overview
34
36
 
@@ -47,6 +49,66 @@ Add this to your project's `spec/spec_helper_acceptance.rb`:
47
49
  require 'simp/beaker_helpers'
48
50
  include Simp::BeakerHelpers
49
51
  ```
52
+ ## General Enhancements
53
+
54
+ ### Suites
55
+
56
+ The 'beaker:suites' rake task provides the ability to run isolated test sets
57
+ with a full reset of the Beaker environment.
58
+
59
+ These are entirely isolated runs of Beaker and have been designed to be used
60
+ for situations where you need to eliminate all of the cruft from your previous
61
+ runs to perform a new type of test.
62
+
63
+ #### Suite Execution
64
+
65
+ By default the only suite that will be executed is `default`. Since each suite
66
+ is executed in a new environment, spin up can take a lot of time. Therefore,
67
+ the default is to only run the default suite.
68
+
69
+ If there is a suite where the metadata contains `default_run` set to the
70
+ Boolean `true`, then that suite will be part of the default suite execution.
71
+
72
+ You can run all suites by setting the passed suite name to `ALL` (case
73
+ sensitive).
74
+
75
+ #### Environment Variables
76
+
77
+ * BEAKER_suite_runall
78
+ * Run all Suites
79
+
80
+ * BEAKER_suite_basedir
81
+ * The base directory where suites will be defined
82
+ * Default: spec/acceptance
83
+
84
+ #### Global Suite Configuration
85
+
86
+ A file `config.yml` can be placed in the `suites` directory to control certain
87
+ aspects of the suite run.
88
+
89
+ ##### Supported Config:
90
+
91
+ ```yaml
92
+ ---
93
+ # Fail the entire suite at the first failure
94
+ 'fail_fast' : <true|false> => Default: true
95
+ ```
96
+
97
+ #### Individual Suite Configuration
98
+
99
+ Each suite may contain a YAML file, metadata.yml, which will be used to provide
100
+ information to the suite of tests.
101
+
102
+ ##### Supported Config:
103
+
104
+ ```yaml
105
+ ---
106
+ 'name' : '<User friendly name for the suite>'
107
+
108
+ # Run this suite by default
109
+ 'default_run' : <true|false> => Default: false
110
+ ```
111
+
50
112
  ## Nodeset Enhancements
51
113
 
52
114
  ### YUM Repo Support
@@ -67,10 +129,34 @@ yum_repos:
67
129
 
68
130
  #### `copy_fixture_modules_to`
69
131
 
70
- Copies the local fixture modules (under `spec/fixtures/modules`) onto a list of SUTs
71
- `copy_fixture_modules_to( suts = hosts )`
132
+ Copies the local fixture modules (under `spec/fixtures/modules`) onto a list of
133
+ SUTs.
72
134
 
135
+ ```ruby
136
+ copy_fixture_modules_to( suts = hosts, opts = {} )
137
+ ```
138
+ - **`suts`** = _(Array,String)_ list of SUTs to copy modules to
139
+ - **`opts`** = _(Hash)_ Options passed on to `copy_module_to()` for each SUT
73
140
 
141
+ By default, this will copy modules to the first path listed in each SUT's
142
+ `modulepath` and simulate a pluginsync so the Beaker DSL's `facter_on` will
143
+ still work.
144
+
145
+ If you need to use a non-default module path:
146
+ ```ruby
147
+ # WARNING: this will use the same :target_module_dir for each SUT
148
+ copy_fixture_modules_to( hosts, {
149
+ :target_module_dir => '/path/to/my/modules',
150
+ })
151
+ ```
152
+
153
+ If you want to disable pluginsync:
154
+ ```ruby
155
+ # WARNING: `fact_on` will not see custom facts
156
+ copy_fixture_modules_to( hosts, {
157
+ :pluginsync => false
158
+ })
159
+ ```
74
160
 
75
161
  #### `fix_errata_on`
76
162
 
@@ -88,13 +174,13 @@ SUT will have the appropriate openssl in its environment.
88
174
 
89
175
  `run_fake_pki_ca_on( ca_sut = master, suts = hosts, local_dir = '' )`
90
176
 
91
- - **ca_sut** = the SUT to generate the CA & certs on
92
- - **suts** = list of SUTs to generate certs for
93
- - **local_dir** = local path where the CA+cert directory tree should copied back to
177
+ - **`ca_sut`** = the SUT to generate the CA & certs on
178
+ - **`suts`** = list of SUTs to generate certs for
179
+ - **`local_dir`** = local path where the CA+cert directory tree should copied back to
94
180
 
95
181
  #### `copy_pki_to`
96
182
 
97
- Copy a single SUT's PKI certs (with cacerts) onto an SUT. This simulates the result of `pki::copy` without requiring a full master and `simp-pki` module.
183
+ Copy a single SUT's PKI certs (with cacerts) onto the SUT. This simulates the result of `pki::copy` without requiring a full master and `simp-pki` module.
98
184
 
99
185
  The directory structure copied to the SUT is:
100
186
  ```
@@ -111,7 +197,7 @@ The directory structure copied to the SUT is:
111
197
 
112
198
  #### `copy_keydist_to`
113
199
 
114
- Copy a CA keydist/ directory of CA+host certs into an SUT
200
+ Copy a CA keydist/ directory of CA+host certs into an SUT.
115
201
 
116
202
  This simulates the output of FakeCA's `gencerts_nopass.sh` into `keydist/` and is useful for constructing a Puppet master SUT that will distribute PKI keys via agent runs.
117
203
 
@@ -120,14 +206,14 @@ This simulates the output of FakeCA's `gencerts_nopass.sh` into `keydist/` and i
120
206
 
121
207
  #### `pfact_on`
122
208
 
123
- Look up a face on a given SUT's using the `puppet fact` face. This honors whatever facter-related settings the SUT's Puppet has been configured to use (i.e., `factpath`, `stringify_facts`, etc).
209
+ Look up a fact on a given SUT using the `puppet fact` face. This honors whatever facter-related settings the SUT's Puppet installation has been configured to use (i.e., `factpath`, `stringify_facts`, etc).
124
210
 
125
211
  `pfact_on( sut, fact_name )`
126
212
 
127
213
 
128
214
  #### `pluginsync_on`
129
215
 
130
- Simulates a custom fact pluginsync on given SUTs
216
+ Simulates a `pluginsync` (useful for deploying custom facts) on given SUTs.
131
217
 
132
218
  `pluginsync_on( suts = hosts )`
133
219
 
@@ -140,9 +226,9 @@ Set the hiera data file on the provided host to the passed data structure
140
226
 
141
227
  `set_hieradata_on(host, hieradata, data_file='default')`
142
228
 
143
- - **host** = _(Array,String,Symbol)_ One or more hosts to act upon
144
- - **hieradata** = _(Hash)_ The full hiera data structure to write to the system
145
- - **data_file** = _(String)_ The filename (not path) of the hiera data
229
+ - **`host`** = _(Array,String,Symbol)_ One or more hosts to act upon
230
+ - **`hieradata`** = _(Hash)_ The full hiera data structure to write to the system
231
+ - **`data_file`** = _(String)_ The filename (not path) of the hiera data
146
232
 
147
233
  #### `clear_temp_hieradata`
148
234
 
@@ -154,11 +240,19 @@ Clean up all temporary hiera data files; meant to be called from `after(:all)`
154
240
  ## Environment variables
155
241
  #### `BEAKER_fips`
156
242
 
157
- SIMP acceptance tests 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 by default. Acceptance tests can be run without FIPS mode when `BEAKER_fips` is set to `no`
243
+ _(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.
158
244
 
159
- **NOTE:** FIPS mode is only enabled on RedHat family hosts
245
+ **NOTE:** FIPS mode is only enabled on RedHat family hosts.
160
246
 
161
247
  #### `BEAKER_spec_prep`
248
+
249
+ _(Default: `yes`)_ Ensures that each fixture module is present under
250
+ `spec/fixtures/modules`. If any fixture modules are missing, it will run `rake
251
+ spec_prep` to populate the missing modules using `.fixtures.yml`. Note that
252
+ this will _not_ update modules that are already present under
253
+ `spec/fixtures/modules`.
254
+
255
+
162
256
  #### `BEAKER_stringify_facts`
163
257
  #### `BEAKER_use_fixtures_dir_for_modules`
164
258
 
@@ -1,7 +1,7 @@
1
1
  module Simp; end
2
2
 
3
3
  module Simp::BeakerHelpers
4
- VERSION = '1.3.0'
4
+ VERSION = '1.4.0'
5
5
 
6
6
  # use the `puppet fact` face to look up facts on an SUT
7
7
  def pfact_on(sut, fact_name)
@@ -71,19 +71,42 @@ module Simp::BeakerHelpers
71
71
 
72
72
 
73
73
  # Copy the local fixture modules (under `spec/fixtures/modules`) onto each SUT
74
- def copy_fixture_modules_to( suts = hosts, pluginsync = true )
75
- STDERR.puts ' ** copy_fixture_modules_to' if ENV['BEAKER_helpers_verbose']
74
+ def copy_fixture_modules_to( suts = hosts, opts = {})
76
75
  ensure_fixture_modules
77
76
 
77
+ opts[:pluginsync] = opts.fetch(:pluginsync, true)
78
+
78
79
  unless ENV['BEAKER_copy_fixtures'] == 'no'
79
- suts.each do |sut|
80
+ Array(suts).each do |sut|
80
81
  STDERR.puts " ** copy_fixture_modules_to: '#{sut}'" if ENV['BEAKER_helpers_verbose']
81
- # allow spec_prep to provide modules (to support isolated networks)
82
+
83
+ # Use spec_prep to provide modules (this supports isolated networks)
82
84
  unless ENV['BEAKER_use_fixtures_dir_for_modules'] == 'no'
85
+
86
+ # NOTE: As a result of BKR-723, which does not look easy to fix, we
87
+ # cannot rely on `copy_module_to()` to choose a sane default for
88
+ # `target_module_path`. This workaround queries each SUT's
89
+ # `modulepath` and targets the first one.
90
+ target_module_path = on(
91
+ sut, 'puppet config print modulepath --environment production'
92
+ ).output.chomp.split(':').first
93
+
94
+
83
95
  pupmods_in_fixtures_yml.each do |pupmod|
84
96
  STDERR.puts " ** copy_fixture_modules_to: '#{sut}': '#{pupmod}'" if ENV['BEAKER_helpers_verbose']
85
97
  mod_root = File.expand_path( "spec/fixtures/modules/#{pupmod}", File.dirname( fixtures_yml_path ))
86
- copy_module_to( sut, {:source => mod_root, :module_name => pupmod} )
98
+ # These options can be overridden by `opt`
99
+ _opts = {
100
+ :target_module_path => target_module_path,
101
+ }.merge(opts)
102
+
103
+ # These options always override `opt`
104
+ _opts = _opts.merge({
105
+ :source => mod_root,
106
+ :module_name => pupmod,
107
+ })
108
+
109
+ copy_module_to( sut, _opts )
87
110
  end
88
111
  end
89
112
  end
@@ -91,7 +114,7 @@ module Simp::BeakerHelpers
91
114
  STDERR.puts ' ** copy_fixture_modules_to: finished' if ENV['BEAKER_helpers_verbose']
92
115
 
93
116
  # sync custom facts from the new modules to each SUT's factpath
94
- pluginsync_on(suts) if pluginsync
117
+ pluginsync_on(suts) if opts[:pluginsync]
95
118
  end
96
119
 
97
120
 
@@ -213,7 +236,7 @@ DEFAULT_KERNEL_TITLE=`/sbin/grubby --info=\\\${DEFAULT_KERNEL_INFO} | grep -m1 t
213
236
  end
214
237
 
215
238
  # Configure and reboot SUTs into FIPS mode
216
- unless ENV['BEAKER_fips'] == 'no'
239
+ if ENV['BEAKER_fips'] == 'yes'
217
240
  enable_fips_mode_on(suts)
218
241
  end
219
242
  end
@@ -393,7 +416,9 @@ done
393
416
 
394
417
  # pluginsync custom facts for all modules
395
418
  def pluginsync_on( suts = hosts )
419
+ puts "== pluginsync_on'" if ENV['BEAKER_helpers_verbose']
396
420
  suts.each do |sut|
421
+ puts " ** pluginsync_on: '#{sut}'" if ENV['BEAKER_helpers_verbose']
397
422
  fact_path = on(sut, %q(puppet config print factpath)).output.strip.split(':').first
398
423
  on(sut, %q(puppet config print modulepath)).output.strip.split(':').each do |mod_path|
399
424
  on(sut, %Q(mkdir -p #{fact_path}))
@@ -1,6 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
3
3
  require 'simp/beaker_helpers.rb'
4
+ require 'date'
4
5
 
5
6
  Gem::Specification.new do |s|
6
7
  s.name = 'simp-beaker-helpers'
@@ -0,0 +1,29 @@
1
+ require 'spec_helper_acceptance'
2
+
3
+ context 'after copy_fixture_modules_to( hosts )' do
4
+ before(:all) do
5
+ # This should automatically run pluginsync_on hosts
6
+ copy_fixture_modules_to( hosts )
7
+ end
8
+
9
+ describe "fact_on(master,'root_home')" do
10
+ it 'should not return value of `root_home`' do
11
+ puts fact = fact_on(master, 'root_home')
12
+ expect( fact ).to eq ''
13
+ end
14
+ end
15
+
16
+ describe "fact_on(master,'root_home', {:puppet => nil})" do
17
+ it 'should return value of `root_home`' do
18
+ puts fact = fact_on(master, 'root_home', {:puppet => nil} )
19
+ expect( fact ).to eq '/root'
20
+ end
21
+ end
22
+
23
+ describe "pfact_on(master,'root_home')" do
24
+ it 'should return value of `root_home`' do
25
+ puts fact = pfact_on(master, 'root_home')
26
+ expect( fact ).to eq '/root'
27
+ end
28
+ end
29
+ 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.3.0
4
+ version: 1.4.0
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: 2016-04-15 00:00:00.000000000 Z
12
+ date: 2016-05-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: beaker
@@ -25,9 +25,8 @@ dependencies:
25
25
  - - ~>
26
26
  - !ruby/object:Gem::Version
27
27
  version: '2'
28
- description: ! ' Beaker helper methods to help scaffold SIMP acceptance tests
29
-
30
- '
28
+ description: |2
29
+ Beaker helper methods to help scaffold SIMP acceptance tests
31
30
  email: simp@simp-project.org
32
31
  executables: []
33
32
  extensions: []
@@ -48,11 +47,11 @@ files:
48
47
  - lib/simp/beaker_helpers.rb
49
48
  - lib/simp/rake/beaker.rb
50
49
  - simp-beaker-helpers.gemspec
50
+ - spec/acceptance/fixture_modules_spec.rb
51
51
  - spec/acceptance/nodesets/centos-66-x64.yml
52
52
  - spec/acceptance/nodesets/centos-7-x64.yml
53
53
  - spec/acceptance/nodesets/centos-combined-x64.yaml
54
54
  - spec/acceptance/nodesets/default.yml
55
- - spec/acceptance/pfacter_spec.rb
56
55
  - spec/acceptance/pki_tests_spec.rb
57
56
  - spec/spec_helper_acceptance.rb
58
57
  homepage: https://github.com/simp/rubygem-simp-beaker-helpers
@@ -66,12 +65,12 @@ require_paths:
66
65
  - lib
67
66
  required_ruby_version: !ruby/object:Gem::Requirement
68
67
  requirements:
69
- - - ! '>='
68
+ - - '>='
70
69
  - !ruby/object:Gem::Version
71
70
  version: '0'
72
71
  required_rubygems_version: !ruby/object:Gem::Requirement
73
72
  requirements:
74
- - - ! '>='
73
+ - - '>='
75
74
  - !ruby/object:Gem::Version
76
75
  version: '0'
77
76
  requirements: []
@@ -81,10 +80,11 @@ signing_key:
81
80
  specification_version: 4
82
81
  summary: beaker helper methods for SIMP
83
82
  test_files:
83
+ - spec/acceptance/fixture_modules_spec.rb
84
84
  - spec/acceptance/nodesets/centos-66-x64.yml
85
85
  - spec/acceptance/nodesets/centos-7-x64.yml
86
86
  - spec/acceptance/nodesets/centos-combined-x64.yaml
87
87
  - spec/acceptance/nodesets/default.yml
88
- - spec/acceptance/pfacter_spec.rb
89
88
  - spec/acceptance/pki_tests_spec.rb
90
89
  - spec/spec_helper_acceptance.rb
90
+ has_rdoc:
@@ -1,14 +0,0 @@
1
- require 'spec_helper_acceptance'
2
-
3
- context 'pfact_on operations' do
4
- before(:all) do
5
- copy_fixture_modules_to( hosts )
6
- pluginsync_on( [master] )
7
- end
8
-
9
- describe "pfact_on(master,'root_home')" do
10
- it 'should return value of root_home' do
11
- expect( pfact_on(master, 'root_home')).to_not be_nil
12
- end
13
- end
14
- end