puppet_litmus 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,53 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'bolt_spec/run'
4
- require 'honeycomb-beeline'
5
4
  require 'puppet_litmus/version'
6
- Honeycomb.configure do |config|
7
- # override client if no configuration is provided, so that the pesky libhoney warning about lack of configuration is not shown
8
- config.client = Libhoney::NullClient.new unless ENV['HONEYCOMB_WRITEKEY'] && ENV['HONEYCOMB_DATASET']
9
- end
10
- process_span = Honeycomb.start_span(name: "litmus: #{([$PROGRAM_NAME] + ($ARGV || [])).join(' ')}", serialized_trace: ENV.fetch('HONEYCOMB_TRACE', nil))
11
- ENV['HONEYCOMB_TRACE'] = process_span.to_trace_header
12
- Honeycomb.add_field_to_trace('litmus.pid', Process.pid)
13
- if defined? PuppetLitmus::VERSION
14
- Honeycomb.add_field_to_trace('litmus.version', PuppetLitmus::VERSION)
15
- else
16
- Honeycomb.add_field_to_trace('litmus.version', 'undefined')
17
- end
18
- if ENV['CI'] == 'true' && ENV['TRAVIS'] == 'true'
19
- Honeycomb.add_field_to_trace('module_name', ENV.fetch('TRAVIS_REPO_SLUG', nil))
20
- Honeycomb.add_field_to_trace('ci.provider', 'travis')
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))
26
- elsif ENV['CI'] == 'True' && ENV['APPVEYOR'] == 'True'
27
- Honeycomb.add_field_to_trace('module_name', ENV.fetch('APPVEYOR_PROJECT_SLUG', nil))
28
- Honeycomb.add_field_to_trace('ci.provider', 'appveyor')
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))
34
- elsif ENV['GITHUB_ACTIONS'] == 'true'
35
- Honeycomb.add_field_to_trace('module_name', ENV.fetch('GITHUB_REPOSITORY', nil))
36
- Honeycomb.add_field_to_trace('ci.provider', 'github')
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))
40
- end
41
- at_exit do
42
- if $ERROR_INFO.is_a?(SystemExit)
43
- process_span.add_field('process.exit_code', $ERROR_INFO.status)
44
- elsif $ERROR_INFO
45
- process_span.add_field('process.exit_code', $ERROR_INFO.class.name)
46
- else
47
- process_span.add_field('process.exit_code', 'unknown')
48
- end
49
- process_span.send
50
- end
51
5
 
52
6
  # helper methods for the litmus rake tasks
53
7
  module PuppetLitmus::RakeHelper
@@ -100,18 +54,13 @@ module PuppetLitmus::RakeHelper
100
54
  # @param command [String] command to execute.
101
55
  # @return [Object] the standard out stream.
102
56
  def run_local_command(command)
103
- Honeycomb.start_span(name: 'litmus.run_local_command') do |span|
104
- ENV['HONEYCOMB_TRACE'] = span.to_trace_header
105
- span.add_field('litmus.command', command)
57
+ require 'open3'
58
+ stdout, stderr, status = Open3.capture3(command)
59
+ error_message = "Attempted to run\ncommand:'#{command}'\nstdout:#{stdout}\nstderr:#{stderr}"
106
60
 
107
- require 'open3'
108
- stdout, stderr, status = Open3.capture3(command)
109
- error_message = "Attempted to run\ncommand:'#{command}'\nstdout:#{stdout}\nstderr:#{stderr}"
61
+ raise error_message unless status.to_i.zero?
110
62
 
111
- raise error_message unless status.to_i.zero?
112
-
113
- stdout
114
- end
63
+ stdout
115
64
  end
116
65
 
117
66
  def provision(provisioner, platform, inventory_vars)
@@ -122,24 +71,11 @@ module PuppetLitmus::RakeHelper
122
71
  params = { 'action' => 'provision', 'platform' => platform, 'inventory' => Dir.pwd }
123
72
  params['vars'] = inventory_vars unless inventory_vars.nil?
124
73
 
125
- Honeycomb.add_field_to_trace('litmus.provisioner', provisioner)
126
- Honeycomb.start_span(name: 'litmus.provision') do |span|
127
- ENV['HONEYCOMB_TRACE'] = span.to_trace_header
128
- span.add_field('litmus.platform', platform)
129
-
130
- task_name = provisioner_task(provisioner)
131
- span.add_field('litmus.task_name', task_name)
132
- span.add_field('litmus.params', params)
133
- span.add_field('litmus.config', DEFAULT_CONFIG_DATA)
134
-
135
- bolt_result = run_task(task_name, 'localhost', params, config: DEFAULT_CONFIG_DATA, inventory: nil)
136
- span.add_field('litmus.result', bolt_result)
137
- span.add_field('litmus.node_name', bolt_result&.first&.dig('value', 'node_name'))
74
+ task_name = provisioner_task(provisioner)
75
+ bolt_result = run_task(task_name, 'localhost', params, config: DEFAULT_CONFIG_DATA, inventory: nil)
76
+ raise_bolt_errors(bolt_result, "provisioning of #{platform} failed.")
138
77
 
