simp-beaker-helpers 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjliNTUyNTQzNzFkNjZkYWZlNjU2YTA3OGFjMWUyZGU3NWFiZGQ2Yw==
4
+ MDAxZjY1OTM4ZjRlYjZlM2RjMDNhM2MwNjFkMDgxYTdlYmFlYmZmMw==
5
5
  data.tar.gz: !binary |-
6
- N2VlYzNjMGM3ZDMwZTk5Y2ZiOWE1OWJkODUyMzA1ODJmZjVlNDQwNw==
6
+ YTdmN2U2ZTMxMGQ2MTYzZGUzODJjNDAyYTFkZWUwOTBjOWIxNGE4Zg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzU0ZjJmZTNlNmIwNzNlYzE4ZGE3YmFmZDc5MDUzMjIyMzE5M2JmNGUxMjJm
10
- Zjc3MzU3NDhmZWYzYTJjMjA5ODc4MDJhYjUwYzAyMTA0NTNmOTYwM2IwYWQy
11
- NzM4NWJmMjZjZTRmOWZmYzgwMDFjNzllOGVkOTA5ZjY4MTEwZDg=
9
+ ZDU4NTI0YTMyMGNhYTVjYTg2ODIyMjEyNzBiMzcwOTAxZDcwMTc3YTM0MWM5
10
+ M2U1NWFmYWMzMTUyNjIyOTMwZmZhNzM4MmM4MDM1M2QxNzU3MmNlN2U1YmVi
11
+ Mjg4NTliZTY1ZDBmNWYzYTdlMTJmMWI0YmJmNzcxMWM2YzcyYWM=
12
12
  data.tar.gz: !binary |-
13
- OTc5YTI3YjBmYTI4NjU5ODcxN2FlYTE5Y2Y2NGU2NjlhMzg2NTk0NWQ1NDRl
14
- NTdmZmMzYjFiMjNiYmI2OTExZmE1ZTQ0Mjg2ZDIxYTdmZWVhZDBjYzMzMjUw
15
- NDc5ZWJiYjEyN2M4NjA1NzM3OTA2Y2U4ZTRmNjI0YTM5ZjA1YTE=
13
+ MDdmNmE2YmVmNzk2NjA4ZTg1MjE5NWMzNzViZTZhZGE0MzM1ZmNhYzY4NGNi
14
+ YzRhNGM0MzIwYjI3MmVkZDU3ZmYxMWY5NmNlOTQ0YjRmODA3NTA0N2YwMjQz
15
+ NmZmMWE0ZWJhZWFjNWEwMjhhYjNmNGRkODNiMzM4ODI1OTJkZjc=
@@ -1,7 +1,7 @@
1
1
  module Simp; end
2
2
 
3
3
  module Simp::BeakerHelpers
4
- VERSION = '1.2.1'
4
+ VERSION = '1.3.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)
@@ -21,8 +21,8 @@ module Simp::Rake
21
21
 
22
22
  namespace :beaker do
23
23
  desc <<-EOM
24
- Run a Beaker test against a specific Nodeset
25
- * :nodeset - The nodeset against which you wish to run
24
+ Run a Beaker test against a specific Nodeset
25
+ * :nodeset - The nodeset against which you wish to run
26
26
  EOM
27
27
  task :run, [:nodeset] do |t,args|
28
28
  fail "You must pass :nodeset to #{t}" unless args[:nodeset]
@@ -44,6 +44,178 @@ module Simp::Rake
44
44
 
45
45
  Rake::Task['beaker'].invoke
46
46
  end
