puppet_litmus 0.15.0 → 0.18.2

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,7 +2,26 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- load File.expand_path('../../../lib/puppet_litmus/rake_helper.rb', __dir__)
5
+ RSpec.shared_examples 'supported provisioner' do |args|
6
+ let(:provisioner) { args[:provisioner] }
7
+ let(:platform) { args[:platform] }
8
+ let(:inventory_vars) { args[:inventory_vars] }
9
+ let(:provision_hash) { args[:provision_hash] }
10
+ let(:results) { args[:results] }
11
+ let(:params) { args[:params] }
12
+
13
+ it 'calls function' do
14
+ allow(File).to receive(:directory?).and_call_original
15
+ allow(File).to receive(:directory?)
16
+ .with(File.join(described_class::DEFAULT_CONFIG_DATA['modulepath'], 'provision'))
17
+ .and_return(true)
18
+ allow_any_instance_of(BoltSpec::Run).to receive(:run_task)
19
+ .with("provision::#{provisioner}", 'localhost', params, config: described_class::DEFAULT_CONFIG_DATA, inventory: nil)
20
+ .and_return(results)
21
+ result = provision(provisioner, platform, inventory_vars)
22
+ expect(result).to eq(results)
23
+ end
24
+ end
6
25
 
7
26
  RSpec.describe PuppetLitmus::RakeHelper do
8
27
  context 'with provision_list' do
@@ -10,21 +29,35 @@ RSpec.describe PuppetLitmus::RakeHelper do
10
29
  let(:results) { [] }
11
30
 
12
31
  it 'calls function' do
13
- expect(described_class).to receive(:provision).with('docker', 'waffleimage/centos7', nil).and_return(results)
14
- described_class.provision_list(provision_hash, 'default')
32
+ expect(self).to receive(:provision).with('docker', 'waffleimage/centos7', nil).and_return(results)
33
+ provision_list(provision_hash, 'default')
15
34
  end
16
35
  end
17
36
 
18
37
  context 'with provision' do
19
- let(:provision_hash) { { 'default' => { 'provisioner' => 'docker', 'images' => ['waffleimage/centos7'] } } }
20
- let(:results) { [] }
21
- let(:params) { { 'action' => 'provision', 'platform' => 'waffleimage/centos7', 'inventory' => Dir.pwd } }
22
-
23
- it 'calls function' do
24
- allow(File).to receive(:directory?).and_call_original
25
- allow(File).to receive(:directory?).with(File.join(DEFAULT_CONFIG_DATA['modulepath'], 'provision')).and_return(true)
26
- allow_any_instance_of(BoltSpec::Run).to receive(:run_task).with('provision::docker', 'localhost', params, config: DEFAULT_CONFIG_DATA, inventory: nil).and_return(results)
27
- described_class.provision('docker', 'waffleimage/centos7', nil)
38
+ examples = [
39
+ {
40
+ provisioner: 'docker',
41
+ platform: 'waffleimage/centos7',
42
+ inventory_vars: nil,
43
+ provision_hash: { 'default' => { 'provisioner' => 'docker', 'images' => ['waffleimage/centos7'] } },
44
+ results: [],
45
+ params: { 'action' => 'provision', 'platform' => 'waffleimage/centos7', 'inventory' => Dir.pwd },
46
+ },
47
+ {
48
+ provisioner: 'vagrant',
49
+ platform: 'centos7',
50
+ inventory_vars: nil,
51
+ provision_hash: { 'default' => { 'provisioner' => 'vagrant', 'images' => ['centos7'] } },
52
+ results: [],
53
+ params: { 'action' => 'provision', 'platform' => 'centos7', 'inventory' => Dir.pwd },
54
+ },
55
+ ].freeze
56
+
57
+ examples.each do |e|
58
+ describe e[:provisioner] do
59
+ it_behaves_like 'supported provisioner', e
60
+ end
28
61
  end
29
62
  end
30
63
 
@@ -38,9 +71,9 @@ RSpec.describe PuppetLitmus::RakeHelper do
38
71
  let(:params) { { 'action' => 'tear_down', 'node_name' => 'some.host', 'inventory' => Dir.pwd } }