139
- raise_bolt_errors(bolt_result, "provisioning of #{platform} failed.")
140
-
141
- bolt_result
142
- end
78
+ bolt_result
143
79
  end
144
80
 
145
81
  def provision_list(provision_hash, key)
@@ -149,7 +85,6 @@ module PuppetLitmus::RakeHelper
149
85
  provision_hash[key]['params']&.each { |k, value| ENV[k.upcase] = value.to_s }
150
86
  results = []
151
87
 
152
- Honeycomb.current_span.add_field('litmus.images', provision_hash[key]['images'])
153
88
  provision_hash[key]['images'].each do |image|
154
89
  results << provision(provisioner, image, inventory_vars)
155
90
  end
@@ -157,73 +92,57 @@ module PuppetLitmus::RakeHelper
157
92
  end
158
93
 
159
94
  def tear_down_nodes(targets, inventory_hash)
160
- Honeycomb.start_span(name: 'litmus.tear_down_nodes') do |span|
161
- ENV['HONEYCOMB_TRACE'] = span.to_trace_header
162
- span.add_field('litmus.targets', targets)
163
-
164
- include ::BoltSpec::Run
165
- config_data = { 'modulepath' => File.join(Dir.pwd, 'spec', 'fixtures', 'modules') }
166
- raise "the provision module was not found in #{config_data['modulepath']}, please amend the .fixtures.yml file" unless File.directory?(File.join(config_data['modulepath'], 'provision'))
167
-
168
- results = {}
169
- targets.each do |node_name|
170
- next if node_name == 'litmus_localhost'
171
-
172
- result = tear_down(node_name, inventory_hash)
173
- # Some provisioners tear_down targets that were created as a batch job.
174
- # These provisioners should return the list of additional targets
175
- # removed so that we do not attempt to process them.
176
- if result != [] && result[0]['value'].key?('removed')
177
- removed_targets = result[0]['value']['removed']
178
- result[0]['value'].delete('removed')
179
- removed_targets.each do |removed_target|
180
- targets.delete(removed_target)
181
- results[removed_target] = result
182
- end
95
+ include ::BoltSpec::Run
96
+ config_data = { 'modulepath' => File.join(Dir.pwd, 'spec', 'fixtures', 'modules') }
97
+ raise "the provision module was not found in #{config_data['modulepath']}, please amend the .fixtures.yml file" unless File.directory?(File.join(config_data['modulepath'], 'provision'))
98
+
99
+ results = {}
100
+ targets.each do |node_name|
101
+ next if node_name == 'litmus_localhost'
102
+
103
+ result = tear_down(node_name, inventory_hash)
104
+ # Some provisioners tear_down targets that were created as a batch job.
105
+ # These provisioners should return the list of additional targets
106
+ # removed so that we do not attempt to process them.
107
+ if result != [] && result[0]['value'].key?('removed')
108
+ removed_targets = result[0]['value']['removed']
109
+ result[0]['value'].delete('removed')
110
+ removed_targets.each do |removed_target|
111
+ targets.delete(removed_target)
112
+ results[removed_target] = result
183
113
  end
184
-
185
- results[node_name] = result unless result == []
186
114
  end
187
- results
115
+
116
+ results[node_name] = result unless result == []
188
117
  end
118
+ results
189
119
  end
190
120
 
191
121
  def tear_down(node_name, inventory_hash)
192
- Honeycomb.start_span(name: 'litmus.tear_down') do |span|
193
- ENV['HONEYCOMB_TRACE'] = span.to_trace_header
194
- # how do we know what provisioner to use
195
-
196
- span.add_field('litmus.node_name', node_name)
197
- add_platform_field(inventory_hash, node_name)
198
-
199
- params = { 'action' => 'tear_down', 'node_name' => node_name, 'inventory' => Dir.pwd }
200
- node_facts = facts_from_node(inventory_hash, node_name)
201
- bolt_result = run_task(provisioner_task(node_facts['provisioner']), 'localhost', params, config: DEFAULT_CONFIG_DATA, inventory: nil)
202
- raise_bolt_errors(bolt_result, "tear_down of #{node_name} failed.")
203
- bolt_result
204
- end
122
+ # how do we know what provisioner to use
123
+ add_platform_field(inventory_hash, node_name)
124
+
125
+ params = { 'action' => 'tear_down', 'node_name' => node_name, 'inventory' => Dir.pwd }
126
+ node_facts = facts_from_node(inventory_hash, node_name)
127
+ bolt_result = run_task(provisioner_task(node_facts['provisioner']), 'localhost', params, config: DEFAULT_CONFIG_DATA, inventory: nil)
128
+ raise_bolt_errors(bolt_result, "tear_down of #{node_name} failed.")
129
+ bolt_result
205
130
  end
