puppet_litmus 0.19.0 → 0.20.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f012bba513b46a7010b134d2ca78b733c9bdad8320e13798a4439ae1a7b43e3
|
4
|
+
data.tar.gz: da8f952b4faf060ffe4ec4913235e065a17019ede06437dddb0077a123d61149
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1889d8192777dfb2e2a006c96c549e58b6c080d59a8c0279bf66ce07d048ebb03e5ce4cc694bb24e20ad37560bb19e2112e7030dad57dab8c9b8d142b1046f21
|
7
|
+
data.tar.gz: ffe79dd1557c4d40bc9f04eb737964cadd807c8b4f72a3615e1d13b7d6fb5e15c7c5cc8732f8e6b57aa8a36d8d370c83b6ae571ad68cfe217751cee3db3824a0
|
@@ -262,7 +262,12 @@ module PuppetLitmus::InventoryManipulation
|
|
262
262
|
# @param inventory_hash [Hash] hash of the inventory.yaml file
|
263
263
|
# @param node_name [String] node of nodes to limit the search for the node_name in
|
264
264
|
def add_platform_field(inventory_hash, node_name)
|
265
|
-
facts =
|
265
|
+
facts = begin
|
266
|
+
facts_from_node(inventory_hash, node_name)
|
267
|
+
rescue StandardError => e
|
268
|
+
warn e
|
269
|
+
{}
|
270
|
+
end
|
266
271
|
Honeycomb.current_span.add_field('litmus.platform', facts&.dig('platform'))
|
267
272
|
end
|
268
273
|
end
|
@@ -192,7 +192,6 @@ module PuppetLitmus::RakeHelper
|
|
192
192
|
params = if collection.nil?
|
193
193
|
{}
|
194
194
|
else
|
195
|
-
Honeycomb.current_span.add_field('litmus.collection', collection)
|
196
195
|
{ 'collection' => collection }
|
197
196
|
end
|
198
197
|
raise "puppet_agent was not found in #{DEFAULT_CONFIG_DATA['modulepath']}, please amend the .fixtures.yml file" \
|
@@ -336,19 +335,24 @@ module PuppetLitmus::RakeHelper
|
|
336
335
|
ENV['HTTP_X_HONEYCOMB_TRACE'] = span.to_trace_header
|
337
336
|
# if we're only checking connectivity for a single node
|
338
337
|
if target_node_name
|
339
|
-
span.add_field('litmus.
|
338
|
+
span.add_field('litmus.target_node_name', target_node_name)
|
340
339
|
add_platform_field(inventory_hash, target_node_name)
|
341
340
|
end
|
342
341
|
|
343
342
|
include ::BoltSpec::Run
|
344
343
|
target_nodes = find_targets(inventory_hash, target_node_name)
|
344
|
+
puts "Checking connectivity for #{target_nodes.inspect}"
|
345
|
+
span.add_field('litmus.target_nodes', target_nodes)
|
346
|
+
|
345
347
|
results = run_command('cd .', target_nodes, config: nil, inventory: inventory_hash)
|
346
348
|
span.add_field('litmus.bolt_result', results)
|
347
349
|
failed = []
|
348
|
-
results.each do |result|
|
349
|
-
|
350
|
+
results.reject { |r| r['status'] == 'success' }.each do |result|
|
351
|
+
puts "Failure connecting to #{result['target']}:\n#{result.inspect}"
|
352
|
+
failed.push(result['target'])
|
350
353
|
end
|
351
|
-
span.add_field('litmus.
|
354
|
+
span.add_field('litmus.connectivity_success', results.select { |r| r['status'] == 'success' })
|
355
|
+
span.add_field('litmus.connectivity_failure', results.reject { |r| r['status'] == 'success' })
|
352
356
|
raise "Connectivity has failed on: #{failed}" unless failed.length.zero?
|
353
357
|
|
354
358
|
true
|
@@ -397,4 +401,50 @@ module PuppetLitmus::RakeHelper
|
|
397
401
|
|
398
402
|
nil
|
399
403
|
end
|
404
|
+
|
405
|
+
def start_spinner(message)
|
406
|
+
if (ENV['CI'] || '').downcase == 'true'
|
407
|
+
puts message
|
408
|
+
spinner = Thread.new do
|
409
|
+
# CI systems are strange beasts, we only output a '.' every wee while to keep the terminal alive.
|
410
|
+
loop do
|
411
|
+
printf '.'
|
412
|
+
sleep(10)
|
413
|
+
end
|
414
|
+
end
|
415
|
+
else
|
416
|
+
require 'tty-spinner'
|
417
|
+
spinner = TTY::Spinner.new("[:spinner] #{message}")
|
418
|
+
spinner.auto_spin
|
419
|
+
end
|
420
|
+
spinner
|
421
|
+
end
|
422
|
+
|
423
|
+
def stop_spinner(spinner)
|
424
|
+
if (ENV['CI'] || '').downcase == 'true'
|
425
|
+
Thread.kill(spinner)
|
426
|
+
else
|
427
|
+
spinner.success
|
428
|
+
end
|
429
|
+
end
|
430
|
+
|
431
|
+
require 'retryable'
|
432
|
+
|
433
|
+
Retryable.configure do |config|
|
434
|
+
config.sleep = ->(n) { (1.5**n) + Random.rand(0.5) }
|
435
|
+
# config.log_method = ->(retries, exception) do
|
436
|
+
# Logger.new($stdout).debug("[Attempt ##{retries}] Retrying because [#{exception.class} - #{exception.message}]: #{exception.backtrace.first(5).join(' | ')}")
|
437
|
+
# end
|
438
|
+
end
|
439
|
+
|
440
|
+
class LitmusTimeoutError < StandardError; end
|
441
|
+
|
442
|
+
def with_retries(options: { tries: Float::INFINITY }, max_wait_minutes: 5)
|
443
|
+
stop = Time.now + (max_wait_minutes * 60)
|
444
|
+
Retryable.retryable(options.merge(not: [LitmusTimeoutError])) do
|
445
|
+
raise LitmusTimeoutError if Time.now > stop
|
446
|
+
|
447
|
+
yield
|
448
|
+
end
|
449
|
+
end
|
400
450
|
end
|
@@ -36,24 +36,11 @@ namespace :litmus do
|
|
36
36
|
results = []
|
37
37
|
failed_image_message = ''
|
38
38
|
provision_hash[args[:key]]['images'].each do |image|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
46
|
-
else
|
47
|
-
require 'tty-spinner'
|
48
|
-
spinner = TTY::Spinner.new("Provisioning #{image} using #{provisioner} provisioner.[:spinner]")
|
49
|
-
spinner.auto_spin
|
50
|
-
end
|
51
|
-
result = provision(provisioner, image, inventory_vars)
|
52
|
-
|
53
|
-
if (ENV['CI'] == 'true') || !ENV['DISTELLI_BUILDNUM'].nil?
|
54
|
-
Thread.kill(progress)
|
55
|
-
else
|
56
|
-
spinner.success
|
39
|
+
begin
|
40
|
+
spinner = start_spinner("Provisioning #{image} using #{provisioner} provisioner.")
|
41
|
+
result = provision(provisioner, image, inventory_vars)
|
42
|
+
ensure
|
43
|
+
stop_spinner(spinner)
|
57
44
|
end
|
58
45
|
|
59
46
|
if result.first['status'] != 'success'
|
@@ -74,28 +61,35 @@ namespace :litmus do
|
|
74
61
|
desc 'provision a test system using the given provisioner and platform name. See the puppetlabs-provision module tasks for more documentation'
|
75
62
|
task :provision, [:provisioner, :platform, :inventory_vars] do |_task, args|
|
76
63
|
Rake::Task['spec_prep'].invoke
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
64
|
+
|
65
|
+
begin
|
66
|
+
spinner = start_spinner("Provisioning #{args[:platform]} using #{args[:provisioner]} provisioner.")
|
67
|
+
|
68
|
+
results = provision(args[:provisioner], args[:platform], args[:inventory_vars])
|
69
|
+
|
70
|
+
unless results.first['status'] == 'success'
|
71
|
+
raise "Failed provisioning #{args[:platform]} using #{args[:provisioner]}\n#{results.first}"
|
72
|
+
end
|
73
|
+
|
74
|
+
puts "Successfully provisioned #{args[:platform]} using #{args[:provisioner]}\n"
|
75
|
+
|
76
|
+
target_names = if results.first['value']['node']
|
77
|
+
[results.first['value']['node']['uri']]
|
78
|
+
else
|
79
|
+
results.first['value']['target_names'] || [] # provision_service multi-node provisioning
|
80
|
+
end
|
81
|
+
target_names.each do |target|
|
82
|
+
Honeycomb.start_span(name: 'litmus.provision.check_connectivity') do |span|
|
83
|
+
span.add_field('target_name', target)
|
84
|
+
with_retries do
|
85
|
+
check_connectivity?(inventory_hash_from_inventory_file, target)
|
86
|
+
end
|
82
87
|
end
|
83
88
|
end
|
84
|
-
|
85
|
-
|
86
|
-
spinner = TTY::Spinner.new("Provisioning #{args[:platform]} using #{args[:provisioner]} provisioner.[:spinner]")
|
87
|
-
spinner.auto_spin
|
88
|
-
end
|
89
|
-
results = provision(args[:provisioner], args[:platform], args[:inventory_vars])
|
90
|
-
if results.first['status'] != 'success'
|
91
|
-
raise "Failed provisioning #{args[:platform]} using #{args[:provisioner]}\n#{results.first}"
|
89
|
+
ensure
|
90
|
+
stop_spinner(spinner)
|
92
91
|
end
|
93
92
|
|
94
|
-
if (ENV['CI'] == 'true') || !ENV['DISTELLI_BUILDNUM'].nil?
|
95
|
-
Thread.kill(progress)
|
96
|
-
else
|
97
|
-
spinner.success
|
98
|
-
end
|
99
93
|
puts "#{results.first['value']['node_name']}, #{args[:platform]}"
|
100
94
|
end
|
101
95
|
|
@@ -134,8 +128,10 @@ namespace :litmus do
|
|
134
128
|
puts "ERROR:#{e}"
|
135
129
|
# fix the path
|
136
130
|
path_changes = configure_path(inventory_hash)
|
137
|
-
|
138
|
-
|
131
|
+
if ENV['DEBUG'] == true
|
132
|
+
path_changes.each do |change|
|
133
|
+
puts "Configuring puppet path result: #{change.inspect}"
|
134
|
+
end
|
139
135
|
end
|
140
136
|
|
141
137
|
retries += 1
|
@@ -362,7 +358,7 @@ namespace :litmus do
|
|
362
358
|
success_list = []
|
363
359
|
failure_list = []
|
364
360
|
# Provision targets depending on what environment we're in
|
365
|
-
if
|
361
|
+
if ENV['CI'] == 'true'
|
366
362
|
# CI systems are strange beasts, we only output a '.' every wee while to keep the terminal alive.
|
367
363
|
puts "Running against #{targets.size} targets.\n"
|
368
364
|
progress = Thread.new do
|
@@ -68,6 +68,9 @@ describe 'litmus rake tasks' do
|
|
68
68
|
|
69
69
|
allow(File).to receive(:directory?).with(any_args).and_return(true)
|
70
70
|
allow_any_instance_of(BoltSpec::Run).to receive(:run_task).with(any_args).and_return(results)
|
71
|
+
expect_any_instance_of(PuppetLitmus::InventoryManipulation).to receive(:inventory_hash_from_inventory_file).and_return({})
|
72
|
+
allow_any_instance_of(PuppetLitmus::RakeHelper).to receive(:check_connectivity?).with(any_args).and_return(true)
|
73
|
+
expect($stdout).to receive(:puts).with("Successfully provisioned centos:7 using docker\n")
|
71
74
|
expect($stdout).to receive(:puts).with('localhost:2222, centos:7')
|
72
75
|
Rake::Task['litmus:provision'].invoke('docker', 'centos:7')
|
73
76
|
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: 0.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet, Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bolt
|
@@ -90,6 +90,20 @@ dependencies:
|
|
90
90
|
- - "<"
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: 3.0.0
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: retryable
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - "~>"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '3.0'
|
100
|
+
type: :runtime
|
101
|
+
prerelease: false
|
102
|
+
version_requirements: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - "~>"
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '3.0'
|
93
107
|
- !ruby/object:Gem::Dependency
|
94
108
|
name: parallel
|
95
109
|
requirement: !ruby/object:Gem::Requirement
|
@@ -180,7 +194,7 @@ homepage: https://github.com/puppetlabs/puppet_litmus
|
|
180
194
|
licenses:
|
181
195
|
- Apache-2.0
|
182
196
|
metadata: {}
|
183
|
-
post_install_message:
|
197
|
+
post_install_message:
|
184
198
|
rdoc_options: []
|
185
199
|
require_paths:
|
186
200
|
- lib
|
@@ -196,18 +210,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
210
|
version: '0'
|
197
211
|
requirements: []
|
198
212
|
rubygems_version: 3.1.4
|
199
|
-
signing_key:
|
213
|
+
signing_key:
|
200
214
|
specification_version: 4
|
201
215
|
summary: Providing a simple command line tool for puppet content creators, to enable
|
202
216
|
simple and complex test deployments.
|
203
217
|
test_files:
|
204
|
-
- spec/
|
205
|
-
- spec/
|
206
|
-
- spec/
|
218
|
+
- spec/data/doot.tar.gz
|
219
|
+
- spec/data/inventory.yaml
|
220
|
+
- spec/data/jim.yaml
|
207
221
|
- spec/lib/puppet_litmus/util_spec.rb
|
222
|
+
- spec/lib/puppet_litmus/version_spec.rb
|
208
223
|
- spec/lib/puppet_litmus/inventory_manipulation_spec.rb
|
209
224
|
- spec/lib/puppet_litmus/rake_helper_spec.rb
|
210
225
|
- spec/lib/puppet_litmus/puppet_helpers_spec.rb
|
211
|
-
- spec/
|
212
|
-
- spec/
|
213
|
-
- spec/data/inventory.yaml
|
226
|
+
- spec/lib/puppet_litmus/rake_tasks_spec.rb
|
227
|
+
- spec/spec_helper.rb
|