39
72
 
40
73
  it 'calls function' do
41
- allow(File).to receive(:directory?).with(File.join(DEFAULT_CONFIG_DATA['modulepath'], 'provision')).and_return(true)
42
- allow_any_instance_of(BoltSpec::Run).to receive(:run_task).with('provision::docker', 'localhost', params, config: DEFAULT_CONFIG_DATA, inventory: nil).and_return([])
43
- described_class.tear_down_nodes(targets, inventory_hash)
74
+ allow(File).to receive(:directory?).with(File.join(described_class::DEFAULT_CONFIG_DATA['modulepath'], 'provision')).and_return(true)
75
+ allow_any_instance_of(BoltSpec::Run).to receive(:run_task).with('provision::docker', 'localhost', params, config: described_class::DEFAULT_CONFIG_DATA, inventory: nil).and_return([])
76
+ tear_down_nodes(targets, inventory_hash)
44
77
  end
45
78
  end
46
79
 
@@ -54,9 +87,9 @@ RSpec.describe PuppetLitmus::RakeHelper do
54
87
  let(:params) { { 'collection' => 'puppet6' } }
55
88
 
56
89
  it 'calls function' do
57
- allow(File).to receive(:directory?).with(File.join(DEFAULT_CONFIG_DATA['modulepath'], 'puppet_agent')).and_return(true)
58
- allow_any_instance_of(BoltSpec::Run).to receive(:run_task).with('puppet_agent::install', targets, params, config: DEFAULT_CONFIG_DATA, inventory: inventory_hash).and_return([])
59
- described_class.install_agent('puppet6', targets, inventory_hash)
90
+ allow(File).to receive(:directory?).with(File.join(described_class::DEFAULT_CONFIG_DATA['modulepath'], 'puppet_agent')).and_return(true)
91
+ allow_any_instance_of(BoltSpec::Run).to receive(:run_task).with('puppet_agent::install', targets, params, config: described_class::DEFAULT_CONFIG_DATA, inventory: inventory_hash).and_return([])
92
+ install_agent('puppet6', targets, inventory_hash)
60
93
  end
61
94
  end
62
95
 
@@ -69,13 +102,18 @@ RSpec.describe PuppetLitmus::RakeHelper do
69
102
  end
70
103
  let(:module_tar) { '/tmp/foo.tar.gz' }
71
104
  let(:targets) { ['some.host'] }
72
- let(:install_module_command) { "puppet module install /tmp/#{File.basename(module_tar)}" }
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}" }
73
107
 
74
108
  it 'calls function' do
75
- allow(Open3).to receive(:capture3).with("bundle exec bolt file upload \"#{module_tar}\" /tmp/#{File.basename(module_tar)} --nodes all --inventoryfile inventory.yaml")
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
+ allow(File).to receive(:exist?).with(File.join(Dir.pwd, 'metadata.json')).and_return(true)
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")
76
113
  .and_return(['success', '', 0])
114
+ allow_any_instance_of(BoltSpec::Run).to receive(:run_command).with(uninstall_module_command, targets, config: nil, inventory: inventory_hash).and_return([])
77
115
  allow_any_instance_of(BoltSpec::Run).to receive(:run_command).with(install_module_command, targets, config: nil, inventory: inventory_hash).and_return([])
78
- described_class.install_module(inventory_hash, nil, module_tar)
116
+ install_module(inventory_hash, nil, module_tar)
79
117
  end
80
118
  end
81
119
 
@@ -91,12 +129,12 @@ RSpec.describe PuppetLitmus::RakeHelper do
91
129
  it 'node available' do
92
130
  allow(Open3).to receive(:capture3).with('cd .').and_return(['success', '', 0])
93
131
  allow_any_instance_of(BoltSpec::Run).to receive(:run_command).with(command, targets, config: nil, inventory: inventory_hash).and_return([{ 'target' => 'some.host', 'status' => 'success' }])
94
- described_class.check_connectivity?(inventory_hash, nil)
132
+ check_connectivity?(inventory_hash, 'some.host')
95
133
  end