206
131
 
207
132
  def install_agent(collection, targets, inventory_hash)
208
- Honeycomb.start_span(name: 'litmus.install_agent') do |span|
209
- ENV['HONEYCOMB_TRACE'] = span.to_trace_header
210
- span.add_field('litmus.collection', collection)
211
- span.add_field('litmus.targets', targets)
212
-
213
- include ::BoltSpec::Run
214
- params = if collection.nil?
215
- {}
216
- else
217
- { 'collection' => collection }
218
- end
219
- raise "puppet_agent was not found in #{DEFAULT_CONFIG_DATA['modulepath']}, please amend the .fixtures.yml file" \
220
- unless File.directory?(File.join(DEFAULT_CONFIG_DATA['modulepath'], 'puppet_agent'))
221
-
222
- # using boltspec, when the runner is called it changes the inventory_hash dropping the version field. The clone works around this
223
- bolt_result = run_task('puppet_agent::install', targets, params, config: DEFAULT_CONFIG_DATA, inventory: inventory_hash.clone)
224
- raise_bolt_errors(bolt_result, 'Installation of agent failed.')
225
- bolt_result
226
- end
133
+ include ::BoltSpec::Run
134
+ params = if collection.nil?
135
+ {}
136
+ else
137
+ { 'collection' => collection }
138
+ end
139
+ raise "puppet_agent was not found in #{DEFAULT_CONFIG_DATA['modulepath']}, please amend the .fixtures.yml file" \
140
+ unless File.directory?(File.join(DEFAULT_CONFIG_DATA['modulepath'], 'puppet_agent'))
141
+
142
+ # using boltspec, when the runner is called it changes the inventory_hash dropping the version field. The clone works around this
143
+ bolt_result = run_task('puppet_agent::install', targets, params, config: DEFAULT_CONFIG_DATA, inventory: inventory_hash.clone)
144
+ raise_bolt_errors(bolt_result, 'Installation of agent failed.')
145
+ bolt_result
227
146
  end
228
147
 
229
148
  def configure_path(inventory_hash)
@@ -297,32 +216,24 @@ module PuppetLitmus::RakeHelper
297
216
  # @param ignore_dependencies [Boolean] flag used to ignore module dependencies defaults to false.
298
217
  # @return a bolt result
299
218
  def install_module(inventory_hash, target_node_name, module_tar, module_repository = nil, ignore_dependencies = false) # rubocop:disable Style/OptionalBooleanParameter
