beaker 4.41.2 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -9,24 +9,22 @@ class ClassMixedWithDSLHelpers
|
|
9
9
|
def logger
|
10
10
|
RSpec::Mocks::Double.new('logger').as_null_object
|
11
11
|
end
|
12
|
-
|
13
12
|
end
|
14
13
|
|
15
14
|
describe ClassMixedWithDSLHelpers do
|
16
|
-
let(
|
17
|
-
let(
|
18
|
-
let(
|
19
|
-
let(
|
20
|
-
|
21
|
-
let(
|
22
|
-
let(
|
23
|
-
let(
|
24
|
-
let(
|
25
|
-
let(
|
26
|
-
let(
|
15
|
+
let(:opts) { Beaker::Options::Presets.env_vars }
|
16
|
+
let(:command) { 'ls' }
|
17
|
+
let(:host) { double.as_null_object }
|
18
|
+
let(:result) { Beaker::Result.new(host, command) }
|
19
|
+
|
20
|
+
let(:master) { make_host('master', :roles => %w(master agent default)) }
|
21
|
+
let(:agent) { make_host('agent', :roles => %w(agent)) }
|
22
|
+
let(:custom) { make_host('custom', :roles => %w(custom agent)) }
|
23
|
+
let(:dash) { make_host('console', :roles => %w(dashboard agent)) }
|
24
|
+
let(:db) { make_host('db', :roles => %w(database agent)) }
|
25
|
+
let(:hosts) { [master, agent, dash, db, custom] }
|
27
26
|
|
28
27
|
describe '#on' do
|
29
|
-
|
30
28
|
before do
|
31
29
|
result.stdout = 'stdout'
|
32
30
|
result.stderr = 'stderr'
|
@@ -34,175 +32,156 @@ describe ClassMixedWithDSLHelpers do
|
|
34
32
|
end
|
35
33
|
|
36
34
|
it 'allows the environment the command is run within to be specified' do
|
37
|
-
allow(
|
35
|
+
allow(subject).to receive(:hosts).and_return(hosts)
|
38
36
|
|
39
|
-
expect(
|
40
|
-
with(
|
37
|
+
expect(Beaker::Command).to receive(:new)
|
38
|
+
.with('ls ~/.bin', [], { 'ENV' => { :HOME => '/tmp/test_home' } })
|
41
39
|
|
42
|
-
subject.on(
|
40
|
+
subject.on(host, 'ls ~/.bin', :environment => { :HOME => '/tmp/test_home' })
|
43
41
|
end
|
44
42
|
|
45
43
|
describe 'with a beaker command object passed in as the command argument' do
|
46
|
-
let(
|
44
|
+
let(:command) { Beaker::Command.new('commander command', [], :environment => { :HOME => 'default' }) }
|
47
45
|
|
48
46
|
it 'overwrites the command environment with the environment specified in #on' do
|
49
|
-
expect(
|
50
|
-
expect(command.environment).to eq({:HOME => 'override'})
|
47
|
+
expect(host).to receive(:exec) do |command|
|
48
|
+
expect(command.environment).to eq({ :HOME => 'override' })
|
51
49
|
end
|
52
|
-
subject.on(
|
50
|
+
subject.on(host, command, :environment => { :HOME => 'override' })
|
53
51
|
end
|
54
52
|
|
55
53
|
it 'uses the command environment if there is no overriding argument in #on' do
|
56
|
-
expect(
|
57
|
-
expect(command.environment).to eq({:HOME => 'default'})
|
54
|
+
expect(host).to receive(:exec) do |command|
|
55
|
+
expect(command.environment).to eq({ :HOME => 'default' })
|
58
56
|
end
|
59
|
-
subject.on(
|
57
|
+
subject.on(host, command)
|
60
58
|
end
|
61
|
-
|
62
59
|
end
|
63
60
|
|
64
61
|
it 'if the host is a String Object, finds the matching hosts with that String as role' do
|
65
|
-
allow(
|
62
|
+
allow(subject).to receive(:hosts).and_return(hosts)
|
66
63
|
|
67
|
-
expect(
|
64
|
+
expect(master).to receive(:exec).once
|
68
65
|
|
69
|
-
subject.on(
|
66
|
+
subject.on('master', 'echo hello')
|
70
67
|
end
|
71
68
|
|
72
69
|
it 'if the host is a Symbol Object, finds the matching hosts with that Symbol as role' do
|
73
|
-
allow(
|
70
|
+
allow(subject).to receive(:hosts).and_return(hosts)
|
74
71
|
|
75
|
-
expect(
|
72
|
+
expect(master).to receive(:exec).once
|
76
73
|
|
77
|
-
subject.on(
|
74
|
+
subject.on(:master, 'echo hello')
|
78
75
|
end
|
79
76
|
|
80
77
|
it 'executes in parallel if run_in_parallel=true' do
|
81
78
|
InParallel::InParallelExecutor.logger = logger
|
82
79
|
FakeFS.deactivate!
|
83
|
-
allow(
|
80
|
+
allow(subject).to receive(:hosts).and_return(hosts)
|
84
81
|
expected = []
|
85
82
|
hosts.each_with_index do |host, i|
|
86
83
|
expected << i
|
87
|
-
allow(
|
84
|
+
allow(host).to receive(:exec).and_return(i)
|
88
85
|
end
|
89
86
|
|
90
87
|
# This will only get hit if forking processes is supported and at least 2 items are being submitted to run in parallel
|
91
|
-
expect(
|
92
|
-
results = subject.on(
|
93
|
-
expect(
|
88
|
+
expect(InParallel::InParallelExecutor).to receive(:_execute_in_parallel).with(any_args).and_call_original.exactly(5).times
|
89
|
+
results = subject.on(hosts, command, { :run_in_parallel => true })
|
90
|
+
expect(results).to be == expected
|
94
91
|
end
|
95
92
|
|
96
93
|
it 'delegates to itself for each host passed' do
|
97
|
-
allow(
|
94
|
+
allow(subject).to receive(:hosts).and_return(hosts)
|
98
95
|
expected = []
|
99
96
|
hosts.each_with_index do |host, i|
|
100
97
|
expected << i
|
101
|
-
expect(
|
98
|
+
expect(host).to receive(:exec).and_return(i)
|
102
99
|
end
|
103
100
|
|
104
|
-
results = subject.on(
|
105
|
-
expect(
|
101
|
+
results = subject.on(hosts, command)
|
102
|
+
expect(results).to be == expected
|
106
103
|
end
|
107
104
|
|
108
105
|
context 'upon command completion' do
|
109
106
|
before do
|
110
|
-
allow(
|
111
|
-
expect(
|
112
|
-
@res = subject.on(
|
107
|
+
allow(subject).to receive(:hosts).and_return(hosts)
|
108
|
+
expect(host).to receive(:exec).and_return(result)
|
109
|
+
@res = subject.on(host, command)
|
113
110
|
end
|
114
111
|
|
115
112
|
it 'returns the result of the action' do
|
116
|
-
expect(
|
113
|
+
expect(@res).to be == result
|
117
114
|
end
|
118
115
|
|
119
116
|
it 'provides access to stdout' do
|
120
|
-
expect(
|
117
|
+
expect(@res.stdout).to be == 'stdout'
|
121
118
|
end
|
122
119
|
|
123
120
|
it 'provides access to stderr' do
|
124
|
-
expect(
|
121
|
+
expect(@res.stderr).to be == 'stderr'
|
125
122
|
end
|
126
123
|
|
127
124
|
it 'provides access to exit_code' do
|
128
|
-
expect(
|
125
|
+
expect(@res.exit_code).to be == 0
|
129
126
|
end
|
130
127
|
end
|
131
128
|
|
132
129
|
context 'when passed a block with arity of 1' do
|
133
130
|
before do
|
134
|
-
allow(
|
135
|
-
expect(
|
131
|
+
allow(subject).to receive(:hosts).and_return(hosts)
|
132
|
+
expect(host).to receive(:exec).and_return(result)
|
136
133
|
end
|
137
134
|
|
138
135
|
it 'yields result' do
|
139
136
|
subject.on host, command do |containing_class|
|
140
|
-
expect(
|
141
|
-
to be_an_instance_of(
|
137
|
+
expect(containing_class)
|
138
|
+
.to be_an_instance_of(Beaker::Result)
|
142
139
|
end
|
143
140
|
end
|
144
141
|
|
145
142
|
it 'provides access to stdout' do
|
146
143
|
subject.on host, command do |containing_class|
|
147
|
-
expect(
|
144
|
+
expect(containing_class.stdout).to be == 'stdout'
|
148
145
|
end
|
149
146
|
end
|
150
147
|
|
151
148
|
it 'provides access to stderr' do
|
152
149
|
subject.on host, command do |containing_class|
|
153
|
-
expect(
|
150
|
+
expect(containing_class.stderr).to be == 'stderr'
|
154
151
|
end
|
155
152
|
end
|
156
153
|
|
157
154
|
it 'provides access to exit_code' do
|
158
155
|
subject.on host, command do |containing_class|
|
159
|
-
expect(
|
156
|
+
expect(containing_class.exit_code).to be == 0
|
160
157
|
end
|
161
158
|
end
|
162
159
|
end
|
163
160
|
|
164
161
|
context 'when passed a block with arity of 0' do
|
165
162
|
before do
|
166
|
-
allow(
|
167
|
-
expect(
|
163
|
+
allow(subject).to receive(:hosts).and_return(hosts)
|
164
|
+
expect(host).to receive(:exec).and_return(result)
|
168
165
|
end
|
169
166
|
|
170
167
|
it 'yields self' do
|
171
168
|
subject.on host, command do
|
172
|
-
expect(
|
173
|
-
to be_an_instance_of(
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
it 'provides access to stdout' do
|
178
|
-
subject.on host, command do
|
179
|
-
expect( subject.stdout ).to be == 'stdout'
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
it 'provides access to stderr' do
|
184
|
-
subject.on host, command do
|
185
|
-
expect( subject.stderr ).to be == 'stderr'
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
it 'provides access to exit_code' do
|
190
|
-
subject.on host, command do
|
191
|
-
expect( subject.exit_code ).to be == 0
|
169
|
+
expect(subject)
|
170
|
+
.to be_an_instance_of(described_class)
|
192
171
|
end
|
193
172
|
end
|
194
173
|
end
|
195
174
|
|
196
175
|
it 'errors if command is not a String or Beaker::Command' do
|
197
|
-
expect
|
198
|
-
subject.on(
|
199
|
-
|
176
|
+
expect do
|
177
|
+
subject.on(host, Object.new)
|
178
|
+
end.to raise_error(ArgumentError, /called\ with\ a\ String\ or\ Beaker/)
|
200
179
|
end
|
201
180
|
|
202
181
|
it 'executes the passed Beaker::Command if given as command argument' do
|
203
|
-
command_test = Beaker::Command.new(
|
204
|
-
expect(
|
205
|
-
subject.on(
|
182
|
+
command_test = Beaker::Command.new('echo face_testing')
|
183
|
+
expect(master).to receive(:exec).with(command_test, anything)
|
184
|
+
subject.on(master, command_test)
|
206
185
|
end
|
207
186
|
end
|
208
187
|
|
@@ -215,12 +194,12 @@ describe ClassMixedWithDSLHelpers do
|
|
215
194
|
retries = 5
|
216
195
|
|
217
196
|
opts = {
|
218
|
-
:max_retries
|
197
|
+
:max_retries => retries,
|
219
198
|
:retry_interval => 0.0001,
|
220
199
|
}
|
221
200
|
|
222
|
-
allow(
|
223
|
-
expect(
|
201
|
+
allow(subject).to receive(:on).and_return(result)
|
202
|
+
expect(subject).to receive(:on).exactly(retries + 2)
|
224
203
|
expect { subject.retry_on(host, command, opts) }.to raise_error(RuntimeError)
|
225
204
|
end
|
226
205
|
|
@@ -230,12 +209,12 @@ describe ClassMixedWithDSLHelpers do
|
|
230
209
|
result.exit_code = 0
|
231
210
|
|
232
211
|
opts = {
|
233
|
-
:max_retries
|
212
|
+
:max_retries => 5,
|
234
213
|
:retry_interval => 0.0001,
|
235
214
|
}
|
236
215
|
|
237
|
-
allow(
|
238
|
-
expect(
|
216
|
+
allow(subject).to receive(:on).and_return(result)
|
217
|
+
expect(subject).to receive(:on).once
|
239
218
|
|
240
219
|
result_given = subject.retry_on(host, command, opts)
|
241
220
|
expect(result_given.exit_code).to be === 0
|
@@ -246,18 +225,18 @@ describe ClassMixedWithDSLHelpers do
|
|
246
225
|
result.stderr = 'stderr'
|
247
226
|
|
248
227
|
opts = {
|
249
|
-
:max_retries
|
228
|
+
:max_retries => 10,
|
250
229
|
:retry_interval => 0.1,
|
251
230
|
}
|
252
231
|
|
253
232
|
reps_num = 4
|
254
233
|
count = 0
|
255
|
-
allow(
|
234
|
+
allow(subject).to receive(:on) do
|
256
235
|
result.exit_code = count > reps_num ? 0 : 1
|
257
236
|
count += 1
|
258
237
|
result
|
259
238
|
end
|
260
|
-
expect(
|
239
|
+
expect(subject).to receive(:on).exactly(reps_num + 2)
|
261
240
|
|
262
241
|
result_given = subject.retry_on(host, command, opts)
|
263
242
|
expect(result_given.exit_code).to be === 0
|
@@ -266,51 +245,51 @@ describe ClassMixedWithDSLHelpers do
|
|
266
245
|
|
267
246
|
describe "shell" do
|
268
247
|
it 'delegates to #on with the default host' do
|
269
|
-
allow(
|
248
|
+
allow(subject).to receive(:hosts).and_return(hosts)
|
270
249
|
|
271
|
-
expect(
|
250
|
+
expect(subject).to receive(:on).with(master, "echo hello", {}).once
|
272
251
|
|
273
|
-
subject.shell(
|
252
|
+
subject.shell("echo hello")
|
274
253
|
end
|
275
254
|
end
|
276
255
|
|
277
256
|
describe '#scp_from' do
|
278
257
|
it 'delegates to the host' do
|
279
|
-
allow(
|
280
|
-
expect(
|
281
|
-
expect(
|
258
|
+
allow(subject).to receive(:hosts).and_return(hosts)
|
259
|
+
expect(subject).to receive(:logger).exactly(hosts.length).times
|
260
|
+
expect(result).to receive(:log).exactly(hosts.length).times
|
282
261
|
|
283
262
|
hosts.each do |host|
|
284
|
-
expect(
|
263
|
+
expect(host).to receive(:do_scp_from).and_return(result)
|
285
264
|
end
|
286
265
|
|
287
|
-
subject.scp_from(
|
266
|
+
subject.scp_from(hosts, '/var/log/my.log', 'log/my.log')
|
288
267
|
end
|
289
268
|
end
|
290
269
|
|
291
270
|
describe '#scp_to' do
|
292
271
|
it 'delegates to the host' do
|
293
|
-
allow(
|
294
|
-
expect(
|
295
|
-
expect(
|
272
|
+
allow(subject).to receive(:hosts).and_return(hosts)
|
273
|
+
expect(subject).to receive(:logger).exactly(hosts.length).times
|
274
|
+
expect(result).to receive(:log).exactly(hosts.length).times
|
296
275
|
|
297
276
|
hosts.each do |host|
|
298
|
-
expect(
|
277
|
+
expect(host).to receive(:do_scp_to).and_return(result)
|
299
278
|
end
|
300
279
|
|
301
|
-
subject.scp_to(
|
280
|
+
subject.scp_to(hosts, '/var/log/my.log', 'log/my.log')
|
302
281
|
end
|
303
282
|
end
|
304
283
|
|
305
284
|
describe '#rsync_to' do
|
306
285
|
it 'delegates to the host' do
|
307
|
-
allow(
|
286
|
+
allow(subject).to receive(:hosts).and_return(hosts)
|
308
287
|
|
309
288
|
hosts.each do |host|
|
310
|
-
expect(
|
289
|
+
expect(host).to receive(:do_rsync_to).and_return(result)
|
311
290
|
end
|
312
291
|
|
313
|
-
subject.rsync_to(
|
292
|
+
subject.rsync_to(hosts, '/var/log/my.log', 'log/my.log')
|
314
293
|
end
|
315
294
|
end
|
316
295
|
|
@@ -319,17 +298,17 @@ describe ClassMixedWithDSLHelpers do
|
|
319
298
|
my_opts = { :silent => true }
|
320
299
|
tmpfile = double
|
321
300
|
|
322
|
-
expect(
|
323
|
-
|
301
|
+
expect(tmpfile).to receive(:path).twice
|
302
|
+
.and_return('/local/path/to/blah')
|
324
303
|
|
325
|
-
expect(
|
304
|
+
expect(Tempfile).to receive(:open).and_yield(tmpfile)
|
326
305
|
|
327
|
-
expect(
|
306
|
+
expect(File).to receive(:open)
|
328
307
|
|
329
|
-
expect(
|
330
|
-
with(
|
308
|
+
expect(subject).to receive(:scp_to)
|
309
|
+
.with(hosts, '/local/path/to/blah', '/remote/path', my_opts)
|
331
310
|
|
332
|
-
subject.create_remote_file(
|
311
|
+
subject.create_remote_file(hosts, '/remote/path', 'blah', my_opts)
|
333
312
|
end
|
334
313
|
end
|
335
314
|
|
@@ -338,49 +317,49 @@ describe ClassMixedWithDSLHelpers do
|
|
338
317
|
my_opts = { :silent => true, :protocol => 'rsync' }
|
339
318
|
tmpfile = double
|
340
319
|
|
341
|
-
expect(
|
342
|
-
|
320
|
+
expect(tmpfile).to receive(:path).twice
|
321
|
+
.and_return('/local/path/to/blah')
|
343
322
|
|
344
|
-
expect(
|
323
|
+
expect(Tempfile).to receive(:open).and_yield(tmpfile)
|
345
324
|
|
346
|
-
expect(
|
325
|
+
expect(File).to receive(:open)
|
347
326
|
|
348
|
-
expect(
|
349
|
-
with(
|
327
|
+
expect(subject).to receive(:rsync_to)
|
328
|
+
.with(hosts, '/local/path/to/blah', '/remote/path', my_opts)
|
350
329
|
|
351
|
-
subject.create_remote_file(
|
330
|
+
subject.create_remote_file(hosts, '/remote/path', 'blah', my_opts)
|
352
331
|
end
|
353
332
|
end
|
354
333
|
|
355
334
|
describe '#run_script_on' do
|
356
335
|
it 'scps the script to a tmpdir and executes it on host(s)' do
|
357
|
-
expect(
|
358
|
-
expect(
|
359
|
-
subject.run_script_on(
|
336
|
+
expect(subject).to receive(:scp_to)
|
337
|
+
expect(subject).to receive(:on)
|
338
|
+
subject.run_script_on('host', '~/.bin/make-enterprisy')
|
360
339
|
end
|
361
340
|
end
|
362
341
|
|
363
342
|
describe '#run_script' do
|
364
343
|
it 'delegates to #run_script_on with the default host' do
|
365
|
-
allow(
|
344
|
+
allow(subject).to receive(:hosts).and_return(hosts)
|
366
345
|
|
367
|
-
expect(
|
346
|
+
expect(subject).to receive(:run_script_on).with(master, "/tmp/test.sh", {}).once
|
368
347
|
|
369
|
-
subject.run_script(
|
348
|
+
subject.run_script('/tmp/test.sh')
|
370
349
|
end
|
371
350
|
end
|
372
351
|
|
373
352
|
describe '#install_package' do
|
374
353
|
it 'delegates to Host#install_package with arguments on the passed Host' do
|
375
|
-
expect(
|
376
|
-
subject.install_package(
|
354
|
+
expect(host).to receive(:install_package).with('pkg_name', '', '1.2.3')
|
355
|
+
subject.install_package(host, 'pkg_name', '1.2.3')
|
377
356
|
end
|
378
357
|
end
|
379
358
|
|
380
359
|
describe '#uninstall_package' do
|
381
360
|
it 'delegates to Host#uninstall_package on the passed Host' do
|
382
|
-
expect(
|
383
|
-
subject.uninstall_package(
|
361
|
+
expect(host).to receive(:uninstall_package).with('pkg_name')
|
362
|
+
subject.uninstall_package(host, 'pkg_name')
|
384
363
|
end
|
385
364
|
end
|
386
365
|
end
|
@@ -9,7 +9,6 @@ class ClassMixedWithDSLHelpers
|
|
9
9
|
def logger
|
10
10
|
RSpec::Mocks::Double.new('logger').as_null_object
|
11
11
|
end
|
12
|
-
|
13
12
|
end
|
14
13
|
|
15
14
|
describe ClassMixedWithDSLHelpers do
|
@@ -18,60 +17,60 @@ describe ClassMixedWithDSLHelpers do
|
|
18
17
|
describe '#current_test_name' do
|
19
18
|
it 'returns nil if the case is undefined' do
|
20
19
|
allow(subject).to receive(:metadata).and_return(metadata)
|
21
|
-
expect(
|
20
|
+
expect(subject.current_test_name).to be_nil
|
22
21
|
end
|
23
22
|
|
24
23
|
it 'returns nil if the name is undefined' do
|
25
24
|
@metadata = { :case => {} }
|
26
25
|
allow(subject).to receive(:metadata).and_return(metadata)
|
27
|
-
expect(
|
26
|
+
expect(subject.current_test_name).to be_nil
|
28
27
|
end
|
29
28
|
|
30
29
|
it 'returns the set value' do
|
31
30
|
name = 'holyGrail_testName'
|
32
31
|
@metadata = { :case => { :name => name } }
|
33
32
|
allow(subject).to receive(:metadata).and_return(metadata)
|
34
|
-
expect(
|
33
|
+
expect(subject.current_test_name).to be === name
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
38
37
|
describe '#current_test_filename' do
|
39
38
|
it 'returns nil if the case is undefined' do
|
40
39
|
allow(subject).to receive(:metadata).and_return(metadata)
|
41
|
-
expect(
|
40
|
+
expect(subject.current_test_filename).to be_nil
|
42
41
|
end
|
43
42
|
|
44
43
|
it 'returns nil if the name is undefined' do
|
45
44
|
@metadata = { :case => {} }
|
46
45
|
allow(subject).to receive(:metadata).and_return(metadata)
|
47
|
-
expect(
|
46
|
+
expect(subject.current_test_filename).to be_nil
|
48
47
|
end
|
49
48
|
|
50
49
|
it 'returns the set value' do
|
51
50
|
name = 'holyGrail_testFilename'
|
52
51
|
@metadata = { :case => { :file_name => name } }
|
53
52
|
allow(subject).to receive(:metadata).and_return(metadata)
|
54
|
-
expect(
|
53
|
+
expect(subject.current_test_filename).to be === name
|
55
54
|
end
|
56
55
|
end
|
57
56
|
|
58
57
|
describe '#current_step_name' do
|
59
58
|
it 'returns nil if the step is undefined' do
|
60
59
|
allow(subject).to receive(:metadata).and_return(metadata)
|
61
|
-
expect(
|
60
|
+
expect(subject.current_step_name).to be_nil
|
62
61
|
end
|
63
62
|
|
64
63
|
it 'returns nil if the name is undefined' do
|
65
64
|
@metadata = { :step => {} }
|
66
65
|
allow(subject).to receive(:metadata).and_return(metadata)
|
67
|
-
expect(
|
66
|
+
expect(subject.current_step_name).to be_nil
|
68
67
|
end
|
69
68
|
|
70
69
|
it 'returns the set value' do
|
71
70
|
name = 'holyGrail_stepName'
|
72
71
|
@metadata = { :step => { :name => name } }
|
73
72
|
allow(subject).to receive(:metadata).and_return(metadata)
|
74
|
-
expect(
|
73
|
+
expect(subject.current_step_name).to be === name
|
75
74
|
end
|
76
75
|
end
|
77
76
|
end
|