96
134
 
97
135
  it 'node unavailable' do
98
136
  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' }])
99
- expect { described_class.check_connectivity?(inventory_hash, nil) }.to raise_error(RuntimeError, %r{Connectivity has failed on:})
137
+ expect { check_connectivity?(inventory_hash, 'some.host') }.to raise_error(RuntimeError, %r{Connectivity has failed on:})
100
138
  end
101
139
  end
102
140
 
@@ -111,13 +149,13 @@ RSpec.describe PuppetLitmus::RakeHelper do
111
149
 
112
150
  it 'uninstalls module' do
113
151
  allow_any_instance_of(BoltSpec::Run).to receive(:run_command).with(uninstall_module_command, targets, config: nil, inventory: inventory_hash).and_return([])
114
- expect(described_class).to receive(:metadata_module_name).and_return('foo-bar')
115
- described_class.uninstall_module(inventory_hash, nil)
152
+ expect(self).to receive(:metadata_module_name).and_return('foo-bar')
153
+ uninstall_module(inventory_hash, nil)
116
154
  end
117
155
 
118
156
  it 'and custom name' do
119
157
  allow_any_instance_of(BoltSpec::Run).to receive(:run_command).with(uninstall_module_command, targets, config: nil, inventory: inventory_hash).and_return([])
120
- described_class.uninstall_module(inventory_hash, nil, 'foo-bar')
158
+ uninstall_module(inventory_hash, nil, 'foo-bar')
121
159
  end
122
160
  end
123
161
 
@@ -127,8 +165,20 @@ RSpec.describe PuppetLitmus::RakeHelper do
127
165
  it 'reads module name' do
128
166
  allow(File).to receive(:exist?).with(File.join(Dir.pwd, 'metadata.json')).and_return(true)
129
167
  allow(File).to receive(:read).with(File.join(Dir.pwd, 'metadata.json')).and_return(metadata)
130
- name = described_class.metadata_module_name
168
+ name = metadata_module_name
131
169
  expect(name).to eq('foo-bar')
132
170
  end
133
171
  end
172
+
173
+ context 'with provisioner_task' do
174
+ described_class::SUPPORTED_PROVISIONERS.each do |supported_provisioner|
175
+ it "returns supported provisioner task name for #{supported_provisioner}" do
176
+ expect(provisioner_task(supported_provisioner)).to eq("provision::#{supported_provisioner}")
177
+ end
178
+ end
179
+
180
+ it 'returns an unsupported provisioner name' do
181
+ expect(provisioner_task('my_org::custom_provisioner')).to eql('my_org::custom_provisioner')
182
+ end
183
+ end
134
184
  end
@@ -1,9 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'spec_helper'
4
- require 'rake'
5
- load File.expand_path('../../../lib/puppet_litmus/inventory_manipulation.rb', __dir__)
6
- include PuppetLitmus::InventoryManipulation # rubocop:disable Style/MixinUsage
4
+
7
5
  describe 'litmus rake tasks' do
8
6
  before(:all) do # rubocop:disable RSpec/BeforeAfterAll
9
7
  load File.expand_path('../../../lib/puppet_litmus/rake_tasks.rb', __dir__)
@@ -34,15 +32,17 @@ describe 'litmus rake tasks' do
34
32
  let(:dummy_tar) { File.new('spec/data/doot.tar.gz') }
35
33
 
36
34
  it 'happy path' do
35
+ allow(File).to receive(:exist?).with(File.join(Dir.pwd, 'metadata.json')).and_return(true)
36
+ allow(File).to receive(:read).with(File.join(Dir.pwd, 'metadata.json')).and_return(JSON.dump({ name: 'foo' }))
37
+
37
38
  stub_const('ENV', ENV.to_hash.merge('TARGET_HOST' => 'some.host'))
38
39
  expect_any_instance_of(PuppetLitmus::InventoryManipulation).to receive(:inventory_hash_from_inventory_file).and_return(inventory_hash)
39
40
  expect(File).to receive(:directory?).with(target_folder).and_return(true)
