puppet_litmus 0.36.2 → 1.0.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/matrix_from_metadata +8 -12
- data/exe/matrix_from_metadata_v2 +5 -7
- data/lib/puppet_litmus/inventory_manipulation.rb +16 -26
- data/lib/puppet_litmus/puppet_helpers.rb +13 -15
- data/lib/puppet_litmus/rake_helper.rb +23 -25
- data/lib/puppet_litmus/rake_tasks.rb +14 -16
- data/lib/puppet_litmus/spec_helper_acceptance.rb +7 -7
- data/lib/puppet_litmus/version.rb +1 -1
- data/spec/exe/matrix_from_metadata_v2_spec.rb +3 -3
- data/spec/lib/puppet_litmus/inventory_manipulation_spec.rb +4 -6
- data/spec/lib/puppet_litmus/puppet_helpers_spec.rb +13 -11
- data/spec/lib/puppet_litmus/puppet_litmus_version_spec.rb +2 -2
- data/spec/lib/puppet_litmus/rake_helper_spec.rb +6 -6
- data/spec/lib/puppet_litmus/rake_tasks_spec.rb +9 -6
- data/spec/lib/puppet_litmus/util_spec.rb +4 -4
- data/spec/spec_helper.rb +2 -2
- data/spec/support/inventory.rb +11 -11
- metadata +43 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 663e4fef74a9dc41409ef796755b930f4d2951c8afe4c5e7654d7369c5cb2d16
|
4
|
+
data.tar.gz: 12fac1890879d8eed9556a99d1ad171cda4706a20d62f4b4b2794fd5799b5dea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d375cecaf9dcb122868fc6446c32273593ca778c54eaf072a83a647616936dff6547fdffa3e6011944f7a4ce421c827100b579165a1e3a1c0ac01ea642715b88
|
7
|
+
data.tar.gz: e593d344216b5e9c7bc26af7b792446c73c64721230626e86e0da82df80b9fb9f2060bf76e701484e2df2ef48aef5a859f366df33aca07545a5ded3ed396b5bb
|
data/exe/matrix_from_metadata
CHANGED
@@ -31,7 +31,7 @@ IMAGE_TABLE = {
|
|
31
31
|
'SLES-15' => 'sles-15',
|
32
32
|
'Windows-2012 R2' => 'windows-2012-r2-core',
|
33
33
|
'Windows-2016' => 'windows-2016',
|
34
|
-
'Windows-2019' => 'windows-2019-core'
|
34
|
+
'Windows-2019' => 'windows-2019-core'
|
35
35
|
}.freeze
|
36
36
|
|
37
37
|
DOCKER_PLATFORMS = [
|
@@ -48,26 +48,26 @@ DOCKER_PLATFORMS = [
|
|
48
48
|
'Ubuntu-14.04',
|
49
49
|
'Ubuntu-16.04',
|
50
50
|
'Ubuntu-18.04',
|
51
|
-
'Ubuntu-20.04'
|
51
|
+
'Ubuntu-20.04'
|
52
52
|
].freeze
|
53
53
|
|
54
54
|
# This table uses the latest version in each collection for accurate
|
55
55
|
# comparison when evaluating puppet requirements from the metadata
|
56
56
|
COLLECTION_TABLE = {
|
57
57
|
'6.21.0' => 'puppet6-nightly',
|
58
|
-
'7.4.0' => 'puppet7-nightly'
|
58
|
+
'7.4.0' => 'puppet7-nightly'
|
59
59
|
}.freeze
|
60
60
|
|
61
61
|
matrix = {
|
62
62
|
platform: [],
|
63
|
-
collection: []
|
63
|
+
collection: []
|
64
64
|
}
|
65
65
|
|
66
66
|
metadata = JSON.parse(File.read('metadata.json'))
|
67
67
|
# Set platforms based on declared operating system support
|
68
68
|
metadata['operatingsystem_support'].sort_by { |a| a['operatingsystem'] }.each do |sup|
|
69
69
|
os = sup['operatingsystem']
|
70
|
-
sup['operatingsystemrelease'].sort_by
|
70
|
+
sup['operatingsystemrelease'].sort_by(&:to_i).each do |ver|
|
71
71
|
image_key = "#{os}-#{ver}"
|
72
72
|
if IMAGE_TABLE.key? image_key
|
73
73
|
matrix[:platform] << IMAGE_TABLE[image_key]
|
@@ -84,7 +84,7 @@ if metadata.key?('requirements') && metadata['requirements'].length.positive?
|
|
84
84
|
metadata['requirements'].each do |req|
|
85
85
|
next unless req.key?('name') && req.key?('version_requirement') && req['name'] == 'puppet'
|
86
86
|
|
87
|
-
ver_regexp =
|
87
|
+
ver_regexp = /^([>=<]{1,2})\s*([\d.]+)\s+([>=<]{1,2})\s*([\d.]+)$/
|
88
88
|
match = ver_regexp.match(req['version_requirement'])
|
89
89
|
if match.nil?
|
90
90
|
puts "::warning::Didn't recognize version_requirement '#{req['version_requirement']}'"
|
@@ -95,17 +95,13 @@ if metadata.key?('requirements') && metadata['requirements'].length.positive?
|
|
95
95
|
reqs = ["#{cmp_one} #{ver_one}", "#{cmp_two} #{ver_two}"]
|
96
96
|
|
97
97
|
COLLECTION_TABLE.each do |key, val|
|
98
|
-
if Gem::Requirement.create(reqs).satisfied_by?(Gem::Version.new(key))
|
99
|
-
matrix[:collection] << val
|
100
|
-
end
|
98
|
+
matrix[:collection] << val if Gem::Requirement.create(reqs).satisfied_by?(Gem::Version.new(key))
|
101
99
|
end
|
102
100
|
end
|
103
101
|
end
|
104
102
|
|
105
103
|
# Set to defaults (all collections) if no matches are found
|
106
|
-
if matrix[:collection].empty?
|
107
|
-
matrix[:collection] = COLLECTION_TABLE.values
|
108
|
-
end
|
104
|
+
matrix[:collection] = COLLECTION_TABLE.values if matrix[:collection].empty?
|
109
105
|
|
110
106
|
# Just to make sure there aren't any duplicates
|
111
107
|
matrix[:platform] = matrix[:platform].uniq.sort
|
data/exe/matrix_from_metadata_v2
CHANGED
@@ -142,13 +142,11 @@ if metadata.key?('requirements') && metadata['requirements'].length.positive?
|
|
142
142
|
next unless Gem::Requirement.create(reqs).satisfied_by?(Gem::Version.new("#{collection[:puppet_maj_version]}.9999"))
|
143
143
|
|
144
144
|
matrix[:collection] << "puppet#{collection[:puppet_maj_version]}-nightly"
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
}
|
151
|
-
spec_matrix[:include] << { puppet_version: include_version[collection[:puppet_maj_version]], ruby_version: collection[:ruby_version] }
|
145
|
+
spec_matrix[:include] << if collection[:puppet_maj_version] == 8
|
146
|
+
{ puppet_version: 'https://github.com/puppetlabs/puppet', ruby_version: collection[:ruby_version] }
|
147
|
+
else
|
148
|
+
{ puppet_version: "~> #{collection[:puppet_maj_version]}.0", ruby_version: collection[:ruby_version] }
|
149
|
+
end
|
152
150
|
end
|
153
151
|
end
|
154
152
|
end
|
@@ -32,11 +32,11 @@ module PuppetLitmus::InventoryManipulation
|
|
32
32
|
{
|
33
33
|
'uri' => 'litmus_localhost',
|
34
34
|
'config' => { 'transport' => 'local' },
|
35
|
-
'feature' => 'puppet-agent'
|
36
|
-
}
|
37
|
-
]
|
38
|
-
}
|
39
|
-
]
|
35
|
+
'feature' => 'puppet-agent'
|
36
|
+
}
|
37
|
+
]
|
38
|
+
}
|
39
|
+
]
|
40
40
|
}
|
41
41
|
end
|
42
42
|
|
@@ -47,7 +47,7 @@ module PuppetLitmus::InventoryManipulation
|
|
47
47
|
# @return [Array] array of targets.
|
48
48
|
def find_targets(inventory_hash, targets)
|
49
49
|
if targets.nil?
|
50
|
-
inventory_hash.to_s.scan(
|
50
|
+
inventory_hash.to_s.scan(/uri"=>"(\S*)"/).flatten
|
51
51
|
else
|
52
52
|
[targets]
|
53
53
|
end
|
@@ -62,7 +62,7 @@ module PuppetLitmus::InventoryManipulation
|
|
62
62
|
def groups_in_inventory(inventory_hash, &block)
|
63
63
|
inventory_hash['groups'].flat_map do |group|
|
64
64
|
output_collector = []
|
65
|
-
output_collector << if
|
65
|
+
output_collector << if block
|
66
66
|
yield group
|
67
67
|
else
|
68
68
|
group['name'].downcase
|
@@ -104,7 +104,7 @@ module PuppetLitmus::InventoryManipulation
|
|
104
104
|
targets_in_inventory(inventory) do |target|
|
105
105
|
vars = target['vars']
|
106
106
|
roles = [(vars['role'] || vars['roles'])].flatten
|
107
|
-
roles = roles.map
|
107
|
+
roles = roles.map(&:downcase)
|
108
108
|
output_collector << target['uri'] if roles.include? role.downcase
|
109
109
|
end
|
110
110
|
output_collector unless output_collector.empty?
|
@@ -166,7 +166,7 @@ module PuppetLitmus::InventoryManipulation
|
|
166
166
|
# @return [Hash] config for node of name node_name
|
167
167
|
def config_from_node(inventory_hash, node_name)
|
168
168
|
config = targets_in_inventory(inventory_hash) do |target|
|
169
|
-
next unless target['uri'].
|
169
|
+
next unless target['uri'].casecmp(node_name).zero?
|
170
170
|
|
171
171
|
return target['config'] unless target['config'].nil?
|
172
172
|
end
|
@@ -181,7 +181,7 @@ module PuppetLitmus::InventoryManipulation
|
|
181
181
|
# @return [Hash] facts for node of name node_name
|
182
182
|
def facts_from_node(inventory_hash, node_name)
|
183
183
|
facts = targets_in_inventory(inventory_hash) do |target|
|
184
|
-
next unless target['uri'].
|
184
|
+
next unless target['uri'].casecmp(node_name).zero?
|
185
185
|
|
186
186
|
target['facts'] unless target['facts'].nil?
|
187
187
|
end
|
@@ -196,7 +196,7 @@ module PuppetLitmus::InventoryManipulation
|
|
196
196
|
# @return [Hash] vars for node of name node_name
|
197
197
|
def vars_from_node(inventory_hash, node_name)
|
198
198
|
vars = targets_in_inventory(inventory_hash) do |target|
|
199
|
-
next unless target['uri'].
|
199
|
+
next unless target['uri'].casecmp(node_name).zero?
|
200
200
|
|
201
201
|
target['vars'] unless target['vars'].nil?
|
202
202
|
end
|
@@ -213,9 +213,7 @@ module PuppetLitmus::InventoryManipulation
|
|
213
213
|
# check if group exists
|
214
214
|
if inventory_hash['groups'].any? { |g| g['name'] == group_name }
|
215
215
|
inventory_hash['groups'].each do |group|
|
216
|
-
if group['name'] == group_name
|
217
|
-
group['targets'].push node
|
218
|
-
end
|
216
|
+
group['targets'].push node if group['name'] == group_name
|
219
217
|
end
|
220
218
|
else
|
221
219
|
# add new group
|
@@ -248,9 +246,7 @@ module PuppetLitmus::InventoryManipulation
|
|
248
246
|
i = 0
|
249
247
|
inventory_hash['groups'].each do |group|
|
250
248
|
if group['name'] == group_name
|
251
|
-
if group['features'].nil? == true
|
252
|
-
group = group.merge('features' => [])
|
253
|
-
end
|
249
|
+
group = group.merge('features' => []) if group['features'].nil? == true
|
254
250
|
group['features'].push feature_name unless group['features'].include?(feature_name)
|
255
251
|
inventory_hash['groups'][i] = group
|
256
252
|
end
|
@@ -268,9 +264,7 @@ module PuppetLitmus::InventoryManipulation
|
|
268
264
|
# @return [Hash] inventory_hash with feature added to group if group_name exists in inventory hash.
|
269
265
|
def remove_feature_from_group(inventory_hash, feature_name, group_name)
|
270
266
|
inventory_hash['groups'].each do |group|
|
271
|
-
if group['name'] == group_name && group['features'].nil? != true
|
272
|
-
group['features'].delete(feature_name)
|
273
|
-
end
|
267
|
+
group['features'].delete(feature_name) if group['name'] == group_name && group['features'].nil? != true
|
274
268
|
end
|
275
269
|
inventory_hash
|
276
270
|
end
|
@@ -288,9 +282,7 @@ module PuppetLitmus::InventoryManipulation
|
|
288
282
|
node_index = 0
|
289
283
|
group['targets'].each do |node|
|
290
284
|
if node['uri'] == node_name
|
291
|
-
if node['features'].nil? == true
|
292
|
-
node = node.merge('features' => [])
|
293
|
-
end
|
285
|
+
node = node.merge('features' => []) if node['features'].nil? == true
|
294
286
|
node['features'].push feature_name unless node['features'].include?(feature_name)
|
295
287
|
inventory_hash['groups'][group_index]['targets'][node_index] = node
|
296
288
|
end
|
@@ -311,9 +303,7 @@ module PuppetLitmus::InventoryManipulation
|
|
311
303
|
def remove_feature_from_node(inventory_hash, feature_name, node_name)
|
312
304
|
inventory_hash['groups'].each do |group|
|
313
305
|
group['targets'].each do |node|
|
314
|
-
if node['uri'] == node_name && node['features'].nil? != true
|
315
|
-
node['features'].delete(feature_name)
|
316
|
-
end
|
306
|
+
node['features'].delete(feature_name) if node['uri'] == node_name && node['features'].nil? != true
|
317
307
|
end
|
318
308
|
end
|
319
309
|
inventory_hash
|
@@ -54,7 +54,7 @@ module PuppetLitmus::PuppetHelpers
|
|
54
54
|
span.add_field('litmus.manifest', manifest)
|
55
55
|
span.add_field('litmus.opts', opts)
|
56
56
|
|
57
|
-
target_node_name = targeting_localhost? ? 'litmus_localhost' : ENV
|
57
|
+
target_node_name = targeting_localhost? ? 'litmus_localhost' : ENV.fetch('TARGET_HOST', nil)
|
58
58
|
raise 'manifest and manifest_file_location in the opts hash are mutually exclusive arguments, pick one' if !manifest.nil? && !opts[:manifest_file_location].nil?
|
59
59
|
raise 'please pass a manifest or the manifest_file_location in the opts hash' if (manifest.nil? || manifest == '') && opts[:manifest_file_location].nil?
|
60
60
|
raise 'please specify only one of `catch_changes`, `expect_changes`, `catch_failures` or `expect_failures`' if
|
@@ -92,10 +92,10 @@ module PuppetLitmus::PuppetHelpers
|
|
92
92
|
add_node_fields_to_span(span, target_node_name, inventory_hash)
|
93
93
|
|
94
94
|
# Forcibly set the locale of the command
|
95
|
-
locale = if os[:family]
|
96
|
-
'LC_ALL=en_US.UTF-8 '
|
97
|
-
else
|
95
|
+
locale = if os[:family] == 'windows'
|
98
96
|
''
|
97
|
+
else
|
98
|
+
'LC_ALL=en_US.UTF-8 '
|
99
99
|
end
|
100
100
|
command_to_run = "#{locale}#{opts[:prefix_command]} puppet apply #{manifest_file_location}"
|
101
101
|
command_to_run += ' --trace' if !opts[:trace].nil? && (opts[:trace] == true)
|
@@ -154,7 +154,7 @@ module PuppetLitmus::PuppetHelpers
|
|
154
154
|
span.add_field('litmus.manifest', manifest)
|
155
155
|
|
156
156
|
require 'tmpdir'
|
157
|
-
target_node_name = ENV
|
157
|
+
target_node_name = ENV.fetch('TARGET_HOST', nil)
|
158
158
|
tmp_filename = File.join(Dir.tmpdir, "manifest_#{Time.now.strftime('%Y%m%d')}_#{Process.pid}_#{rand(0x100000000).to_s(36)}.pp")
|
159
159
|
manifest_file = File.open(tmp_filename, 'w')
|
160
160
|
manifest_file.write(manifest)
|
@@ -193,7 +193,7 @@ module PuppetLitmus::PuppetHelpers
|
|
193
193
|
|
194
194
|
require 'tmpdir'
|
195
195
|
inventory_hash = inventory_hash_from_inventory_file
|
196
|
-
target_node_name = ENV
|
196
|
+
target_node_name = ENV.fetch('TARGET_HOST', nil)
|
197
197
|
target_option = opts['targets'] || opts[:targets]
|
198
198
|
target_node_name = search_for_target(target_option, inventory_hash) unless target_option.nil?
|
199
199
|
|
@@ -234,7 +234,7 @@ module PuppetLitmus::PuppetHelpers
|
|
234
234
|
|
235
235
|
target_option = opts['targets'] || opts[:targets]
|
236
236
|
if target_option.nil?
|
237
|
-
target_node_name = targeting_localhost? ? 'litmus_localhost' : ENV
|
237
|
+
target_node_name = targeting_localhost? ? 'litmus_localhost' : ENV.fetch('TARGET_HOST', nil)
|
238
238
|
raise "Target '#{target_node_name}' not found in spec/fixtures/litmus_inventory.yaml" unless target_in_inventory?(inventory_hash, target_node_name)
|
239
239
|
else
|
240
240
|
target_node_name = search_for_target(target_option, inventory_hash)
|
@@ -245,9 +245,7 @@ module PuppetLitmus::PuppetHelpers
|
|
245
245
|
bolt_result = run_command(command_to_run, target_node_name, config: nil, inventory: inventory_hash)
|
246
246
|
span.add_field('litmus.bolt_result', bolt_result)
|
247
247
|
|
248
|
-
if bolt_result.first['value']['exit_code'] != 0 && opts[:expect_failures] != true
|
249
|
-
raise "shell failed\n`#{command_to_run}`\n======\n#{bolt_result}"
|
250
|
-
end
|
248
|
+
raise "shell failed\n`#{command_to_run}`\n======\n#{bolt_result}" if bolt_result.first['value']['exit_code'] != 0 && opts[:expect_failures] != true
|
251
249
|
|
252
250
|
result = OpenStruct.new(exit_code: bolt_result.first['value']['exit_code'],
|
253
251
|
exit_status: bolt_result.first['value']['exit_code'],
|
@@ -277,7 +275,7 @@ module PuppetLitmus::PuppetHelpers
|
|
277
275
|
inventory_hash = File.exist?('spec/fixtures/litmus_inventory.yaml') ? inventory_hash_from_inventory_file : localhost_inventory_hash
|
278
276
|
target_option = opts['targets'] || opts[:targets]
|
279
277
|
if target_option.nil?
|
280
|
-
target_node_name = targeting_localhost? ? 'litmus_localhost' : ENV
|
278
|
+
target_node_name = targeting_localhost? ? 'litmus_localhost' : ENV.fetch('TARGET_HOST', nil)
|
281
279
|
raise "Target '#{target_node_name}' not found in spec/fixtures/litmus_inventory.yaml" unless target_in_inventory?(inventory_hash, target_node_name)
|
282
280
|
else
|
283
281
|
target_node_name = search_for_target(target_option, inventory_hash)
|
@@ -292,7 +290,7 @@ module PuppetLitmus::PuppetHelpers
|
|
292
290
|
exit_code: 0,
|
293
291
|
stdout: bolt_result.first['value']['_output'],
|
294
292
|
stderr: nil,
|
295
|
-
result: bolt_result.first['value']
|
293
|
+
result: bolt_result.first['value']
|
296
294
|
}
|
297
295
|
|
298
296
|
if bolt_result.first['status'] != 'success'
|
@@ -330,7 +328,7 @@ module PuppetLitmus::PuppetHelpers
|
|
330
328
|
span.add_field('litmus.opts', opts)
|
331
329
|
|
332
330
|
config_data = { 'modulepath' => File.join(Dir.pwd, 'spec', 'fixtures', 'modules') }
|
333
|
-
target_node_name = targeting_localhost? ? 'litmus_localhost' : ENV
|
331
|
+
target_node_name = targeting_localhost? ? 'litmus_localhost' : ENV.fetch('TARGET_HOST', nil)
|
334
332
|
inventory_hash = if !opts[:inventory_file].nil? && File.exist?(opts[:inventory_file])
|
335
333
|
inventory_hash_from_inventory_file(opts[:inventory_file])
|
336
334
|
elsif File.exist?('spec/fixtures/litmus_inventory.yaml')
|
@@ -353,7 +351,7 @@ module PuppetLitmus::PuppetHelpers
|
|
353
351
|
exit_code: 0,
|
354
352
|
stdout: nil,
|
355
353
|
stderr: nil,
|
356
|
-
result: bolt_result.first['value']
|
354
|
+
result: bolt_result.first['value']
|
357
355
|
}
|
358
356
|
|
359
357
|
if bolt_result.first['status'] == 'success'
|
@@ -402,7 +400,7 @@ module PuppetLitmus::PuppetHelpers
|
|
402
400
|
span.add_field('litmus.opts', opts)
|
403
401
|
span.add_field('litmus.arguments', arguments)
|
404
402
|
|
405
|
-
target_node_name = targeting_localhost? ? 'litmus_localhost' : ENV
|
403
|
+
target_node_name = targeting_localhost? ? 'litmus_localhost' : ENV.fetch('TARGET_HOST', nil)
|
406
404
|
inventory_hash = File.exist?('spec/fixtures/litmus_inventory.yaml') ? inventory_hash_from_inventory_file : localhost_inventory_hash
|
407
405
|
target_option = opts['targets'] || opts[:targets]
|
408
406
|
if target_option.nil?
|
@@ -5,11 +5,9 @@ require 'honeycomb-beeline'
|
|
5
5
|
require 'puppet_litmus/version'
|
6
6
|
Honeycomb.configure do |config|
|
7
7
|
# override client if no configuration is provided, so that the pesky libhoney warning about lack of configuration is not shown
|
8
|
-
unless ENV['HONEYCOMB_WRITEKEY'] && ENV['HONEYCOMB_DATASET']
|
9
|
-
config.client = Libhoney::NullClient.new
|
10
|
-
end
|
8
|
+
config.client = Libhoney::NullClient.new unless ENV['HONEYCOMB_WRITEKEY'] && ENV['HONEYCOMB_DATASET']
|
11
9
|
end
|
12
|
-
process_span = Honeycomb.start_span(name: "litmus: #{([$PROGRAM_NAME] + ($ARGV || [])).join(' ')}", serialized_trace: ENV
|
10
|
+
process_span = Honeycomb.start_span(name: "litmus: #{([$PROGRAM_NAME] + ($ARGV || [])).join(' ')}", serialized_trace: ENV.fetch('HONEYCOMB_TRACE', nil))
|
13
11
|
ENV['HONEYCOMB_TRACE'] = process_span.to_trace_header
|
14
12
|
Honeycomb.add_field_to_trace('litmus.pid', Process.pid)
|
15
13
|
if defined? PuppetLitmus::VERSION
|
@@ -18,27 +16,27 @@ else
|
|
18
16
|
Honeycomb.add_field_to_trace('litmus.version', 'undefined')
|
19
17
|
end
|
20
18
|
if ENV['CI'] == 'true' && ENV['TRAVIS'] == 'true'
|
21
|
-
Honeycomb.add_field_to_trace('module_name', ENV
|
19
|
+
Honeycomb.add_field_to_trace('module_name', ENV.fetch('TRAVIS_REPO_SLUG', nil))
|
22
20
|
Honeycomb.add_field_to_trace('ci.provider', 'travis')
|
23
|
-
Honeycomb.add_field_to_trace('ci.build_id', ENV
|
24
|
-
Honeycomb.add_field_to_trace('ci.build_url', ENV
|
25
|
-
Honeycomb.add_field_to_trace('ci.job_url', ENV
|
26
|
-
Honeycomb.add_field_to_trace('ci.commit_message', ENV
|
27
|
-
Honeycomb.add_field_to_trace('ci.sha', ENV['TRAVIS_PULL_REQUEST_SHA'] || ENV
|
21
|
+
Honeycomb.add_field_to_trace('ci.build_id', ENV.fetch('TRAVIS_BUILD_ID', nil))
|
22
|
+
Honeycomb.add_field_to_trace('ci.build_url', ENV.fetch('TRAVIS_BUILD_WEB_URL', nil))
|
23
|
+
Honeycomb.add_field_to_trace('ci.job_url', ENV.fetch('TRAVIS_JOB_WEB_URL', nil))
|
24
|
+
Honeycomb.add_field_to_trace('ci.commit_message', ENV.fetch('TRAVIS_COMMIT_MESSAGE', nil))
|
25
|
+
Honeycomb.add_field_to_trace('ci.sha', ENV['TRAVIS_PULL_REQUEST_SHA'] || ENV.fetch('TRAVIS_COMMIT', nil))
|
28
26
|
elsif ENV['CI'] == 'True' && ENV['APPVEYOR'] == 'True'
|
29
|
-
Honeycomb.add_field_to_trace('module_name', ENV
|
27
|
+
Honeycomb.add_field_to_trace('module_name', ENV.fetch('APPVEYOR_PROJECT_SLUG', nil))
|
30
28
|
Honeycomb.add_field_to_trace('ci.provider', 'appveyor')
|
31
|
-
Honeycomb.add_field_to_trace('ci.build_id', ENV
|
32
|
-
Honeycomb.add_field_to_trace('ci.build_url', "https://ci.appveyor.com/project/#{ENV
|
33
|
-
Honeycomb.add_field_to_trace('ci.job_url', "https://ci.appveyor.com/project/#{ENV
|
34
|
-
Honeycomb.add_field_to_trace('ci.commit_message', ENV
|
35
|
-
Honeycomb.add_field_to_trace('ci.sha', ENV['APPVEYOR_PULL_REQUEST_HEAD_COMMIT'] || ENV
|
29
|
+
Honeycomb.add_field_to_trace('ci.build_id', ENV.fetch('APPVEYOR_BUILD_ID', nil))
|
30
|
+
Honeycomb.add_field_to_trace('ci.build_url', "https://ci.appveyor.com/project/#{ENV.fetch('APPVEYOR_REPO_NAME', nil)}/builds/#{ENV.fetch('APPVEYOR_BUILD_ID', nil)}")
|
31
|
+
Honeycomb.add_field_to_trace('ci.job_url', "https://ci.appveyor.com/project/#{ENV.fetch('APPVEYOR_REPO_NAME', nil)}/build/job/#{ENV.fetch('APPVEYOR_JOB_ID', nil)}")
|
32
|
+
Honeycomb.add_field_to_trace('ci.commit_message', ENV.fetch('APPVEYOR_REPO_COMMIT_MESSAGE', nil))
|
33
|
+
Honeycomb.add_field_to_trace('ci.sha', ENV['APPVEYOR_PULL_REQUEST_HEAD_COMMIT'] || ENV.fetch('APPVEYOR_REPO_COMMIT', nil))
|
36
34
|
elsif ENV['GITHUB_ACTIONS'] == 'true'
|
37
|
-
Honeycomb.add_field_to_trace('module_name', ENV
|
35
|
+
Honeycomb.add_field_to_trace('module_name', ENV.fetch('GITHUB_REPOSITORY', nil))
|
38
36
|
Honeycomb.add_field_to_trace('ci.provider', 'github')
|
39
|
-
Honeycomb.add_field_to_trace('ci.build_id', ENV
|
40
|
-
Honeycomb.add_field_to_trace('ci.build_url', "https://github.com/#{ENV
|
41
|
-
Honeycomb.add_field_to_trace('ci.sha', ENV
|
37
|
+
Honeycomb.add_field_to_trace('ci.build_id', ENV.fetch('GITHUB_RUN_ID', nil))
|
38
|
+
Honeycomb.add_field_to_trace('ci.build_url', "https://github.com/#{ENV.fetch('GITHUB_REPOSITORY', nil)}/actions/runs/#{ENV.fetch('GITHUB_RUN_ID', nil)}")
|
39
|
+
Honeycomb.add_field_to_trace('ci.sha', ENV.fetch('GITHUB_SHA', nil))
|
42
40
|
end
|
43
41
|
at_exit do
|
44
42
|
if $ERROR_INFO.is_a?(SystemExit)
|
@@ -54,8 +52,8 @@ end
|
|
54
52
|
# helper methods for the litmus rake tasks
|
55
53
|
module PuppetLitmus::RakeHelper
|
56
54
|
# DEFAULT_CONFIG_DATA should be frozen for our safety, but it needs to work around https://github.com/puppetlabs/bolt/pull/1696
|
57
|
-
DEFAULT_CONFIG_DATA
|
58
|
-
SUPPORTED_PROVISIONERS
|
55
|
+
DEFAULT_CONFIG_DATA = { 'modulepath' => File.join(Dir.pwd, 'spec', 'fixtures', 'modules') } # .freeze # rubocop:disable Style/MutableConstant
|
56
|
+
SUPPORTED_PROVISIONERS = %w[abs docker docker_exp provision_service vagrant vmpooler].freeze
|
59
57
|
|
60
58
|
# Gets a string representing the operating system and version.
|
61
59
|
#
|
@@ -318,7 +316,7 @@ module PuppetLitmus::RakeHelper
|
|
318
316
|
|
319
317
|
module_repository_opts = "--module_repository '#{module_repository}'" unless module_repository.nil?
|
320
318
|
install_module_command = "puppet module install #{module_repository_opts} #{File.basename(module_tar)}"
|
321
|
-
install_module_command += ' --ignore-dependencies --force' if ignore_dependencies.to_s.
|
319
|
+
install_module_command += ' --ignore-dependencies --force' if ignore_dependencies.to_s.casecmp('true').zero?
|
322
320
|
span.add_field('litmus.install_module_command', install_module_command)
|
323
321
|
|
324
322
|
bolt_result = run_command(install_module_command, target_nodes, config: nil, inventory: inventory_hash.clone)
|
@@ -428,7 +426,7 @@ module PuppetLitmus::RakeHelper
|
|
428
426
|
end
|
429
427
|
|
430
428
|
def start_spinner(message)
|
431
|
-
if (ENV['CI'] || '').
|
429
|
+
if (ENV['CI'] || '').casecmp('true').zero?
|
432
430
|
puts message
|
433
431
|
spinner = Thread.new do
|
434
432
|
# CI systems are strange beasts, we only output a '.' every wee while to keep the terminal alive.
|
@@ -446,7 +444,7 @@ module PuppetLitmus::RakeHelper
|
|
446
444
|
end
|
447
445
|
|
448
446
|
def stop_spinner(spinner)
|
449
|
-
if (ENV['CI'] || '').
|
447
|
+
if (ENV['CI'] || '').casecmp('true').zero?
|
450
448
|
Thread.kill(spinner)
|
451
449
|
else
|
452
450
|
spinner.success
|
@@ -42,10 +42,10 @@ namespace :litmus do
|
|
42
42
|
stop_spinner(spinner)
|
43
43
|
end
|
44
44
|
|
45
|
-
if result.first['status']
|
46
|
-
failed_image_message += "=====\n#{result.first['target']}\n#{result.first['value']['_output']}\n#{result.inspect}"
|
47
|
-
else
|
45
|
+
if result.first['status'] == 'success'
|
48
46
|
$stdout.puts 'Success'
|
47
|
+
else
|
48
|
+
failed_image_message += "=====\n#{result.first['target']}\n#{result.first['value']['_output']}\n#{result.inspect}"
|
49
49
|
end
|
50
50
|
else
|
51
51
|
provision_hash[args[:key]]['images'].each do |image|
|
@@ -56,10 +56,10 @@ namespace :litmus do
|
|
56
56
|
stop_spinner(spinner)
|
57
57
|
end
|
58
58
|
|
59
|
-
if result.first['status']
|
60
|
-
failed_image_message += "=====\n#{result.first['target']}\n#{result.first['value']['_output']}\n#{result.inspect}"
|
61
|
-
else
|
59
|
+
if result.first['status'] == 'success'
|
62
60
|
$stdout.puts "#{result.first['value']['node_name']}, #{image}"
|
61
|
+
else
|
62
|
+
failed_image_message += "=====\n#{result.first['target']}\n#{result.first['value']['_output']}\n#{result.inspect}"
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -80,9 +80,7 @@ namespace :litmus do
|
|
80
80
|
|
81
81
|
results = provision(args[:provisioner], args[:platform], args[:inventory_vars])
|
82
82
|
|
83
|
-
unless results.first['status'] == 'success'
|
84
|
-
raise "Failed provisioning #{args[:platform]} using #{args[:provisioner]}\n#{results.first}"
|
85
|
-
end
|
83
|
+
raise "Failed provisioning #{args[:platform]} using #{args[:provisioner]}\n#{results.first}" unless results.first['status'] == 'success'
|
86
84
|
|
87
85
|
puts "Successfully provisioned #{args[:platform]} using #{args[:provisioner]}\n"
|
88
86
|
|
@@ -320,10 +318,10 @@ namespace :litmus do
|
|
320
318
|
bad_results = []
|
321
319
|
results = tear_down_nodes(targets, inventory_hash)
|
322
320
|
results.each do |node, result|
|
323
|
-
if result.first['status']
|
324
|
-
bad_results << "#{node}, #{result.first['value']['_error']['msg']}"
|
325
|
-
else
|
321
|
+
if result.first['status'] == 'success'
|
326
322
|
puts "#{node}: #{result.first['status']}"
|
323
|
+
else
|
324
|
+
bad_results << "#{node}, #{result.first['value']['_error']['msg']}"
|
327
325
|
end
|
328
326
|
end
|
329
327
|
puts ''
|
@@ -361,8 +359,8 @@ namespace :litmus do
|
|
361
359
|
title = "#{target}, #{facts_from_node(inventory_hash, target)['platform']}"
|
362
360
|
options = {
|
363
361
|
env: {
|
364
|
-
'TARGET_HOST' => target
|
365
|
-
}
|
362
|
+
'TARGET_HOST' => target
|
363
|
+
}
|
366
364
|
}
|
367
365
|
payloads << [title, test, options]
|
368
366
|
end
|
@@ -395,9 +393,9 @@ namespace :litmus do
|
|
395
393
|
# because we cannot modify variables inside of Parallel
|
396
394
|
results.each do |result|
|
397
395
|
if result.last.to_i.zero?
|
398
|
-
success_list.push(result.first.scan(
|
396
|
+
success_list.push(result.first.scan(/.*/)[3])
|
399
397
|
else
|
400
|
-
failure_list.push(result.first.scan(
|
398
|
+
failure_list.push(result.first.scan(/.*/)[3])
|
401
399
|
end
|
402
400
|
end
|
403
401
|
Thread.kill(progress)
|
@@ -22,13 +22,13 @@ module PuppetLitmus
|
|
22
22
|
else
|
23
23
|
# load inventory
|
24
24
|
inventory_hash = inventory_hash_from_inventory_file
|
25
|
-
node_config = config_from_node(inventory_hash, ENV
|
25
|
+
node_config = config_from_node(inventory_hash, ENV.fetch('TARGET_HOST', nil))
|
26
26
|
|
27
|
-
if target_in_group(inventory_hash, ENV
|
28
|
-
host = ENV
|
27
|
+
if target_in_group(inventory_hash, ENV.fetch('TARGET_HOST', nil), 'docker_nodes')
|
28
|
+
host = ENV.fetch('TARGET_HOST', nil)
|
29
29
|
set :backend, :docker
|
30
30
|
set :docker_container, host
|
31
|
-
elsif target_in_group(inventory_hash, ENV
|
31
|
+
elsif target_in_group(inventory_hash, ENV.fetch('TARGET_HOST', nil), 'ssh_nodes')
|
32
32
|
set :backend, :ssh
|
33
33
|
options = Net::SSH::Config.for(host)
|
34
34
|
options[:user] = node_config.dig('ssh', 'user') unless node_config.dig('ssh', 'user').nil?
|
@@ -70,14 +70,14 @@ module PuppetLitmus
|
|
70
70
|
set :request_pty, false
|
71
71
|
set :sudo_password, options[:password] if run_as
|
72
72
|
puts "Running tests as #{run_as}" if run_as
|
73
|
-
elsif target_in_group(inventory_hash, ENV
|
73
|
+
elsif target_in_group(inventory_hash, ENV.fetch('TARGET_HOST', nil), 'winrm_nodes')
|
74
74
|
require 'winrm'
|
75
75
|
|
76
76
|
set :backend, :winrm
|
77
77
|
set :os, family: 'windows'
|
78
78
|
user = node_config.dig('winrm', 'user') unless node_config.dig('winrm', 'user').nil?
|
79
79
|
pass = node_config.dig('winrm', 'password') unless node_config.dig('winrm', 'password').nil?
|
80
|
-
endpoint = URI("http://#{ENV
|
80
|
+
endpoint = URI("http://#{ENV.fetch('TARGET_HOST', nil)}")
|
81
81
|
endpoint.port = 5985 if endpoint.port == 80
|
82
82
|
endpoint.path = '/wsman'
|
83
83
|
|
@@ -85,7 +85,7 @@ module PuppetLitmus
|
|
85
85
|
user: user,
|
86
86
|
password: pass,
|
87
87
|
endpoint: endpoint,
|
88
|
-
operation_timeout: 300
|
88
|
+
operation_timeout: 300
|
89
89
|
}
|
90
90
|
|
91
91
|
winrm = WinRM::Connection.new opts
|
@@ -33,7 +33,7 @@ RSpec.describe 'matrix_from_metadata_v2' do
|
|
33
33
|
].join
|
34
34
|
)
|
35
35
|
expect(github_output_content).to include(
|
36
|
-
'spec_matrix={"include":[{"puppet_version":"~> 7.
|
36
|
+
'spec_matrix={"include":[{"puppet_version":"~> 7.0","ruby_version":2.7},{"puppet_version":"https://github.com/puppetlabs/puppet","ruby_version":3.2}]}'
|
37
37
|
)
|
38
38
|
expect(result.stdout).to include("Created matrix with 8 cells:\n - Acceptance Test Cells: 6\n - Spec Test Cells: 2")
|
39
39
|
end
|
@@ -69,7 +69,7 @@ RSpec.describe 'matrix_from_metadata_v2' do
|
|
69
69
|
].join
|
70
70
|
)
|
71
71
|
expect(github_output_content).to include(
|
72
|
-
'spec_matrix={"include":[{"puppet_version":"~> 7.
|
72
|
+
'spec_matrix={"include":[{"puppet_version":"~> 7.0","ruby_version":2.7},{"puppet_version":"https://github.com/puppetlabs/puppet","ruby_version":3.2}]}'
|
73
73
|
)
|
74
74
|
expect(result.stdout).to include("Created matrix with 6 cells:\n - Acceptance Test Cells: 4\n - Spec Test Cells: 2")
|
75
75
|
end
|
@@ -105,7 +105,7 @@ RSpec.describe 'matrix_from_metadata_v2' do
|
|
105
105
|
].join
|
106
106
|
)
|
107
107
|
expect(github_output_content).to include(
|
108
|
-
'spec_matrix={"include":[{"puppet_version":"~> 7.
|
108
|
+
'spec_matrix={"include":[{"puppet_version":"~> 7.0","ruby_version":2.7},{"puppet_version":"https://github.com/puppetlabs/puppet","ruby_version":3.2}]}'
|
109
109
|
)
|
110
110
|
expect(result.stdout).to include("Created matrix with 4 cells:\n - Acceptance Test Cells: 2\n - Spec Test Cells: 2")
|
111
111
|
end
|
@@ -8,11 +8,11 @@ RSpec.describe PuppetLitmus::InventoryManipulation do
|
|
8
8
|
|
9
9
|
context 'with config_from_node' do
|
10
10
|
it 'no matching node, returns nil' do
|
11
|
-
expect(config_from_node(config_hash, 'not.here')).to
|
11
|
+
expect(config_from_node(config_hash, 'not.here')).to be_nil
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'no config section, returns nil' do
|
15
|
-
expect(config_from_node(no_config_hash, 'test.delivery.puppetlabs.net')).to
|
15
|
+
expect(config_from_node(no_config_hash, 'test.delivery.puppetlabs.net')).to be_nil
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'config exists, and returns' do
|
@@ -82,9 +82,7 @@ RSpec.describe PuppetLitmus::InventoryManipulation do
|
|
82
82
|
|
83
83
|
it 'applies a code block to groups' do
|
84
84
|
counts = groups_in_inventory(complex_inventory) do |group|
|
85
|
-
if group.key? 'targets'
|
86
|
-
group['targets'].count
|
87
|
-
end
|
85
|
+
group['targets'].count if group.key? 'targets'
|
88
86
|
end
|
89
87
|
expect(counts.sum).to be 4
|
90
88
|
end
|
@@ -133,7 +131,7 @@ RSpec.describe PuppetLitmus::InventoryManipulation do
|
|
133
131
|
end
|
134
132
|
|
135
133
|
it 'searches for roles as symbols' do
|
136
|
-
expect(search_for_target([
|
134
|
+
expect(search_for_target(%i[iis nginx], complex_inventory)).to eql ['test4.delivery.puppetlabs.net', 'test3.delivery.puppetlabs.net']
|
137
135
|
end
|
138
136
|
|
139
137
|
it 'raises an error if target not found' do
|
@@ -33,7 +33,7 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
|
|
33
33
|
let(:result) { ['value' => { 'exit_code' => 0, 'stdout' => nil, 'stderr' => nil }] }
|
34
34
|
let :os do
|
35
35
|
{
|
36
|
-
family: 'redhat'
|
36
|
+
family: 'redhat'
|
37
37
|
}
|
38
38
|
end
|
39
39
|
let(:command) { "LC_ALL=en_US.UTF-8 puppet apply /bla.pp --trace --modulepath #{Dir.pwd}/spec/fixtures/modules --hiera_config='/hiera.yaml'" }
|
@@ -54,7 +54,7 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
|
|
54
54
|
let(:command) { "LC_ALL=en_US.UTF-8 puppet apply /bla.pp --trace --modulepath #{Dir.pwd}/spec/fixtures/modules --detailed-exitcodes" }
|
55
55
|
let :os do
|
56
56
|
{
|
57
|
-
family: 'redhat'
|
57
|
+
family: 'redhat'
|
58
58
|
}
|
59
59
|
end
|
60
60
|
|
@@ -176,7 +176,7 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
|
|
176
176
|
expect(self).to receive(:target_in_inventory?).and_return(true)
|
177
177
|
expect(self).to receive(:target_in_inventory?).and_return(true)
|
178
178
|
expect(self).to receive(:upload_file).with(local, remote, 'some.host', options: {}, config: nil, inventory: inventory_hash).and_return(result_failure)
|
179
|
-
expect { bolt_upload_file(local, remote) }.to raise_error(RuntimeError,
|
179
|
+
expect { bolt_upload_file(local, remote) }.to raise_error(RuntimeError, /upload file failed/)
|
180
180
|
end
|
181
181
|
|
182
182
|
it 'returns the exit code and error message when expecting failure' do
|
@@ -307,7 +307,7 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
|
|
307
307
|
expect(self).to receive(:target_in_inventory?).and_return(true)
|
308
308
|
expect(self).to receive(:target_in_inventory?).and_return(true)
|
309
309
|
expect(self).to receive(:run_task).with(task_name, 'some.host', params, config: config_data, inventory: inventory_hash).and_return(result_failure)
|
310
|
-
expect { run_bolt_task(task_name, params, opts: {}) }.to raise_error(RuntimeError,
|
310
|
+
expect { run_bolt_task(task_name, params, opts: {}) }.to raise_error(RuntimeError, /task failed/)
|
311
311
|
end
|
312
312
|
|
313
313
|
it 'returns the exit code and error message when expecting failure' do
|
@@ -330,7 +330,7 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
|
|
330
330
|
let(:owner) { 'foo:foo' }
|
331
331
|
let(:local_path) { '/tmp/local_foo' }
|
332
332
|
|
333
|
-
before
|
333
|
+
before do
|
334
334
|
allow_any_instance_of(File).to receive(:path).and_return(local_path)
|
335
335
|
end
|
336
336
|
|
@@ -342,9 +342,10 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
|
|
342
342
|
it 'call upload file with the correct params' do
|
343
343
|
stub_const('ENV', ENV.to_hash.merge('TARGET_HOST' => 'some.host'))
|
344
344
|
expect(self).to receive(:inventory_hash_from_inventory_file).and_return(inventory_hash)
|
345
|
-
|
346
|
-
|
347
|
-
expect(self).to receive(:upload_file).with(local_path, destination, 'some.host', options: {}, config: nil, inventory: inventory_hash).and_return(
|
345
|
+
|
346
|
+
expected_result = [{ 'status' => 'success' }]
|
347
|
+
expect(self).to receive(:upload_file).with(local_path, destination, 'some.host', options: {}, config: nil, inventory: inventory_hash).and_return(expected_result)
|
348
|
+
|
348
349
|
result = write_file(content, destination)
|
349
350
|
expect(result).to be true
|
350
351
|
end
|
@@ -354,9 +355,10 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
|
|
354
355
|
it 'call upload file with the correct params' do
|
355
356
|
stub_const('ENV', ENV.to_hash.merge('TARGET_HOST' => 'some.host'))
|
356
357
|
expect(self).to receive(:inventory_hash_from_inventory_file).and_return(inventory_hash)
|
357
|
-
|
358
|
-
|
359
|
-
expect(self).to receive(:upload_file).with(local_path, destination, 'some.host', options: {}, config: nil, inventory: inventory_hash).and_return(
|
358
|
+
|
359
|
+
expected_result = [{ 'status' => 'failure', 'value' => 'foo error' }]
|
360
|
+
expect(self).to receive(:upload_file).with(local_path, destination, 'some.host', options: {}, config: nil, inventory: inventory_hash).and_return(expected_result)
|
361
|
+
|
360
362
|
expect { write_file(content, destination) }.to raise_error 'foo error'
|
361
363
|
end
|
362
364
|
end
|
@@ -4,7 +4,7 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
RSpec.describe PuppetLitmus do
|
6
6
|
it 'has a version number' do
|
7
|
-
expect(described_class::VERSION).not_to
|
8
|
-
expect(described_class::VERSION).to
|
7
|
+
expect(described_class::VERSION).not_to be_nil
|
8
|
+
expect(described_class::VERSION).to be_a(String)
|
9
9
|
end
|
10
10
|
end
|
@@ -42,7 +42,7 @@ RSpec.describe PuppetLitmus::RakeHelper do
|
|
42
42
|
inventory_vars: nil,
|
43
43
|
provision_hash: { 'default' => { 'provisioner' => 'docker', 'images' => ['waffleimage/centos7'] } },
|
44
44
|
results: [],
|
45
|
-
params: { 'action' => 'provision', 'platform' => 'waffleimage/centos7', 'inventory' => Dir.pwd }
|
45
|
+
params: { 'action' => 'provision', 'platform' => 'waffleimage/centos7', 'inventory' => Dir.pwd }
|
46
46
|
},
|
47
47
|
{
|
48
48
|
provisioner: 'vagrant',
|
@@ -50,8 +50,8 @@ RSpec.describe PuppetLitmus::RakeHelper do
|
|
50
50
|
inventory_vars: nil,
|
51
51
|
provision_hash: { 'default' => { 'provisioner' => 'vagrant', 'images' => ['centos7'] } },
|
52
52
|
results: [],
|
53
|
-
params: { 'action' => 'provision', 'platform' => 'centos7', 'inventory' => Dir.pwd }
|
54
|
-
}
|
53
|
+
params: { 'action' => 'provision', 'platform' => 'centos7', 'inventory' => Dir.pwd }
|
54
|
+
}
|
55
55
|
].freeze
|
56
56
|
|
57
57
|
examples.each do |e|
|
@@ -85,7 +85,7 @@ RSpec.describe PuppetLitmus::RakeHelper do
|
|
85
85
|
{ 'uri' => 'one.host', 'facts' => { 'provisioner' => 'abs', 'platform' => 'ubuntu-1604-x86_64', 'job_id' => 'iac-task-pid-21648' } },
|
86
86
|
{ 'uri' => 'two.host', 'facts' => { 'provisioner' => 'abs', 'platform' => 'ubuntu-1804-x86_64', 'job_id' => 'iac-task-pid-21648' } },
|
87
87
|
{ 'uri' => 'three.host', 'facts' => { 'provisioner' => 'abs', 'platform' => 'ubuntu-2004-x86_64', 'job_id' => 'iac-task-pid-21648' } },
|
88
|
-
{ 'uri' => 'four.host', 'facts' => { 'provisioner' => 'abs', 'platform' => 'ubuntu-2004-x86_64', 'job_id' => 'iac-task-pid-21649' } }
|
88
|
+
{ 'uri' => 'four.host', 'facts' => { 'provisioner' => 'abs', 'platform' => 'ubuntu-2004-x86_64', 'job_id' => 'iac-task-pid-21649' } }
|
89
89
|
] }] }
|
90
90
|
end
|
91
91
|
let(:targets) { ['one.host'] }
|
@@ -103,7 +103,7 @@ RSpec.describe PuppetLitmus::RakeHelper do
|
|
103
103
|
'removed' =>
|
104
104
|
['one.host',
|
105
105
|
'two.host',
|
106
|
-
'three.host'] } }]
|
106
|
+
'three.host'] } }]
|
107
107
|
)
|
108
108
|
results = tear_down_nodes(targets, inventory_hash)
|
109
109
|
expect(results.keys).to eq(['one.host', 'two.host', 'three.host'])
|
@@ -170,7 +170,7 @@ RSpec.describe PuppetLitmus::RakeHelper do
|
|
170
170
|
|
171
171
|
it 'node unavailable' do
|
172
172
|
allow_any_instance_of(BoltSpec::Run).to receive(:run_command).with(command, targets, config: nil, inventory: inventory_hash).and_return([{ 'target' => 'some.host', 'status' => 'failure' }])
|
173
|
-
expect { check_connectivity?(inventory_hash, 'some.host') }.to raise_error(RuntimeError,
|
173
|
+
expect { check_connectivity?(inventory_hash, 'some.host') }.to raise_error(RuntimeError, /Connectivity has failed on:/)
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
@@ -59,6 +59,13 @@ describe 'litmus rake tasks' do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
context 'with litmus:provision task' do
|
62
|
+
let(:expected_output) do
|
63
|
+
<<~OUTPUT
|
64
|
+
Successfully provisioned centos:7 using docker
|
65
|
+
localhost:2222, centos:7
|
66
|
+
OUTPUT
|
67
|
+
end
|
68
|
+
|
62
69
|
it 'happy path' do
|
63
70
|
results = [{ 'target' => 'localhost',
|
64
71
|
'action' => 'task',
|
@@ -71,11 +78,7 @@ describe 'litmus rake tasks' do
|
|
71
78
|
allow_any_instance_of(PuppetLitmus::InventoryManipulation).to receive(:inventory_hash_from_inventory_file).with(any_args).and_return({})
|
72
79
|
allow_any_instance_of(PuppetLitmus::RakeHelper).to receive(:check_connectivity?).with(any_args).and_return(true)
|
73
80
|
|
74
|
-
expect
|
75
|
-
expect($stdout).to receive(:puts).with("Successfully provisioned centos:7 using docker\n")
|
76
|
-
expect($stdout).to receive(:puts).with('localhost:2222, centos:7')
|
77
|
-
|
78
|
-
Rake::Task['litmus:provision'].invoke('docker', 'centos:7')
|
81
|
+
expect { Rake::Task['litmus:provision'].invoke('docker', 'centos:7') }.to output(expected_output).to_stdout
|
79
82
|
end
|
80
83
|
end
|
81
84
|
|
@@ -86,7 +89,7 @@ describe 'litmus rake tasks' do
|
|
86
89
|
it 'no key in provision file' do
|
87
90
|
allow(File).to receive(:file?).with(any_args).and_return(true)
|
88
91
|
expect(YAML).to receive(:load_file).with(provision_file).and_return(provision_hash)
|
89
|
-
expect { Rake::Task['litmus:provision_list'].invoke('deet') }.to raise_error(
|
92
|
+
expect { Rake::Task['litmus:provision_list'].invoke('deet') }.to raise_error(/deet/)
|
90
93
|
end
|
91
94
|
end
|
92
95
|
|
@@ -6,10 +6,10 @@ load File.expand_path('../../../lib/puppet_litmus/util.rb', __dir__)
|
|
6
6
|
RSpec.describe PuppetLitmus::Util do
|
7
7
|
context 'when using interpolate_powershell' do
|
8
8
|
it 'interpolates the command' do
|
9
|
-
expect(described_class.interpolate_powershell('foo')).to match(
|
10
|
-
expect(described_class.interpolate_powershell('foo')).to match(
|
11
|
-
expect(described_class.interpolate_powershell('foo')).to match(
|
12
|
-
expect(described_class.interpolate_powershell('foo')).not_to match(
|
9
|
+
expect(described_class.interpolate_powershell('foo')).to match(/powershell\.exe/)
|
10
|
+
expect(described_class.interpolate_powershell('foo')).to match(/NoProfile/)
|
11
|
+
expect(described_class.interpolate_powershell('foo')).to match(/EncodedCommand/)
|
12
|
+
expect(described_class.interpolate_powershell('foo')).not_to match(/foo/)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -12,7 +12,7 @@ if ENV['COVERAGE'] == 'yes'
|
|
12
12
|
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
13
13
|
else
|
14
14
|
SimpleCov.formatters = [
|
15
|
-
SimpleCov::Formatter::HTMLFormatter
|
15
|
+
SimpleCov::Formatter::HTMLFormatter
|
16
16
|
]
|
17
17
|
end
|
18
18
|
SimpleCov.start do
|
@@ -41,7 +41,7 @@ def run_matrix_from_metadata_v2(options = {})
|
|
41
41
|
OpenStruct.new(
|
42
42
|
stdout: result[0],
|
43
43
|
stderr: result[1],
|
44
|
-
status_code: result[2]
|
44
|
+
status_code: result[2]
|
45
45
|
)
|
46
46
|
end
|
47
47
|
|
data/spec/support/inventory.rb
CHANGED
@@ -7,7 +7,7 @@ def no_config_hash
|
|
7
7
|
'targets' =>
|
8
8
|
[{ 'uri' => 'test.delivery.puppetlabs.net',
|
9
9
|
'facts' => { 'provisioner' => 'vmpooler', 'platform' => 'centos-5-x86_64' } }] },
|
10
|
-
{ 'name' => 'winrm_nodes', 'targets' => [] }
|
10
|
+
{ 'name' => 'winrm_nodes', 'targets' => [] }
|
11
11
|
] }
|
12
12
|
end
|
13
13
|
|
@@ -99,21 +99,21 @@ def complex_inventory
|
|
99
99
|
'uri' => 'test.delivery.puppetlabs.net',
|
100
100
|
'config' => { 'transport' => 'ssh', 'ssh' => { 'user' => 'root', 'password' => 'Qu@lity!', 'host-key-check' => false } },
|
101
101
|
'facts' => { 'provisioner' => 'vmpooler', 'platform' => 'centos-5-x86_64' },
|
102
|
-
'vars' => { 'role' => 'agent' }
|
102
|
+
'vars' => { 'role' => 'agent' }
|
103
103
|
},
|
104
104
|
{
|
105
105
|
'uri' => 'test2.delivery.puppetlabs.net',
|
106
106
|
'config' => { 'transport' => 'ssh', 'ssh' => { 'user' => 'root', 'password' => 'Qu@lity!', 'host-key-check' => false } },
|
107
107
|
'facts' => { 'provisioner' => 'vmpooler', 'platform' => 'centos-5-x86_64' },
|
108
|
-
'vars' => { 'role' => 'server' }
|
108
|
+
'vars' => { 'role' => 'server' }
|
109
109
|
},
|
110
110
|
{
|
111
111
|
'uri' => 'test3.delivery.puppetlabs.net',
|
112
112
|
'config' => { 'transport' => 'ssh', 'ssh' => { 'user' => 'root', 'password' => 'Qu@lity!', 'host-key-check' => false } },
|
113
|
-
'vars' => { 'roles' => %w[agent nginx webserver] }
|
114
|
-
}
|
115
|
-
] }
|
116
|
-
]
|
113
|
+
'vars' => { 'roles' => %w[agent nginx webserver] }
|
114
|
+
}
|
115
|
+
] }
|
116
|
+
]
|
117
117
|
},
|
118
118
|
{
|
119
119
|
'name' => 'winrm_nodes',
|
@@ -122,9 +122,9 @@ def complex_inventory
|
|
122
122
|
'uri' => 'test4.delivery.puppetlabs.net',
|
123
123
|
'config' => { 'transport' => 'winrm', 'winrm' => { 'user' => 'admin', 'password' => 'Qu@lity!' } },
|
124
124
|
'facts' => { 'provisioner' => 'vmpooler', 'platform' => 'centos-5-x86_64' },
|
125
|
-
'vars' => { 'roles' => %w[agent iis webserver] }
|
126
|
-
}
|
127
|
-
]
|
128
|
-
}
|
125
|
+
'vars' => { 'roles' => %w[agent iis webserver] }
|
126
|
+
}
|
127
|
+
]
|
128
|
+
}
|
129
129
|
] }
|
130
130
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet_litmus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.rc.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bolt
|
@@ -25,93 +25,87 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: docker-api
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '1.34'
|
34
34
|
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version:
|
36
|
+
version: 3.0.0
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: '1.34'
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
46
|
+
version: 3.0.0
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
48
|
+
name: honeycomb-beeline
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0
|
54
|
-
- - "<"
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: 1.0.0
|
53
|
+
version: '0'
|
57
54
|
type: :runtime
|
58
55
|
prerelease: false
|
59
56
|
version_requirements: !ruby/object:Gem::Requirement
|
60
57
|
requirements:
|
61
58
|
- - ">="
|
62
59
|
- !ruby/object:Gem::Version
|
63
|
-
version: 0
|
64
|
-
- - "<"
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: 1.0.0
|
60
|
+
version: '0'
|
67
61
|
- !ruby/object:Gem::Dependency
|
68
|
-
name:
|
62
|
+
name: parallel
|
69
63
|
requirement: !ruby/object:Gem::Requirement
|
70
64
|
requirements:
|
71
65
|
- - ">="
|
72
66
|
- !ruby/object:Gem::Version
|
73
|
-
version: '
|
74
|
-
- - "<"
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: 3.0.0
|
67
|
+
version: '0'
|
77
68
|
type: :runtime
|
78
69
|
prerelease: false
|
79
70
|
version_requirements: !ruby/object:Gem::Requirement
|
80
71
|
requirements:
|
81
72
|
- - ">="
|
82
73
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
84
|
-
- - "<"
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
version: 3.0.0
|
74
|
+
version: '0'
|
87
75
|
- !ruby/object:Gem::Dependency
|
88
|
-
name:
|
76
|
+
name: puppet-modulebuilder
|
89
77
|
requirement: !ruby/object:Gem::Requirement
|
90
78
|
requirements:
|
91
|
-
- - "
|
79
|
+
- - ">="
|
92
80
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
81
|
+
version: 0.2.1
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 1.0.0.rc
|
94
85
|
type: :runtime
|
95
86
|
prerelease: false
|
96
87
|
version_requirements: !ruby/object:Gem::Requirement
|
97
88
|
requirements:
|
98
|
-
- - "
|
89
|
+
- - ">="
|
99
90
|
- !ruby/object:Gem::Version
|
100
|
-
version:
|
91
|
+
version: 0.2.1
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 1.0.0.rc
|
101
95
|
- !ruby/object:Gem::Dependency
|
102
|
-
name:
|
96
|
+
name: retryable
|
103
97
|
requirement: !ruby/object:Gem::Requirement
|
104
98
|
requirements:
|
105
|
-
- - "
|
99
|
+
- - "~>"
|
106
100
|
- !ruby/object:Gem::Version
|
107
|
-
version: '0'
|
101
|
+
version: '3.0'
|
108
102
|
type: :runtime
|
109
103
|
prerelease: false
|
110
104
|
version_requirements: !ruby/object:Gem::Requirement
|
111
105
|
requirements:
|
112
|
-
- - "
|
106
|
+
- - "~>"
|
113
107
|
- !ruby/object:Gem::Version
|
114
|
-
version: '0'
|
108
|
+
version: '3.0'
|
115
109
|
- !ruby/object:Gem::Dependency
|
116
110
|
name: rspec
|
117
111
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,7 +121,7 @@ dependencies:
|
|
127
121
|
- !ruby/object:Gem::Version
|
128
122
|
version: '0'
|
129
123
|
- !ruby/object:Gem::Dependency
|
130
|
-
name:
|
124
|
+
name: rspec_honeycomb_formatter
|
131
125
|
requirement: !ruby/object:Gem::Requirement
|
132
126
|
requirements:
|
133
127
|
- - ">="
|
@@ -141,19 +135,25 @@ dependencies:
|
|
141
135
|
- !ruby/object:Gem::Version
|
142
136
|
version: '0'
|
143
137
|
- !ruby/object:Gem::Dependency
|
144
|
-
name:
|
138
|
+
name: tty-spinner
|
145
139
|
requirement: !ruby/object:Gem::Requirement
|
146
140
|
requirements:
|
147
141
|
- - ">="
|
148
142
|
- !ruby/object:Gem::Version
|
149
|
-
version:
|
143
|
+
version: 0.5.0
|
144
|
+
- - "<"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: 1.0.0
|
150
147
|
type: :runtime
|
151
148
|
prerelease: false
|
152
149
|
version_requirements: !ruby/object:Gem::Requirement
|
153
150
|
requirements:
|
154
151
|
- - ">="
|
155
152
|
- !ruby/object:Gem::Version
|
156
|
-
version:
|
153
|
+
version: 0.5.0
|
154
|
+
- - "<"
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: 1.0.0
|
157
157
|
description: " Providing a simple command line tool for puppet content creators,
|
158
158
|
to enable simple and complex test deployments.\n"
|
159
159
|
email:
|
@@ -202,30 +202,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
202
202
|
requirements:
|
203
203
|
- - ">="
|
204
204
|
- !ruby/object:Gem::Version
|
205
|
-
version: 2.
|
205
|
+
version: 2.7.0
|
206
206
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
207
|
requirements:
|
208
|
-
- - "
|
208
|
+
- - ">"
|
209
209
|
- !ruby/object:Gem::Version
|
210
|
-
version:
|
210
|
+
version: 1.3.1
|
211
211
|
requirements: []
|
212
212
|
rubygems_version: 3.1.6
|
213
213
|
signing_key:
|
214
214
|
specification_version: 4
|
215
215
|
summary: Providing a simple command line tool for puppet content creators, to enable
|
216
216
|
simple and complex test deployments.
|
217
|
-
test_files:
|
218
|
-
- spec/spec_helper.rb
|
219
|
-
- spec/support/inventory.rb
|
220
|
-
- spec/support/inventorytesting.yaml
|
221
|
-
- spec/lib/puppet_litmus/rake_tasks_spec.rb
|
222
|
-
- spec/lib/puppet_litmus/puppet_litmus_version_spec.rb
|
223
|
-
- spec/lib/puppet_litmus/util_spec.rb
|
224
|
-
- spec/lib/puppet_litmus/inventory_manipulation_spec.rb
|
225
|
-
- spec/lib/puppet_litmus/rake_helper_spec.rb
|
226
|
-
- spec/lib/puppet_litmus/puppet_helpers_spec.rb
|
227
|
-
- spec/exe/fake_metadata.json
|
228
|
-
- spec/exe/matrix_from_metadata_v2_spec.rb
|
229
|
-
- spec/data/doot.tar.gz
|
230
|
-
- spec/data/jim.yaml
|
231
|
-
- spec/data/inventory.yaml
|
217
|
+
test_files: []
|