300
- Honeycomb.start_span(name: 'install_module') do |span|
301
- ENV['HONEYCOMB_TRACE'] = span.to_trace_header
302
- span.add_field('litmus.target_node_name', target_node_name)
303
- span.add_field('litmus.module_tar', module_tar)
304
-
305
- # make sure the module to install is not installed
306
- # otherwise `puppet module install` might silently skip it
307
- module_name = File.basename(module_tar, '.tar.gz').split('-', 3)[0..1].join('-')
308
- uninstall_module(inventory_hash.clone, target_node_name, module_name, force: true)
309
-
310
- include ::BoltSpec::Run
311
-
312
- target_nodes = find_targets(inventory_hash, target_node_name)
313
- span.add_field('litmus.target_nodes', target_nodes)
314
- bolt_result = upload_file(module_tar, File.basename(module_tar), target_nodes, options: {}, config: nil, inventory: inventory_hash.clone)
315
- raise_bolt_errors(bolt_result, 'Failed to upload module.')
316
-
317
- module_repository_opts = "--module_repository '#{module_repository}'" unless module_repository.nil?
318
- install_module_command = "puppet module install #{module_repository_opts} #{File.basename(module_tar)}"
319
- install_module_command += ' --ignore-dependencies --force' if ignore_dependencies.to_s.casecmp('true').zero?
320
- span.add_field('litmus.install_module_command', install_module_command)
321
-
322
- bolt_result = run_command(install_module_command, target_nodes, config: nil, inventory: inventory_hash.clone)
323
- raise_bolt_errors(bolt_result, "Installation of package #{File.basename(module_tar)} failed.")
324
- bolt_result
325
- end
219
+ # make sure the module to install is not installed
220
+ # otherwise `puppet module install` might silently skip it
221
+ module_name = File.basename(module_tar, '.tar.gz').split('-', 3)[0..1].join('-')
222
+ uninstall_module(inventory_hash.clone, target_node_name, module_name, force: true)
223
+
224
+ include ::BoltSpec::Run
225
+
226
+ target_nodes = find_targets(inventory_hash, target_node_name)
227
+ bolt_result = upload_file(module_tar, File.basename(module_tar), target_nodes, options: {}, config: nil, inventory: inventory_hash.clone)
228
+ raise_bolt_errors(bolt_result, 'Failed to upload module.')
229
+
230
+ module_repository_opts = "--module_repository '#{module_repository}'" unless module_repository.nil?
231
+ install_module_command = "puppet module install #{module_repository_opts} #{File.basename(module_tar)}"
232
+ install_module_command += ' --ignore-dependencies --force' if ignore_dependencies.to_s.casecmp('true').zero?
233
+
234
+ bolt_result = run_command(install_module_command, target_nodes, config: nil, inventory: inventory_hash.clone)
235
+ raise_bolt_errors(bolt_result, "Installation of package #{File.basename(module_tar)} failed.")
236
+ bolt_result
326
237
  end
327
238
 
328
239
  def metadata_module_name
@@ -353,33 +264,23 @@ module PuppetLitmus::RakeHelper
353
264
  end
354
265
 
355
266
  def check_connectivity?(inventory_hash, target_node_name)
356
- Honeycomb.start_span(name: 'litmus.check_connectivity') do |span|
357
- ENV['HONEYCOMB_TRACE'] = span.to_trace_header
358
- # if we're only checking connectivity for a single node
359
- if target_node_name
360
- span.add_field('litmus.target_node_name', target_node_name)
361
- add_platform_field(inventory_hash, target_node_name)
362
- end
267
+ # if we're only checking connectivity for a single node
268
+ add_platform_field(inventory_hash, target_node_name) if target_node_name
363
269
 
364
- include ::BoltSpec::Run
365
- target_nodes = find_targets(inventory_hash, target_node_name)
366
- puts "Checking connectivity for #{target_nodes.inspect}"
367
- span.add_field('litmus.target_nodes', target_nodes)
368
-
369
- results = run_command('cd .', target_nodes, config: nil, inventory: inventory_hash)
370
- span.add_field('litmus.bolt_result', results)
371
- failed = []
372
- results.reject { |r| r['status'] == 'success' }.each do |result|
373
- puts "Failure connecting to #{result['target']}:\n#{result.inspect}"
374
- failed.push(result['target'])
375
- end
376
- span.add_field('litmus.connectivity_success', results.select { |r| r['status'] == 'success' })
377
- span.add_field('litmus.connectivity_failure', results.reject { |r| r['status'] == 'success' })
378
- raise "Connectivity has failed on: #{failed}" unless failed.empty?
270
+ include ::BoltSpec::Run
271
+ target_nodes = find_targets(inventory_hash, target_node_name)
272
+ puts "Checking connectivity for #{target_nodes.inspect}"
379
273
 
380
- puts 'Connectivity check PASSED.'
381
- true
274
+ results = run_command('cd .', target_nodes, config: nil, inventory: inventory_hash)
275
+ failed = []
276
+ results.reject { |r| r['status'] == 'success' }.each do |result|
277
+ puts "Failure connecting to #{result['target']}:\n#{result.inspect}"
278
+ failed.push(result['target'])
382
279
  end
280
+ raise "Connectivity has failed on: #{failed}" unless failed.empty?
281
+
282
+ puts 'Connectivity check PASSED.'
283
+ true
383
284
  end
384
285
 
385
286
  def provisioner_task(provisioner)
@@ -90,11 +90,8 @@ namespace :litmus do
90
90
  results.first['value']['target_names'] || [] # provision_service multi-node provisioning
91
91
  end
92
92
  target_names.each do |target|
93
- Honeycomb.start_span(name: 'litmus.provision.check_connectivity') do |span|
94
- span.add_field('target_name', target)
95
- with_retries do
96
- check_connectivity?(inventory_hash_from_inventory_file, target)
97
- end
93
+ with_retries do
94
+ check_connectivity?(inventory_hash_from_inventory_file, target)
98
95
  end
99
96
  end
100
97
  ensure
