test-kitchen 1.14.1 → 1.14.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.
- checksums.yaml +4 -4
- data/Berksfile +1 -1
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -1
- data/Guardfile +5 -5
- data/Rakefile +5 -5
- data/bin/kitchen +1 -1
- data/features/step_definitions/gem_steps.rb +6 -6
- data/features/support/env.rb +6 -7
- data/lib/kitchen.rb +5 -7
- data/lib/kitchen/base64_stream.rb +2 -8
- data/lib/kitchen/cli.rb +76 -80
- data/lib/kitchen/collection.rb +0 -2
- data/lib/kitchen/color.rb +7 -9
- data/lib/kitchen/command.rb +0 -4
- data/lib/kitchen/command/action.rb +0 -3
- data/lib/kitchen/command/console.rb +4 -7
- data/lib/kitchen/command/diagnose.rb +7 -14
- data/lib/kitchen/command/driver_discover.rb +1 -4
- data/lib/kitchen/command/exec.rb +0 -3
- data/lib/kitchen/command/list.rb +9 -12
- data/lib/kitchen/command/login.rb +0 -3
- data/lib/kitchen/command/package.rb +0 -3
- data/lib/kitchen/command/sink.rb +6 -9
- data/lib/kitchen/command/test.rb +1 -4
- data/lib/kitchen/config.rb +25 -27
- data/lib/kitchen/configurable.rb +26 -31
- data/lib/kitchen/data_munger.rb +34 -36
- data/lib/kitchen/diagnostic.rb +5 -7
- data/lib/kitchen/driver.rb +3 -5
- data/lib/kitchen/driver/base.rb +0 -3
- data/lib/kitchen/driver/dummy.rb +0 -3
- data/lib/kitchen/driver/proxy.rb +0 -3
- data/lib/kitchen/driver/ssh_base.rb +13 -16
- data/lib/kitchen/errors.rb +11 -16
- data/lib/kitchen/generator/driver_create.rb +18 -21
- data/lib/kitchen/generator/init.rb +21 -26
- data/lib/kitchen/instance.rb +19 -23
- data/lib/kitchen/lazy_hash.rb +1 -2
- data/lib/kitchen/loader/yaml.rb +22 -25
- data/lib/kitchen/logger.rb +9 -14
- data/lib/kitchen/logging.rb +0 -3
- data/lib/kitchen/login_command.rb +0 -2
- data/lib/kitchen/metadata_chopper.rb +0 -2
- data/lib/kitchen/platform.rb +1 -3
- data/lib/kitchen/provisioner.rb +3 -5
- data/lib/kitchen/provisioner/base.rb +2 -5
- data/lib/kitchen/provisioner/chef/berkshelf.rb +1 -5
- data/lib/kitchen/provisioner/chef/common_sandbox.rb +24 -29
- data/lib/kitchen/provisioner/chef/librarian.rb +2 -6
- data/lib/kitchen/provisioner/chef/policyfile.rb +4 -8
- data/lib/kitchen/provisioner/chef_apply.rb +14 -17
- data/lib/kitchen/provisioner/chef_base.rb +43 -46
- data/lib/kitchen/provisioner/chef_solo.rb +10 -13
- data/lib/kitchen/provisioner/chef_zero.rb +22 -29
- data/lib/kitchen/provisioner/dummy.rb +0 -3
- data/lib/kitchen/provisioner/shell.rb +6 -9
- data/lib/kitchen/rake_tasks.rb +4 -6
- data/lib/kitchen/shell_out.rb +3 -5
- data/lib/kitchen/ssh.rb +16 -22
- data/lib/kitchen/state_file.rb +3 -5
- data/lib/kitchen/suite.rb +0 -2
- data/lib/kitchen/thor_tasks.rb +2 -4
- data/lib/kitchen/transport.rb +3 -5
- data/lib/kitchen/transport/base.rb +1 -7
- data/lib/kitchen/transport/dummy.rb +0 -4
- data/lib/kitchen/transport/ssh.rb +41 -47
- data/lib/kitchen/transport/winrm.rb +41 -40
- data/lib/kitchen/util.rb +1 -3
- data/lib/kitchen/verifier.rb +3 -5
- data/lib/kitchen/verifier/base.rb +2 -5
- data/lib/kitchen/verifier/busser.rb +24 -24
- data/lib/kitchen/verifier/dummy.rb +0 -3
- data/lib/kitchen/verifier/shell.rb +1 -3
- data/lib/kitchen/version.rb +1 -1
- data/lib/vendor/hash_recursive_merge.rb +0 -2
- data/spec/kitchen/base64_stream_spec.rb +3 -6
- data/spec/kitchen/cli_spec.rb +0 -2
- data/spec/kitchen/collection_spec.rb +4 -8
- data/spec/kitchen/color_spec.rb +0 -3
- data/spec/kitchen/config_spec.rb +91 -106
- data/spec/kitchen/configurable_spec.rb +44 -76
- data/spec/kitchen/data_munger_spec.rb +1178 -1247
- data/spec/kitchen/diagnostic_spec.rb +37 -38
- data/spec/kitchen/driver/base_spec.rb +7 -14
- data/spec/kitchen/driver/dummy_spec.rb +1 -7
- data/spec/kitchen/driver/proxy_spec.rb +2 -7
- data/spec/kitchen/driver/ssh_base_spec.rb +128 -149
- data/spec/kitchen/driver_spec.rb +7 -13
- data/spec/kitchen/errors_spec.rb +50 -60
- data/spec/kitchen/instance_spec.rb +217 -294
- data/spec/kitchen/lazy_hash_spec.rb +14 -18
- data/spec/kitchen/loader/yaml_spec.rb +201 -227
- data/spec/kitchen/logger_spec.rb +7 -15
- data/spec/kitchen/logging_spec.rb +1 -4
- data/spec/kitchen/login_command_spec.rb +3 -4
- data/spec/kitchen/metadata_chopper_spec.rb +0 -3
- data/spec/kitchen/platform_spec.rb +31 -32
- data/spec/kitchen/provisioner/base_spec.rb +22 -41
- data/spec/kitchen/provisioner/chef/policyfile_spec.rb +15 -15
- data/spec/kitchen/provisioner/chef_apply_spec.rb +8 -13
- data/spec/kitchen/provisioner/chef_base_spec.rb +150 -182
- data/spec/kitchen/provisioner/chef_solo_spec.rb +58 -72
- data/spec/kitchen/provisioner/chef_zero_spec.rb +99 -125
- data/spec/kitchen/provisioner/dummy_spec.rb +8 -11
- data/spec/kitchen/provisioner/shell_spec.rb +86 -103
- data/spec/kitchen/provisioner_spec.rb +5 -11
- data/spec/kitchen/shell_out_spec.rb +15 -19
- data/spec/kitchen/ssh_spec.rb +16 -35
- data/spec/kitchen/state_file_spec.rb +6 -11
- data/spec/kitchen/suite_spec.rb +5 -6
- data/spec/kitchen/transport/base_spec.rb +6 -14
- data/spec/kitchen/transport/ssh_spec.rb +39 -64
- data/spec/kitchen/transport/winrm_spec.rb +99 -127
- data/spec/kitchen/transport_spec.rb +7 -13
- data/spec/kitchen/util_spec.rb +17 -26
- data/spec/kitchen/verifier/base_spec.rb +24 -40
- data/spec/kitchen/verifier/busser_spec.rb +38 -68
- data/spec/kitchen/verifier/dummy_spec.rb +8 -11
- data/spec/kitchen/verifier/shell_spec.rb +14 -17
- data/spec/kitchen/verifier_spec.rb +7 -13
- data/spec/kitchen_spec.rb +4 -6
- data/spec/spec_helper.rb +1 -1
- data/spec/support/powershell_max_size_spec.rb +1 -2
- data/support/chef-client-zero.rb +3 -4
- data/test-kitchen.gemspec +4 -6
- metadata +9 -9
|
@@ -22,22 +22,21 @@ require "kitchen"
|
|
|
22
22
|
require "kitchen/provisioner/chef_solo"
|
|
23
23
|
|
|
24
24
|
describe Kitchen::Provisioner::ChefSolo do
|
|
25
|
-
|
|
26
25
|
let(:logged_output) { StringIO.new }
|
|
27
26
|
let(:logger) { Logger.new(logged_output) }
|
|
28
|
-
let(:platform) { stub(:
|
|
29
|
-
let(:suite) { stub(:
|
|
27
|
+
let(:platform) { stub(os_type: nil) }
|
|
28
|
+
let(:suite) { stub(name: "fries") }
|
|
30
29
|
|
|
31
30
|
let(:config) do
|
|
32
|
-
{ :
|
|
31
|
+
{ test_base_path: "/b", kitchen_root: "/r" }
|
|
33
32
|
end
|
|
34
33
|
|
|
35
34
|
let(:instance) do
|
|
36
35
|
stub(
|
|
37
|
-
:
|
|
38
|
-
:
|
|
39
|
-
:
|
|
40
|
-
:
|
|
36
|
+
name: "coolbeans",
|
|
37
|
+
logger: logger,
|
|
38
|
+
suite: suite,
|
|
39
|
+
platform: platform
|
|
41
40
|
)
|
|
42
41
|
end
|
|
43
42
|
|
|
@@ -54,9 +53,7 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
54
53
|
end
|
|
55
54
|
|
|
56
55
|
describe "default config" do
|
|
57
|
-
|
|
58
56
|
describe "for unix operating systems" do
|
|
59
|
-
|
|
60
57
|
before { platform.stubs(:os_type).returns("unix") }
|
|
61
58
|
|
|
62
59
|
it "sets :chef_solo_path to a path using :chef_omnibus_root" do
|
|
@@ -67,14 +64,13 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
67
64
|
end
|
|
68
65
|
|
|
69
66
|
describe "for windows operating systems" do
|
|
70
|
-
|
|
71
67
|
before { platform.stubs(:os_type).returns("windows") }
|
|
72
68
|
|
|
73
69
|
it "sets :chef_solo_path to a path using :chef_omnibus_root" do
|
|
74
|
-
config[:chef_omnibus_root] =
|
|
70
|
+
config[:chef_omnibus_root] = '$env:systemdrive\\nice\\place'
|
|
75
71
|
|
|
76
|
-
provisioner[:chef_solo_path]
|
|
77
|
-
must_equal
|
|
72
|
+
provisioner[:chef_solo_path]
|
|
73
|
+
.must_equal '$env:systemdrive\\nice\\place\\bin\\chef-solo.bat'
|
|
78
74
|
end
|
|
79
75
|
end
|
|
80
76
|
|
|
@@ -84,7 +80,6 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
84
80
|
end
|
|
85
81
|
|
|
86
82
|
describe "#create_sandbox" do
|
|
87
|
-
|
|
88
83
|
before do
|
|
89
84
|
@root = Dir.mktmpdir
|
|
90
85
|
config[:kitchen_root] = @root
|
|
@@ -99,7 +94,6 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
99
94
|
end
|
|
100
95
|
|
|
101
96
|
describe "solo.rb file" do
|
|
102
|
-
|
|
103
97
|
let(:file) do
|
|
104
98
|
IO.read(sandbox_path("solo.rb")).lines.map(&:chomp)
|
|
105
99
|
end
|
|
@@ -119,12 +113,11 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
119
113
|
it "logs a message on debug" do
|
|
120
114
|
provisioner.create_sandbox
|
|
121
115
|
|
|
122
|
-
logged_output.string
|
|
123
|
-
|
|
116
|
+
logged_output.string
|
|
117
|
+
.must_match debug_line_starting_with("Creating solo.rb from {")
|
|
124
118
|
end
|
|
125
119
|
|
|
126
120
|
describe "defaults" do
|
|
127
|
-
|
|
128
121
|
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
|
129
122
|
def self.common_solo_rb_specs
|
|
130
123
|
it "sets node_name to the instance name" do
|
|
@@ -188,7 +181,6 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
188
181
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
|
189
182
|
|
|
190
183
|
describe "for unix os types" do
|
|
191
|
-
|
|
192
184
|
before do
|
|
193
185
|
platform.stubs(:os_type).returns("unix")
|
|
194
186
|
provisioner.create_sandbox
|
|
@@ -200,23 +192,21 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
200
192
|
end
|
|
201
193
|
|
|
202
194
|
describe "for windows os types with full path" do
|
|
203
|
-
|
|
204
195
|
before do
|
|
205
196
|
platform.stubs(:os_type).returns("windows")
|
|
206
|
-
config[:root_path] =
|
|
197
|
+
config[:root_path] = '\\a\\b'
|
|
207
198
|
provisioner.create_sandbox
|
|
208
199
|
end
|
|
209
200
|
|
|
210
|
-
let(:base) {
|
|
201
|
+
let(:base) { '\\\\a\\\\b\\\\' }
|
|
211
202
|
|
|
212
203
|
common_solo_rb_specs
|
|
213
204
|
end
|
|
214
205
|
|
|
215
206
|
describe "for windows os types with $env:TEMP prefixed paths" do
|
|
216
|
-
|
|
217
207
|
before do
|
|
218
208
|
platform.stubs(:os_type).returns("windows")
|
|
219
|
-
config[:root_path] =
|
|
209
|
+
config[:root_path] = '$env:TEMP\\a'
|
|
220
210
|
provisioner.create_sandbox
|
|
221
211
|
end
|
|
222
212
|
|
|
@@ -228,9 +218,9 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
228
218
|
|
|
229
219
|
it "supports overwriting defaults" do
|
|
230
220
|
config[:solo_rb] = {
|
|
231
|
-
:
|
|
232
|
-
:
|
|
233
|
-
:
|
|
221
|
+
node_name: "eagles",
|
|
222
|
+
user_path: "/a/b/c/u",
|
|
223
|
+
client_key: "lol",
|
|
234
224
|
}
|
|
235
225
|
provisioner.create_sandbox
|
|
236
226
|
|
|
@@ -241,7 +231,7 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
241
231
|
|
|
242
232
|
it "supports adding new configuration" do
|
|
243
233
|
config[:solo_rb] = {
|
|
244
|
-
:
|
|
234
|
+
dark_secret: "golang",
|
|
245
235
|
}
|
|
246
236
|
provisioner.create_sandbox
|
|
247
237
|
|
|
@@ -250,7 +240,7 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
250
240
|
|
|
251
241
|
it "formats array values correctly" do
|
|
252
242
|
config[:solo_rb] = {
|
|
253
|
-
:
|
|
243
|
+
foos: %w{foo1 foo2},
|
|
254
244
|
}
|
|
255
245
|
provisioner.create_sandbox
|
|
256
246
|
|
|
@@ -259,7 +249,7 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
259
249
|
|
|
260
250
|
it "formats integer values correctly" do
|
|
261
251
|
config[:solo_rb] = {
|
|
262
|
-
:
|
|
252
|
+
foo: 7,
|
|
263
253
|
}
|
|
264
254
|
provisioner.create_sandbox
|
|
265
255
|
|
|
@@ -268,7 +258,7 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
268
258
|
|
|
269
259
|
it "formats symbol-looking string values correctly" do
|
|
270
260
|
config[:solo_rb] = {
|
|
271
|
-
:
|
|
261
|
+
foo: ":bar",
|
|
272
262
|
}
|
|
273
263
|
provisioner.create_sandbox
|
|
274
264
|
|
|
@@ -277,8 +267,8 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
277
267
|
|
|
278
268
|
it "formats boolean values correctly" do
|
|
279
269
|
config[:solo_rb] = {
|
|
280
|
-
:
|
|
281
|
-
:
|
|
270
|
+
foo: false,
|
|
271
|
+
bar: true,
|
|
282
272
|
}
|
|
283
273
|
provisioner.create_sandbox
|
|
284
274
|
|
|
@@ -293,11 +283,9 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
293
283
|
end
|
|
294
284
|
|
|
295
285
|
describe "#run_command" do
|
|
296
|
-
|
|
297
286
|
let(:cmd) { provisioner.run_command }
|
|
298
287
|
|
|
299
288
|
describe "common behavior" do
|
|
300
|
-
|
|
301
289
|
before { platform.stubs(:shell_type).returns("fake") }
|
|
302
290
|
|
|
303
291
|
it "prefixs the whole command with the command_prefix if set" do
|
|
@@ -314,7 +302,6 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
314
302
|
end
|
|
315
303
|
|
|
316
304
|
describe "for bourne shells" do
|
|
317
|
-
|
|
318
305
|
before { platform.stubs(:shell_type).returns("bourne") }
|
|
319
306
|
|
|
320
307
|
it "uses bourne shell" do
|
|
@@ -330,18 +317,18 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
330
317
|
config[:http_proxy] = "http://proxy"
|
|
331
318
|
|
|
332
319
|
cmd.lines.to_a[1..2].must_equal([
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
320
|
+
%{http_proxy="http://proxy"; export http_proxy\n},
|
|
321
|
+
%{HTTP_PROXY="http://proxy"; export HTTP_PROXY\n},
|
|
322
|
+
])
|
|
336
323
|
end
|
|
337
324
|
|
|
338
325
|
it "exports https_proxy & HTTPS_PROXY when :https_proxy is set" do
|
|
339
326
|
config[:https_proxy] = "https://proxy"
|
|
340
327
|
|
|
341
328
|
cmd.lines.to_a[1..2].must_equal([
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
329
|
+
%{https_proxy="https://proxy"; export https_proxy\n},
|
|
330
|
+
%{HTTPS_PROXY="https://proxy"; export HTTPS_PROXY\n},
|
|
331
|
+
])
|
|
345
332
|
end
|
|
346
333
|
|
|
347
334
|
it "exports all http proxy variables when both are set" do
|
|
@@ -349,11 +336,11 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
349
336
|
config[:https_proxy] = "https://proxy"
|
|
350
337
|
|
|
351
338
|
cmd.lines.to_a[1..4].must_equal([
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
339
|
+
%{http_proxy="http://proxy"; export http_proxy\n},
|
|
340
|
+
%{HTTP_PROXY="http://proxy"; export HTTP_PROXY\n},
|
|
341
|
+
%{https_proxy="https://proxy"; export https_proxy\n},
|
|
342
|
+
%{HTTPS_PROXY="https://proxy"; export HTTPS_PROXY\n},
|
|
343
|
+
])
|
|
357
344
|
end
|
|
358
345
|
|
|
359
346
|
it "does no powershell PATH reloading for older chef omnibus packages" do
|
|
@@ -462,7 +449,6 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
462
449
|
end
|
|
463
450
|
|
|
464
451
|
describe "for powershell shells on windows os types" do
|
|
465
|
-
|
|
466
452
|
before do
|
|
467
453
|
platform.stubs(:shell_type).returns("powershell")
|
|
468
454
|
platform.stubs(:os_type).returns("windows")
|
|
@@ -472,18 +458,18 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
472
458
|
config[:http_proxy] = "http://proxy"
|
|
473
459
|
|
|
474
460
|
cmd.lines.to_a[0..1].must_equal([
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
461
|
+
%{$env:http_proxy = "http://proxy"\n},
|
|
462
|
+
%{$env:HTTP_PROXY = "http://proxy"\n},
|
|
463
|
+
])
|
|
478
464
|
end
|
|
479
465
|
|
|
480
466
|
it "exports https_proxy & HTTPS_PROXY when :https_proxy is set" do
|
|
481
467
|
config[:https_proxy] = "https://proxy"
|
|
482
468
|
|
|
483
469
|
cmd.lines.to_a[0..1].must_equal([
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
470
|
+
%{$env:https_proxy = "https://proxy"\n},
|
|
471
|
+
%{$env:HTTPS_PROXY = "https://proxy"\n},
|
|
472
|
+
])
|
|
487
473
|
end
|
|
488
474
|
|
|
489
475
|
it "exports all http proxy variables when both are set" do
|
|
@@ -491,11 +477,11 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
491
477
|
config[:https_proxy] = "https://proxy"
|
|
492
478
|
|
|
493
479
|
cmd.lines.to_a[0..3].must_equal([
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
480
|
+
%{$env:http_proxy = "http://proxy"\n},
|
|
481
|
+
%{$env:HTTP_PROXY = "http://proxy"\n},
|
|
482
|
+
%{$env:https_proxy = "https://proxy"\n},
|
|
483
|
+
%{$env:HTTPS_PROXY = "https://proxy"\n},
|
|
484
|
+
])
|
|
499
485
|
end
|
|
500
486
|
|
|
501
487
|
it "reloads PATH for older chef omnibus packages" do
|
|
@@ -505,33 +491,33 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
505
491
|
end
|
|
506
492
|
|
|
507
493
|
it "calls the chef-solo command from :chef_solo_path" do
|
|
508
|
-
config[:chef_solo_path] =
|
|
494
|
+
config[:chef_solo_path] = '\\r\\chef-solo.bat'
|
|
509
495
|
|
|
510
|
-
cmd.must_match regexify(
|
|
496
|
+
cmd.must_match regexify('& \\r\\chef-solo.bat ', :partial_line)
|
|
511
497
|
end
|
|
512
498
|
|
|
513
499
|
it "sets config flag on chef-solo" do
|
|
514
500
|
cmd.must_match regexify(
|
|
515
|
-
|
|
501
|
+
' --config $env:TEMP\\kitchen\\solo.rb', :partial_line)
|
|
516
502
|
end
|
|
517
503
|
|
|
518
504
|
it "sets config flag for custom root_path" do
|
|
519
|
-
config[:root_path] =
|
|
505
|
+
config[:root_path] = '\\a\\b'
|
|
520
506
|
|
|
521
507
|
cmd.must_match regexify(
|
|
522
|
-
|
|
508
|
+
' --config \\a\\b\\solo.rb', :partial_line)
|
|
523
509
|
end
|
|
524
510
|
|
|
525
511
|
it "sets json attributes flag on chef-solo" do
|
|
526
512
|
cmd.must_match regexify(
|
|
527
|
-
|
|
513
|
+
' --json-attributes $env:TEMP\\kitchen\\dna.json', :partial_line)
|
|
528
514
|
end
|
|
529
515
|
|
|
530
516
|
it "sets json attribtes flag for custom root_path" do
|
|
531
|
-
config[:root_path] =
|
|
517
|
+
config[:root_path] = '\\booyah'
|
|
532
518
|
|
|
533
519
|
cmd.must_match regexify(
|
|
534
|
-
|
|
520
|
+
' --json-attributes \\booyah\\dna.json', :partial_line)
|
|
535
521
|
end
|
|
536
522
|
|
|
537
523
|
it "sets log level flag on chef-solo to auto by default" do
|
|
@@ -557,19 +543,19 @@ describe Kitchen::Provisioner::ChefSolo do
|
|
|
557
543
|
end
|
|
558
544
|
|
|
559
545
|
it "sets logfile flag for custom value" do
|
|
560
|
-
config[:log_file] =
|
|
546
|
+
config[:log_file] = '\\a\\out.log'
|
|
561
547
|
|
|
562
|
-
cmd.must_match regexify(
|
|
548
|
+
cmd.must_match regexify(' --logfile \\a\\out.log', :partial_line)
|
|
563
549
|
end
|
|
564
550
|
end
|
|
565
551
|
end
|
|
566
552
|
|
|
567
553
|
def info_line(msg)
|
|
568
|
-
|
|
554
|
+
/^I, .* : #{Regexp.escape(msg)}$/
|
|
569
555
|
end
|
|
570
556
|
|
|
571
557
|
def debug_line_starting_with(msg)
|
|
572
|
-
|
|
558
|
+
/^D, .* : #{Regexp.escape(msg)}/
|
|
573
559
|
end
|
|
574
560
|
|
|
575
561
|
def regexify(str, line = :whole_line)
|
|
@@ -22,22 +22,21 @@ require "kitchen"
|
|
|
22
22
|
require "kitchen/provisioner/chef_zero"
|
|
23
23
|
|
|
24
24
|
describe Kitchen::Provisioner::ChefZero do
|
|
25
|
-
|
|
26
25
|
let(:logged_output) { StringIO.new }
|
|
27
26
|
let(:logger) { Logger.new(logged_output) }
|
|
28
|
-
let(:platform) { stub(:
|
|
29
|
-
let(:suite) { stub(:
|
|
27
|
+
let(:platform) { stub(os_type: nil) }
|
|
28
|
+
let(:suite) { stub(name: "fries") }
|
|
30
29
|
|
|
31
30
|
let(:config) do
|
|
32
|
-
{ :
|
|
31
|
+
{ test_base_path: "/b", kitchen_root: "/r" }
|
|
33
32
|
end
|
|
34
33
|
|
|
35
34
|
let(:instance) do
|
|
36
35
|
stub(
|
|
37
|
-
:
|
|
38
|
-
:
|
|
39
|
-
:
|
|
40
|
-
:
|
|
36
|
+
name: "coolbeans",
|
|
37
|
+
logger: logger,
|
|
38
|
+
suite: suite,
|
|
39
|
+
platform: platform
|
|
41
40
|
)
|
|
42
41
|
end
|
|
43
42
|
|
|
@@ -54,16 +53,14 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
54
53
|
end
|
|
55
54
|
|
|
56
55
|
describe "default config" do
|
|
57
|
-
|
|
58
56
|
describe "for unix operating systems" do
|
|
59
|
-
|
|
60
57
|
before { platform.stubs(:os_type).returns("unix") }
|
|
61
58
|
|
|
62
59
|
it "sets :chef_client_path to a path using :chef_omnibus_root" do
|
|
63
60
|
config[:chef_omnibus_root] = "/nice/place"
|
|
64
61
|
|
|
65
|
-
provisioner[:chef_client_path]
|
|
66
|
-
must_equal "/nice/place/bin/chef-client"
|
|
62
|
+
provisioner[:chef_client_path]
|
|
63
|
+
.must_equal "/nice/place/bin/chef-client"
|
|
67
64
|
end
|
|
68
65
|
|
|
69
66
|
it "sets :ruby_bindir to use an Omnibus Ruby" do
|
|
@@ -74,20 +71,19 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
74
71
|
end
|
|
75
72
|
|
|
76
73
|
describe "for windows operating systems" do
|
|
77
|
-
|
|
78
74
|
before { platform.stubs(:os_type).returns("windows") }
|
|
79
75
|
|
|
80
76
|
it "sets :chef_client_path to a path using :chef_omnibus_root" do
|
|
81
|
-
config[:chef_omnibus_root] =
|
|
77
|
+
config[:chef_omnibus_root] = '$env:systemdrive\\nice\\place'
|
|
82
78
|
|
|
83
|
-
provisioner[:chef_client_path]
|
|
84
|
-
must_equal
|
|
79
|
+
provisioner[:chef_client_path]
|
|
80
|
+
.must_equal '$env:systemdrive\\nice\\place\\bin\\chef-client.bat'
|
|
85
81
|
end
|
|
86
82
|
|
|
87
83
|
it "sets :ruby_bindir to use an Omnibus Ruby" do
|
|
88
|
-
config[:chef_omnibus_root] =
|
|
84
|
+
config[:chef_omnibus_root] = 'c:\\nice'
|
|
89
85
|
|
|
90
|
-
provisioner[:ruby_bindir].must_equal
|
|
86
|
+
provisioner[:ruby_bindir].must_equal 'c:\\nice\\embedded\\bin'
|
|
91
87
|
end
|
|
92
88
|
end
|
|
93
89
|
|
|
@@ -109,7 +105,6 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
109
105
|
end
|
|
110
106
|
|
|
111
107
|
describe "#create_sandbox" do
|
|
112
|
-
|
|
113
108
|
before do
|
|
114
109
|
@root = Dir.mktmpdir
|
|
115
110
|
config[:kitchen_root] = @root
|
|
@@ -124,7 +119,6 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
124
119
|
end
|
|
125
120
|
|
|
126
121
|
describe "client.rb file" do
|
|
127
|
-
|
|
128
122
|
let(:file) do
|
|
129
123
|
IO.read(sandbox_path("client.rb")).lines.map(&:chomp)
|
|
130
124
|
end
|
|
@@ -144,12 +138,11 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
144
138
|
it "logs a message on debug" do
|
|
145
139
|
provisioner.create_sandbox
|
|
146
140
|
|
|
147
|
-
logged_output.string
|
|
148
|
-
|
|
141
|
+
logged_output.string
|
|
142
|
+
.must_match debug_line_starting_with("Creating client.rb from {")
|
|
149
143
|
end
|
|
150
144
|
|
|
151
145
|
describe "defaults" do
|
|
152
|
-
|
|
153
146
|
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
|
154
147
|
def self.common_client_rb_specs
|
|
155
148
|
it "sets node_name to the instance name" do
|
|
@@ -213,7 +206,6 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
213
206
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
|
214
207
|
|
|
215
208
|
describe "for unix os types" do
|
|
216
|
-
|
|
217
209
|
before do
|
|
218
210
|
platform.stubs(:os_type).returns("unix")
|
|
219
211
|
provisioner.create_sandbox
|
|
@@ -225,23 +217,21 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
225
217
|
end
|
|
226
218
|
|
|
227
219
|
describe "for windows os types with full path" do
|
|
228
|
-
|
|
229
220
|
before do
|
|
230
221
|
platform.stubs(:os_type).returns("windows")
|
|
231
|
-
config[:root_path] =
|
|
222
|
+
config[:root_path] = '\\a\\b'
|
|
232
223
|
provisioner.create_sandbox
|
|
233
224
|
end
|
|
234
225
|
|
|
235
|
-
let(:base) {
|
|
226
|
+
let(:base) { '\\\\a\\\\b\\\\' }
|
|
236
227
|
|
|
237
228
|
common_client_rb_specs
|
|
238
229
|
end
|
|
239
230
|
|
|
240
231
|
describe "for windows os types with $env:TEMP prefixed paths" do
|
|
241
|
-
|
|
242
232
|
before do
|
|
243
233
|
platform.stubs(:os_type).returns("windows")
|
|
244
|
-
config[:root_path] =
|
|
234
|
+
config[:root_path] = '$env:TEMP\\a'
|
|
245
235
|
provisioner.create_sandbox
|
|
246
236
|
end
|
|
247
237
|
|
|
@@ -253,9 +243,9 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
253
243
|
|
|
254
244
|
it "supports overwriting defaults" do
|
|
255
245
|
config[:client_rb] = {
|
|
256
|
-
:
|
|
257
|
-
:
|
|
258
|
-
:
|
|
246
|
+
node_name: "eagles",
|
|
247
|
+
user_path: "/a/b/c/u",
|
|
248
|
+
client_key: "lol",
|
|
259
249
|
}
|
|
260
250
|
provisioner.create_sandbox
|
|
261
251
|
|
|
@@ -266,7 +256,7 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
266
256
|
|
|
267
257
|
it " supports adding new configuration" do
|
|
268
258
|
config[:client_rb] = {
|
|
269
|
-
:
|
|
259
|
+
dark_secret: "golang",
|
|
270
260
|
}
|
|
271
261
|
provisioner.create_sandbox
|
|
272
262
|
|
|
@@ -275,7 +265,7 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
275
265
|
|
|
276
266
|
it "formats array values correctly" do
|
|
277
267
|
config[:client_rb] = {
|
|
278
|
-
:
|
|
268
|
+
foos: %w{foo1 foo2},
|
|
279
269
|
}
|
|
280
270
|
provisioner.create_sandbox
|
|
281
271
|
|
|
@@ -284,7 +274,7 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
284
274
|
|
|
285
275
|
it "formats integer values correctly" do
|
|
286
276
|
config[:client_rb] = {
|
|
287
|
-
:
|
|
277
|
+
foo: 7,
|
|
288
278
|
}
|
|
289
279
|
provisioner.create_sandbox
|
|
290
280
|
|
|
@@ -293,7 +283,7 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
293
283
|
|
|
294
284
|
it "formats symbol-looking string values correctly" do
|
|
295
285
|
config[:client_rb] = {
|
|
296
|
-
:
|
|
286
|
+
foo: ":bar",
|
|
297
287
|
}
|
|
298
288
|
provisioner.create_sandbox
|
|
299
289
|
|
|
@@ -302,8 +292,8 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
302
292
|
|
|
303
293
|
it "formats boolean values correctly" do
|
|
304
294
|
config[:client_rb] = {
|
|
305
|
-
:
|
|
306
|
-
:
|
|
295
|
+
foo: false,
|
|
296
|
+
bar: true,
|
|
307
297
|
}
|
|
308
298
|
provisioner.create_sandbox
|
|
309
299
|
|
|
@@ -313,7 +303,6 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
313
303
|
end
|
|
314
304
|
|
|
315
305
|
describe "validation.pem file" do
|
|
316
|
-
|
|
317
306
|
it "creates file" do
|
|
318
307
|
provisioner.create_sandbox
|
|
319
308
|
|
|
@@ -329,15 +318,13 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
329
318
|
it "logs a message on debug" do
|
|
330
319
|
provisioner.create_sandbox
|
|
331
320
|
|
|
332
|
-
logged_output.string
|
|
333
|
-
|
|
321
|
+
logged_output.string
|
|
322
|
+
.must_match debug_line_starting_with("Using a dummy validation.pem")
|
|
334
323
|
end
|
|
335
324
|
end
|
|
336
325
|
|
|
337
326
|
describe "chef-client-zero.rb file" do
|
|
338
|
-
|
|
339
327
|
describe "for modern Chef versions" do
|
|
340
|
-
|
|
341
328
|
before { config[:require_chef_omnibus] = "11.10" }
|
|
342
329
|
|
|
343
330
|
it "does not create the file" do
|
|
@@ -362,7 +349,6 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
362
349
|
end
|
|
363
350
|
|
|
364
351
|
describe "for old Chef versions" do
|
|
365
|
-
|
|
366
352
|
before { config[:require_chef_omnibus] = "10.20" }
|
|
367
353
|
|
|
368
354
|
it "creates the file when using an old Chef version" do
|
|
@@ -374,8 +360,8 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
374
360
|
it "logs a message on info" do
|
|
375
361
|
provisioner.create_sandbox
|
|
376
362
|
|
|
377
|
-
logged_output.string
|
|
378
|
-
|
|
363
|
+
logged_output.string
|
|
364
|
+
.must_match info_line("Preparing chef-client-zero.rb")
|
|
379
365
|
end
|
|
380
366
|
|
|
381
367
|
it "logs a message on debug" do
|
|
@@ -393,11 +379,9 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
393
379
|
end
|
|
394
380
|
|
|
395
381
|
describe "#prepare_command" do
|
|
396
|
-
|
|
397
382
|
let(:cmd) { provisioner.prepare_command }
|
|
398
383
|
|
|
399
384
|
describe "for modern Chef versions" do
|
|
400
|
-
|
|
401
385
|
before { config[:require_chef_omnibus] = "11.10" }
|
|
402
386
|
|
|
403
387
|
it "returns nil" do
|
|
@@ -406,11 +390,9 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
406
390
|
end
|
|
407
391
|
|
|
408
392
|
describe "for old Chef versions" do
|
|
409
|
-
|
|
410
393
|
before { config[:require_chef_omnibus] = "10.20" }
|
|
411
394
|
|
|
412
395
|
describe "for bourne shells" do
|
|
413
|
-
|
|
414
396
|
before do
|
|
415
397
|
platform.stubs(:shell_type).returns("bourne")
|
|
416
398
|
config[:ruby_bindir] = "/rbd"
|
|
@@ -429,18 +411,18 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
429
411
|
config[:http_proxy] = "http://proxy"
|
|
430
412
|
|
|
431
413
|
cmd.lines.to_a[1..2].must_equal([
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
414
|
+
%{http_proxy="http://proxy"; export http_proxy\n},
|
|
415
|
+
%{HTTP_PROXY="http://proxy"; export HTTP_PROXY\n},
|
|
416
|
+
])
|
|
435
417
|
end
|
|
436
418
|
|
|
437
419
|
it "exports https_proxy & HTTPS_PROXY when :https_proxy is set" do
|
|
438
420
|
config[:https_proxy] = "https://proxy"
|
|
439
421
|
|
|
440
422
|
cmd.lines.to_a[1..2].must_equal([
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
423
|
+
%{https_proxy="https://proxy"; export https_proxy\n},
|
|
424
|
+
%{HTTPS_PROXY="https://proxy"; export HTTPS_PROXY\n},
|
|
425
|
+
])
|
|
444
426
|
end
|
|
445
427
|
|
|
446
428
|
it "exports all http proxy variables when both are set" do
|
|
@@ -448,11 +430,11 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
448
430
|
config[:https_proxy] = "https://proxy"
|
|
449
431
|
|
|
450
432
|
cmd.lines.to_a[1..4].must_equal([
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
433
|
+
%{http_proxy="http://proxy"; export http_proxy\n},
|
|
434
|
+
%{HTTP_PROXY="http://proxy"; export HTTP_PROXY\n},
|
|
435
|
+
%{https_proxy="https://proxy"; export https_proxy\n},
|
|
436
|
+
%{HTTPS_PROXY="https://proxy"; export HTTPS_PROXY\n},
|
|
437
|
+
])
|
|
456
438
|
end
|
|
457
439
|
|
|
458
440
|
it "sets the CHEF_REPO_PATH environment variable" do
|
|
@@ -497,30 +479,29 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
497
479
|
end
|
|
498
480
|
|
|
499
481
|
describe "for powershell shells on windows os types" do
|
|
500
|
-
|
|
501
482
|
before do
|
|
502
483
|
platform.stubs(:shell_type).returns("powershell")
|
|
503
484
|
platform.stubs(:os_type).returns("windows")
|
|
504
|
-
config[:root_path] =
|
|
505
|
-
config[:ruby_bindir] =
|
|
485
|
+
config[:root_path] = '\\r'
|
|
486
|
+
config[:ruby_bindir] = '\\rbd'
|
|
506
487
|
end
|
|
507
488
|
|
|
508
489
|
it "exports http_proxy & HTTP_PROXY when :http_proxy is set" do
|
|
509
490
|
config[:http_proxy] = "http://proxy"
|
|
510
491
|
|
|
511
492
|
cmd.lines.to_a[0..1].must_equal([
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
493
|
+
%{$env:http_proxy = "http://proxy"\n},
|
|
494
|
+
%{$env:HTTP_PROXY = "http://proxy"\n},
|
|
495
|
+
])
|
|
515
496
|
end
|
|
516
497
|
|
|
517
498
|
it "exports https_proxy & HTTPS_PROXY when :https_proxy is set" do
|
|
518
499
|
config[:https_proxy] = "https://proxy"
|
|
519
500
|
|
|
520
501
|
cmd.lines.to_a[0..1].must_equal([
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
502
|
+
%{$env:https_proxy = "https://proxy"\n},
|
|
503
|
+
%{$env:HTTPS_PROXY = "https://proxy"\n},
|
|
504
|
+
])
|
|
524
505
|
end
|
|
525
506
|
|
|
526
507
|
it "exports all http proxy variables when both are set" do
|
|
@@ -528,36 +509,36 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
528
509
|
config[:https_proxy] = "https://proxy"
|
|
529
510
|
|
|
530
511
|
cmd.lines.to_a[0..3].must_equal([
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
512
|
+
%{$env:http_proxy = "http://proxy"\n},
|
|
513
|
+
%{$env:HTTP_PROXY = "http://proxy"\n},
|
|
514
|
+
%{$env:https_proxy = "https://proxy"\n},
|
|
515
|
+
%{$env:HTTPS_PROXY = "https://proxy"\n},
|
|
516
|
+
])
|
|
536
517
|
end
|
|
537
518
|
|
|
538
519
|
it "sets the CHEF_REPO_PATH environment variable" do
|
|
539
|
-
config[:root_path] =
|
|
520
|
+
config[:root_path] = '\\r'
|
|
540
521
|
|
|
541
522
|
cmd.must_match regexify(
|
|
542
523
|
%{$env:CHEF_REPO_PATH = "\\r"})
|
|
543
524
|
end
|
|
544
525
|
|
|
545
526
|
it "sets the GEM_HOME environment variable" do
|
|
546
|
-
config[:root_path] =
|
|
527
|
+
config[:root_path] = '\\r'
|
|
547
528
|
|
|
548
529
|
cmd.must_match regexify(
|
|
549
530
|
%{$env:GEM_HOME = "\\r\\chef-client-zero-gems"})
|
|
550
531
|
end
|
|
551
532
|
|
|
552
533
|
it "sets the GEM_PATH environment variable" do
|
|
553
|
-
config[:root_path] =
|
|
534
|
+
config[:root_path] = '\\r'
|
|
554
535
|
|
|
555
536
|
cmd.must_match regexify(
|
|
556
537
|
%{$env:GEM_PATH = "\\r\\chef-client-zero-gems"})
|
|
557
538
|
end
|
|
558
539
|
|
|
559
540
|
it "sets the GEM_CACHE environment variable" do
|
|
560
|
-
config[:root_path] =
|
|
541
|
+
config[:root_path] = '\\r'
|
|
561
542
|
|
|
562
543
|
cmd.must_match regexify(
|
|
563
544
|
%{$env:GEM_CACHE = "\\r\\chef-client-zero-gems\\cache"})
|
|
@@ -571,7 +552,6 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
571
552
|
end
|
|
572
553
|
|
|
573
554
|
describe "#run_command" do
|
|
574
|
-
|
|
575
555
|
let(:cmd) { provisioner.run_command }
|
|
576
556
|
|
|
577
557
|
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
|
@@ -650,7 +630,6 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
650
630
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
|
651
631
|
|
|
652
632
|
describe "for modern Chef versions" do
|
|
653
|
-
|
|
654
633
|
before { config[:require_chef_omnibus] = "11.10" }
|
|
655
634
|
|
|
656
635
|
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
|
@@ -703,7 +682,6 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
703
682
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
|
704
683
|
|
|
705
684
|
describe "for bourne shells" do
|
|
706
|
-
|
|
707
685
|
before { platform.stubs(:shell_type).returns("bourne") }
|
|
708
686
|
|
|
709
687
|
let(:base) { "/tmp/kitchen/" }
|
|
@@ -726,18 +704,18 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
726
704
|
config[:http_proxy] = "http://proxy"
|
|
727
705
|
|
|
728
706
|
cmd.lines.to_a[1..2].must_equal([
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
707
|
+
%{http_proxy="http://proxy"; export http_proxy\n},
|
|
708
|
+
%{HTTP_PROXY="http://proxy"; export HTTP_PROXY\n},
|
|
709
|
+
])
|
|
732
710
|
end
|
|
733
711
|
|
|
734
712
|
it "exports https_proxy & HTTPS_PROXY when :https_proxy is set" do
|
|
735
713
|
config[:https_proxy] = "https://proxy"
|
|
736
714
|
|
|
737
715
|
cmd.lines.to_a[1..2].must_equal([
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
716
|
+
%{https_proxy="https://proxy"; export https_proxy\n},
|
|
717
|
+
%{HTTPS_PROXY="https://proxy"; export HTTPS_PROXY\n},
|
|
718
|
+
])
|
|
741
719
|
end
|
|
742
720
|
|
|
743
721
|
it "exports all http proxy variables when both are set" do
|
|
@@ -745,11 +723,11 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
745
723
|
config[:https_proxy] = "https://proxy"
|
|
746
724
|
|
|
747
725
|
cmd.lines.to_a[1..4].must_equal([
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
726
|
+
%{http_proxy="http://proxy"; export http_proxy\n},
|
|
727
|
+
%{HTTP_PROXY="http://proxy"; export HTTP_PROXY\n},
|
|
728
|
+
%{https_proxy="https://proxy"; export https_proxy\n},
|
|
729
|
+
%{HTTPS_PROXY="https://proxy"; export HTTPS_PROXY\n},
|
|
730
|
+
])
|
|
753
731
|
end
|
|
754
732
|
|
|
755
733
|
it "does no powershell PATH reloading for older chef omnibus packages" do
|
|
@@ -773,15 +751,14 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
773
751
|
end
|
|
774
752
|
|
|
775
753
|
describe "for powershell shells on windows os types" do
|
|
776
|
-
|
|
777
754
|
before do
|
|
778
755
|
platform.stubs(:shell_type).returns("powershell")
|
|
779
756
|
platform.stubs(:os_type).returns("windows")
|
|
780
757
|
end
|
|
781
758
|
|
|
782
|
-
let(:base) {
|
|
783
|
-
let(:custom_base) {
|
|
784
|
-
let(:custom_root) {
|
|
759
|
+
let(:base) { '$env:TEMP\\kitchen\\' }
|
|
760
|
+
let(:custom_base) { '\\a\\b\\' }
|
|
761
|
+
let(:custom_root) { '\\a\\b' }
|
|
785
762
|
|
|
786
763
|
common_shell_specs
|
|
787
764
|
common_modern_shell_specs
|
|
@@ -790,18 +767,18 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
790
767
|
config[:http_proxy] = "http://proxy"
|
|
791
768
|
|
|
792
769
|
cmd.lines.to_a[0..1].must_equal([
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
770
|
+
%{$env:http_proxy = "http://proxy"\n},
|
|
771
|
+
%{$env:HTTP_PROXY = "http://proxy"\n},
|
|
772
|
+
])
|
|
796
773
|
end
|
|
797
774
|
|
|
798
775
|
it "exports https_proxy & HTTPS_PROXY when :https_proxy is set" do
|
|
799
776
|
config[:https_proxy] = "https://proxy"
|
|
800
777
|
|
|
801
778
|
cmd.lines.to_a[0..1].must_equal([
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
779
|
+
%{$env:https_proxy = "https://proxy"\n},
|
|
780
|
+
%{$env:HTTPS_PROXY = "https://proxy"\n},
|
|
781
|
+
])
|
|
805
782
|
end
|
|
806
783
|
|
|
807
784
|
it "exports all http proxy variables when both are set" do
|
|
@@ -809,11 +786,11 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
809
786
|
config[:https_proxy] = "https://proxy"
|
|
810
787
|
|
|
811
788
|
cmd.lines.to_a[0..3].must_equal([
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
789
|
+
%{$env:http_proxy = "http://proxy"\n},
|
|
790
|
+
%{$env:HTTP_PROXY = "http://proxy"\n},
|
|
791
|
+
%{$env:https_proxy = "https://proxy"\n},
|
|
792
|
+
%{$env:HTTPS_PROXY = "https://proxy"\n},
|
|
793
|
+
])
|
|
817
794
|
end
|
|
818
795
|
|
|
819
796
|
it "reloads PATH for older chef omnibus packages" do
|
|
@@ -823,15 +800,14 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
823
800
|
end
|
|
824
801
|
|
|
825
802
|
it "calls the chef-client command from :chef_client_path" do
|
|
826
|
-
config[:chef_client_path] =
|
|
803
|
+
config[:chef_client_path] = '\\r\\chef-client.bat'
|
|
827
804
|
|
|
828
|
-
cmd.must_match regexify(
|
|
805
|
+
cmd.must_match regexify('& \\r\\chef-client.bat ', :partial_line)
|
|
829
806
|
end
|
|
830
807
|
end
|
|
831
808
|
end
|
|
832
809
|
|
|
833
810
|
describe "for old Chef versions" do
|
|
834
|
-
|
|
835
811
|
before do
|
|
836
812
|
config[:require_chef_omnibus] = "10.20"
|
|
837
813
|
end
|
|
@@ -855,7 +831,6 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
855
831
|
end
|
|
856
832
|
|
|
857
833
|
describe "for bourne shells" do
|
|
858
|
-
|
|
859
834
|
before do
|
|
860
835
|
platform.stubs(:shell_type).returns("bourne")
|
|
861
836
|
config[:ruby_bindir] = "/r/bin"
|
|
@@ -929,50 +904,49 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
929
904
|
end
|
|
930
905
|
|
|
931
906
|
describe "for powershell shells on windows os types" do
|
|
932
|
-
|
|
933
907
|
before do
|
|
934
908
|
platform.stubs(:shell_type).returns("powershell")
|
|
935
909
|
platform.stubs(:os_type).returns("windows")
|
|
936
|
-
config[:ruby_bindir] =
|
|
910
|
+
config[:ruby_bindir] = '\\r\\bin'
|
|
937
911
|
end
|
|
938
912
|
|
|
939
|
-
let(:base) {
|
|
940
|
-
let(:custom_base) {
|
|
941
|
-
let(:custom_root) {
|
|
913
|
+
let(:base) { '$env:TEMP\\kitchen\\' }
|
|
914
|
+
let(:custom_base) { '\\a\\b\\' }
|
|
915
|
+
let(:custom_root) { '\\a\\b' }
|
|
942
916
|
|
|
943
917
|
common_shell_specs
|
|
944
918
|
common_old_shell_specs
|
|
945
919
|
|
|
946
920
|
it "calls ruby from :ruby_bindir" do
|
|
947
|
-
config[:root_path] =
|
|
921
|
+
config[:root_path] = '\\x'
|
|
948
922
|
|
|
949
923
|
cmd.must_match regexify(
|
|
950
|
-
|
|
924
|
+
'\\r\\bin\\ruby.exe \\x\\chef-client-zero.rb ', :partial_line)
|
|
951
925
|
end
|
|
952
926
|
|
|
953
927
|
it "sets the CHEF_REPO_PATH environment variable" do
|
|
954
|
-
config[:root_path] =
|
|
928
|
+
config[:root_path] = '\\r'
|
|
955
929
|
|
|
956
930
|
cmd.must_match regexify(
|
|
957
931
|
%{$env:CHEF_REPO_PATH = "\\r"})
|
|
958
932
|
end
|
|
959
933
|
|
|
960
934
|
it "sets the GEM_HOME environment variable" do
|
|
961
|
-
config[:root_path] =
|
|
935
|
+
config[:root_path] = '\\r'
|
|
962
936
|
|
|
963
937
|
cmd.must_match regexify(
|
|
964
938
|
%{$env:GEM_HOME = "\\r\\chef-client-zero-gems"})
|
|
965
939
|
end
|
|
966
940
|
|
|
967
941
|
it "sets the GEM_PATH environment variable" do
|
|
968
|
-
config[:root_path] =
|
|
942
|
+
config[:root_path] = '\\r'
|
|
969
943
|
|
|
970
944
|
cmd.must_match regexify(
|
|
971
945
|
%{$env:GEM_PATH = "\\r\\chef-client-zero-gems"})
|
|
972
946
|
end
|
|
973
947
|
|
|
974
948
|
it "sets the GEM_CACHE environment variable" do
|
|
975
|
-
config[:root_path] =
|
|
949
|
+
config[:root_path] = '\\r'
|
|
976
950
|
|
|
977
951
|
cmd.must_match regexify(
|
|
978
952
|
%{$env:GEM_CACHE = "\\r\\chef-client-zero-gems\\cache"})
|
|
@@ -988,11 +962,11 @@ describe Kitchen::Provisioner::ChefZero do
|
|
|
988
962
|
end
|
|
989
963
|
|
|
990
964
|
def info_line(msg)
|
|
991
|
-
|
|
965
|
+
/^I, .* : #{Regexp.escape(msg)}$/
|
|
992
966
|
end
|
|
993
967
|
|
|
994
968
|
def debug_line_starting_with(msg)
|
|
995
|
-
|
|
969
|
+
/^D, .* : #{Regexp.escape(msg)}/
|
|
996
970
|
end
|
|
997
971
|
|
|
998
972
|
def regexify(str, line = :whole_line)
|