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
@@ -13,90 +13,90 @@ describe ClassMixedWithDSLStructure do
|
|
13
13
|
let(:metadata) { @metadata ||= {} }
|
14
14
|
|
15
15
|
before do
|
16
|
-
allow(
|
16
|
+
allow(subject).to receive(:metadata).and_return(metadata)
|
17
17
|
end
|
18
18
|
|
19
19
|
describe '#step' do
|
20
20
|
it 'requires a name' do
|
21
|
-
expect { subject.step
|
21
|
+
expect { subject.step { ; } }.to raise_error ArgumentError
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'notifies the logger' do
|
25
|
-
allow(
|
26
|
-
expect(
|
27
|
-
expect(
|
25
|
+
allow(subject).to receive(:set_current_step_name)
|
26
|
+
expect(subject).to receive(:logger).and_return(logger)
|
27
|
+
expect(logger).to receive(:notify)
|
28
28
|
subject.step 'blah'
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'yields if a block is given' do
|
32
|
-
expect(
|
33
|
-
allow(
|
34
|
-
allow(
|
35
|
-
expect(
|
36
|
-
expect(
|
32
|
+
expect(subject).to receive(:logger).and_return(logger).twice
|
33
|
+
allow(subject).to receive(:set_current_step_name)
|
34
|
+
allow(logger).to receive(:with_indent).and_yield
|
35
|
+
expect(logger).to receive(:notify)
|
36
|
+
expect(subject).to receive(:foo)
|
37
37
|
subject.step 'blah' do
|
38
38
|
subject.foo
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'sets the metadata' do
|
43
|
-
allow(
|
44
|
-
allow(
|
43
|
+
allow(subject).to receive(:logger).and_return(logger)
|
44
|
+
allow(logger).to receive(:notify)
|
45
45
|
step_name = 'pierceBrosnanTests'
|
46
46
|
subject.step step_name
|
47
|
-
expect(
|
47
|
+
expect(metadata[:step][:name]).to be === step_name
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
describe '#manual_step' do
|
52
52
|
context 'without exec manual test option' do
|
53
|
-
let(
|
53
|
+
let(:options) { {} }
|
54
54
|
|
55
55
|
it 'throws an error' do
|
56
|
-
expect(
|
56
|
+
expect(Readline).not_to receive(:readline)
|
57
57
|
expect { subject.manual_step 'blah' do; end }.to raise_error StandardError
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
context 'with exec manual test option' do
|
62
|
-
let(
|
62
|
+
let(:options) { { exec_manual_tests: nil } }
|
63
63
|
|
64
64
|
it 'requires a name' do
|
65
|
-
expect { subject.manual_step
|
65
|
+
expect { subject.manual_step { ; } }.to raise_error ArgumentError
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'notifies the logger' do
|
69
69
|
subject.instance_variable_set(:@options, options)
|
70
|
-
allow(
|
71
|
-
expect(
|
72
|
-
expect(
|
73
|
-
allow(
|
70
|
+
allow(subject).to receive(:set_current_step_name)
|
71
|
+
expect(subject).to receive(:logger).and_return(logger)
|
72
|
+
expect(logger).to receive(:notify)
|
73
|
+
allow(Readline).to receive(:readline).and_return('Y')
|
74
74
|
subject.manual_step 'blah'
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
78
|
context 'with exec manual test option set to true' do
|
79
|
-
let(
|
79
|
+
let(:options) { { exec_manual_tests: true } }
|
80
80
|
|
81
81
|
it 'requires a name' do
|
82
|
-
expect { subject.manual_step
|
82
|
+
expect { subject.manual_step { ; } }.to raise_error ArgumentError
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'pass when user enters Y' do
|
86
86
|
subject.instance_variable_set(:@options, options)
|
87
|
-
allow(
|
88
|
-
allow(
|
89
|
-
allow(
|
90
|
-
expect(
|
87
|
+
allow(subject).to receive(:set_current_step_name)
|
88
|
+
allow(subject).to receive(:logger).and_return(logger)
|
89
|
+
allow(logger).to receive(:notify)
|
90
|
+
expect(Readline).to receive(:readline).and_return('Y')
|
91
91
|
subject.manual_step 'blahblah'
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'fails when user enters n and uses default error when no message is entered' do
|
95
95
|
subject.instance_variable_set(:@options, options)
|
96
|
-
allow(
|
97
|
-
allow(
|
98
|
-
allow(
|
99
|
-
expect(
|
96
|
+
allow(subject).to receive(:set_current_step_name)
|
97
|
+
allow(subject).to receive(:logger).and_return(logger)
|
98
|
+
allow(logger).to receive(:notify)
|
99
|
+
expect(Readline).to receive(:readline).and_return('n', 'step failed')
|
100
100
|
expect { subject.manual_step 'blah two' do; end }.to raise_error(Beaker::DSL::FailTest, 'step failed')
|
101
101
|
end
|
102
102
|
end
|
@@ -104,41 +104,41 @@ describe ClassMixedWithDSLStructure do
|
|
104
104
|
|
105
105
|
describe '#manual_test' do
|
106
106
|
context 'without exec manual test option' do
|
107
|
-
let(
|
107
|
+
let(:options) { {} }
|
108
108
|
|
109
109
|
it 'requires a name' do
|
110
|
-
expect { subject.manual_test
|
110
|
+
expect { subject.manual_test { ; } }.to raise_error ArgumentError
|
111
111
|
end
|
112
112
|
|
113
113
|
it 'raises a skip test' do
|
114
114
|
subject.instance_variable_set(:@options, options)
|
115
|
-
allow(
|
116
|
-
allow(
|
115
|
+
allow(subject).to receive(:logger).and_return(logger)
|
116
|
+
allow(logger).to receive(:notify)
|
117
117
|
test_name = 'random test name'
|
118
118
|
expect { subject.manual_test test_name do; end }.to raise_error Beaker::DSL::SkipTest
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
122
|
context 'with exec manual test option' do
|
123
|
-
let(
|
123
|
+
let(:options) { { exec_manual_tests: true } }
|
124
124
|
|
125
125
|
it 'requires a name' do
|
126
|
-
expect { subject.manual_test
|
126
|
+
expect { subject.manual_test { ; } }.to raise_error ArgumentError
|
127
127
|
end
|
128
128
|
|
129
129
|
it 'notifies the logger' do
|
130
130
|
subject.instance_variable_set(:@options, options)
|
131
|
-
expect(
|
132
|
-
expect(
|
131
|
+
expect(subject).to receive(:logger).and_return(logger)
|
132
|
+
expect(logger).to receive(:notify)
|
133
133
|
subject.manual_test 'blah blah'
|
134
134
|
end
|
135
135
|
|
136
136
|
it 'yields if a block is given' do
|
137
137
|
subject.instance_variable_set(:@options, options)
|
138
|
-
expect(
|
139
|
-
expect(
|
140
|
-
allow(
|
141
|
-
expect(
|
138
|
+
expect(subject).to receive(:logger).and_return(logger).twice
|
139
|
+
expect(logger).to receive(:notify)
|
140
|
+
allow(logger).to receive(:with_indent).and_yield
|
141
|
+
expect(subject).to receive(:foo)
|
142
142
|
subject.manual_test 'blah' do
|
143
143
|
subject.foo
|
144
144
|
end
|
@@ -146,43 +146,42 @@ describe ClassMixedWithDSLStructure do
|
|
146
146
|
|
147
147
|
it 'sets the metadata' do
|
148
148
|
subject.instance_variable_set(:@options, options)
|
149
|
-
allow(
|
150
|
-
allow(
|
149
|
+
allow(subject).to receive(:logger).and_return(logger)
|
150
|
+
allow(logger).to receive(:notify)
|
151
151
|
test_name = 'test is setting metadata yay!'
|
152
152
|
subject.manual_test test_name
|
153
|
-
expect(
|
153
|
+
expect(metadata[:case][:name]).to be === test_name
|
154
154
|
end
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
158
|
describe '#test_name' do
|
159
|
-
|
160
159
|
it 'requires a name' do
|
161
|
-
expect { subject.test_name
|
160
|
+
expect { subject.test_name { ; } }.to raise_error ArgumentError
|
162
161
|
end
|
163
162
|
|
164
163
|
it 'notifies the logger' do
|
165
|
-
expect(
|
166
|
-
expect(
|
164
|
+
expect(subject).to receive(:logger).and_return(logger)
|
165
|
+
expect(logger).to receive(:notify)
|
167
166
|
subject.test_name 'blah'
|
168
167
|
end
|
169
168
|
|
170
169
|
it 'yields if a block is given' do
|
171
|
-
expect(
|
172
|
-
expect(
|
173
|
-
allow(
|
174
|
-
expect(
|
170
|
+
expect(subject).to receive(:logger).and_return(logger).twice
|
171
|
+
expect(logger).to receive(:notify)
|
172
|
+
allow(logger).to receive(:with_indent).and_yield
|
173
|
+
expect(subject).to receive(:foo)
|
175
174
|
subject.test_name 'blah' do
|
176
175
|
subject.foo
|
177
176
|
end
|
178
177
|
end
|
179
178
|
|
180
179
|
it 'sets the metadata' do
|
181
|
-
allow(
|
182
|
-
allow(
|
180
|
+
allow(subject).to receive(:logger).and_return(logger)
|
181
|
+
allow(logger).to receive(:notify)
|
183
182
|
test_name = '15-05-08\'s weather is beautiful'
|
184
183
|
subject.test_name test_name
|
185
|
-
expect(
|
184
|
+
expect(metadata[:case][:name]).to be === test_name
|
186
185
|
end
|
187
186
|
end
|
188
187
|
|
@@ -190,161 +189,174 @@ describe ClassMixedWithDSLStructure do
|
|
190
189
|
it 'append a block to the @teardown var' do
|
191
190
|
teardown_array = double
|
192
191
|
subject.instance_variable_set :@teardown_procs, teardown_array
|
193
|
-
block =
|
194
|
-
expect(
|
192
|
+
block = -> { 'blah' }
|
193
|
+
expect(teardown_array).to receive(:<<).with(block)
|
195
194
|
subject.teardown(&block)
|
196
195
|
end
|
197
196
|
end
|
198
197
|
|
199
198
|
describe '#expect_failure' do
|
200
|
-
it 'passes when a
|
201
|
-
expect(
|
202
|
-
expect(
|
199
|
+
it 'passes when a MiniTest assertion is raised' do
|
200
|
+
expect(subject).to receive(:logger).and_return(logger)
|
201
|
+
expect(logger).to receive(:notify)
|
203
202
|
# We changed this lambda to use the simplest assert possible; using assert_equal
|
204
|
-
# caused an error in
|
205
|
-
block =
|
206
|
-
expect{ subject.expect_failure 'this is an expected failure', &block }.not_to raise_error
|
203
|
+
# caused an error in minitest 5.9.0 trying to write to the file system.
|
204
|
+
block = -> { assert(false, 'this assertion should be caught') }
|
205
|
+
expect { subject.expect_failure 'this is an expected failure', &block }.not_to raise_error
|
207
206
|
end
|
208
207
|
|
209
208
|
it 'passes when a Beaker assertion is raised' do
|
210
|
-
expect(
|
211
|
-
expect(
|
212
|
-
block =
|
213
|
-
expect{ subject.expect_failure 'this is an expected failure', &block }.not_to raise_error
|
209
|
+
expect(subject).to receive(:logger).and_return(logger)
|
210
|
+
expect(logger).to receive(:notify)
|
211
|
+
block = -> { refute_match('1', '1', '1 and 1 should not match') }
|
212
|
+
expect { subject.expect_failure 'this is an expected failure', &block }.not_to raise_error
|
214
213
|
end
|
215
214
|
|
216
|
-
it 'fails when a non-Beaker, non-
|
217
|
-
block =
|
218
|
-
expect{ subject.expect_failure 'this has a non-Beaker, non-
|
215
|
+
it 'fails when a non-Beaker, non-MiniTest assertion is raised' do
|
216
|
+
block = -> { raise 'not a Beaker or MiniTest error' }
|
217
|
+
expect { subject.expect_failure 'this has a non-Beaker, non-MiniTest exception', &block }.to raise_error(RuntimeError, /not a Beaker or MiniTest error/)
|
219
218
|
end
|
220
219
|
|
221
220
|
it 'fails when no assertion is raised' do
|
222
|
-
block =
|
223
|
-
expect{ subject.expect_failure 'this has no failure', &block }.to raise_error(RuntimeError, /An assertion was expected to fail, but passed/)
|
221
|
+
block = -> { expect('1').to(eq('1'), '1 should equal 1') }
|
222
|
+
expect { subject.expect_failure 'this has no failure', &block }.to raise_error(RuntimeError, /An assertion was expected to fail, but passed/)
|
224
223
|
end
|
225
224
|
end
|
226
225
|
|
227
|
-
describe 'confine' do
|
226
|
+
describe '#confine' do
|
228
227
|
let(:logger) { double.as_null_object }
|
229
228
|
|
230
229
|
before do
|
231
|
-
allow(
|
230
|
+
allow(subject).to receive(:logger).and_return(logger)
|
232
231
|
end
|
233
232
|
|
234
233
|
it ':to - skips the test if there are no applicable hosts' do
|
235
|
-
allow(
|
236
|
-
allow(
|
237
|
-
expect(
|
238
|
-
expect(
|
239
|
-
subject.confine(
|
234
|
+
allow(subject).to receive(:hosts).and_return([])
|
235
|
+
allow(subject).to receive(:hosts=)
|
236
|
+
expect(logger).to receive(:warn)
|
237
|
+
expect(subject).to receive(:skip_test).with('No suitable hosts found with {}')
|
238
|
+
subject.confine(:to, {})
|
240
239
|
end
|
241
240
|
|
242
241
|
it ':except - skips the test if there are no applicable hosts' do
|
243
|
-
allow(
|
244
|
-
allow(
|
245
|
-
expect(
|
246
|
-
expect(
|
247
|
-
subject.confine(
|
242
|
+
allow(subject).to receive(:hosts).and_return([])
|
243
|
+
allow(subject).to receive(:hosts=)
|
244
|
+
expect(logger).to receive(:warn)
|
245
|
+
expect(subject).to receive(:skip_test).with('No suitable hosts found without {}')
|
246
|
+
subject.confine(:except, {})
|
248
247
|
end
|
249
248
|
|
250
249
|
it ':to - uses a provided host subset when no criteria is provided' do
|
251
|
-
subset = [
|
250
|
+
subset = %w[host1 host2]
|
252
251
|
hosts = subset.dup << 'host3'
|
253
|
-
allow(
|
254
|
-
expect(
|
252
|
+
allow(subject).to receive(:hosts).and_return(hosts).twice
|
253
|
+
expect(subject).to receive(:hosts=).with(subset)
|
255
254
|
subject.confine :to, {}, subset
|
256
255
|
end
|
257
256
|
|
258
257
|
it ':except - excludes provided host subset when no criteria is provided' do
|
259
|
-
subset = [
|
258
|
+
subset = %w[host1 host2]
|
260
259
|
hosts = subset.dup << 'host3'
|
261
|
-
allow(
|
262
|
-
expect(
|
260
|
+
allow(subject).to receive(:hosts).and_return(hosts).twice
|
261
|
+
expect(subject).to receive(:hosts=).with(hosts - subset)
|
263
262
|
subject.confine :except, {}, subset
|
264
263
|
end
|
265
264
|
|
266
265
|
it 'raises when given mode is not :to or :except' do
|
267
|
-
hosts = [
|
268
|
-
allow(
|
269
|
-
allow(
|
266
|
+
hosts = %w[host1 host2]
|
267
|
+
allow(subject).to receive(:hosts).and_return(hosts)
|
268
|
+
allow(subject).to receive(:hosts=)
|
270
269
|
|
271
|
-
expect
|
272
|
-
subject.confine(
|
273
|
-
|
270
|
+
expect do
|
271
|
+
subject.confine(:regardless, { :thing => 'value' })
|
272
|
+
end.to raise_error('Unknown option regardless')
|
274
273
|
end
|
275
274
|
|
276
275
|
it 'rejects hosts that do not meet simple hash criteria' do
|
277
|
-
hosts = [
|
276
|
+
hosts = [{ 'thing' => 'foo' }, { 'thing' => 'bar' }]
|
278
277
|
|
279
|
-
expect(
|
280
|
-
expect(
|
281
|
-
with(
|
278
|
+
expect(subject).to receive(:hosts).and_return(hosts).twice
|
279
|
+
expect(subject).to receive(:hosts=)
|
280
|
+
.with([{ 'thing' => 'foo' }])
|
282
281
|
|
283
282
|
subject.confine :to, :thing => 'foo'
|
284
283
|
end
|
285
284
|
|
286
285
|
it 'rejects hosts that match a list of criteria' do
|
287
|
-
hosts = [
|
286
|
+
hosts = [{ 'thing' => 'foo' }, { 'thing' => 'bar' }, { 'thing' => 'baz' }]
|
288
287
|
|
289
|
-
expect(
|
290
|
-
expect(
|
291
|
-
with(
|
288
|
+
expect(subject).to receive(:hosts).and_return(hosts).twice
|
289
|
+
expect(subject).to receive(:hosts=)
|
290
|
+
.with([{ 'thing' => 'bar' }])
|
292
291
|
|
293
|
-
subject.confine :except, :thing => [
|
292
|
+
subject.confine :except, :thing => %w[foo baz]
|
294
293
|
end
|
295
294
|
|
296
295
|
it 'rejects hosts when a passed block returns true' do
|
297
|
-
host1 = {'platform' => 'solaris'}
|
298
|
-
host2 = {'platform' => 'solaris'}
|
299
|
-
host3 = {'platform' => 'windows'}
|
296
|
+
host1 = { 'platform' => 'solaris' }
|
297
|
+
host2 = { 'platform' => 'solaris' }
|
298
|
+
host3 = { 'platform' => 'windows' }
|
300
299
|
ret1 = (Struct.new('Result1', :stdout)).new(':global')
|
301
300
|
ret2 = (Struct.new('Result2', :stdout)).new('a_zone')
|
302
|
-
hosts = [
|
301
|
+
hosts = [host1, host2, host3]
|
303
302
|
|
304
|
-
expect(
|
305
|
-
expect(
|
306
|
-
with(
|
307
|
-
and_return(
|
308
|
-
expect(
|
309
|
-
with(
|
310
|
-
and_return(
|
303
|
+
expect(subject).to receive(:hosts).and_return(hosts).twice
|
304
|
+
expect(subject).to receive(:on)
|
305
|
+
.with(host1, '/sbin/zonename')
|
306
|
+
.and_return(ret1)
|
307
|
+
expect(subject).to receive(:on)
|
308
|
+
.with(host1, '/sbin/zonename')
|
309
|
+
.and_return(ret2)
|
311
310
|
|
312
|
-
expect(
|
311
|
+
expect(subject).to receive(:hosts=).with([host1])
|
313
312
|
|
314
313
|
subject.confine :to, :platform => 'solaris' do |host|
|
315
|
-
subject.on(
|
314
|
+
subject.on(host, '/sbin/zonename').stdout.include?(':global')
|
316
315
|
end
|
317
316
|
end
|
318
317
|
|
319
318
|
it 'doesn\'t corrupt the global hosts hash when confining from a subset of hosts' do
|
320
|
-
host1 = {'platform' => 'solaris', :roles => ['master']}
|
321
|
-
host2 = {'platform' => 'solaris', :roles => ['agent']}
|
322
|
-
host3 = {'platform' => 'windows', :roles => ['agent']}
|
323
|
-
hosts = [
|
324
|
-
agents = [
|
319
|
+
host1 = { 'platform' => 'solaris', :roles => ['master'] }
|
320
|
+
host2 = { 'platform' => 'solaris', :roles => ['agent'] }
|
321
|
+
host3 = { 'platform' => 'windows', :roles => ['agent'] }
|
322
|
+
hosts = [host1, host2, host3]
|
323
|
+
agents = [host2, host3]
|
325
324
|
|
326
|
-
expect(
|
327
|
-
expect(
|
328
|
-
confined_hosts = subject.confine :except, {:platform => 'windows'}, agents
|
329
|
-
expect(
|
325
|
+
expect(subject).to receive(:hosts).and_return(hosts)
|
326
|
+
expect(subject).to receive(:hosts=).with([host2, host1])
|
327
|
+
confined_hosts = subject.confine :except, { :platform => 'windows' }, agents
|
328
|
+
expect(confined_hosts).to be === [host2, host1]
|
330
329
|
end
|
331
330
|
|
332
331
|
it 'can apply multiple confines correctly' do
|
333
|
-
host1 = {'platform' => 'solaris', :roles => ['master']}
|
334
|
-
host2 = {'platform' => 'solaris', :roles => ['agent']}
|
335
|
-
host3 = {'platform' => 'windows', :roles => ['agent']}
|
336
|
-
host4 = {'platform' => 'fedora', :roles => ['agent']}
|
337
|
-
host5 = {'platform' => 'fedora', :roles => ['agent']}
|
338
|
-
hosts = [
|
339
|
-
agents = [
|
340
|
-
|
341
|
-
expect(
|
342
|
-
expect(
|
343
|
-
hosts = subject.confine :except, {:platform => 'windows'}
|
344
|
-
expect(
|
345
|
-
expect(
|
346
|
-
hosts = subject.confine :to, {:platform => 'fedora'}, agents
|
347
|
-
expect(
|
332
|
+
host1 = { 'platform' => 'solaris', :roles => ['master'] }
|
333
|
+
host2 = { 'platform' => 'solaris', :roles => ['agent'] }
|
334
|
+
host3 = { 'platform' => 'windows', :roles => ['agent'] }
|
335
|
+
host4 = { 'platform' => 'fedora', :roles => ['agent'] }
|
336
|
+
host5 = { 'platform' => 'fedora', :roles => ['agent'] }
|
337
|
+
hosts = [host1, host2, host3, host4, host5]
|
338
|
+
agents = [host2, host3, host4, host5]
|
339
|
+
|
340
|
+
expect(subject).to receive(:hosts).and_return(hosts).exactly(3).times
|
341
|
+
expect(subject).to receive(:hosts=).with([host1, host2, host4, host5])
|
342
|
+
hosts = subject.confine :except, { :platform => 'windows' }
|
343
|
+
expect(hosts).to be === [host1, host2, host4, host5]
|
344
|
+
expect(subject).to receive(:hosts=).with([host4, host5, host1])
|
345
|
+
hosts = subject.confine :to, { :platform => 'fedora' }, agents
|
346
|
+
expect(hosts).to be === [host4, host5, host1]
|
347
|
+
end
|
348
|
+
|
349
|
+
it 'can apply confine with multiple arguments' do
|
350
|
+
host1 = { 'platform' => 'solaris', 'hypervisor' => 'vmpooler' }
|
351
|
+
host2 = { 'platform' => 'windows', 'hypervisor' => 'vmpooler' }
|
352
|
+
host3 = { 'platform' => 'fedora', 'hypervisor' => 'vmpooler' }
|
353
|
+
host4 = { 'platform' => 'fedora', 'hypervisor' => 'docker' }
|
354
|
+
hosts = [host1, host2, host3, host4]
|
355
|
+
|
356
|
+
expect(subject).to receive(:hosts).and_return(hosts).twice
|
357
|
+
expect(subject).to receive(:hosts=).with([host1, host2, host3])
|
358
|
+
result = subject.confine :except, { :platform => 'fedora', :hypervisor => 'docker' }
|
359
|
+
expect(result).to eq([host1, host2, host3])
|
348
360
|
end
|
349
361
|
end
|
350
362
|
|
@@ -352,40 +364,39 @@ describe ClassMixedWithDSLStructure do
|
|
352
364
|
let(:logger) { double.as_null_object }
|
353
365
|
|
354
366
|
before do
|
355
|
-
allow(
|
367
|
+
allow(subject).to receive(:logger).and_return(logger)
|
356
368
|
end
|
357
369
|
|
358
370
|
it 'returns an empty array if there are no applicable hosts' do
|
359
|
-
hosts = [
|
371
|
+
hosts = [{ 'thing' => 'foo' }, { 'thing' => 'bar' }]
|
360
372
|
|
361
|
-
expect(subject.select_hosts(
|
373
|
+
expect(subject.select_hosts({ 'thing' => 'nope' }, hosts)).to be == []
|
362
374
|
end
|
363
375
|
|
364
376
|
it 'selects hosts that match a list of criteria' do
|
365
|
-
hosts = [
|
377
|
+
hosts = [{ 'thing' => 'foo' }, { 'thing' => 'bar' }, { 'thing' => 'baz' }]
|
366
378
|
|
367
|
-
expect(subject.select_hosts(
|
379
|
+
expect(subject.select_hosts({ :thing => %w[foo baz] }, hosts)).to be == [{ 'thing' => 'foo' }, { 'thing' => 'baz' }]
|
368
380
|
end
|
369
381
|
|
370
382
|
it 'selects hosts when a passed block returns true' do
|
371
|
-
host1 = {'platform' => 'solaris1'}
|
372
|
-
host2 = {'platform' => 'solaris2'}
|
373
|
-
host3 = {'platform' => 'windows'}
|
383
|
+
host1 = { 'platform' => 'solaris1' }
|
384
|
+
host2 = { 'platform' => 'solaris2' }
|
385
|
+
host3 = { 'platform' => 'windows' }
|
374
386
|
ret1 = double('result1')
|
375
|
-
allow(
|
387
|
+
allow(ret1).to receive(:stdout).and_return(':global')
|
376
388
|
ret2 = double('result2')
|
377
|
-
allow(
|
378
|
-
hosts = [
|
379
|
-
expect(
|
389
|
+
allow(ret2).to receive(:stdout).and_return('a_zone')
|
390
|
+
hosts = [host1, host2, host3]
|
391
|
+
expect(subject).to receive(:hosts).and_return(hosts)
|
380
392
|
|
381
|
-
expect(
|
382
|
-
expect(
|
393
|
+
expect(subject).to receive(:on).with(host1, '/sbin/zonename').once.and_return(ret1)
|
394
|
+
expect(subject).to receive(:on).with(host2, '/sbin/zonename').once.and_return(ret2)
|
383
395
|
|
384
396
|
selected_hosts = subject.select_hosts 'platform' => 'solaris' do |host|
|
385
|
-
|
397
|
+
subject.on(host, '/sbin/zonename').stdout.include?(':global')
|
386
398
|
end
|
387
|
-
expect(
|
399
|
+
expect(selected_hosts).to be == [host1]
|
388
400
|
end
|
389
401
|
end
|
390
|
-
|
391
402
|
end
|