40
41
  expect_any_instance_of(Object).to receive(:build_modules_in_folder).with(target_folder).and_return([dummy_tar])
41
42
  expect(STDOUT).to receive(:puts).with('Building')
42
- expect(STDOUT).to receive(:puts).with("\nSending")
43
- expect_any_instance_of(Object).to receive(:upload_file).once
43
+ expect_any_instance_of(Object).to receive(:upload_file).once.and_return([])
44
44
  expect(STDOUT).to receive(:puts).with("\nInstalling")
45
- expect_any_instance_of(Object).to receive(:run_command).once
45
+ expect_any_instance_of(Object).to receive(:run_command).twice.and_return([])
46
46
  Rake::Task['litmus:install_modules_from_directory'].invoke('./spec/fixtures/modules')
47
47
  end
48
48
  end
@@ -59,12 +59,11 @@ describe 'litmus rake tasks' do
59
59
 
60
60
  context 'with litmus:provision task' do
61
61
  it 'happy path' do
62
- results = [{ 'node' => 'localhost',
63
- 'target' => 'localhost',
62
+ results = [{ 'target' => 'localhost',
64
63
  'action' => 'task',
65
64
  'object' => 'provision::docker',
66
65
  'status' => 'success',
67
- 'result' => { 'status' => 'ok', 'node_name' => 'localhost:2222' } }]
66
+ 'value' => { 'status' => 'ok', 'node_name' => 'localhost:2222' } }]
68
67
 
69
68
  allow(File).to receive(:directory?).with(any_args).and_return(true)
70
69
  allow_any_instance_of(BoltSpec::Run).to receive(:run_task).with(any_args).and_return(results)
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ load File.expand_path('../../../lib/puppet_litmus/util.rb', __dir__)
5
+
6
+ RSpec.describe PuppetLitmus::Util do
7
+ context 'when using interpolate_powershell' do
8
+ it 'interpolates the command' do
9
+ expect(described_class.interpolate_powershell('foo')).to match(%r{powershell\.exe})
10
+ expect(described_class.interpolate_powershell('foo')).to match(%r{NoProfile})
11
+ expect(described_class.interpolate_powershell('foo')).to match(%r{EncodedCommand})
12
+ expect(described_class.interpolate_powershell('foo')).not_to match(%r{foo})
13
+ end
14
+ end
15
+ end
@@ -1,9 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'spec_helper'
4
- load File.expand_path('../../../lib/puppet_litmus/version.rb', __dir__)
5
-
6
- include PuppetLitmus # rubocop:disable Style/MixinUsage
7
4
 
8
5
  RSpec.describe PuppetLitmus do
9
6
  it 'has a version number' do
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rspec'
4
- require 'puppet_litmus'
5
4
 
6
5
  if ENV['COVERAGE'] == 'yes'
7
6
  require 'simplecov'
@@ -32,3 +31,10 @@ if ENV['COVERAGE'] == 'yes'
32
31
  end
33
32
  end
34
33
  end
34
+
35
+ # This is basically how `configure!` sets up RSpec in tests.
36
+ require 'puppet_litmus'
37
+ RSpec.configure do |config|
38
+ config.include PuppetLitmus
39
+ config.extend PuppetLitmus
40
+ 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.15.0
4
+ version: 0.18.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-03 00:00:00.000000000 Z
11
+ date: 2020-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bolt
@@ -16,40 +16,34 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.13.1
19
+ version: 2.0.1
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 2.0.0
22
+ version: 3.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 1.13.1
29
+ version: 2.0.1
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 2.0.0
32
+ version: 3.0.0
33
33
  - !ruby/object:Gem::Dependency
34
- name: pdk
34
+ name: puppet-modulebuilder
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: 1.10.0
40
- - - "<"
37
+ - - "~>"
41
38
  - !ruby/object:Gem::Version
42
- version: 2.0.0
39
+ version: '0.1'
43
40
  type: :runtime
44
41
  prerelease: false
45
42
  version_requirements: !ruby/object:Gem::Requirement
46
43
  requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: 1.10.0
50
- - - "<"
44
+ - - "~>"
51
45
  - !ruby/object:Gem::Version