@@ -355,7 +352,7 @@ namespace :litmus do
355
352
  payloads = []
356
353
  # Generate list of targets to provision
357
354
  targets.each do |target|
358
- test = "bundle exec rspec ./spec/acceptance #{tag_value} --format progress --require rspec_honeycomb_formatter --format RSpecHoneycombFormatter"
355
+ test = "bundle exec rspec ./spec/acceptance #{tag_value} --format progress"
359
356
  title = "#{target}, #{facts_from_node(inventory_hash, target)['platform']}"
360
357
  options = {
361
358
  env: {
@@ -386,7 +383,6 @@ namespace :litmus do
386
383
  at_exit { exit! }
387
384
 
388
385
  env = options[:env].nil? ? {} : options[:env]
389
- env['HONEYCOMB_TRACE'] = Honeycomb.current_span.to_trace_header
390
386
  stdout, stderr, status = Open3.capture3(env, test)
391
387
  ["\n================\n#{title}\n", stdout, stderr, status]
392
388
  end
@@ -404,7 +400,6 @@ namespace :litmus do
404
400
  spinners = TTY::Spinner::Multi.new("[:spinner] Running against #{targets.size} targets.")
405
401
  payloads.each do |title, test, options|
406
402
  env = options[:env].nil? ? {} : options[:env]
407
- env['HONEYCOMB_TRACE'] = Honeycomb.current_span.to_trace_header
408
403
  spinners.register("[:spinner] #{title}") do |sp|
409
404
  stdout, stderr, status = Open3.capture3(env, test)
410
405
  if status.to_i.zero?
@@ -2,5 +2,5 @@
2
2
 
3
3
  # version of this gem
4
4
  module PuppetLitmus
5
- VERSION = '1.0.1'
5
+ VERSION = '1.0.3'
6
6
  end
@@ -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.0","ruby_version":2.7},{"puppet_version":"https://github.com/puppetlabs/puppet","ruby_version":3.2}]}'
36
+ 'spec_matrix={"include":[{"puppet_version":"~> 7.24","ruby_version":2.7},{"puppet_version":"~> 8.0","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.0","ruby_version":2.7},{"puppet_version":"https://github.com/puppetlabs/puppet","ruby_version":3.2}]}'
72
+ 'spec_matrix={"include":[{"puppet_version":"~> 7.24","ruby_version":2.7},{"puppet_version":"~> 8.0","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.0","ruby_version":2.7},{"puppet_version":"https://github.com/puppetlabs/puppet","ruby_version":3.2}]}'
108
+ 'spec_matrix={"include":[{"puppet_version":"~> 7.24","ruby_version":2.7},{"puppet_version":"~> 8.0","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
@@ -41,7 +41,6 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
41
41
  it 'passes the --hiera_config flag if the :hiera_config opt is specified' do
42
42
  expect(File).to receive(:exist?).with('spec/fixtures/litmus_inventory.yaml').and_return(false)
43
43
  expect(self).to receive(:target_in_inventory?).and_return(true)
44
- expect(self).to receive(:target_in_inventory?).and_return(true)
45
44
  expect(self).to receive(:create_manifest_file).with(manifest).and_return('/bla.pp')
46
45
  expect(self).to receive(:run_command).with(command, 'litmus_localhost', config: nil, inventory: localhost_inventory_hash).and_return(result)
47
46
  apply_manifest(manifest, hiera_config: '/hiera.yaml')
@@ -61,7 +60,6 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
61
60
  it 'uses detailed-exitcodes with expect_failures' do
62
61
  expect(File).to receive(:exist?).with('spec/fixtures/litmus_inventory.yaml').and_return(false)
63
62
  expect(self).to receive(:target_in_inventory?).and_return(true)
64
- expect(self).to receive(:target_in_inventory?).and_return(true)
65
63
  expect(self).to receive(:create_manifest_file).with(manifest).and_return('/bla.pp')
66
64
  expect(self).to receive(:run_command).with(command, 'litmus_localhost', config: nil, inventory: localhost_inventory_hash).and_return(result)
67
65
  expect { apply_manifest(manifest, expect_failures: true) }.to raise_error(RuntimeError)
@@ -70,7 +68,6 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
70
68
  it 'uses detailed-exitcodes with catch_failures' do
71
69
  expect(File).to receive(:exist?).with('spec/fixtures/litmus_inventory.yaml').and_return(false)
72
70
  expect(self).to receive(:target_in_inventory?).and_return(true)
73
- expect(self).to receive(:target_in_inventory?).and_return(true)
74
71
  expect(self).to receive(:create_manifest_file).with(manifest).and_return('/bla.pp')
75
72
  expect(self).to receive(:run_command).with(command, 'litmus_localhost', config: nil, inventory: localhost_inventory_hash).and_return(result)
76
73
  apply_manifest(manifest, catch_failures: true)
@@ -79,7 +76,6 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
79
76
  it 'uses detailed-exitcodes with expect_changes' do
80
77
  expect(File).to receive(:exist?).with('spec/fixtures/litmus_inventory.yaml').and_return(false)
81
78
  expect(self).to receive(:target_in_inventory?).and_return(true)
82
- expect(self).to receive(:target_in_inventory?).and_return(true)
83
79
  expect(self).to receive(:create_manifest_file).with(manifest).and_return('/bla.pp')
84
80
  expect(self).to receive(:run_command).with(command, 'litmus_localhost', config: nil, inventory: localhost_inventory_hash).and_return(result)
85
81
  expect { apply_manifest(manifest, expect_changes: true) }.to raise_error(RuntimeError)
@@ -88,7 +84,6 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
88
84
  it 'uses detailed-exitcodes with catch_changes' do
89
85
  expect(File).to receive(:exist?).with('spec/fixtures/litmus_inventory.yaml').and_return(false)
90
86
  expect(self).to receive(:target_in_inventory?).and_return(true)
91
- expect(self).to receive(:target_in_inventory?).and_return(true)
92
87
  expect(self).to receive(:create_manifest_file).with(manifest).and_return('/bla.pp')
93
88
  expect(self).to receive(:run_command).with(command, 'litmus_localhost', config: nil, inventory: localhost_inventory_hash).and_return(result)
94
89
  apply_manifest(manifest, catch_changes: true)
@@ -114,7 +109,6 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
114
109
  stub_const('ENV', ENV.to_hash.merge('TARGET_HOST' => 'localhost'))
115
110
  expect(File).to receive(:exist?).with('spec/fixtures/litmus_inventory.yaml').and_return(false)
116
111
  expect(self).to receive(:target_in_inventory?).and_return(true)
117
- expect(self).to receive(:target_in_inventory?).and_return(true)
118
112
  expect(self).to receive(:run_command).with(command_to_run, 'litmus_localhost', config: nil, inventory: localhost_inventory_hash).and_return(result)
119
113
  expect { run_shell(command_to_run) }.not_to raise_error
120
114
  end
@@ -126,7 +120,6 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
126
120
  expect(File).to receive(:exist?).with('spec/fixtures/litmus_inventory.yaml').and_return(true)
127
121
  expect(self).to receive(:inventory_hash_from_inventory_file).and_return(inventory_hash)
128
122
  expect(self).to receive(:target_in_inventory?).and_return(true)
129
- expect(self).to receive(:target_in_inventory?).and_return(true)
130
123
  expect(self).to receive(:run_command).with(command_to_run, 'some.host', config: nil, inventory: inventory_hash).and_return(result)
131
124
  expect { run_shell(command_to_run) }.not_to raise_error
132
125
  end
@@ -152,7 +145,6 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
152
145
  expect(File).to receive(:exist?).with('spec/fixtures/litmus_inventory.yaml').and_return(true)
153
146
  expect(self).to receive(:inventory_hash_from_inventory_file).and_return(inventory_hash)
154
147
  expect(self).to receive(:target_in_inventory?).and_return(true)
155
- expect(self).to receive(:target_in_inventory?).and_return(true)
156
148
  expect(self).to receive(:upload_file).with(local, remote, 'some.host', options: {}, config: nil, inventory: inventory_hash).and_return(result_success)
157
149
  expect { bolt_upload_file(local, remote) }.not_to raise_error
158
150
  end
@@ -162,7 +154,6 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
162
154
  expect(File).to receive(:exist?).with('spec/fixtures/litmus_inventory.yaml').and_return(false)
163
155
  expect(self).not_to receive(:inventory_hash_from_inventory_file)
164
156
  expect(self).to receive(:target_in_inventory?).and_return(true)
165
- expect(self).to receive(:target_in_inventory?).and_return(true)
166
157
  expect(self).to receive(:upload_file).with(local, remote, 'litmus_localhost', options: {}, config: nil, inventory: localhost_inventory_hash).and_return(result_success)
167
158
  expect { bolt_upload_file(local, remote) }.not_to raise_error
168
159
  end
@@ -174,7 +165,6 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
174
165
  expect(File).to receive(:exist?).with('spec/fixtures/litmus_inventory.yaml').and_return(true)
175
166
  expect(self).to receive(:inventory_hash_from_inventory_file).and_return(inventory_hash)
176
167
  expect(self).to receive(:target_in_inventory?).and_return(true)
177
- expect(self).to receive(:target_in_inventory?).and_return(true)
178
168
  expect(self).to receive(:upload_file).with(local, remote, 'some.host', options: {}, config: nil, inventory: inventory_hash).and_return(result_failure)
179
169
  expect { bolt_upload_file(local, remote) }.to raise_error(RuntimeError, /upload file failed/)
180
170
  end
@@ -184,7 +174,6 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
184
174
  expect(File).to receive(:exist?).with('spec/fixtures/litmus_inventory.yaml').and_return(true)
185
175
  expect(self).to receive(:inventory_hash_from_inventory_file).and_return(inventory_hash)
186
176
  expect(self).to receive(:target_in_inventory?).and_return(true)
187
- expect(self).to receive(:target_in_inventory?).and_return(true)
188
177
  expect(self).to receive(:upload_file).with(local, remote, 'some.host', options: {}, config: nil, inventory: inventory_hash).and_return(result_failure)
189
178
  method_result = bolt_upload_file(local, remote, expect_failures: true)
190
179
  expect(method_result.exit_code).to be(255)
@@ -207,7 +196,6 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
207
196
  expect(File).to receive(:exist?).with('spec/fixtures/litmus_inventory.yaml').and_return(false)
208
197
  expect(self).not_to receive(:inventory_hash_from_inventory_file)
209
198
  expect(self).to receive(:target_in_inventory?).and_return(true)
210
- expect(self).to receive(:target_in_inventory?).and_return(true)
211
199
  expect(self).to receive(:run_script).with(script, 'litmus_localhost', [], options: {}, config: nil, inventory: localhost_inventory_hash).and_return(result)
212
200
  expect { bolt_run_script(script) }.not_to raise_error
213
201
  end
@@ -219,7 +207,6 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
219
207
  expect(File).to receive(:exist?).with('spec/fixtures/litmus_inventory.yaml').and_return(true)
220
208
  expect(self).to receive(:inventory_hash_from_inventory_file).and_return(inventory_hash)
221
209
  expect(self).to receive(:target_in_inventory?).and_return(true)
222
- expect(self).to receive(:target_in_inventory?).and_return(true)
223
210
  expect(self).to receive(:run_script).with(script, 'some.host', [], options: {}, config: nil, inventory: inventory_hash).and_return(result)
224
211
  expect { bolt_run_script(script) }.not_to raise_error
225
212
  end
@@ -231,7 +218,6 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
231
218
  expect(File).to receive(:exist?).with('spec/fixtures/litmus_inventory.yaml').and_return(false)
232
219
  expect(self).not_to receive(:inventory_hash_from_inventory_file)
233
220
  expect(self).to receive(:target_in_inventory?).and_return(true)
234
- expect(self).to receive(:target_in_inventory?).and_return(true)
235
221
  expect(self).to receive(:run_script).with(script, 'litmus_localhost', ['doot'], options: {}, config: nil, inventory: localhost_inventory_hash).and_return(result)
236
222
  expect { bolt_run_script(script, arguments: ['doot']) }.not_to raise_error
237
223
  end
@@ -259,7 +245,6 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
259
245
  expect(File).to receive(:exist?).with('spec/fixtures/litmus_inventory.yaml').and_return(true)
260
246
  expect(self).to receive(:inventory_hash_from_inventory_file).and_return(inventory_hash)
261
247
  expect(self).to receive(:target_in_inventory?).and_return(true)
262
- expect(self).to receive(:target_in_inventory?).and_return(true)
263
248
  expect(self).to receive(:run_task).with(task_name, 'some.host', params, config: config_data, inventory: inventory_hash).and_return(result_unstructured_task_success)
264
249
  expect { run_bolt_task(task_name, params, opts: {}) }.not_to raise_error
265
250
  end
@@ -269,7 +254,6 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
269
254
  expect(File).to receive(:exist?).with('jim.yaml').and_return(true)
270
255
  expect(self).to receive(:inventory_hash_from_inventory_file).and_return(inventory_hash)
271
256
  expect(self).to receive(:target_in_inventory?).and_return(true)
272
- expect(self).to receive(:target_in_inventory?).and_return(true)
273
257
  expect(self).to receive(:run_task).with(task_name, 'some.host', params, config: config_data, inventory: inventory_hash).and_return(result_unstructured_task_success)
274
258
  expect { run_bolt_task(task_name, params, inventory_file: 'jim.yaml') }.not_to raise_error
275
259
  end
@@ -279,7 +263,6 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
279
263
  expect(File).to receive(:exist?).with('spec/fixtures/litmus_inventory.yaml').and_return(true)
280
264
  expect(self).to receive(:inventory_hash_from_inventory_file).and_return(inventory_hash)
281
265
  expect(self).to receive(:target_in_inventory?).and_return(true)
282
- expect(self).to receive(:target_in_inventory?).and_return(true)
283
266
  expect(self).to receive(:run_task).with(task_name, 'some.host', params, config: config_data, inventory: inventory_hash).and_return(result_unstructured_task_success)
284
267
  method_result = run_bolt_task(task_name, params, opts: {})
285
268
  expect(method_result.stdout).to eq('SUCCESS!')
@@ -290,7 +273,6 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
290
273
  expect(File).to receive(:exist?).with('spec/fixtures/litmus_inventory.yaml').and_return(true)
291
274
  expect(self).to receive(:inventory_hash_from_inventory_file).and_return(inventory_hash)
292
275
  expect(self).to receive(:target_in_inventory?).and_return(true)
293
- expect(self).to receive(:target_in_inventory?).and_return(true)
294
276
  expect(self).to receive(:run_task).with(task_name, 'some.host', params, config: config_data, inventory: inventory_hash).and_return(result_structured_task_success)
295
277
  method_result = run_bolt_task(task_name, params, opts: {})
296
278
  expect(method_result.stdout).to eq('{"key1"=>"foo", "key2"=>"bar"}')
@@ -305,7 +287,6 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
305
287
  expect(File).to receive(:exist?).with('spec/fixtures/litmus_inventory.yaml').and_return(true)
306
288
  expect(self).to receive(:inventory_hash_from_inventory_file).and_return(inventory_hash)
307
289
  expect(self).to receive(:target_in_inventory?).and_return(true)
308
- expect(self).to receive(:target_in_inventory?).and_return(true)
309
290
  expect(self).to receive(:run_task).with(task_name, 'some.host', params, config: config_data, inventory: inventory_hash).and_return(result_failure)
310
291
  expect { run_bolt_task(task_name, params, opts: {}) }.to raise_error(RuntimeError, /task failed/)
311
292
  end
@@ -315,7 +296,6 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
315
296
  expect(File).to receive(:exist?).with('spec/fixtures/litmus_inventory.yaml').and_return(true)
316
297
  expect(self).to receive(:inventory_hash_from_inventory_file).and_return(inventory_hash)
317
298
  expect(self).to receive(:target_in_inventory?).and_return(true)
318
- expect(self).to receive(:target_in_inventory?).and_return(true)
319
299
  expect(self).to receive(:run_task).with(task_name, 'some.host', params, config: config_data, inventory: inventory_hash).and_return(result_failure)
320
300
  method_result = run_bolt_task(task_name, params, expect_failures: true)
321
301
  expect(method_result.exit_code).to be(123)
@@ -78,7 +78,7 @@ describe 'litmus rake tasks' do
78
78
  allow_any_instance_of(PuppetLitmus::InventoryManipulation).to receive(:inventory_hash_from_inventory_file).with(any_args).and_return({})
79
79
  allow_any_instance_of(PuppetLitmus::RakeHelper).to receive(:check_connectivity?).with(any_args).and_return(true)
80
80
 
81
- expect { Rake::Task['litmus:provision'].invoke('docker', 'centos:7') }.to output(expected_output).to_stdout
81
+ expect { Rake::Task['litmus:provision'].invoke('docker', 'centos:7') }.to output(/#{expected_output}/).to_stdout
82
82
  end
83
83
  end
84
84
 
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: 1.0.1
4
+ version: 1.0.3
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-25 00:00:00.000000000 Z
11
+ date: 2023-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bolt
@@ -44,20 +44,6 @@ dependencies:
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: 3.0.0
47
- - !ruby/object:Gem::Dependency
48
- name: honeycomb-beeline
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '0'
61
47
  - !ruby/object:Gem::Dependency
62
48
  name: parallel
63
49
  requirement: !ruby/object:Gem::Requirement
@@ -114,20 +100,6 @@ dependencies:
114
100
  - - ">="
115
101
  - !ruby/object:Gem::Version
116
102
  version: '0'
117
- - !ruby/object:Gem::Dependency
118
- name: rspec_honeycomb_formatter
119
- requirement: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- version: '0'
124
- type: :runtime
125
- prerelease: false
126
- version_requirements: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - ">="
129
- - !ruby/object:Gem::Version
130
- version: '0'
131
103
  - !ruby/object:Gem::Dependency
132
104
  name: tty-spinner
133
105
  requirement: !ruby/object:Gem::Requirement