puppet_litmus 0.18.1 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,5 +2,5 @@
2
2
 
3
3
  # version of this gem
4
4
  module PuppetLitmus
5
- VERSION ||= '0.18.1'
5
+ VERSION ||= '0.20.0'
6
6
  end
@@ -113,10 +113,10 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
113
113
  let(:local) { '/tmp' }
114
114
  let(:remote) { '/remote_tmp' }
115
115
  # Ignore rubocop because these hashes are representative of output from an external method and editing them leads to test failures.
116
- # rubocop:disable Layout/SpaceInsideHashLiteralBraces, Layout/SpaceInsideBlockBraces, Layout/SpaceAroundOperators, Layout/LineLength, Layout/SpaceAfterComma
117
- let(:result_success) {[{'target'=>'some.host','action'=>'upload','object'=>'C:\foo\bar.ps1','status'=>'success','value'=>{'_output'=>'Uploaded \'C:\foo\bar.ps1\' to \'some.host:C:\bar\''}}]}
118
- let(:result_failure) {[{'target'=>'some.host','action'=>nil,'object'=>nil,'status'=>'failure','value'=>{'_error'=>{'kind'=>'puppetlabs.tasks/task_file_error','msg'=>'No such file or directory @ rb_sysopen - /nonexistant/file/path','details'=>{},'issue_code'=>'WRITE_ERROR'}}}]}
119
- # rubocop:enable Layout/SpaceInsideHashLiteralBraces, Layout/SpaceInsideBlockBraces, Layout/SpaceAroundOperators, Layout/LineLength, Layout/SpaceAfterComma
116
+ # rubocop:disable Layout/SpaceAroundOperators, Layout/LineLength, Layout/SpaceAfterComma
117
+ let(:result_success) { [{ 'target'=>'some.host','action'=>'upload','object'=>'C:\foo\bar.ps1','status'=>'success','value'=>{ '_output'=>'Uploaded \'C:\foo\bar.ps1\' to \'some.host:C:\bar\'' } }] }
118
+ let(:result_failure) { [{ 'target'=>'some.host','action'=>nil,'object'=>nil,'status'=>'failure','value'=>{ '_error'=>{ 'kind'=>'puppetlabs.tasks/task_file_error','msg'=>'No such file or directory @ rb_sysopen - /nonexistant/file/path','details'=>{},'issue_code'=>'WRITE_ERROR' } } }] }
119
+ # rubocop:enable, Layout/SpaceAroundOperators, Layout/LineLength, Layout/SpaceAfterComma
120
120
 
121
121
  it 'responds to run_shell' do
122
122
  expect(self).to respond_to(:bolt_upload_file).with(2..3).arguments
@@ -212,11 +212,11 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
212
212
  let(:params) { { 'action' => 'install', 'name' => 'foo' } }
213
213
  let(:config_data) { { 'modulepath' => File.join(Dir.pwd, 'spec', 'fixtures', 'modules') } }
214
214
  # Ignore rubocop because these hashes are representative of output from an external method and editing them leads to test failures.
215
- # rubocop:disable Layout/SpaceInsideHashLiteralBraces, Layout/SpaceBeforeBlockBraces, Layout/SpaceInsideBlockBraces, Layout/SpaceAroundOperators, Layout/LineLength, Layout/SpaceAfterComma
216
- let(:result_unstructured_task_success){ [{'target'=>'some.host','action'=>'task','object'=>'testtask::unstructured','status'=>'success','value'=>{'_output'=>'SUCCESS!'}}]}
217
- let(:result_structured_task_success){ [{'target'=>'some.host','action'=>'task','object'=>'testtask::structured','status'=>'success','value'=>{'key1'=>'foo','key2'=>'bar'}}]}
218
- let(:result_failure) {[{'target'=>'some.host','action'=>'task','object'=>'testtask::unstructured','status'=>'failure','value'=>{'_error'=>{'msg'=>'FAILURE!','kind'=>'puppetlabs.tasks/task-error','details'=>{'exitcode'=>123}}}}]}
219
- # rubocop:enable Layout/SpaceInsideHashLiteralBraces, Layout/SpaceBeforeBlockBraces, Layout/SpaceInsideBlockBraces, Layout/SpaceAroundOperators, Layout/LineLength, Layout/SpaceAfterComma
215
+ # rubocop:disable Layout/SpaceBeforeBlockBraces
216
+ let(:result_unstructured_task_success){ [{ 'target'=>'some.host','action'=>'task','object'=>'testtask::unstructured','status'=>'success','value'=>{ '_output'=>'SUCCESS!' } }] }
217
+ let(:result_structured_task_success){ [{ 'target'=>'some.host','action'=>'task','object'=>'testtask::structured','status'=>'success','value'=>{ 'key1'=>'foo','key2'=>'bar' } }] }
218
+ let(:result_failure) { [{ 'target'=>'some.host','action'=>'task','object'=>'testtask::unstructured','status'=>'failure','value'=>{ '_error'=>{ 'msg'=>'FAILURE!','kind'=>'puppetlabs.tasks/task-error','details'=>{ 'exitcode'=>123 } } } }] }
219
+ # rubocop:enable Layout/SpaceBeforeBlockBraces, Layout/SpaceAroundOperators, Layout/LineLength, Layout/SpaceAfterComma
220
220
 
