beaker 4.38.1 → 4.39.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +12 -0
- data/.rubocop.yml +62 -0
- data/.rubocop_todo.yml +215 -0
- data/CHANGELOG.md +72 -33
- data/Gemfile +8 -1
- data/HISTORY.md +103 -0
- data/Rakefile +10 -9
- data/acceptance/fixtures/module/Gemfile +1 -1
- data/acceptance/fixtures/module/Rakefile +2 -2
- data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -11
- data/acceptance/fixtures/module/spec/classes/init_spec.rb +1 -1
- data/acceptance/lib/helpers/test_helper.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +6 -6
- data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +6 -6
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +6 -12
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +1 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +7 -7
- data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +8 -11
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +2 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +6 -11
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +5 -9
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +2 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +1 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +1 -1
- data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +1 -1
- data/acceptance/tests/base/dsl/structure_test.rb +4 -10
- data/acceptance/tests/base/host/file_test.rb +7 -7
- data/acceptance/tests/base/host/group_test.rb +2 -2
- data/acceptance/tests/base/host/host_test.rb +5 -5
- data/acceptance/tests/base/host/packages.rb +26 -28
- data/acceptance/tests/base/host/packages_unix.rb +4 -4
- data/acceptance/tests/base/host/user_test.rb +2 -2
- data/acceptance/tests/install/from_file.rb +2 -2
- data/beaker.gemspec +9 -9
- data/docs/concepts/style_guide.md +1 -1
- data/docs/how_to/debug_beaker_tests.md +1 -1
- data/docs/how_to/test_arbitrary_beaker_versions.md +2 -2
- data/lib/beaker/cli.rb +6 -8
- data/lib/beaker/command.rb +3 -3
- data/lib/beaker/command_factory.rb +2 -2
- data/lib/beaker/dsl/assertions.rb +1 -1
- data/lib/beaker/dsl/helpers/hocon_helpers.rb +2 -2
- data/lib/beaker/dsl/helpers/host_helpers.rb +11 -11
- data/lib/beaker/dsl/helpers/web_helpers.rb +3 -3
- data/lib/beaker/dsl/outcomes.rb +4 -4
- data/lib/beaker/dsl/roles.rb +2 -2
- data/lib/beaker/dsl/structure.rb +10 -10
- data/lib/beaker/host/aix/group.rb +3 -3
- data/lib/beaker/host/aix/user.rb +3 -3
- data/lib/beaker/host/cisco.rb +11 -11
- data/lib/beaker/host/eos.rb +2 -2
- data/lib/beaker/host/mac/exec.rb +1 -1
- data/lib/beaker/host/mac/group.rb +7 -7
- data/lib/beaker/host/mac/pkg.rb +6 -6
- data/lib/beaker/host/mac/user.rb +6 -6
- data/lib/beaker/host/pswindows/exec.rb +8 -8
- data/lib/beaker/host/pswindows/file.rb +1 -1
- data/lib/beaker/host/pswindows/group.rb +3 -3
- data/lib/beaker/host/pswindows/pkg.rb +6 -6
- data/lib/beaker/host/pswindows/user.rb +2 -2
- data/lib/beaker/host/unix/exec.rb +6 -6
- data/lib/beaker/host/unix/file.rb +3 -4
- data/lib/beaker/host/unix/group.rb +3 -3
- data/lib/beaker/host/unix/pkg.rb +17 -17
- data/lib/beaker/host/unix/user.rb +3 -3
- data/lib/beaker/host/unix.rb +10 -9
- data/lib/beaker/host/windows/exec.rb +3 -3
- data/lib/beaker/host/windows/file.rb +2 -2
- data/lib/beaker/host/windows/group.rb +3 -3
- data/lib/beaker/host/windows/pkg.rb +6 -6
- data/lib/beaker/host/windows/user.rb +2 -2
- data/lib/beaker/host/windows.rb +2 -2
- data/lib/beaker/host.rb +7 -7
- data/lib/beaker/host_prebuilt_steps.rb +38 -45
- data/lib/beaker/hypervisor.rb +4 -4
- data/lib/beaker/local_connection.rb +3 -3
- data/lib/beaker/logger.rb +5 -11
- data/lib/beaker/logger_junit.rb +2 -2
- data/lib/beaker/network_manager.rb +2 -2
- data/lib/beaker/options/command_line_parser.rb +1 -1
- data/lib/beaker/options/hosts_file_parser.rb +21 -4
- data/lib/beaker/options/options_file_parser.rb +1 -1
- data/lib/beaker/options/options_hash.rb +1 -3
- data/lib/beaker/options/parser.rb +6 -6
- data/lib/beaker/options/presets.rb +2 -2
- data/lib/beaker/options/validator.rb +2 -2
- data/lib/beaker/perf.rb +9 -9
- data/lib/beaker/platform.rb +1 -1
- data/lib/beaker/shared/host_manager.rb +4 -5
- data/lib/beaker/shared/repetition.rb +4 -4
- data/lib/beaker/shared/semvar.rb +2 -2
- data/lib/beaker/shared/timed.rb +2 -2
- data/lib/beaker/ssh_connection.rb +9 -9
- data/lib/beaker/subcommand.rb +6 -6
- data/lib/beaker/tasks/quick_start.rb +2 -2
- data/lib/beaker/tasks/rake_task.rb +3 -3
- data/lib/beaker/test_suite.rb +2 -2
- data/lib/beaker/test_suite_result.rb +8 -11
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/cli_spec.rb +46 -43
- data/spec/beaker/command_spec.rb +17 -7
- data/spec/beaker/dsl/assertions_spec.rb +2 -11
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +7 -7
- data/spec/beaker/dsl/helpers/web_helpers_spec.rb +2 -2
- data/spec/beaker/dsl/outcomes_spec.rb +1 -0
- data/spec/beaker/dsl/roles_spec.rb +48 -5
- data/spec/beaker/dsl/structure_spec.rb +22 -15
- data/spec/beaker/dsl/test_tagging_spec.rb +16 -16
- data/spec/beaker/dsl/wrappers_spec.rb +7 -7
- data/spec/beaker/host/cisco_spec.rb +8 -8
- data/spec/beaker/host/freebsd/exec_spec.rb +3 -3
- data/spec/beaker/host/freebsd/pkg_spec.rb +6 -3
- data/spec/beaker/host/mac/exec_spec.rb +3 -3
- data/spec/beaker/host/mac_spec.rb +6 -6
- data/spec/beaker/host/pswindows/exec_spec.rb +8 -5
- data/spec/beaker/host/pswindows/file_spec.rb +6 -3
- data/spec/beaker/host/pswindows_spec.rb +1 -1
- data/spec/beaker/host/unix/exec_spec.rb +24 -24
- data/spec/beaker/host/unix/file_spec.rb +18 -17
- data/spec/beaker/host/unix/pkg_spec.rb +26 -22
- data/spec/beaker/host/unix_spec.rb +8 -8
- data/spec/beaker/host/windows/exec_spec.rb +4 -4
- data/spec/beaker/host/windows/file_spec.rb +4 -4
- data/spec/beaker/host/windows/group_spec.rb +12 -12
- data/spec/beaker/host/windows/pkg_spec.rb +5 -5
- data/spec/beaker/host_prebuilt_steps_spec.rb +26 -20
- data/spec/beaker/host_spec.rb +72 -63
- data/spec/beaker/hypervisor/hypervisor_spec.rb +14 -14
- data/spec/beaker/localhost_connection_spec.rb +6 -4
- data/spec/beaker/logger_junit_spec.rb +16 -17
- data/spec/beaker/logger_spec.rb +54 -52
- data/spec/beaker/network_manager_spec.rb +5 -5
- data/spec/beaker/options/command_line_parser_spec.rb +2 -2
- data/spec/beaker/options/data/hosts_preserved.yml +395 -0
- data/spec/beaker/options/hosts_file_parser_spec.rb +9 -2
- data/spec/beaker/options/options_file_parser_spec.rb +1 -1
- data/spec/beaker/options/options_hash_spec.rb +4 -4
- data/spec/beaker/options/parser_spec.rb +23 -23
- data/spec/beaker/options/presets_spec.rb +2 -2
- data/spec/beaker/options/subcommand_options_parser_spec.rb +4 -3
- data/spec/beaker/options/validator_spec.rb +18 -18
- data/spec/beaker/perf_spec.rb +29 -28
- data/spec/beaker/platform_spec.rb +3 -2
- data/spec/beaker/shared/error_handler_spec.rb +1 -1
- data/spec/beaker/shared/fog_credentials_spec.rb +12 -12
- data/spec/beaker/shared/host_manager_spec.rb +7 -7
- data/spec/beaker/shared/repetition_spec.rb +9 -9
- data/spec/beaker/ssh_connection_spec.rb +14 -12
- data/spec/beaker/subcommand/subcommand_util_spec.rb +9 -4
- data/spec/beaker/subcommand_spec.rb +30 -28
- data/spec/beaker/test_case_spec.rb +11 -15
- data/spec/beaker/test_suite_spec.rb +24 -24
- data/spec/matchers.rb +1 -1
- data/spec/mocks.rb +5 -5
- data/spec/spec_helper.rb +0 -3
- metadata +59 -59
- data/spec/mock_fission.rb +0 -60
- data/spec/mock_vsphere.rb +0 -314
- data/spec/mock_vsphere_helper.rb +0 -183
data/spec/beaker/host_spec.rb
CHANGED
@@ -16,7 +16,7 @@ module Beaker
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'can be read like a hash' do
|
19
|
-
expect{ host['value'] }.
|
19
|
+
expect{ host['value'] }.not_to raise_error
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'can be written like a hash' do
|
@@ -29,39 +29,39 @@ module Beaker
|
|
29
29
|
|
30
30
|
it "can be a pe host" do
|
31
31
|
options['type'] = 'pe'
|
32
|
-
expect(host
|
33
|
-
expect(host
|
34
|
-
expect(host
|
35
|
-
expect(host
|
32
|
+
expect(host).to be_is_pe
|
33
|
+
expect(host).to be_use_service_scripts
|
34
|
+
expect(host).to be_is_using_passenger
|
35
|
+
expect(host).not_to be_graceful_restarts
|
36
36
|
end
|
37
37
|
|
38
38
|
it "can be a foss-source host" do
|
39
|
-
expect(host
|
40
|
-
expect(host
|
41
|
-
expect(host
|
39
|
+
expect(host).not_to be_is_pe
|
40
|
+
expect(host).not_to be_use_service_scripts
|
41
|
+
expect(host).not_to be_is_using_passenger
|
42
42
|
end
|
43
43
|
|
44
44
|
it "can be a foss-package host" do
|
45
45
|
options['use-service'] = true
|
46
|
-
expect(host
|
47
|
-
expect(host
|
48
|
-
expect(host
|
49
|
-
expect(host
|
46
|
+
expect(host).not_to be_is_pe
|
47
|
+
expect(host).to be_use_service_scripts
|
48
|
+
expect(host).not_to be_is_using_passenger
|
49
|
+
expect(host).not_to be_graceful_restarts
|
50
50
|
end
|
51
51
|
|
52
52
|
it "can be a foss-packaged host using passenger" do
|
53
53
|
host.uses_passenger!
|
54
|
-
expect(host
|
55
|
-
expect(host
|
56
|
-
expect(host
|
57
|
-
expect(host
|
54
|
+
expect(host).not_to be_is_pe
|
55
|
+
expect(host).to be_use_service_scripts
|
56
|
+
expect(host).to be_is_using_passenger
|
57
|
+
expect(host).to be_graceful_restarts
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'can be an AIO host' do
|
61
61
|
options['type'] = 'aio'
|
62
|
-
expect(host
|
63
|
-
expect(host
|
64
|
-
expect(host
|
62
|
+
expect(host).not_to be_is_pe
|
63
|
+
expect(host).not_to be_use_service_scripts
|
64
|
+
expect(host).not_to be_is_using_passenger
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'sets the paths correctly for an AIO host' do
|
@@ -74,7 +74,7 @@ module Beaker
|
|
74
74
|
it "sets passenger property" do
|
75
75
|
host.uses_passenger!
|
76
76
|
expect(host['passenger']).to be_truthy
|
77
|
-
expect(host
|
77
|
+
expect(host).to be_is_using_passenger
|
78
78
|
end
|
79
79
|
|
80
80
|
it "sets puppetservice" do
|
@@ -91,28 +91,28 @@ module Beaker
|
|
91
91
|
describe "graceful_restarts?" do
|
92
92
|
it "is true if graceful-restarts property is set true" do
|
93
93
|
options['graceful-restarts'] = true
|
94
|
-
expect(host
|
94
|
+
expect(host).to be_graceful_restarts
|
95
95
|
end
|
96
96
|
|
97
97
|
it "is false if graceful-restarts property is set false" do
|
98
98
|
options['graceful-restarts'] = false
|
99
|
-
expect(host
|
99
|
+
expect(host).not_to be_graceful_restarts
|
100
100
|
end
|
101
101
|
|
102
102
|
it "is false if is_pe and graceful-restarts is nil" do
|
103
103
|
options['type'] = 'pe'
|
104
|
-
expect(host
|
104
|
+
expect(host).not_to be_graceful_restarts
|
105
105
|
end
|
106
106
|
|
107
107
|
it "is true if is_pe and graceful-restarts is true" do
|
108
108
|
options['type'] = 'pe'
|
109
109
|
options['graceful-restarts'] = true
|
110
|
-
expect(host
|
110
|
+
expect(host).to be_graceful_restarts
|
111
111
|
end
|
112
112
|
|
113
113
|
it "falls back to passenger property if not pe and graceful-restarts is nil" do
|
114
114
|
host.uses_passenger!
|
115
|
-
expect(host
|
115
|
+
expect(host).to be_graceful_restarts
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
@@ -199,17 +199,17 @@ module Beaker
|
|
199
199
|
|
200
200
|
describe "executing commands" do
|
201
201
|
let(:command) { Beaker::Command.new('ls') }
|
202
|
-
let(:host) {
|
202
|
+
let(:host) { described_class.create('host', {}, make_host_opts('host', options.merge(platform))) }
|
203
203
|
let(:result) { Beaker::Result.new(host, 'ls') }
|
204
204
|
|
205
|
-
before
|
205
|
+
before do
|
206
206
|
result.stdout = 'stdout'
|
207
207
|
result.stderr = 'stderr'
|
208
208
|
|
209
209
|
logger = double(:logger)
|
210
210
|
allow( logger ).to receive(:host_output)
|
211
211
|
allow( logger ).to receive(:debug)
|
212
|
-
allow( logger ).to receive(:with_indent)
|
212
|
+
allow( logger ).to receive(:with_indent).and_yield
|
213
213
|
host.instance_variable_set :@logger, logger
|
214
214
|
conn = double(:connection)
|
215
215
|
allow( conn ).to receive(:execute).and_return(result)
|
@@ -221,12 +221,12 @@ module Beaker
|
|
221
221
|
|
222
222
|
it 'takes a command object and a hash of options' do
|
223
223
|
result.exit_code = 0
|
224
|
-
expect{ host.exec(command, {}) }.
|
224
|
+
expect{ host.exec(command, {}) }.not_to raise_error
|
225
225
|
end
|
226
226
|
|
227
227
|
it 'acts on the host\'s logger and connection object' do
|
228
228
|
result.exit_code = 0
|
229
|
-
expect( host.instance_variable_get(:@logger) ).to receive(:debug).at_least(
|
229
|
+
expect( host.instance_variable_get(:@logger) ).to receive(:debug).at_least(:once)
|
230
230
|
expect( host.instance_variable_get(:@connection) ).to receive(:execute).once
|
231
231
|
host.exec(command)
|
232
232
|
end
|
@@ -280,38 +280,43 @@ module Beaker
|
|
280
280
|
}
|
281
281
|
expect( host.logger ).to receive( :warn ).with( /overrides/ )
|
282
282
|
|
283
|
-
expect { host.exec(command, opts) }.
|
283
|
+
expect { host.exec(command, opts) }.not_to raise_error
|
284
284
|
end
|
285
285
|
|
286
286
|
it 'explicitly closes the connection when :reset_connection is set' do
|
287
287
|
expect( host ).to receive( :close )
|
288
|
-
expect { host.exec(command, :reset_connection => true) }.
|
288
|
+
expect { host.exec(command, :reset_connection => true) }.not_to raise_error
|
289
289
|
end
|
290
290
|
|
291
291
|
context "controls the result objects logging" do
|
292
292
|
it "and passes a test if the exit_code doesn't match the default :acceptable_exit_codes of 0" do
|
293
293
|
result.exit_code = 0
|
294
|
-
expect{ host.exec(command,{}) }.
|
294
|
+
expect{ host.exec(command,{}) }.not_to raise_error
|
295
295
|
end
|
296
|
+
|
296
297
|
it "and fails a test if the exit_code doesn't match the default :acceptable_exit_codes of 0" do
|
297
298
|
result.exit_code = 1
|
298
299
|
expect{ host.exec(command,{}) }.to raise_error
|
299
300
|
end
|
301
|
+
|
300
302
|
it "and passes a test if the exit_code matches :acceptable_exit_codes" do
|
301
303
|
result.exit_code = 0
|
302
|
-
expect{ host.exec(command,{:acceptable_exit_codes => 0}) }.
|
304
|
+
expect{ host.exec(command,{:acceptable_exit_codes => 0}) }.not_to raise_error
|
303
305
|
end
|
306
|
+
|
304
307
|
it "and fails a test if the exit_code doesn't match :acceptable_exit_codes" do
|
305
308
|
result.exit_code = 0
|
306
309
|
expect{ host.exec(command,{:acceptable_exit_codes => 1}) }.to raise_error
|
307
310
|
end
|
311
|
+
|
308
312
|
it "and passes a test if the exit_code matches one of the :acceptable_exit_codes" do
|
309
313
|
result.exit_code = 127
|
310
|
-
expect{ host.exec(command,{:acceptable_exit_codes => [1,127]}) }.
|
314
|
+
expect{ host.exec(command,{:acceptable_exit_codes => [1,127]}) }.not_to raise_error
|
311
315
|
end
|
316
|
+
|
312
317
|
it "and passes a test if the exit_code matches one of the range of :acceptable_exit_codes" do
|
313
318
|
result.exit_code = 1
|
314
|
-
expect{ host.exec(command,{:acceptable_exit_codes => (0..127)}) }.
|
319
|
+
expect{ host.exec(command,{:acceptable_exit_codes => (0..127)}) }.not_to raise_error
|
315
320
|
end
|
316
321
|
end
|
317
322
|
end
|
@@ -401,7 +406,7 @@ module Beaker
|
|
401
406
|
allow( conn ).to receive(:vmhostname).and_return(host['vmhostname'])
|
402
407
|
allow( conn ).to receive(:hostname).and_return(host.name)
|
403
408
|
|
404
|
-
host.do_scp_to
|
409
|
+
host.do_scp_to(*args)
|
405
410
|
end
|
406
411
|
|
407
412
|
it 'calls for host scp post operations after SCPing happens' do
|
@@ -422,7 +427,7 @@ module Beaker
|
|
422
427
|
allow( conn ).to receive(:hostname).and_return(host.name)
|
423
428
|
expect( host ).to receive( :scp_post_operations ).ordered
|
424
429
|
|
425
|
-
host.do_scp_to
|
430
|
+
host.do_scp_to(*args)
|
426
431
|
end
|
427
432
|
|
428
433
|
it 'throws an IOError when the file given doesn\'t exist' do
|
@@ -433,7 +438,7 @@ module Beaker
|
|
433
438
|
let( :source_path ) { '/repos/puppetlabs-inifile' }
|
434
439
|
let( :target_path ) { '/etc/puppetlabs/modules/inifile' }
|
435
440
|
|
436
|
-
before
|
441
|
+
before do
|
437
442
|
test_dir = "#{source_path}/tests"
|
438
443
|
other_test_dir = "#{source_path}/tests2"
|
439
444
|
|
@@ -449,6 +454,7 @@ module Beaker
|
|
449
454
|
create_files( @fileset1 )
|
450
455
|
create_files( @fileset2 )
|
451
456
|
end
|
457
|
+
|
452
458
|
it 'can take an ignore list that excludes all files and not call scp_to' do
|
453
459
|
logger = host[:logger]
|
454
460
|
conn = double(:connection)
|
@@ -460,8 +466,9 @@ module Beaker
|
|
460
466
|
expect( host ).to receive( :mkdir_p ).exactly(0).times
|
461
467
|
expect( conn ).to receive(:scp_to).exactly(0).times
|
462
468
|
|
463
|
-
host.do_scp_to
|
469
|
+
host.do_scp_to(*args)
|
464
470
|
end
|
471
|
+
|
465
472
|
it 'can take an ignore list that excludes a single file and scp the rest' do
|
466
473
|
created_target_path = File.join(target_path, File.basename(source_path))
|
467
474
|
exclude_file = '07_InstallCACerts.rb'
|
@@ -478,21 +485,21 @@ module Beaker
|
|
478
485
|
expect( host ).to receive( :mkdir_p ).with("#{created_target_path}/tests2")
|
479
486
|
|
480
487
|
(@fileset1 + @fileset2).each do |file|
|
481
|
-
if
|
488
|
+
if !/#{exclude_file}/.match?(file)
|
482
489
|
file_args = [ file, File.join(created_target_path, File.dirname(file).gsub(source_path,'')), {:ignore => [exclude_file], :dry_run => false} ]
|
483
490
|
conn_args = file_args
|
484
491
|
expect( conn ).to receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
|
485
492
|
else
|
486
493
|
file_args = [ file, File.join(created_target_path, File.dirname(file).gsub(source_path,'')), {:ignore => [exclude_file], :dry_run => false} ]
|
487
494
|
conn_args = file_args
|
488
|
-
expect( conn ).
|
495
|
+
expect( conn ).not_to receive(:scp_to).with( *conn_args )
|
489
496
|
end
|
490
497
|
end
|
491
498
|
allow( conn ).to receive(:ip).and_return(host['ip'])
|
492
499
|
allow( conn ).to receive(:vmhostname).and_return(host['vmhostname'])
|
493
500
|
allow( conn ).to receive(:hostname).and_return(host.name)
|
494
501
|
|
495
|
-
host.do_scp_to
|
502
|
+
host.do_scp_to(*args)
|
496
503
|
end
|
497
504
|
end
|
498
505
|
|
@@ -500,7 +507,7 @@ module Beaker
|
|
500
507
|
let( :source_path ) { '/puppetlabs-inifile' }
|
501
508
|
let( :target_path ) { '/etc/puppetlabs/modules/inifile' }
|
502
509
|
|
503
|
-
before
|
510
|
+
before do
|
504
511
|
test_dir = "#{source_path}/tests"
|
505
512
|
other_test_dir = "#{source_path}/tests/tests2"
|
506
513
|
another_test_dir = "#{source_path}/tests/tests3"
|
@@ -520,7 +527,7 @@ module Beaker
|
|
520
527
|
create_files( @fileset3 )
|
521
528
|
end
|
522
529
|
|
523
|
-
it "
|
530
|
+
it "creates target dirs with correct path seperator" do
|
524
531
|
create_files(['source'])
|
525
532
|
exclude_file = '04_ValidateSignCert.rb'
|
526
533
|
logger = host[:logger]
|
@@ -538,27 +545,27 @@ module Beaker
|
|
538
545
|
expect( host ).to receive( :mkdir_p ).with("#{created_target_path}/tests/tests3")
|
539
546
|
|
540
547
|
(@fileset1 + @fileset2 + @fileset3).each do |file|
|
541
|
-
if
|
548
|
+
if !/#{exclude_file}/.match?(file)
|
542
549
|
file_args = [ file, File.join(created_target_path, File.dirname(file).gsub(source_path,'')), {:ignore => [exclude_file], :dry_run => false} ]
|
543
550
|
conn_args = file_args
|
544
551
|
expect( conn ).to receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
|
545
552
|
else
|
546
553
|
file_args = [ file, File.join(created_target_path, File.dirname(file).gsub(source_path,'')), {:ignore => [exclude_file], :dry_run => false} ]
|
547
554
|
conn_args = file_args
|
548
|
-
expect( conn ).
|
555
|
+
expect( conn ).not_to receive(:scp_to).with( *conn_args )
|
549
556
|
end
|
550
557
|
end
|
551
558
|
allow( conn ).to receive(:ip).and_return(host['ip'])
|
552
559
|
allow( conn ).to receive(:vmhostname).and_return(host['vmhostname'])
|
553
560
|
allow( conn ).to receive(:hostname).and_return(host.name)
|
554
561
|
|
555
|
-
host.do_scp_to
|
562
|
+
host.do_scp_to(*args)
|
556
563
|
end
|
557
564
|
end
|
558
565
|
|
559
566
|
context "using an ignore array" do
|
560
567
|
|
561
|
-
before
|
568
|
+
before do
|
562
569
|
test_dir = 'tmp/tests'
|
563
570
|
other_test_dir = 'tmp/tests2'
|
564
571
|
|
@@ -586,7 +593,7 @@ module Beaker
|
|
586
593
|
expect( host ).to receive( :mkdir_p ).exactly(0).times
|
587
594
|
expect( conn ).to receive(:scp_to).exactly(0).times
|
588
595
|
|
589
|
-
host.do_scp_to
|
596
|
+
host.do_scp_to(*args)
|
590
597
|
end
|
591
598
|
|
592
599
|
it 'can take an ignore list that excludes a single file and scp the rest' do
|
@@ -603,20 +610,20 @@ module Beaker
|
|
603
610
|
expect( host ).to receive( :mkdir_p ).with('target/tmp/tests')
|
604
611
|
expect( host ).to receive( :mkdir_p ).with('target/tmp/tests2')
|
605
612
|
(@fileset1 + @fileset2).each do |file|
|
606
|
-
if
|
613
|
+
if !/#{exclude_file}/.match?(file)
|
607
614
|
file_args = [ file, File.join('target', File.dirname(file)), {:ignore => [exclude_file], :dry_run => false} ]
|
608
615
|
conn_args = file_args
|
609
616
|
expect( conn ).to receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
|
610
617
|
else
|
611
618
|
file_args = [ file, File.join('target', File.dirname(file)), {:ignore => [exclude_file], :dry_run => false} ]
|
612
619
|
conn_args = file_args
|
613
|
-
expect( conn ).
|
620
|
+
expect( conn ).not_to receive(:scp_to).with( *conn_args )
|
614
621
|
end
|
615
622
|
end
|
616
623
|
allow( conn ).to receive(:ip).and_return(host['ip'])
|
617
624
|
allow( conn ).to receive(:vmhostname).and_return(host['vmhostname'])
|
618
625
|
allow( conn ).to receive(:hostname).and_return(host.name)
|
619
|
-
host.do_scp_to
|
626
|
+
host.do_scp_to(*args)
|
620
627
|
end
|
621
628
|
|
622
629
|
it 'can take an ignore list that excludes a dir and scp the rest' do
|
@@ -630,12 +637,12 @@ module Beaker
|
|
630
637
|
allow( Dir ).to receive( :glob ).and_return( @fileset1 + @fileset2 )
|
631
638
|
|
632
639
|
expect( logger ).to receive(:trace)
|
633
|
-
expect( host ).
|
640
|
+
expect( host ).not_to receive( :mkdir_p ).with('target/tmp/tests')
|
634
641
|
expect( host ).to receive( :mkdir_p ).with('target/tmp/tests2')
|
635
642
|
(@fileset1).each do |file|
|
636
643
|
file_args = [ file, File.join('target', File.dirname(file)), {:ignore => [exclude_file], :dry_run => false} ]
|
637
644
|
conn_args = file_args
|
638
|
-
expect( conn ).
|
645
|
+
expect( conn ).not_to receive(:scp_to).with( *conn_args )
|
639
646
|
end
|
640
647
|
(@fileset2).each do |file|
|
641
648
|
file_args = [ file, File.join('target', File.dirname(file)), {:ignore => [exclude_file], :dry_run => false} ]
|
@@ -646,7 +653,7 @@ module Beaker
|
|
646
653
|
allow( conn ).to receive(:ip).and_return(host['ip'])
|
647
654
|
allow( conn ).to receive(:vmhostname).and_return(host['vmhostname'])
|
648
655
|
allow( conn ).to receive(:hostname).and_return(host.name)
|
649
|
-
host.do_scp_to
|
656
|
+
host.do_scp_to(*args)
|
650
657
|
end
|
651
658
|
end
|
652
659
|
end
|
@@ -666,7 +673,7 @@ module Beaker
|
|
666
673
|
allow( conn ).to receive(:ip).and_return(host['ip'])
|
667
674
|
allow( conn ).to receive(:vmhostname).and_return(host['vmhostname'])
|
668
675
|
allow( conn ).to receive(:hostname).and_return(host.name)
|
669
|
-
host.do_scp_from
|
676
|
+
host.do_scp_from(*args)
|
670
677
|
end
|
671
678
|
end
|
672
679
|
|
@@ -686,7 +693,7 @@ module Beaker
|
|
686
693
|
|
687
694
|
expect( Rsync ).to receive(:run).with( *rsync_args ).and_return(Rsync::Result.new('raw rsync output', 0))
|
688
695
|
|
689
|
-
host.do_rsync_to
|
696
|
+
host.do_rsync_to(*args)
|
690
697
|
|
691
698
|
expect(Rsync.host).to eq('root@default.ip.address')
|
692
699
|
end
|
@@ -730,8 +737,8 @@ module Beaker
|
|
730
737
|
rsync_args = ['source', 'target', ['-az', "-e \"ssh -i #{key} -p 22 -o 'StrictHostKeyChecking no'\"", "--exclude '.bundle'"]]
|
731
738
|
expect(Rsync).to receive(:run).twice.with(*rsync_args).and_return(Rsync::Result.new('raw rsync output', 0))
|
732
739
|
|
733
|
-
host.do_rsync_to
|
734
|
-
host.do_rsync_to
|
740
|
+
host.do_rsync_to(*args)
|
741
|
+
host.do_rsync_to(*args)
|
735
742
|
end
|
736
743
|
end
|
737
744
|
|
@@ -746,14 +753,16 @@ module Beaker
|
|
746
753
|
host.instance_variable_set :@connection, conn
|
747
754
|
allow(host).to receive(:close).and_call_original
|
748
755
|
end
|
756
|
+
|
749
757
|
it 'does not raise an error' do
|
750
|
-
expect { host.close }.
|
758
|
+
expect { host.close }.not_to raise_error
|
751
759
|
end
|
752
760
|
end
|
753
761
|
end
|
754
762
|
|
755
763
|
describe '#get_public_ip' do
|
756
|
-
let
|
764
|
+
let(:aws) { double('AWSmock')}
|
765
|
+
|
757
766
|
it 'calls upon the ec2 instance to get the ip address' do
|
758
767
|
host.host_hash[:hypervisor] = 'ec2'
|
759
768
|
host.host_hash[:instance] = aws
|
@@ -814,7 +823,7 @@ module Beaker
|
|
814
823
|
|
815
824
|
it 'does not call get_ip when #get_public_ip returns an address' do
|
816
825
|
allow( host ).to receive(:get_public_ip).and_return('127.0.0.1')
|
817
|
-
expect(host).
|
826
|
+
expect(host).not_to receive(:get_ip)
|
818
827
|
expect(host.ip).to eq('127.0.0.1')
|
819
828
|
end
|
820
829
|
end
|
@@ -4,8 +4,8 @@ module Beaker
|
|
4
4
|
describe Hypervisor do
|
5
5
|
let( :hosts ) { make_hosts( { :platform => 'el-5' } ) }
|
6
6
|
|
7
|
-
|
8
|
-
let( :hypervisor ) {
|
7
|
+
describe "#create" do
|
8
|
+
let( :hypervisor ) { described_class }
|
9
9
|
|
10
10
|
it "includes custom hypervisor and call set_ssh_connection_preference" do
|
11
11
|
allow(hypervisor).to receive(:set_ssh_connection_preference).with([], hypervisor)
|
@@ -39,9 +39,9 @@ module Beaker
|
|
39
39
|
|
40
40
|
end
|
41
41
|
|
42
|
-
|
42
|
+
describe "#configure" do
|
43
43
|
let( :options ) { make_opts.merge({ 'logger' => double().as_null_object }) }
|
44
|
-
let( :hypervisor ) {
|
44
|
+
let( :hypervisor ) { described_class.new( hosts, options ) }
|
45
45
|
|
46
46
|
context 'if :timesync option set true on host' do
|
47
47
|
it 'does call timesync for host' do
|
@@ -67,7 +67,7 @@ module Beaker
|
|
67
67
|
options[:timesync] = true
|
68
68
|
hosts[0].options[:timesync] = false
|
69
69
|
allow( hypervisor ).to receive( :set_env )
|
70
|
-
expect( hypervisor ).
|
70
|
+
expect( hypervisor ).not_to receive( :timesync )
|
71
71
|
hypervisor.configure
|
72
72
|
end
|
73
73
|
end
|
@@ -92,7 +92,7 @@ module Beaker
|
|
92
92
|
it "does not call disable_iptables" do
|
93
93
|
options[:disable_iptables] = false
|
94
94
|
allow( hypervisor ).to receive( :set_env )
|
95
|
-
expect( hypervisor ).
|
95
|
+
expect( hypervisor ).not_to receive( :disable_iptables )
|
96
96
|
hypervisor.configure
|
97
97
|
end
|
98
98
|
end
|
@@ -101,7 +101,7 @@ module Beaker
|
|
101
101
|
it "calls disable_iptables once" do
|
102
102
|
options[:disable_iptables] = true
|
103
103
|
allow( hypervisor ).to receive( :set_env )
|
104
|
-
expect( hypervisor ).to receive( :disable_iptables ).
|
104
|
+
expect( hypervisor ).to receive( :disable_iptables ).once
|
105
105
|
hypervisor.configure
|
106
106
|
end
|
107
107
|
end
|
@@ -119,7 +119,7 @@ module Beaker
|
|
119
119
|
it "does not call disable_updates_puppetlabs_com" do
|
120
120
|
options[:disable_updates] = false
|
121
121
|
allow( hypervisor ).to receive( :set_env )
|
122
|
-
expect( hypervisor ).
|
122
|
+
expect( hypervisor ).not_to receive( :disable_updates )
|
123
123
|
hypervisor.configure
|
124
124
|
end
|
125
125
|
end
|
@@ -132,12 +132,12 @@ module Beaker
|
|
132
132
|
options[:add_el_extras] = true
|
133
133
|
options[:disable_iptables] = true
|
134
134
|
options[:host_name_prefix] = "test-"
|
135
|
-
expect( hypervisor ).
|
136
|
-
expect( hypervisor ).
|
137
|
-
expect( hypervisor ).
|
138
|
-
expect( hypervisor ).
|
139
|
-
expect( hypervisor ).
|
140
|
-
expect( hypervisor ).
|
135
|
+
expect( hypervisor ).not_to receive( :timesync )
|
136
|
+
expect( hypervisor ).not_to receive( :sync_root_keys )
|
137
|
+
expect( hypervisor ).not_to receive( :add_el_extras )
|
138
|
+
expect( hypervisor ).not_to receive( :disable_iptables )
|
139
|
+
expect( hypervisor ).not_to receive( :set_env )
|
140
|
+
expect( hypervisor ).not_to receive( :host_name_prefix )
|
141
141
|
hypervisor.configure
|
142
142
|
end
|
143
143
|
end
|
@@ -3,18 +3,20 @@ require 'net/ssh'
|
|
3
3
|
|
4
4
|
module Beaker
|
5
5
|
describe LocalConnection do
|
6
|
+
subject(:connection) { described_class.new(options) }
|
7
|
+
|
6
8
|
let( :options ) { { :logger => double('logger').as_null_object, :ssh_env_file => '/path/to/ssh/file'} }
|
7
|
-
subject(:connection) { LocalConnection.new(options) }
|
8
9
|
|
9
|
-
|
10
|
+
|
11
|
+
before do
|
10
12
|
allow( subject ).to receive(:sleep)
|
11
13
|
end
|
12
14
|
|
13
15
|
describe '#self.connect' do
|
14
16
|
it 'loggs message' do
|
15
17
|
expect(options[:logger]).to receive(:debug).with('Local connection, no connection to start')
|
16
|
-
connection_constructor =
|
17
|
-
expect( connection_constructor ).to be_a_kind_of
|
18
|
+
connection_constructor = described_class.connect(options)
|
19
|
+
expect( connection_constructor ).to be_a_kind_of described_class
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
@@ -11,14 +11,14 @@ module Beaker
|
|
11
11
|
it 'rejects all invalid values' do
|
12
12
|
invalid_values = [0x8, 0x10, 0xB, 0x0019, 0xD800, 0xDFFF, 0xFFFE, 0x99999, 0x110000]
|
13
13
|
invalid_values.each do |value|
|
14
|
-
expect(
|
14
|
+
expect( described_class.is_valid_xml(value) ).to be === false
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'accepts valid values' do
|
19
19
|
valid_values = [0x9, 0xA, 0x0020, 0xD7FF, 0xE000, 0xFFFD, 0x100000, 0x10FFFF]
|
20
20
|
valid_values.each do |value|
|
21
|
-
expect(
|
21
|
+
expect( described_class.is_valid_xml(value) ).to be === true
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -29,12 +29,12 @@ module Beaker
|
|
29
29
|
it 'escapes invalid xml characters correctly' do
|
30
30
|
testing_string = 'pants'
|
31
31
|
testing_string << 0x8
|
32
|
-
expect(
|
32
|
+
expect( described_class.escape_invalid_xml_chars(testing_string) ).to be === 'pants\8'
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'leaves a string of all valid xml characters alone' do
|
36
36
|
testing_string = 'pants man, pants!'
|
37
|
-
expect(
|
37
|
+
expect( described_class.escape_invalid_xml_chars(testing_string) ).to be === testing_string
|
38
38
|
end
|
39
39
|
|
40
40
|
end
|
@@ -42,16 +42,16 @@ module Beaker
|
|
42
42
|
describe '#copy_stylesheet_into_xml_dir' do
|
43
43
|
|
44
44
|
it 'copies the stylesheet into the correct location' do
|
45
|
-
allow( File ).to receive( :file? )
|
45
|
+
allow( File ).to receive( :file? ).and_return(false)
|
46
46
|
correct_location = File.join(File.dirname(xml_file), File.basename(stylesheet))
|
47
47
|
expect( FileUtils ).to receive( :copy ).with( stylesheet, correct_location )
|
48
|
-
|
48
|
+
described_class.copy_stylesheet_into_xml_dir(stylesheet, xml_file)
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'skips action if the file doesn\'t exist' do
|
52
|
-
allow( File ).to receive( :file? )
|
52
|
+
allow( File ).to receive( :file? ).and_return(true)
|
53
53
|
expect( FileUtils ).not_to receive( :copy )
|
54
|
-
|
54
|
+
described_class.copy_stylesheet_into_xml_dir(stylesheet, xml_file)
|
55
55
|
end
|
56
56
|
|
57
57
|
end
|
@@ -60,10 +60,9 @@ module Beaker
|
|
60
60
|
|
61
61
|
it 'opens the given file for writing, and writes the doc to it' do
|
62
62
|
mock_doc = Object.new
|
63
|
-
doc_xml = 'flibbity-floo'
|
64
63
|
allow( mock_doc ).to receive( :write ).with(File, 2)
|
65
64
|
expect( File ).to receive( :open ).with( xml_file, 'w' )
|
66
|
-
|
65
|
+
described_class.finish(mock_doc, xml_file)
|
67
66
|
end
|
68
67
|
|
69
68
|
end
|
@@ -71,19 +70,19 @@ module Beaker
|
|
71
70
|
describe '#write_xml' do
|
72
71
|
|
73
72
|
it 'throws an error with 1-arity in the given block' do
|
74
|
-
allow(
|
75
|
-
expect{
|
73
|
+
allow( described_class ).to receive( :get_xml_contents )
|
74
|
+
expect{ described_class.write_xml(xml_file, stylesheet) do |hey| end }.to raise_error(ArgumentError)
|
76
75
|
end
|
77
76
|
|
78
77
|
it 'doesn\'t throw an error with 2-arity in the given block' do
|
79
|
-
allow(
|
80
|
-
allow(
|
81
|
-
expect{
|
78
|
+
allow( described_class ).to receive( :get_xml_contents )
|
79
|
+
allow( described_class ).to receive( :finish )
|
80
|
+
expect{ described_class.write_xml(xml_file, stylesheet) do |hey1, hey2| end }.not_to raise_error
|
82
81
|
end
|
83
82
|
|
84
83
|
it 'throws an error with 3-arity in the given block' do
|
85
|
-
allow(
|
86
|
-
expect{
|
84
|
+
allow( described_class ).to receive( :get_xml_contents )
|
85
|
+
expect{ described_class.write_xml(xml_file, stylesheet) do |hey1, hey2, hey3| end }.to raise_error(ArgumentError)
|
87
86
|
end
|
88
87
|
|
89
88
|
end
|