47
+
48
+ desc <<-EOM
49
+ Run Beaker test suites.
50
+ * :suite - A specific suite to run
51
+ * If you set this to `ALL`, all suites will be run
52
+
53
+ * :nodeset - A specific nodeset to run on within a specific suite
54
+
55
+ ## Suite Execution
56
+
57
+ By default the only suite that will be executed is `default`.
58
+ Since each suite is executed in a new environment, spin up can
59
+ take a lot of time. Therefore, the default is to only run the
60
+ default suite.
61
+
62
+ If there is a suite where the metadata contains `default_run` set
63
+ to the Boolean `true`, then that suite will be part of the
64
+ default suite execution.
65
+
66
+ You can run all suites by setting the passed suite name to `ALL`
67
+ (case sensitive).
68
+
69
+ ## Environment Variables
70
+
71
+ * BEAKER_suite_runall
72
+ * Run all Suites
73
+
74
+ * BEAKER_suite_basedir
75
+ * The base directory where suites will be defined
76
+ * Default: spec/acceptance
77
+
78
+ ## Global Suite Configuration
79
+ A file `config.yml` can be placed in the `suites` directory to
80
+ control certain aspects of the suite run.
81
+
82
+ ### Supported Config:
83
+
84
+ ```yaml
85
+ ---
86
+ # Fail the entire suite at the first failure
87
+ 'fail_fast' : <true|false> => Default: true
88
+ ```
89
+ ## Individual Suite Configuration
90
+
91
+ Each suite may contain a YAML file, metadata.yml, which will be
92
+ used to provide information to the suite of tests.
93
+
94
+ ### Supported Config:
95
+
96
+ ```yaml
97
+ ---
98
+ 'name' : '<User friendly name for the suite>'
99
+
100
+ # Run this suite by default
101
+ 'default_run' : <true|false> => Default: false
102
+ ```
103
+ EOM
104
+ task :suites, [:suite, :nodeset] do |t,args|
105
+ suite = args[:suite]
106
+ nodeset = args[:nodeset]
107
+
108
+ # Record Tasks That Fail
109
+ # Need to figure out how to capture the errors
110
+ failures = Hash.new
111
+
112
+ suite_basedir = 'spec/acceptance/suites'
113
+ if ENV['BEAKER_suite_basedir']
114
+ suite_basedir = ENV['BEAKER_suite_basedir']
115
+ end
116
+
117
+ raise("Error: Suites Directory at '#{suite_basedir}'!") unless File.directory?(suite_basedir)
118
+
119
+ suite_config = {
120
+ 'fail_fast' => true
121
+ }
122
+ suite_config_metadata_path = File.join(suite_basedir, 'config.yml')
123
+ if File.file?(suite_config_metadata_path)
124
+ suite_config.merge!(YAML.load_file(suite_config_metadata_path))
125
+ end
126
+
127
+ suites = Hash.new
128
+ if suite
129
+ suites[suite] = Hash.new
130
+ else
131
+ Dir.glob(File.join(suite_basedir,'*')) do |file|
132
+ if File.directory?(file)
133
+ suites[File.basename(file)] = Hash.new
134
+ end
135
+ end
136
+ end
137
+
138
+ suites.keys.each do |ste|
139
+ suites[ste]['name'] = ste
140
+ suites[ste]['path'] = File.join(suite_basedir, ste)
141
+
142
+ metadata_path = File.join(suites[ste]['path'], 'metadata.yml')
143
+ if File.file?(metadata_path)
144
+ suites[ste]['metadata'] = YAML.load_file(metadata_path)
145
+ end
146
+
147
+ unless File.directory?(File.join(suites[ste]['path'],'nodesets'))
148
+ Dir.chdir(suites[ste]['path']) do
149
+ if File.directory?('../../nodesets')
150
+ FileUtils.ln_s('../../nodesets', 'nodesets')
151
+ end
152
+ end
153
+ end
154
+
155
+ suites[ste].merge!(suites[ste]['metadata']) if suites[ste]['metadata']
156
+
157
+ # Ensure that the 'default' suite runs unless explicitly disabled.
158
+ if suites['default']
159
+ if ( suites['default']['default_run'].nil? ) || ( suites['default']['default_run'] == true )
160
+ suites['default']['default_run'] = true
161
+ end
162
+ end
163
+ end
164
+
165
+ raise("Error: No Suites Found in '#{suite_basedir}'!") if suites.empty?
166
+
167
+ # Need to ensure that 'default' is first
168
+ ordered_suites = suites.keys.sort
169
+ default_suite = ordered_suites.delete('default')
170
+ ordered_suites.unshift(default_suite) if default_suite
171
+
172
+ ordered_suites.each do |ste|
173
+
174
+ next unless (suites[ste]['default_run'] == true)
175
+
176
+ name = suites[ste]['name']
177
+
178
+ $stdout.puts("\n\n=== Suite '#{name}' Starting ===\n\n")
179
+
180
+ if nodeset
181
+ unless File.file?(File.join(suites[ste]['path'],"#{nodeset}.yml"))
182
+ $stdout.puts("=== Suite #{name} Nodeset '#{nodeset}' Not Found, Skipping ===")
183
+ next
184
+ end
185
+
186
+ ENV['BEAKER_set'] = nodeset
187
+ end
188
+
189
+ Rake::Task[:beaker].clear
190
+ RSpec::Core::RakeTask.new(:beaker) do |tsk|
191
+ tsk.rspec_opts = ['--color']
192
+ tsk.pattern = File.join(suites[ste]['path'])
193
+ end
194
+
195
+ current_suite_task = Rake::Task[:beaker]
196
+
197
+ if suite_config['fail_fast'] == true
198
+ current_suite_task.execute
199
+ else
200
+ begin
201
+ current_suite_task.execute
202
+ rescue SystemExit
203
+ failures[suites[ste]['name']] = {
204
+ 'path' => suites[ste]['path']
205
+ }
206
+ end
207
+ end
208
+
209
+ $stdout.puts("\n\n=== Suite '#{name}' Complete ===\n\n")
210
+ end
211
+
212
+ unless failures.keys.empty?
213
+ $stdout.puts("The following tests had failures:")
214
+ failures.keys.sort.each do |ste|
215
+ $stdout.puts(" * #{ste} => #{failures[ste]['path']}")
216
+ end
217
+ end
218
+ end
47
219
  end
48
220
  end
49
221
  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.2.1
4
+ version: 1.3.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-03-24 00:00:00.000000000 Z
12
+ date: 2016-04-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: beaker