221
221
  it 'responds to bolt_run_task' do
222
222
  expect(self).to respond_to(:run_bolt_task).with(2..3).arguments
@@ -286,4 +286,42 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
286
286
  end
287
287
  end
288
288
  end
289
+
290
+ describe '.write_file' do
291
+ let(:content) { 'foo' }
292
+ let(:destination) { '/tmp/foo' }
293
+ let(:owner) { 'foo:foo' }
294
+ let(:local_path) { '/tmp/local_foo' }
295
+
296
+ before(:each) do
297
+ allow_any_instance_of(File).to receive(:path).and_return(local_path)
298
+ end
299
+
300
+ it 'responds to write_file' do
301
+ expect(self).to respond_to(:write_file).with(2).arguments
302
+ end
303
+
304
+ context 'without setting owner' do
305
+ it 'call upload file with the correct params' do
306
+ stub_const('ENV', ENV.to_hash.merge('TARGET_HOST' => 'some.host'))
307
+ expect(self).to receive(:inventory_hash_from_inventory_file).and_return(inventory_hash)
308
+ result = instance_double('result')
309
+ allow(result).to receive(:first).and_return({ 'status' => 'success' })
310
+ expect(self).to receive(:upload_file).with(local_path, destination, 'some.host', options: {}, config: nil, inventory: inventory_hash).and_return(result)
311
+ result = write_file(content, destination)
312
+ expect(result).to be true
313
+ end
314
+ end
315
+
316
+ context 'when upload encounters an error' do
317
+ it 'call upload file with the correct params' do
318
+ stub_const('ENV', ENV.to_hash.merge('TARGET_HOST' => 'some.host'))
319
+ expect(self).to receive(:inventory_hash_from_inventory_file).and_return(inventory_hash)
320
+ result = instance_double('result')
321
+ allow(result).to receive(:first).and_return({ 'status' => 'failure', 'value' => 'foo error' })
322
+ expect(self).to receive(:upload_file).with(local_path, destination, 'some.host', options: {}, config: nil, inventory: inventory_hash).and_return(result)
323
+ expect { write_file(content, destination) }.to raise_error 'foo error'
324
+ end
325
+ end
326
+ end
289
327
  end
@@ -100,20 +100,20 @@ RSpec.describe PuppetLitmus::RakeHelper do
100
100
  [{ 'name' => 'ssh_nodes', 'targets' =>
101
101
  [{ 'uri' => 'some.host', 'facts' => { 'provisioner' => 'docker', 'container_name' => 'foo', 'platform' => 'some.host' } }] }] }
102
102
  end
103
- let(:module_tar) { '/tmp/foo.tar.gz' }
103
+ let(:module_tar) { 'foo.tar.gz' }
104
104
  let(:targets) { ['some.host'] }
105
105
  let(:uninstall_module_command) { 'puppet module uninstall foo --force' }
106
- let(:install_module_command) { "puppet module install --module_repository 'https://forgeapi.puppetlabs.com' #{module_tar}" }
106
+ let(:install_module_command) { "puppet module install --module_repository 'https://forgeapi.example.com' #{module_tar}" }
107
107
 
108
108
  it 'calls function' do