52
- version: 2.0.0
46
+ version: '0.1'
53
47
  - !ruby/object:Gem::Dependency
54
48
  name: tty-spinner
55
49
  requirement: !ruby/object:Gem::Requirement
@@ -132,6 +126,60 @@ dependencies:
132
126
  - - ">="
133
127
  - !ruby/object:Gem::Version
134
128
  version: '0'
129
+ - !ruby/object:Gem::Dependency
130
+ name: rspec_honeycomb_formatter
131
+ requirement: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ type: :runtime
137
+ prerelease: false
138
+ version_requirements: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ - !ruby/object:Gem::Dependency
144
+ name: ed25519
145
+ requirement: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: '1.2'
150
+ - - "<"
151
+ - !ruby/object:Gem::Version
152
+ version: '2.0'
153
+ type: :runtime
154
+ prerelease: false
155
+ version_requirements: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '1.2'
160
+ - - "<"
161
+ - !ruby/object:Gem::Version
162
+ version: '2.0'
163
+ - !ruby/object:Gem::Dependency
164
+ name: bcrypt_pbkdf
165
+ requirement: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '1.0'
170
+ - - "<"
171
+ - !ruby/object:Gem::Version
172
+ version: '2.0'
173
+ type: :runtime
174
+ prerelease: false
175
+ version_requirements: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '1.0'
180
+ - - "<"
181
+ - !ruby/object:Gem::Version
182
+ version: '2.0'
135
183
  description: " Providing a simple command line tool for puppet content creators,
136
184
  to enable simple and complex test deployments.\n"
137
185
  email:
@@ -148,6 +196,7 @@ files:
148
196
  - lib/puppet_litmus/rake_helper.rb
149
197
  - lib/puppet_litmus/rake_tasks.rb
150
198
  - lib/puppet_litmus/spec_helper_acceptance.rb
199
+ - lib/puppet_litmus/util.rb
151
200
  - lib/puppet_litmus/version.rb
152
201
  - spec/data/doot.tar.gz
153
202
  - spec/data/inventory.yaml
@@ -156,6 +205,7 @@ files:
156
205
  - spec/lib/puppet_litmus/puppet_helpers_spec.rb
157
206
  - spec/lib/puppet_litmus/rake_helper_spec.rb
158
207
  - spec/lib/puppet_litmus/rake_tasks_spec.rb
208
+ - spec/lib/puppet_litmus/util_spec.rb
159
209
  - spec/lib/puppet_litmus/version_spec.rb
160
210
  - spec/spec_helper.rb
161
211
  homepage: https://github.com/puppetlabs/puppet_litmus
@@ -177,18 +227,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
227
  - !ruby/object:Gem::Version
178
228
  version: '0'
179
229
  requirements: []
180
- rubygems_version: 3.0.6
230
+ rubygems_version: 3.1.2
181
231
  signing_key:
182
232
  specification_version: 4
183
233
  summary: Providing a simple command line tool for puppet content creators, to enable
184
234
  simple and complex test deployments.
185
235
  test_files:
186
- - spec/data/doot.tar.gz
187
- - spec/data/inventory.yaml
188
- - spec/data/jim.yaml
189
- - spec/lib/puppet_litmus/inventory_manipulation_spec.rb
190
- - spec/lib/puppet_litmus/puppet_helpers_spec.rb
191
- - spec/lib/puppet_litmus/rake_helper_spec.rb
236
+ - spec/spec_helper.rb
192
237
  - spec/lib/puppet_litmus/rake_tasks_spec.rb
193
238
  - spec/lib/puppet_litmus/version_spec.rb
194
- - spec/spec_helper.rb
239
+ - spec/lib/puppet_litmus/util_spec.rb
240
+ - spec/lib/puppet_litmus/inventory_manipulation_spec.rb
241
+ - spec/lib/puppet_litmus/rake_helper_spec.rb
242
+ - spec/lib/puppet_litmus/puppet_helpers_spec.rb
243
+ - spec/data/doot.tar.gz
244
+ - spec/data/jim.yaml
245
+ - spec/data/inventory.yaml