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,199 +2,165 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
module Beaker
|
|
4
4
|
module Shared
|
|
5
|
-
|
|
6
5
|
config = RSpec::Mocks.configuration
|
|
7
6
|
|
|
8
7
|
config.patch_marshal_to_support_partial_doubles = true
|
|
9
8
|
|
|
10
9
|
describe HostManager do
|
|
11
10
|
# The logger double as nil object doesn't work with marshal.load and marshal.unload needed for run_in_parallel.
|
|
12
|
-
let(
|
|
13
|
-
let(
|
|
14
|
-
let(
|
|
15
|
-
let(
|
|
16
|
-
let(
|
|
17
|
-
let(
|
|
18
|
-
let(
|
|
19
|
-
let(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
let(:logger) { double('logger') }
|
|
12
|
+
let(:host_handler) { described_class }
|
|
13
|
+
let(:spec_block) { Proc.new { |arr| arr } }
|
|
14
|
+
let(:platform) { @platform || 'unix' }
|
|
15
|
+
let(:role0) { "role0" }
|
|
16
|
+
let(:role1) { :role1 }
|
|
17
|
+
let(:role2) { :role2 }
|
|
18
|
+
let(:hosts) do
|
|
19
|
+
hosts = make_hosts({ :platform => platform })
|
|
20
|
+
hosts[0][:roles] = ['agent', role0]
|
|
21
|
+
hosts[1][:roles] = ['master', 'dashboard', 'agent', 'database', role1]
|
|
22
|
+
hosts[2][:roles] = ['agent', role2]
|
|
23
|
+
hosts
|
|
24
|
+
end
|
|
24
25
|
|
|
25
26
|
describe "#hosts_with_name" do
|
|
26
|
-
|
|
27
27
|
it "can identify the host by name" do
|
|
28
|
-
|
|
29
|
-
expect( host_handler.hosts_with_name( hosts, 'vm1' )).to be === [hosts[0]]
|
|
30
|
-
|
|
28
|
+
expect(host_handler.hosts_with_name(hosts, 'vm1')).to be === [hosts[0]]
|
|
31
29
|
end
|
|
32
30
|
|
|
33
31
|
it "can identify the host by vmhostname" do
|
|
32
|
+
hosts[0][:vmhostname] = 'myname.whatever'
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
expect( host_handler.hosts_with_name( hosts, 'myname.whatever' )).to be === [hosts[0]]
|
|
38
|
-
|
|
34
|
+
expect(host_handler.hosts_with_name(hosts, 'myname.whatever')).to be === [hosts[0]]
|
|
39
35
|
end
|
|
40
36
|
|
|
41
37
|
it "can identify the host by ip" do
|
|
38
|
+
hosts[0][:ip] = '0.0.0.0'
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
expect( host_handler.hosts_with_name( hosts, '0.0.0.0' )).to be === [hosts[0]]
|
|
46
|
-
|
|
40
|
+
expect(host_handler.hosts_with_name(hosts, '0.0.0.0')).to be === [hosts[0]]
|
|
47
41
|
end
|
|
48
42
|
|
|
49
43
|
it "returns [] when no match is found in a set of hosts" do
|
|
44
|
+
hosts[0][:ip] = '0.0.0.0'
|
|
45
|
+
hosts[0][:vmhostname] = 'myname.whatever'
|
|
50
46
|
|
|
51
|
-
|
|
52
|
-
hosts[0][:vmhostname] = 'myname.whatever'
|
|
53
|
-
|
|
54
|
-
expect( host_handler.hosts_with_name( hosts, 'surprise' )).to be === []
|
|
55
|
-
|
|
47
|
+
expect(host_handler.hosts_with_name(hosts, 'surprise')).to be === []
|
|
56
48
|
end
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
49
|
end
|
|
61
50
|
|
|
62
51
|
describe "#hosts_with_role" do
|
|
63
52
|
it "can find the master in a set of hosts" do
|
|
64
|
-
|
|
65
|
-
expect( host_handler.hosts_with_role( hosts, 'master' ) ).to be === [hosts[1]]
|
|
66
|
-
|
|
53
|
+
expect(host_handler.hosts_with_role(hosts, 'master')).to be === [hosts[1]]
|
|
67
54
|
end
|
|
68
55
|
|
|
69
56
|
it "can find all agents in a set of hosts" do
|
|
70
|
-
|
|
71
|
-
expect( host_handler.hosts_with_role( hosts, 'agent' ) ).to be === hosts
|
|
72
|
-
|
|
57
|
+
expect(host_handler.hosts_with_role(hosts, 'agent')).to be === hosts
|
|
73
58
|
end
|
|
74
59
|
|
|
75
60
|
it "returns [] when no match is found in a set of hosts" do
|
|
76
|
-
|
|
77
|
-
expect( host_handler.hosts_with_role( hosts, 'surprise' ) ).to be === []
|
|
78
|
-
|
|
61
|
+
expect(host_handler.hosts_with_role(hosts, 'surprise')).to be === []
|
|
79
62
|
end
|
|
80
|
-
|
|
81
63
|
end
|
|
82
64
|
|
|
83
65
|
describe "#only_host_with_role" do
|
|
84
66
|
it "can find the single master in a set of hosts" do
|
|
85
|
-
|
|
86
|
-
expect( host_handler.only_host_with_role( hosts, 'master' ) ).to be === hosts[1]
|
|
87
|
-
|
|
67
|
+
expect(host_handler.only_host_with_role(hosts, 'master')).to be === hosts[1]
|
|
88
68
|
end
|
|
89
69
|
|
|
90
70
|
it "throws an error when more than one host with matching role is found" do
|
|
91
|
-
|
|
92
|
-
expect{ host_handler.only_host_with_role( hosts, 'agent' ) }.to raise_error(ArgumentError)
|
|
93
|
-
|
|
71
|
+
expect { host_handler.only_host_with_role(hosts, 'agent') }.to raise_error(ArgumentError)
|
|
94
72
|
end
|
|
95
73
|
|
|
96
74
|
it "throws an error when no host is found matching the role" do
|
|
97
|
-
|
|
98
|
-
expect{ host_handler.only_host_with_role( hosts, 'surprise' ) }.to raise_error(ArgumentError)
|
|
99
|
-
|
|
75
|
+
expect { host_handler.only_host_with_role(hosts, 'surprise') }.to raise_error(ArgumentError)
|
|
100
76
|
end
|
|
101
77
|
|
|
102
78
|
it "throws an error when role = nil" do
|
|
103
|
-
expect{ host_handler.find_at_most_one_host_with_role(
|
|
79
|
+
expect { host_handler.find_at_most_one_host_with_role(hosts, nil) }.to raise_error(ArgumentError)
|
|
104
80
|
end
|
|
105
81
|
end
|
|
106
82
|
|
|
107
83
|
describe "#find_at_most_one_host_with_role" do
|
|
108
84
|
it "can find the single master in a set of hosts" do
|
|
109
|
-
|
|
110
|
-
expect( host_handler.find_at_most_one_host_with_role( hosts, 'master' ) ).to be === hosts[1]
|
|
111
|
-
|
|
85
|
+
expect(host_handler.find_at_most_one_host_with_role(hosts, 'master')).to be === hosts[1]
|
|
112
86
|
end
|
|
113
87
|
|
|
114
88
|
it "throws an error when more than one host with matching role is found" do
|
|
115
|
-
|
|
116
|
-
expect{ host_handler.find_at_most_one_host_with_role( hosts, 'agent' ) }.to raise_error(ArgumentError)
|
|
117
|
-
|
|
89
|
+
expect { host_handler.find_at_most_one_host_with_role(hosts, 'agent') }.to raise_error(ArgumentError)
|
|
118
90
|
end
|
|
119
91
|
|
|
120
92
|
it "returns nil when no host is found matching the role" do
|
|
121
|
-
|
|
122
|
-
expect( host_handler.find_at_most_one_host_with_role( hosts, 'surprise' ) ).to be_nil
|
|
123
|
-
|
|
93
|
+
expect(host_handler.find_at_most_one_host_with_role(hosts, 'surprise')).to be_nil
|
|
124
94
|
end
|
|
125
95
|
|
|
126
96
|
it "throws an error when role = nil" do
|
|
127
|
-
expect{ host_handler.find_at_most_one_host_with_role(
|
|
97
|
+
expect { host_handler.find_at_most_one_host_with_role(hosts, nil) }.to raise_error(ArgumentError)
|
|
128
98
|
end
|
|
129
99
|
end
|
|
130
100
|
|
|
131
101
|
describe "#run_block_on" do
|
|
132
102
|
it "can execute a block against hosts identified by a string" do
|
|
133
|
-
myhosts = host_handler.run_block_on(
|
|
103
|
+
myhosts = host_handler.run_block_on(hosts, role0) do |hosts|
|
|
134
104
|
hosts
|
|
135
105
|
end
|
|
136
|
-
expect(
|
|
106
|
+
expect(myhosts).to be === hosts[0]
|
|
137
107
|
end
|
|
138
108
|
|
|
139
109
|
it "can execute a block against hosts identified by a hostname" do
|
|
140
|
-
myhosts = host_handler.run_block_on(
|
|
110
|
+
myhosts = host_handler.run_block_on(hosts, hosts[0].name) do |hosts|
|
|
141
111
|
hosts
|
|
142
112
|
end
|
|
143
|
-
expect(
|
|
113
|
+
expect(myhosts).to be === hosts[0]
|
|
144
114
|
end
|
|
145
115
|
|
|
146
116
|
it "can execute a block against an array of hosts" do
|
|
147
|
-
myhosts = host_handler.run_block_on(
|
|
117
|
+
myhosts = host_handler.run_block_on(hosts) do |hosts|
|
|
148
118
|
hosts
|
|
149
119
|
end
|
|
150
|
-
expect(
|
|
120
|
+
expect(myhosts).to be === hosts
|
|
151
121
|
end
|
|
152
122
|
|
|
153
123
|
it "can execute a block against an array of hosts in parallel" do
|
|
154
124
|
InParallel::InParallelExecutor.logger = Logger.new(STDOUT)
|
|
155
125
|
FakeFS.deactivate!
|
|
156
126
|
|
|
157
|
-
expect(
|
|
127
|
+
expect(InParallel::InParallelExecutor).to receive(:_execute_in_parallel).with(any_args).and_call_original.exactly(3).times
|
|
158
128
|
|
|
159
|
-
myhosts = host_handler.run_block_on(
|
|
129
|
+
myhosts = host_handler.run_block_on(hosts, nil, { :run_in_parallel => true }) do |host|
|
|
160
130
|
# kind of hacky workaround to remove logger which contains a singleton method injected by rspec
|
|
161
|
-
|
|
162
|
-
host.instance_eval("remove_instance_variable(:@logger)")
|
|
131
|
+
host.send(:remove_instance_variable, :@logger)
|
|
163
132
|
host
|
|
164
133
|
end
|
|
165
134
|
|
|
166
135
|
# After marshal load and marshal unload, the logger option (an rspec double) is no longer 'equal' to the original.
|
|
167
136
|
# Array of results can be in different order.
|
|
168
|
-
new_host = myhosts.find{ |host| host.name == hosts[0].name}
|
|
169
|
-
hosts[0].options.each
|
|
137
|
+
new_host = myhosts.find { |host| host.name == hosts[0].name }
|
|
138
|
+
hosts[0].options.each do |option|
|
|
170
139
|
expect(option[1]).to eq(new_host.options[option[0]]) unless option[0] == :logger
|
|
171
|
-
|
|
140
|
+
end
|
|
172
141
|
end
|
|
173
142
|
|
|
174
143
|
it "will ignore run_in_parallel global option" do
|
|
175
|
-
myhosts = host_handler.run_block_on(
|
|
144
|
+
myhosts = host_handler.run_block_on(hosts, nil, { :run_in_parallel => [] }) do |host|
|
|
176
145
|
host
|
|
177
146
|
end
|
|
178
|
-
expect(
|
|
147
|
+
expect(InParallel::InParallelExecutor).not_to receive(:_execute_in_parallel).with(any_args)
|
|
179
148
|
expect(myhosts).to eq(hosts)
|
|
180
149
|
end
|
|
181
150
|
|
|
182
151
|
it "does not run in parallel if there is only 1 host in the array" do
|
|
183
|
-
myhosts = host_handler.run_block_on(
|
|
152
|
+
myhosts = host_handler.run_block_on([hosts[0]], nil, { :run_in_parallel => true }) do |host|
|
|
184
153
|
puts host
|
|
185
154
|
host
|
|
186
155
|
end
|
|
187
156
|
|
|
188
|
-
expect(
|
|
157
|
+
expect(myhosts).to be === [hosts[0]]
|
|
189
158
|
end
|
|
190
159
|
|
|
191
160
|
it "receives an ArgumentError on empty host" do
|
|
192
|
-
expect { host_handler.run_block_on(
|
|
161
|
+
expect { host_handler.run_block_on([], role0) }.to raise_error(ArgumentError)
|
|
193
162
|
end
|
|
194
|
-
|
|
195
163
|
end
|
|
196
|
-
|
|
197
164
|
end
|
|
198
|
-
|
|
199
165
|
end
|
|
200
166
|
end
|
|
@@ -3,45 +3,42 @@ require 'spec_helper'
|
|
|
3
3
|
module Beaker
|
|
4
4
|
module Shared
|
|
5
5
|
describe OptionsResolver do
|
|
6
|
-
|
|
7
6
|
describe 'run_in_parallel?' do
|
|
8
|
-
|
|
9
7
|
it 'returns true if :run_in_parallel in opts is true' do
|
|
10
|
-
expect(
|
|
8
|
+
expect(subject.run_in_parallel?({ :run_in_parallel => true }, nil, nil)).to be === true
|
|
11
9
|
end
|
|
12
10
|
|
|
13
11
|
it 'returns false if :run_in_parallel in opts is false' do
|
|
14
|
-
expect(
|
|
12
|
+
expect(subject.run_in_parallel?({ :run_in_parallel => false }, nil, nil)).to be === false
|
|
15
13
|
end
|
|
16
14
|
|
|
17
15
|
it 'returns false if :run_in_parallel in opts is an empty array' do
|
|
18
|
-
expect(
|
|
16
|
+
expect(subject.run_in_parallel?({ :run_in_parallel => [] }, nil, nil)).to be === false
|
|
19
17
|
end
|
|
20
18
|
|
|
21
19
|
it 'returns false if :run_in_parallel in opts is an empty array but a mode is specified in options' do
|
|
22
|
-
expect(
|
|
20
|
+
expect(subject.run_in_parallel?({ :run_in_parallel => [] }, { :run_in_parallel => ['install'] }, 'install')).to be === false
|
|
23
21
|
end
|
|
24
22
|
|
|
25
23
|
it 'returns true if opts is nil but a matching mode is specified in options' do
|
|
26
|
-
expect(
|
|
24
|
+
expect(subject.run_in_parallel?(nil, { :run_in_parallel => ['install'] }, 'install')).to be === true
|
|
27
25
|
end
|
|
28
26
|
|
|
29
27
|
it 'returns false if opts is nil and a non matching mode is specified in options' do
|
|
30
|
-
expect(
|
|
28
|
+
expect(subject.run_in_parallel?(nil, { :run_in_parallel => ['configure'] }, 'install')).to be === false
|
|
31
29
|
end
|
|
32
30
|
|
|
33
31
|
it 'returns true if opts is nil and a matching mode and a non matching mode is specified in options' do
|
|
34
|
-
expect(
|
|
32
|
+
expect(subject.run_in_parallel?(nil, { :run_in_parallel => %w[configure install] }, 'install')).to be === true
|
|
35
33
|
end
|
|
36
34
|
|
|
37
35
|
it 'returns false if opts is nil and no mode is specified in options' do
|
|
38
|
-
expect(
|
|
36
|
+
expect(subject.run_in_parallel?(nil, { :run_in_parallel => [] }, 'install')).to be === false
|
|
39
37
|
end
|
|
40
38
|
|
|
41
39
|
it 'returns false if opts is false but a matching mode is specified in options' do
|
|
42
|
-
expect(
|
|
40
|
+
expect(subject.run_in_parallel?({ :run_in_parallel => false }, { :run_in_parallel => ['install'] }, 'install')).to be === false
|
|
43
41
|
end
|
|
44
|
-
|
|
45
42
|
end
|
|
46
43
|
end
|
|
47
44
|
end
|
|
@@ -3,54 +3,51 @@ require 'spec_helper'
|
|
|
3
3
|
module Beaker
|
|
4
4
|
module Shared
|
|
5
5
|
describe Repetition do
|
|
6
|
-
|
|
7
6
|
describe '#repeat_for' do
|
|
8
7
|
it "repeats a block for 5 seconds" do
|
|
9
|
-
allow(
|
|
8
|
+
allow(Time).to receive(:now).and_return(0, 1, 2, 3, 4, 5, 6)
|
|
10
9
|
|
|
11
|
-
block = double(
|
|
12
|
-
expect(
|
|
10
|
+
block = double('block')
|
|
11
|
+
expect(block).to receive(:exec).exactly(5).times.and_return(false)
|
|
13
12
|
|
|
14
|
-
subject.repeat_for(
|
|
13
|
+
subject.repeat_for(5) do
|
|
15
14
|
block.exec
|
|
16
15
|
end
|
|
17
16
|
end
|
|
18
17
|
|
|
19
18
|
it "shorts circuit if the block is complete" do
|
|
20
|
-
allow(
|
|
19
|
+
allow(Time).to receive(:now).and_return(0, 1, 2, 3, 4, 5)
|
|
21
20
|
|
|
22
|
-
block = double(
|
|
23
|
-
expect(
|
|
21
|
+
block = double('block')
|
|
22
|
+
expect(block).to receive(:exec).once.and_return(true)
|
|
24
23
|
|
|
25
|
-
subject.repeat_for(
|
|
24
|
+
subject.repeat_for(5) do
|
|
26
25
|
block.exec
|
|
27
26
|
end
|
|
28
|
-
|
|
29
27
|
end
|
|
30
|
-
|
|
31
28
|
end
|
|
32
29
|
|
|
33
30
|
describe '#repeat_fibonacci_style_for' do
|
|
34
31
|
let(:block) { double("block") }
|
|
35
32
|
|
|
36
33
|
it "sleeps in fibonacci increasing intervals" do
|
|
37
|
-
expect(
|
|
38
|
-
allow(
|
|
34
|
+
expect(block).to receive(:exec).exactly(5).times.and_return(false)
|
|
35
|
+
allow(subject).to receive('sleep').and_return(true)
|
|
39
36
|
|
|
40
|
-
expect(
|
|
41
|
-
expect(
|
|
42
|
-
expect(
|
|
43
|
-
expect(
|
|
44
|
-
expect(
|
|
37
|
+
expect(subject).to receive(:sleep).with(1).twice
|
|
38
|
+
expect(subject).to receive(:sleep).with(2).once
|
|
39
|
+
expect(subject).to receive(:sleep).with(3).once
|
|
40
|
+
expect(subject).to receive(:sleep).with(5).once
|
|
41
|
+
expect(subject).not_to receive(:sleep).with(8)
|
|
45
42
|
|
|
46
|
-
subject.repeat_fibonacci_style_for(
|
|
43
|
+
subject.repeat_fibonacci_style_for(5) do
|
|
47
44
|
block.exec
|
|
48
45
|
end
|
|
49
46
|
end
|
|
50
47
|
|
|
51
48
|
it "shorts circuit if the block succeeds (returns true)" do
|
|
52
49
|
expect(block).to receive(:exec).and_return(false).ordered.exactly(4).times
|
|
53
|
-
expect(block).to receive(:exec).and_return(
|
|
50
|
+
expect(block).to receive(:exec).and_return(true).ordered.once
|
|
54
51
|
|
|
55
52
|
expect(subject).to receive(:sleep).with(1).twice
|
|
56
53
|
expect(subject).to receive(:sleep).with(2).once
|
|
@@ -84,11 +81,7 @@ module Beaker
|
|
|
84
81
|
block.fake01
|
|
85
82
|
end
|
|
86
83
|
end
|
|
87
|
-
|
|
88
|
-
|
|
89
84
|
end
|
|
90
|
-
|
|
91
85
|
end
|
|
92
|
-
|
|
93
86
|
end
|
|
94
87
|
end
|
|
@@ -3,97 +3,92 @@ require 'spec_helper'
|
|
|
3
3
|
module Beaker
|
|
4
4
|
module Shared
|
|
5
5
|
describe Semvar do
|
|
6
|
-
|
|
7
6
|
describe 'version_is_less' do
|
|
8
|
-
|
|
9
7
|
it 'reports 2015.3.0-rc0-8-gf80879a is less than 2016' do
|
|
10
|
-
expect(
|
|
8
|
+
expect(subject.version_is_less('2015.3.0-rc0-8-gf80879a', '2016')).to be === true
|
|
11
9
|
end
|
|
12
10
|
|
|
13
11
|
it 'reports 2015.3.0-rc0-8-gf80879a is less than 2015.3.0' do
|
|
14
|
-
expect(
|
|
12
|
+
expect(subject.version_is_less('2015.3.0-rc0-8-gf80879a', '2015.3.0')).to be === true
|
|
15
13
|
end
|
|
16
14
|
|
|
17
15
|
it 'reports that 2015.3.0-rc0 is less than 2015.3.0-rc0-8-gf80879a' do
|
|
18
|
-
expect(
|
|
16
|
+
expect(subject.version_is_less('2015.3.0-rc0', '2015.3.0-rc0-8-gf80879a')).to be === true
|
|
19
17
|
end
|
|
20
18
|
|
|
21
19
|
it 'reports that 2015.3.0-rc2 is less than 2015.3.0-rc10 (not using string comparison)' do
|
|
22
|
-
expect(
|
|
20
|
+
expect(subject.version_is_less('2015.3.0-rc2', '2015.3.0-rc10')).to be === true
|
|
23
21
|
end
|
|
24
22
|
|
|
25
23
|
it 'reports that 2015.3.0 is less than 2015.3.0-1-gabc1234' do
|
|
26
|
-
expect(
|
|
24
|
+
expect(subject.version_is_less('2015.3.0', '2015.3.0-1-gabc1234')).to be === true
|
|
27
25
|
end
|
|
28
26
|
|
|
29
|
-
it 'reports that 2015.3.0-rc2 is less than 2015.3.0-1-gabc1234' do
|
|
30
|
-
expect(
|
|
27
|
+
it 'reports that 2015.3.0-rc2 is less than 2015.3.0-1-gabc1234' do
|
|
28
|
+
expect(subject.version_is_less('2015.3.0-rc2', '2015.3.0-1-gabc1234')).to be === true
|
|
31
29
|
end
|
|
32
30
|
|
|
33
31
|
it 'reports 2015.3.0-rc0-8-gf80879a is not less than 3.0.0' do
|
|
34
|
-
expect(
|
|
32
|
+
expect(subject.version_is_less('2015.3.0-rc0-8-gf80879a', '3.0.0')).to be === false
|
|
35
33
|
end
|
|
36
34
|
|
|
37
35
|
it 'reports 3.0.0-160-gac44cfb is not less than 3.0.0' do
|
|
38
|
-
expect(
|
|
36
|
+
expect(subject.version_is_less('3.0.0-160-gac44cfb', '3.0.0')).to be === false
|
|
39
37
|
end
|
|
40
38
|
|
|
41
39
|
it 'reports 3.0.0-160-gac44cfb is not less than 2.8.2' do
|
|
42
|
-
expect(
|
|
40
|
+
expect(subject.version_is_less('3.0.0-160-gac44cfb', '2.8.2')).to be === false
|
|
43
41
|
end
|
|
44
42
|
|
|
45
43
|
it 'reports 3.0.0 is less than 3.0.0-160-gac44cfb' do
|
|
46
|
-
expect(
|
|
44
|
+
expect(subject.version_is_less('3.0.0', '3.0.0-160-gac44cfb')).to be === true
|
|
47
45
|
end
|
|
48
46
|
|
|
49
47
|
it 'reports 2.8.2 is less than 3.0.0-160-gac44cfb' do
|
|
50
|
-
expect(
|
|
48
|
+
expect(subject.version_is_less('2.8.2', '3.0.0-160-gac44cfb')).to be === true
|
|
51
49
|
end
|
|
52
50
|
|
|
53
51
|
it 'reports 2.8 is less than 3.0.0-160-gac44cfb' do
|
|
54
|
-
expect(
|
|
52
|
+
expect(subject.version_is_less('2.8', '3.0.0-160-gac44cfb')).to be === true
|
|
55
53
|
end
|
|
56
54
|
|
|
57
55
|
it 'reports 2.8 is less than 2.9' do
|
|
58
|
-
expect(
|
|
56
|
+
expect(subject.version_is_less('2.8', '2.9')).to be === true
|
|
59
57
|
end
|
|
60
58
|
|
|
61
59
|
it 'reports that 2015.3.0 is not less than 2015.3.0' do
|
|
62
|
-
expect(
|
|
60
|
+
expect(subject.version_is_less('2015.3.0', '2015.3.0')).to be == false
|
|
63
61
|
end
|
|
64
62
|
end
|
|
65
63
|
|
|
66
64
|
describe 'max_version' do
|
|
67
|
-
|
|
68
65
|
it 'returns nil if versions isn\'t defined' do
|
|
69
|
-
expect(
|
|
66
|
+
expect(subject.max_version(nil)).to be_nil
|
|
70
67
|
end
|
|
71
68
|
|
|
72
69
|
it 'returns nil if versions is empty' do
|
|
73
|
-
expect(
|
|
70
|
+
expect(subject.max_version([])).to be_nil
|
|
74
71
|
end
|
|
75
72
|
|
|
76
73
|
it 'allows you to set the default, & will return it with faulty input' do
|
|
77
|
-
expect(
|
|
74
|
+
expect(subject.max_version([], '5.9')).to be === '5.9'
|
|
78
75
|
end
|
|
79
76
|
|
|
80
77
|
it 'returns the one value if given a length 1 array' do
|
|
81
|
-
expect(
|
|
78
|
+
expect(subject.max_version(['7.3'])).to be === '7.3'
|
|
82
79
|
end
|
|
83
80
|
|
|
84
81
|
it 'does not mangle the versions array passed in' do
|
|
85
82
|
first_array = ['1.4.3', '8.4.5', '3.5.7', '2.7.5']
|
|
86
83
|
array_to_pass = first_array.dup
|
|
87
84
|
subject.max_version(array_to_pass)
|
|
88
|
-
expect(
|
|
85
|
+
expect(array_to_pass).to be === first_array
|
|
89
86
|
end
|
|
90
87
|
|
|
91
88
|
it 'returns 5.8.9 from [5.8.9, 1.2.3, 0.3.5, 5.7.11]' do
|
|
92
|
-
expect(
|
|
89
|
+
expect(subject.max_version(['5.8.9', '1.2.3', '0.3.5', '5.7.11'])).to be === '5.8.9'
|
|
93
90
|
end
|
|
94
|
-
|
|
95
91
|
end
|
|
96
92
|
end
|
|
97
|
-
|
|
98
93
|
end
|
|
99
94
|
end
|