109
109
  allow_any_instance_of(BoltSpec::Run).to receive(:upload_file).with(module_tar, module_tar, targets, options: {}, config: nil, inventory: inventory_hash).and_return([])
110
110
  allow(File).to receive(:exist?).with(File.join(Dir.pwd, 'metadata.json')).and_return(true)
111
111
  allow(File).to receive(:read).with(File.join(Dir.pwd, 'metadata.json')).and_return(JSON.dump({ name: 'foo' }))
112
- allow(Open3).to receive(:capture3).with("bundle exec bolt file upload \"#{module_tar}\" /tmp/#{File.basename(module_tar)} --targets all --inventoryfile inventory.yaml")
112
+ allow(Open3).to receive(:capture3).with("bundle exec bolt file upload \"#{module_tar}\" #{File.basename(module_tar)} --targets all --inventoryfile inventory.yaml")
113
113
  .and_return(['success', '', 0])
114
114
  allow_any_instance_of(BoltSpec::Run).to receive(:run_command).with(uninstall_module_command, targets, config: nil, inventory: inventory_hash).and_return([])
115
115
  allow_any_instance_of(BoltSpec::Run).to receive(:run_command).with(install_module_command, targets, config: nil, inventory: inventory_hash).and_return([])
116
- install_module(inventory_hash, nil, module_tar)
116
+ install_module(inventory_hash, nil, module_tar, 'https://forgeapi.example.com')
117
117
  end
118
118
  end
119
119
 
@@ -19,17 +19,17 @@ describe 'litmus rake tasks' do
19
19
  'template-ref' => 'heads/master-0-g7827fc2' }
20
20
  expect(File).to receive(:read).with(any_args).once
21
21
  expect(JSON).to receive(:parse).with(any_args).and_return(metadata)
22
- expect(STDOUT).to receive(:puts).with('redhat-5-x86_64')
23
- expect(STDOUT).to receive(:puts).with('ubuntu-1404-x86_64')
24
- expect(STDOUT).to receive(:puts).with('ubuntu-1804-x86_64')
22
+ expect($stdout).to receive(:puts).with('redhat-5-x86_64')
23
+ expect($stdout).to receive(:puts).with('ubuntu-1404-x86_64')
24
+ expect($stdout).to receive(:puts).with('ubuntu-1804-x86_64')
25
25
  Rake::Task['litmus:metadata'].invoke
26
26
  end
27
27
  end
28
28
 
29
29
  context 'with litmus:install_modules_from_directory' do
30
30
  let(:inventory_hash) { { 'groups' => [{ 'name' => 'ssh_nodes', 'nodes' => [{ 'uri' => 'some.host' }] }] } }
31
- let(:target_folder) { File.join(Dir.pwd, 'spec/fixtures/modules') }
32
- let(:dummy_tar) { File.new('spec/data/doot.tar.gz') }
31
+ let(:target_dir) { File.join(Dir.pwd, 'spec/fixtures/modules') }
32
+ let(:dummy_tar) { 'spec/data/doot.tar.gz' }
33
33
 
34
34
  it 'happy path' do
35
35
  allow(File).to receive(:exist?).with(File.join(Dir.pwd, 'metadata.json')).and_return(true)
@@ -37,12 +37,13 @@ describe 'litmus rake tasks' do
37
37
 
38
38
  stub_const('ENV', ENV.to_hash.merge('TARGET_HOST' => 'some.host'))
39
39
  expect_any_instance_of(PuppetLitmus::InventoryManipulation).to receive(:inventory_hash_from_inventory_file).and_return(inventory_hash)
40
- expect(File).to receive(:directory?).with(target_folder).and_return(true)
41
- expect_any_instance_of(Object).to receive(:build_modules_in_folder).with(target_folder).and_return([dummy_tar])
42
- expect(STDOUT).to receive(:puts).with('Building')
40
+ expect(File).to receive(:directory?).with(target_dir).and_return(true)
41
+ expect_any_instance_of(Object).to receive(:build_modules_in_dir).with(target_dir).and_return([dummy_tar])
42
+ expect($stdout).to receive(:puts).with(start_with('Building all modules in'))
43
43
  expect_any_instance_of(Object).to receive(:upload_file).once.and_return([])
