beaker 4.41.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/release.yml +2 -2
- data/.github/workflows/test.yml +26 -13
- data/.rubocop.yml +23 -10
- data/.rubocop_todo.yml +34 -10
- data/CHANGELOG.md +16 -52
- data/Gemfile +12 -7
- data/HISTORY.md +605 -0
- data/Rakefile +99 -111
- data/acceptance/config/acceptance-options.rb +1 -1
- data/acceptance/config/base/acceptance-options.rb +2 -2
- data/acceptance/config/hypervisor/acceptance-options.rb +2 -2
- data/acceptance/config/subcommands/acceptance-options.rb +2 -2
- data/acceptance/fixtures/module/Rakefile +1 -1
- data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -12
- data/acceptance/fixtures/module/spec/classes/init_spec.rb +0 -1
- data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
- data/acceptance/lib/helpers/test_helper.rb +6 -5
- data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
- data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
- data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +1 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +3 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
- data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +19 -26
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +18 -13
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +22 -27
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +12 -16
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +3 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +5 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +3 -5
- data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
- data/acceptance/tests/base/dsl/structure_test.rb +5 -11
- data/acceptance/tests/base/host/file_test.rb +2 -2
- data/acceptance/tests/base/host/group_test.rb +0 -1
- data/acceptance/tests/base/host/host_test.rb +66 -63
- data/acceptance/tests/base/host/packages.rb +1 -2
- data/acceptance/tests/base/host/packages_unix.rb +0 -55
- data/acceptance/tests/base/host/user_test.rb +0 -1
- data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
- data/acceptance/tests/base/test_suite/export.rb +6 -9
- data/acceptance/tests/install/from_file.rb +2 -4
- data/acceptance/tests/load_path_bootstrap.rb +1 -1
- data/acceptance/tests/subcommands/destroy.rb +19 -21
- data/acceptance/tests/subcommands/exec.rb +0 -1
- data/acceptance/tests/subcommands/init.rb +2 -3
- data/acceptance/tests/subcommands/provision.rb +0 -1
- data/beaker.gemspec +4 -7
- data/docs/concepts/argument_processing_and_precedence.md +1 -10
- data/docs/how_to/debug_beaker_tests.md +12 -12
- data/docs/how_to/hosts/eos.md +2 -12
- data/docs/how_to/install_puppet.md +0 -18
- data/docs/how_to/the_beaker_dsl.md +0 -2
- data/lib/beaker/cli.rb +59 -68
- data/lib/beaker/command.rb +20 -28
- data/lib/beaker/command_factory.rb +3 -2
- data/lib/beaker/dsl/assertions.rb +6 -18
- data/lib/beaker/dsl/helpers/hocon_helpers.rb +3 -7
- data/lib/beaker/dsl/helpers/host_helpers.rb +62 -123
- data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
- data/lib/beaker/dsl/helpers/web_helpers.rb +19 -39
- data/lib/beaker/dsl/helpers.rb +2 -4
- data/lib/beaker/dsl/outcomes.rb +13 -15
- data/lib/beaker/dsl/patterns.rb +1 -3
- data/lib/beaker/dsl/roles.rb +17 -20
- data/lib/beaker/dsl/structure.rb +53 -65
- data/lib/beaker/dsl/test_tagging.rb +7 -10
- data/lib/beaker/dsl/wrappers.rb +15 -16
- data/lib/beaker/dsl.rb +2 -3
- data/lib/beaker/host/aix/exec.rb +1 -1
- data/lib/beaker/host/aix/file.rb +0 -1
- data/lib/beaker/host/aix/group.rb +1 -1
- data/lib/beaker/host/aix/user.rb +1 -1
- data/lib/beaker/host/aix.rb +3 -4
- data/lib/beaker/host/cisco.rb +27 -39
- data/lib/beaker/host/eos.rb +4 -30
- data/lib/beaker/host/freebsd/exec.rb +1 -1
- data/lib/beaker/host/freebsd/pkg.rb +3 -3
- data/lib/beaker/host/freebsd.rb +9 -12
- data/lib/beaker/host/mac/exec.rb +4 -4
- data/lib/beaker/host/mac/group.rb +7 -7
- data/lib/beaker/host/mac/pkg.rb +3 -106
- data/lib/beaker/host/mac/user.rb +2 -2
- data/lib/beaker/host/mac.rb +8 -9
- data/lib/beaker/host/pswindows/exec.rb +66 -70
- data/lib/beaker/host/pswindows/file.rb +3 -5
- data/lib/beaker/host/pswindows/group.rb +3 -3
- data/lib/beaker/host/pswindows/pkg.rb +12 -12
- data/lib/beaker/host/pswindows/user.rb +3 -3
- data/lib/beaker/host/pswindows.rb +4 -3
- data/lib/beaker/host/unix/exec.rb +81 -83
- data/lib/beaker/host/unix/file.rb +40 -45
- data/lib/beaker/host/unix/group.rb +1 -1
- data/lib/beaker/host/unix/pkg.rb +138 -401
- data/lib/beaker/host/unix/user.rb +2 -2
- data/lib/beaker/host/unix.rb +8 -11
- data/lib/beaker/host/windows/exec.rb +17 -17
- data/lib/beaker/host/windows/file.rb +3 -3
- data/lib/beaker/host/windows/group.rb +3 -3
- data/lib/beaker/host/windows/pkg.rb +3 -54
- data/lib/beaker/host/windows/user.rb +3 -3
- data/lib/beaker/host/windows.rb +12 -12
- data/lib/beaker/host.rb +76 -133
- data/lib/beaker/host_prebuilt_steps.rb +88 -196
- data/lib/beaker/hypervisor/noop.rb +2 -4
- data/lib/beaker/hypervisor.rb +44 -61
- data/lib/beaker/local_connection.rb +2 -4
- data/lib/beaker/logger.rb +68 -76
- data/lib/beaker/logger_junit.rb +21 -25
- data/lib/beaker/network_manager.rb +39 -42
- data/lib/beaker/options/command_line_parser.rb +12 -23
- data/lib/beaker/options/hosts_file_parser.rb +16 -25
- data/lib/beaker/options/options_file_parser.rb +3 -6
- data/lib/beaker/options/options_hash.rb +2 -7
- data/lib/beaker/options/parser.rb +86 -102
- data/lib/beaker/options/presets.rb +114 -123
- data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
- data/lib/beaker/options/validator.rb +26 -31
- data/lib/beaker/perf.rb +25 -30
- data/lib/beaker/platform.rb +26 -37
- data/lib/beaker/result.rb +7 -6
- data/lib/beaker/shared/error_handler.rb +8 -10
- data/lib/beaker/shared/fog_credentials.rb +5 -9
- data/lib/beaker/shared/host_manager.rb +36 -41
- data/lib/beaker/shared/options_resolver.rb +3 -7
- data/lib/beaker/shared/repetition.rb +2 -4
- data/lib/beaker/shared/semvar.rb +37 -41
- data/lib/beaker/shared/timed.rb +0 -3
- data/lib/beaker/shared.rb +1 -1
- data/lib/beaker/ssh_connection.rb +38 -47
- data/lib/beaker/subcommand.rb +17 -24
- data/lib/beaker/subcommands/subcommand_util.rb +4 -4
- data/lib/beaker/tasks/quick_start.rb +4 -9
- data/lib/beaker/tasks/rake_task.rb +25 -27
- data/lib/beaker/tasks/test.rb +4 -4
- data/lib/beaker/test_case.rb +16 -28
- data/lib/beaker/test_suite.rb +35 -39
- data/lib/beaker/test_suite_result.rb +45 -47
- data/lib/beaker/version.rb +1 -1
- data/lib/beaker.rb +6 -7
- data/spec/beaker/cli_spec.rb +121 -142
- data/spec/beaker/command_spec.rb +55 -59
- data/spec/beaker/dsl/assertions_spec.rb +36 -36
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +110 -131
- data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
- data/spec/beaker/dsl/helpers/web_helpers_spec.rb +22 -31
- data/spec/beaker/dsl/outcomes_spec.rb +14 -14
- data/spec/beaker/dsl/roles_spec.rb +125 -130
- data/spec/beaker/dsl/structure_spec.rb +172 -161
- data/spec/beaker/dsl/test_tagging_spec.rb +89 -90
- data/spec/beaker/dsl/wrappers_spec.rb +32 -33
- data/spec/beaker/host/aix_spec.rb +14 -14
- data/spec/beaker/host/cisco_spec.rb +84 -94
- data/spec/beaker/host/eos_spec.rb +15 -36
- data/spec/beaker/host/freebsd/exec_spec.rb +3 -6
- data/spec/beaker/host/freebsd/pkg_spec.rb +24 -27
- data/spec/beaker/host/mac/exec_spec.rb +2 -3
- data/spec/beaker/host/mac/group_spec.rb +48 -57
- data/spec/beaker/host/mac/user_spec.rb +54 -63
- data/spec/beaker/host/pswindows/exec_spec.rb +30 -32
- data/spec/beaker/host/pswindows/file_spec.rb +16 -16
- data/spec/beaker/host/pswindows/user_spec.rb +17 -23
- data/spec/beaker/host/pswindows_spec.rb +13 -13
- data/spec/beaker/host/unix/exec_spec.rb +75 -80
- data/spec/beaker/host/unix/file_spec.rb +66 -71
- data/spec/beaker/host/unix/pkg_spec.rb +150 -411
- data/spec/beaker/host/unix_spec.rb +11 -207
- data/spec/beaker/host/windows/exec_spec.rb +30 -32
- data/spec/beaker/host/windows/file_spec.rb +18 -19
- data/spec/beaker/host/windows/group_spec.rb +10 -12
- data/spec/beaker/host/windows/pkg_spec.rb +6 -9
- data/spec/beaker/host/windows/user_spec.rb +17 -23
- data/spec/beaker/host/windows_spec.rb +39 -39
- data/spec/beaker/host_prebuilt_steps_spec.rb +168 -349
- data/spec/beaker/host_spec.rb +204 -284
- data/spec/beaker/hypervisor/hypervisor_spec.rb +36 -61
- data/spec/beaker/localhost_connection_spec.rb +10 -11
- data/spec/beaker/logger_junit_spec.rb +19 -30
- data/spec/beaker/logger_spec.rb +153 -136
- data/spec/beaker/network_manager_spec.rb +23 -23
- data/spec/beaker/options/command_line_parser_spec.rb +20 -23
- data/spec/beaker/options/hosts_file_parser_spec.rb +30 -32
- data/spec/beaker/options/options_file_parser_spec.rb +4 -7
- data/spec/beaker/options/options_hash_spec.rb +4 -6
- data/spec/beaker/options/parser_spec.rb +167 -167
- data/spec/beaker/options/presets_spec.rb +7 -9
- data/spec/beaker/options/subcommand_options_parser_spec.rb +13 -14
- data/spec/beaker/options/validator_spec.rb +10 -11
- data/spec/beaker/perf_spec.rb +18 -21
- data/spec/beaker/platform_spec.rb +25 -50
- data/spec/beaker/shared/error_handler_spec.rb +7 -16
- data/spec/beaker/shared/fog_credentials_spec.rb +29 -29
- data/spec/beaker/shared/host_manager_spec.rb +50 -84
- data/spec/beaker/shared/options_resolver_spec.rb +9 -12
- data/spec/beaker/shared/repetition_spec.rb +17 -24
- data/spec/beaker/shared/semvar_spec.rb +21 -26
- data/spec/beaker/ssh_connection_spec.rb +76 -83
- data/spec/beaker/subcommand/subcommand_util_spec.rb +31 -33
- data/spec/beaker/subcommand_spec.rb +75 -77
- data/spec/beaker/test_case_spec.rb +25 -50
- data/spec/beaker/test_suite_spec.rb +147 -154
- data/spec/helpers.rb +39 -45
- data/spec/matchers.rb +8 -7
- data/spec/mocks.rb +1 -6
- data/spec/spec_helper.rb +0 -1
- metadata +8 -24
- data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
- data/acceptance/tests/base/external_resources_test.rb +0 -31
- data/spec/beaker/host/mac_spec.rb +0 -113
|
@@ -2,63 +2,62 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
module Beaker
|
|
4
4
|
describe Hypervisor do
|
|
5
|
-
let(
|
|
5
|
+
let(:hosts) { make_hosts({ :platform => 'el-5' }) }
|
|
6
6
|
|
|
7
7
|
describe "#create" do
|
|
8
|
-
let(
|
|
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)
|
|
12
|
-
expect{ hypervisor.create('custom_hypervisor', [], make_opts
|
|
12
|
+
expect { hypervisor.create('custom_hypervisor', [], make_opts) }.to raise_error(LoadError, "cannot load such file -- beaker/hypervisor/custom_hypervisor")
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it "sets ssh connection preference if connection_preference method is not overwritten" do
|
|
16
|
-
hypervisor.create('none', hosts, make_opts
|
|
17
|
-
expect(hosts[0][:ssh_connection_preference]).to eq([
|
|
16
|
+
hypervisor.create('none', hosts, make_opts)
|
|
17
|
+
expect(hosts[0][:ssh_connection_preference]).to eq(%i[ip vmhostname hostname])
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it "concats overriding connection_preference array with the default connection_preference" do
|
|
21
|
-
allow(hypervisor).to receive(:connection_preference).and_return([
|
|
21
|
+
allow(hypervisor).to receive(:connection_preference).and_return(%i[my invalid method_name])
|
|
22
22
|
hypervisor.set_ssh_connection_preference(hosts, hypervisor)
|
|
23
|
-
expect(hosts[0][:ssh_connection_preference]).to eq([
|
|
23
|
+
expect(hosts[0][:ssh_connection_preference]).to eq(%i[my invalid method_name ip vmhostname hostname])
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
it "removes unique elements from concated array while preserving order of overriding methods" do
|
|
27
|
-
allow(hypervisor).to receive(:connection_preference).and_return([
|
|
27
|
+
allow(hypervisor).to receive(:connection_preference).and_return(%i[my ip vmhostname method_name])
|
|
28
28
|
hypervisor.set_ssh_connection_preference(hosts, hypervisor)
|
|
29
|
-
expect(hosts[0][:ssh_connection_preference]).to eq([
|
|
29
|
+
expect(hosts[0][:ssh_connection_preference]).to eq(%i[my ip vmhostname method_name hostname])
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
it "gives highest precedence to preference specified in host file followed by hypervisor" do
|
|
33
|
-
hosts[0].options[:ssh_preference] = [
|
|
34
|
-
hypervisor.create('none', hosts, make_opts
|
|
35
|
-
allow(hypervisor).to receive(:connection_preference).and_return([
|
|
33
|
+
hosts[0].options[:ssh_preference] = %i[set in hostfile]
|
|
34
|
+
hypervisor.create('none', hosts, make_opts)
|
|
35
|
+
allow(hypervisor).to receive(:connection_preference).and_return(%i[hypervisor pref])
|
|
36
36
|
hypervisor.set_ssh_connection_preference(hosts, hypervisor)
|
|
37
|
-
expect(hosts[0][:ssh_connection_preference]).to eq([
|
|
37
|
+
expect(hosts[0][:ssh_connection_preference]).to eq(%i[set in hostfile hypervisor pref ip vmhostname hostname])
|
|
38
38
|
end
|
|
39
|
-
|
|
40
39
|
end
|
|
41
40
|
|
|
42
41
|
describe "#configure" do
|
|
43
|
-
let(
|
|
44
|
-
let(
|
|
42
|
+
let(:options) { make_opts.merge({ 'logger' => double.as_null_object }) }
|
|
43
|
+
let(:hypervisor) { described_class.new(hosts, options) }
|
|
45
44
|
|
|
46
45
|
context 'if :timesync option set true on host' do
|
|
47
46
|
it 'does call timesync for host' do
|
|
48
47
|
hosts[0].options[:timesync] = true
|
|
49
|
-
allow(
|
|
50
|
-
expect(
|
|
48
|
+
allow(hypervisor).to receive(:set_env)
|
|
49
|
+
expect(hypervisor).to receive(:timesync).once
|
|
51
50
|
hypervisor.configure
|
|
52
51
|
end
|
|
53
52
|
|
|
54
53
|
it 'catches signal exceptions and returns stack trace' do
|
|
55
|
-
logger = double
|
|
54
|
+
logger = double
|
|
56
55
|
hosts[0].options[:timesync] = true
|
|
57
|
-
allow(
|
|
58
|
-
allow(
|
|
56
|
+
allow(logger).to receive(:error)
|
|
57
|
+
allow(logger).to receive(:pretty_backtrace).and_return("multiline\nstring")
|
|
59
58
|
hypervisor.instance_variable_set(:@logger, logger)
|
|
60
59
|
allow(Beaker::Command).to receive(:new).and_raise(SignalException.new('SIGTERM'))
|
|
61
|
-
expect{ hypervisor.configure }.to raise_error(SignalException)
|
|
60
|
+
expect { hypervisor.configure }.to raise_error(SignalException)
|
|
62
61
|
end
|
|
63
62
|
end
|
|
64
63
|
|
|
@@ -66,8 +65,8 @@ module Beaker
|
|
|
66
65
|
it 'does not call timesync for host' do
|
|
67
66
|
options[:timesync] = true
|
|
68
67
|
hosts[0].options[:timesync] = false
|
|
69
|
-
allow(
|
|
70
|
-
expect(
|
|
68
|
+
allow(hypervisor).to receive(:set_env)
|
|
69
|
+
expect(hypervisor).not_to receive(:timesync)
|
|
71
70
|
hypervisor.configure
|
|
72
71
|
end
|
|
73
72
|
end
|
|
@@ -81,27 +80,9 @@ module Beaker
|
|
|
81
80
|
hosts[1].options[:timesync] = true
|
|
82
81
|
hosts[2].options[:timesync] = true
|
|
83
82
|
options[:run_in_parallel] = ['configure']
|
|
84
|
-
allow(
|
|
83
|
+
allow(hypervisor).to receive(:set_env)
|
|
85
84
|
# This will only get hit if forking processes is supported and at least 2 items are being submitted to run in parallel
|
|
86
|
-
expect(
|
|
87
|
-
hypervisor.configure
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
context "if :disable_iptables option set false" do
|
|
92
|
-
it "does not call disable_iptables" do
|
|
93
|
-
options[:disable_iptables] = false
|
|
94
|
-
allow( hypervisor ).to receive( :set_env )
|
|
95
|
-
expect( hypervisor ).not_to receive( :disable_iptables )
|
|
96
|
-
hypervisor.configure
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
context "if :disable_iptables option set true" do
|
|
101
|
-
it "calls disable_iptables once" do
|
|
102
|
-
options[:disable_iptables] = true
|
|
103
|
-
allow( hypervisor ).to receive( :set_env )
|
|
104
|
-
expect( hypervisor ).to receive( :disable_iptables ).once
|
|
85
|
+
expect(InParallel::InParallelExecutor).to receive(:_execute_in_parallel).with(any_args).and_call_original.exactly(3).times
|
|
105
86
|
hypervisor.configure
|
|
106
87
|
end
|
|
107
88
|
end
|
|
@@ -109,8 +90,8 @@ module Beaker
|
|
|
109
90
|
context "if :disable_updates option set true" do
|
|
110
91
|
it "calls disable_updates" do
|
|
111
92
|
options[:disable_updates] = true
|
|
112
|
-
allow(
|
|
113
|
-
expect(
|
|
93
|
+
allow(hypervisor).to receive(:set_env)
|
|
94
|
+
expect(hypervisor).to receive(:disable_updates).once
|
|
114
95
|
hypervisor.configure
|
|
115
96
|
end
|
|
116
97
|
end
|
|
@@ -118,8 +99,8 @@ module Beaker
|
|
|
118
99
|
context "if :disable_updates option set false" do
|
|
119
100
|
it "does not call disable_updates_puppetlabs_com" do
|
|
120
101
|
options[:disable_updates] = false
|
|
121
|
-
allow(
|
|
122
|
-
expect(
|
|
102
|
+
allow(hypervisor).to receive(:set_env)
|
|
103
|
+
expect(hypervisor).not_to receive(:disable_updates)
|
|
123
104
|
hypervisor.configure
|
|
124
105
|
end
|
|
125
106
|
end
|
|
@@ -129,15 +110,11 @@ module Beaker
|
|
|
129
110
|
options[:configure] = false
|
|
130
111
|
options[:timesync] = true
|
|
131
112
|
options[:root_keys] = true
|
|
132
|
-
options[:add_el_extras] = true
|
|
133
|
-
options[:disable_iptables] = true
|
|
134
113
|
options[:host_name_prefix] = "test-"
|
|
135
|
-
expect(
|
|
136
|
-
expect(
|
|
137
|
-
expect(
|
|
138
|
-
expect(
|
|
139
|
-
expect( hypervisor ).not_to receive( :set_env )
|
|
140
|
-
expect( hypervisor ).not_to receive( :host_name_prefix )
|
|
114
|
+
expect(hypervisor).not_to receive(:timesync)
|
|
115
|
+
expect(hypervisor).not_to receive(:sync_root_keys)
|
|
116
|
+
expect(hypervisor).not_to receive(:set_env)
|
|
117
|
+
expect(hypervisor).not_to receive(:host_name_prefix)
|
|
141
118
|
hypervisor.configure
|
|
142
119
|
end
|
|
143
120
|
end
|
|
@@ -145,7 +122,7 @@ module Beaker
|
|
|
145
122
|
context 'if :configure option set true' do
|
|
146
123
|
it 'does call set_env' do
|
|
147
124
|
options[:configure] = true
|
|
148
|
-
expect(
|
|
125
|
+
expect(hypervisor).to receive(:set_env).once
|
|
149
126
|
hypervisor.configure
|
|
150
127
|
end
|
|
151
128
|
end
|
|
@@ -154,12 +131,10 @@ module Beaker
|
|
|
154
131
|
it "generates hostname with prefix" do
|
|
155
132
|
prefix = "testing-prefix-to-test-"
|
|
156
133
|
options[:host_name_prefix] = prefix
|
|
157
|
-
|
|
158
|
-
|
|
134
|
+
expect(hypervisor.generate_host_name.start_with?(prefix)).to be true
|
|
135
|
+
expect(hypervisor.generate_host_name.length - prefix.length >= 15).to be true
|
|
159
136
|
end
|
|
160
137
|
end
|
|
161
|
-
|
|
162
138
|
end
|
|
163
|
-
|
|
164
139
|
end
|
|
165
140
|
end
|
|
@@ -5,18 +5,17 @@ module Beaker
|
|
|
5
5
|
describe LocalConnection do
|
|
6
6
|
subject(:connection) { described_class.new(options) }
|
|
7
7
|
|
|
8
|
-
let(
|
|
9
|
-
|
|
8
|
+
let(:options) { { :logger => double('logger').as_null_object, :ssh_env_file => '/path/to/ssh/file' } }
|
|
10
9
|
|
|
11
10
|
before do
|
|
12
|
-
allow(
|
|
11
|
+
allow(subject).to receive(:sleep)
|
|
13
12
|
end
|
|
14
13
|
|
|
15
14
|
describe '#self.connect' do
|
|
16
15
|
it 'loggs message' do
|
|
17
16
|
expect(options[:logger]).to receive(:debug).with('Local connection, no connection to start')
|
|
18
17
|
connection_constructor = described_class.connect(options)
|
|
19
|
-
expect(
|
|
18
|
+
expect(connection_constructor).to be_a described_class
|
|
20
19
|
end
|
|
21
20
|
end
|
|
22
21
|
|
|
@@ -30,22 +29,22 @@ module Beaker
|
|
|
30
29
|
describe '#with_env' do
|
|
31
30
|
it 'sets envs temporarily' do
|
|
32
31
|
connection.connect
|
|
33
|
-
connection.with_env({'my_env' => 'my_env_value'}) do
|
|
34
|
-
expect(ENV.to_hash).to include({'my_env' => 'my_env_value'})
|
|
32
|
+
connection.with_env({ 'my_env' => 'my_env_value' }) do
|
|
33
|
+
expect(ENV.to_hash).to include({ 'my_env' => 'my_env_value' })
|
|
35
34
|
end
|
|
36
|
-
expect(ENV.to_hash).not_to include({'my_env' => 'my_env_value'})
|
|
35
|
+
expect(ENV.to_hash).not_to include({ 'my_env' => 'my_env_value' })
|
|
37
36
|
end
|
|
38
37
|
end
|
|
39
38
|
|
|
40
39
|
describe '#execute' do
|
|
41
40
|
it 'calls open3' do
|
|
42
|
-
expect(
|
|
41
|
+
expect(Open3).to receive(:capture3).with({}, 'my_command')
|
|
43
42
|
connection.connect
|
|
44
|
-
expect(connection.execute('my_command')).to
|
|
43
|
+
expect(connection.execute('my_command')).to be_a Result
|
|
45
44
|
end
|
|
46
45
|
|
|
47
46
|
it 'sets stdout, stderr and exitcode' do
|
|
48
|
-
allow(Open3).to receive(:capture3).and_return(['stdout', 'stderr', double({exitstatus: 0})])
|
|
47
|
+
allow(Open3).to receive(:capture3).and_return(['stdout', 'stderr', double({ exitstatus: 0 })])
|
|
49
48
|
connection.connect
|
|
50
49
|
result = connection.execute('my_command')
|
|
51
50
|
expect(result.exit_code).to eq(0)
|
|
@@ -54,7 +53,7 @@ module Beaker
|
|
|
54
53
|
end
|
|
55
54
|
|
|
56
55
|
it 'sets logger last_result' do
|
|
57
|
-
allow(Open3).to receive(:capture3).and_return(['stdout', 'stderr', double({exitstatus: 0})])
|
|
56
|
+
allow(Open3).to receive(:capture3).and_return(['stdout', 'stderr', double({ exitstatus: 0 })])
|
|
58
57
|
expect(options[:logger]).to receive(:last_result=).with(an_instance_of(Result))
|
|
59
58
|
connection.connect
|
|
60
59
|
connection.execute('my_command')
|
|
@@ -1,90 +1,79 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
1
|
require 'spec_helper'
|
|
3
2
|
|
|
4
3
|
module Beaker
|
|
5
4
|
describe LoggerJunit do
|
|
6
|
-
let(
|
|
7
|
-
let(
|
|
5
|
+
let(:xml_file) { '/fake/file/location1' }
|
|
6
|
+
let(:stylesheet) { '/fake/file/location2' }
|
|
8
7
|
|
|
9
8
|
describe '#is_valid_xml' do
|
|
10
|
-
|
|
11
9
|
it 'rejects all invalid values' do
|
|
12
10
|
invalid_values = [0x8, 0x10, 0xB, 0x0019, 0xD800, 0xDFFF, 0xFFFE, 0x99999, 0x110000]
|
|
13
11
|
invalid_values.each do |value|
|
|
14
|
-
expect(
|
|
12
|
+
expect(described_class.is_valid_xml(value)).to be === false
|
|
15
13
|
end
|
|
16
14
|
end
|
|
17
15
|
|
|
18
16
|
it 'accepts valid values' do
|
|
19
17
|
valid_values = [0x9, 0xA, 0x0020, 0xD7FF, 0xE000, 0xFFFD, 0x100000, 0x10FFFF]
|
|
20
18
|
valid_values.each do |value|
|
|
21
|
-
expect(
|
|
19
|
+
expect(described_class.is_valid_xml(value)).to be === true
|
|
22
20
|
end
|
|
23
21
|
end
|
|
24
|
-
|
|
25
22
|
end
|
|
26
23
|
|
|
27
24
|
describe '#escape_invalid_xml_chars' do
|
|
28
|
-
|
|
29
25
|
it 'escapes invalid xml characters correctly' do
|
|
30
26
|
testing_string = 'pants'
|
|
31
27
|
testing_string << 0x8
|
|
32
|
-
expect(
|
|
28
|
+
expect(described_class.escape_invalid_xml_chars(testing_string)).to be === 'pants\8'
|
|
33
29
|
end
|
|
34
30
|
|
|
35
31
|
it 'leaves a string of all valid xml characters alone' do
|
|
36
32
|
testing_string = 'pants man, pants!'
|
|
37
|
-
expect(
|
|
33
|
+
expect(described_class.escape_invalid_xml_chars(testing_string)).to be === testing_string
|
|
38
34
|
end
|
|
39
|
-
|
|
40
35
|
end
|
|
41
36
|
|
|
42
37
|
describe '#copy_stylesheet_into_xml_dir' do
|
|
43
|
-
|
|
44
38
|
it 'copies the stylesheet into the correct location' do
|
|
45
|
-
allow(
|
|
39
|
+
allow(File).to receive(:file?).and_return(false)
|
|
46
40
|
correct_location = File.join(File.dirname(xml_file), File.basename(stylesheet))
|
|
47
|
-
expect(
|
|
41
|
+
expect(FileUtils).to receive(:copy).with(stylesheet, correct_location)
|
|
48
42
|
described_class.copy_stylesheet_into_xml_dir(stylesheet, xml_file)
|
|
49
43
|
end
|
|
50
44
|
|
|
51
45
|
it 'skips action if the file doesn\'t exist' do
|
|
52
|
-
allow(
|
|
53
|
-
expect(
|
|
46
|
+
allow(File).to receive(:file?).and_return(true)
|
|
47
|
+
expect(FileUtils).not_to receive(:copy)
|
|
54
48
|
described_class.copy_stylesheet_into_xml_dir(stylesheet, xml_file)
|
|
55
49
|
end
|
|
56
|
-
|
|
57
50
|
end
|
|
58
51
|
|
|
59
52
|
describe '#finish' do
|
|
60
|
-
|
|
61
53
|
it 'opens the given file for writing, and writes the doc to it' do
|
|
62
54
|
mock_doc = Object.new
|
|
63
|
-
allow(
|
|
64
|
-
expect(
|
|
55
|
+
allow(mock_doc).to receive(:write).with(File, 2)
|
|
56
|
+
expect(File).to receive(:open).with(xml_file, 'w')
|
|
65
57
|
described_class.finish(mock_doc, xml_file)
|
|
66
58
|
end
|
|
67
|
-
|
|
68
59
|
end
|
|
69
60
|
|
|
70
61
|
describe '#write_xml' do
|
|
71
|
-
|
|
72
62
|
it 'throws an error with 1-arity in the given block' do
|
|
73
|
-
allow(
|
|
74
|
-
expect{ described_class.write_xml(xml_file, stylesheet)
|
|
63
|
+
allow(described_class).to receive(:get_xml_contents)
|
|
64
|
+
expect { described_class.write_xml(xml_file, stylesheet) { |hey| } }.to raise_error(ArgumentError)
|
|
75
65
|
end
|
|
76
66
|
|
|
77
67
|
it 'doesn\'t throw an error with 2-arity in the given block' do
|
|
78
|
-
allow(
|
|
79
|
-
allow(
|
|
80
|
-
expect{ described_class.write_xml(xml_file, stylesheet)
|
|
68
|
+
allow(described_class).to receive(:get_xml_contents)
|
|
69
|
+
allow(described_class).to receive(:finish)
|
|
70
|
+
expect { described_class.write_xml(xml_file, stylesheet) { |hey1, hey2| } }.not_to raise_error
|
|
81
71
|
end
|
|
82
72
|
|
|
83
73
|
it 'throws an error with 3-arity in the given block' do
|
|
84
|
-
allow(
|
|
85
|
-
expect{ described_class.write_xml(xml_file, stylesheet)
|
|
74
|
+
allow(described_class).to receive(:get_xml_contents)
|
|
75
|
+
expect { described_class.write_xml(xml_file, stylesheet) { |hey1, hey2, hey3| } }.to raise_error(ArgumentError)
|
|
86
76
|
end
|
|
87
|
-
|
|
88
77
|
end
|
|
89
78
|
end
|
|
90
79
|
end
|