44
- expect(STDOUT).to receive(:puts).with("\nInstalling")
44
+ expect($stdout).to receive(:puts).with(start_with('Installing \'spec/data/doot.tar.gz\''))
45
45
  expect_any_instance_of(Object).to receive(:run_command).twice.and_return([])
46
+ expect($stdout).to receive(:puts).with(start_with('Installed \'spec/data/doot.tar.gz\''))
46
47
  Rake::Task['litmus:install_modules_from_directory'].invoke('./spec/fixtures/modules')
47
48
  end
48
49
  end
@@ -67,7 +68,10 @@ describe 'litmus rake tasks' do
67
68
 
68
69
  allow(File).to receive(:directory?).with(any_args).and_return(true)
69
70
  allow_any_instance_of(BoltSpec::Run).to receive(:run_task).with(any_args).and_return(results)
70
- expect(STDOUT).to receive(:puts).with('localhost:2222, centos:7')
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")
74
+ expect($stdout).to receive(:puts).with('localhost:2222, centos:7')
71
75
  Rake::Task['litmus:provision'].invoke('docker', 'centos:7')
72
76
  end
73
77
  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.18.1
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet, Inc.
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-02 00:00:00.000000000 Z
11
+ date: 2020-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bolt
@@ -34,16 +34,22 @@ dependencies:
34
34
  name: puppet-modulebuilder
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "~>"
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 0.2.1
40
+ - - "<"
38
41
  - !ruby/object:Gem::Version
39
- version: '0.1'
42
+ version: 1.0.0
40
43
  type: :runtime
41
44
  prerelease: false
42
45
  version_requirements: !ruby/object:Gem::Requirement
43
46
  requirements:
44
- - - "~>"
47
+ - - ">="
45
48
  - !ruby/object:Gem::Version
46
- version: '0.1'
49
+ version: 0.2.1
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: 1.0.0
47
53
  - !ruby/object:Gem::Dependency
48
54
  name: tty-spinner
49
55
  requirement: !ruby/object:Gem::Requirement
@@ -73,7 +79,7 @@ dependencies:
73
79
  version: '1.34'
74
80
  - - "<"
75
81
  - !ruby/object:Gem::Version
76
- version: 2.0.0
82
+ version: 3.0.0
77
83
  type: :runtime
78
84
  prerelease: false
79
85
  version_requirements: !ruby/object:Gem::Requirement
@@ -83,7 +89,21 @@ dependencies:
83
89
  version: '1.34'
84
90
  - - "<"
85
91
  - !ruby/object:Gem::Version
86
- version: 2.0.0
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'
87
107
  - !ruby/object:Gem::Dependency
88
108
  name: parallel
89
109
  requirement: !ruby/object:Gem::Requirement
@@ -144,12 +164,14 @@ description: " Providing a simple command line tool for puppet content creato
144
164
  to enable simple and complex test deployments.\n"
145
165
  email:
146
166
  - info@puppet.com
147
- executables: []
167
+ executables:
168
+ - matrix_from_metadata
148
169
  extensions: []
149
170
  extra_rdoc_files: []
150
171
  files:
151
172
  - LICENSE
152
173
  - README.md
174
+ - exe/matrix_from_metadata
153
175
  - lib/puppet_litmus.rb
154
176
  - lib/puppet_litmus/inventory_manipulation.rb
155
177
  - lib/puppet_litmus/puppet_helpers.rb
@@ -187,8 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
209
  - !ruby/object:Gem::Version
188
210
  version: '0'
189
211
  requirements: []
190
- rubyforge_project:
191
- rubygems_version: 2.7.6.2
212
+ rubygems_version: 3.1.4
192
213
  signing_key:
193
214
  specification_version: 4
194
215
  summary: Providing a simple command line tool for puppet content creators, to enable
@@ -200,7 +221,7 @@ test_files:
200
221
  - spec/lib/puppet_litmus/util_spec.rb
201
222
  - spec/lib/puppet_litmus/version_spec.rb
202
223
  - spec/lib/puppet_litmus/inventory_manipulation_spec.rb
224
+ - spec/lib/puppet_litmus/rake_helper_spec.rb
203
225
  - spec/lib/puppet_litmus/puppet_helpers_spec.rb
204
226
  - spec/lib/puppet_litmus/rake_tasks_spec.rb
205
- - spec/lib/puppet_litmus/rake_helper_spec.rb
206
227
  - spec/spec_helper.rb