beaker 4.38.1 → 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 +36 -11
- data/.rubocop.yml +75 -0
- data/.rubocop_todo.yml +239 -0
- data/CHANGELOG.md +88 -33
- data/Gemfile +16 -4
- data/HISTORY.md +103 -0
- data/Rakefile +101 -112
- 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/Gemfile +1 -1
- data/acceptance/fixtures/module/Rakefile +3 -3
- data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +16 -23
- data/acceptance/fixtures/module/spec/classes/init_spec.rb +1 -2
- data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
- data/acceptance/lib/helpers/test_helper.rb +7 -6
- 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 +7 -8
- 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 +9 -7
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +15 -21
- 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 +23 -30
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +3 -3
- 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 +21 -16
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +7 -7
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +30 -38
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +14 -18
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +8 -14
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +7 -11
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +5 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +4 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +8 -8
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +4 -6
- data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
- data/acceptance/tests/base/dsl/structure_test.rb +9 -21
- data/acceptance/tests/base/host/file_test.rb +8 -8
- data/acceptance/tests/base/host/group_test.rb +2 -3
- data/acceptance/tests/base/host/host_test.rb +69 -66
- data/acceptance/tests/base/host/packages.rb +27 -30
- data/acceptance/tests/base/host/packages_unix.rb +0 -55
- data/acceptance/tests/base/host/user_test.rb +2 -3
- 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 +3 -5
- 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 +10 -14
- data/docs/concepts/argument_processing_and_precedence.md +1 -10
- data/docs/concepts/style_guide.md +1 -1
- data/docs/how_to/debug_beaker_tests.md +13 -13
- data/docs/how_to/hosts/eos.md +2 -12
- data/docs/how_to/install_puppet.md +0 -18
- data/docs/how_to/test_arbitrary_beaker_versions.md +2 -2
- data/docs/how_to/the_beaker_dsl.md +0 -2
- data/lib/beaker/cli.rb +63 -74
- data/lib/beaker/command.rb +22 -30
- data/lib/beaker/command_factory.rb +4 -3
- data/lib/beaker/dsl/assertions.rb +7 -19
- data/lib/beaker/dsl/helpers/hocon_helpers.rb +5 -9
- data/lib/beaker/dsl/helpers/host_helpers.rb +72 -133
- data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
- data/lib/beaker/dsl/helpers/web_helpers.rb +20 -28
- data/lib/beaker/dsl/helpers.rb +2 -4
- data/lib/beaker/dsl/outcomes.rb +17 -19
- data/lib/beaker/dsl/patterns.rb +1 -3
- data/lib/beaker/dsl/roles.rb +18 -21
- data/lib/beaker/dsl/structure.rb +55 -67
- 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 +3 -3
- data/lib/beaker/host/aix/user.rb +3 -3
- data/lib/beaker/host/aix.rb +3 -4
- data/lib/beaker/host/cisco.rb +36 -48
- 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 +5 -5
- data/lib/beaker/host/mac/group.rb +13 -13
- data/lib/beaker/host/mac/pkg.rb +6 -109
- data/lib/beaker/host/mac/user.rb +7 -7
- data/lib/beaker/host/mac.rb +8 -9
- data/lib/beaker/host/pswindows/exec.rb +70 -74
- data/lib/beaker/host/pswindows/file.rb +4 -6
- data/lib/beaker/host/pswindows/group.rb +5 -5
- data/lib/beaker/host/pswindows/pkg.rb +17 -17
- data/lib/beaker/host/pswindows/user.rb +4 -4
- data/lib/beaker/host/pswindows.rb +4 -3
- data/lib/beaker/host/unix/exec.rb +86 -88
- data/lib/beaker/host/unix/file.rb +41 -47
- data/lib/beaker/host/unix/group.rb +3 -3
- data/lib/beaker/host/unix/pkg.rb +158 -421
- data/lib/beaker/host/unix/user.rb +4 -4
- data/lib/beaker/host/unix.rb +18 -20
- data/lib/beaker/host/windows/exec.rb +20 -20
- data/lib/beaker/host/windows/file.rb +5 -5
- data/lib/beaker/host/windows/group.rb +5 -5
- data/lib/beaker/host/windows/pkg.rb +6 -57
- data/lib/beaker/host/windows/user.rb +4 -4
- data/lib/beaker/host/windows.rb +13 -13
- data/lib/beaker/host.rb +82 -139
- data/lib/beaker/host_prebuilt_steps.rb +121 -233
- data/lib/beaker/hypervisor/noop.rb +2 -4
- data/lib/beaker/hypervisor.rb +46 -63
- data/lib/beaker/local_connection.rb +4 -6
- data/lib/beaker/logger.rb +71 -85
- data/lib/beaker/logger_junit.rb +22 -26
- data/lib/beaker/network_manager.rb +40 -43
- data/lib/beaker/options/command_line_parser.rb +12 -23
- data/lib/beaker/options/hosts_file_parser.rb +34 -25
- data/lib/beaker/options/options_file_parser.rb +3 -6
- data/lib/beaker/options/options_hash.rb +3 -10
- data/lib/beaker/options/parser.rb +89 -105
- 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 +29 -34
- data/lib/beaker/platform.rb +38 -46
- 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 +40 -46
- data/lib/beaker/shared/options_resolver.rb +3 -7
- data/lib/beaker/shared/repetition.rb +6 -8
- data/lib/beaker/shared/semvar.rb +39 -43
- data/lib/beaker/shared/timed.rb +2 -5
- data/lib/beaker/shared.rb +1 -1
- data/lib/beaker/ssh_connection.rb +46 -55
- data/lib/beaker/subcommand.rb +23 -30
- data/lib/beaker/subcommands/subcommand_util.rb +4 -4
- data/lib/beaker/tasks/quick_start.rb +5 -10
- data/lib/beaker/tasks/rake_task.rb +26 -28
- data/lib/beaker/tasks/test.rb +4 -4
- data/lib/beaker/test_case.rb +15 -27
- data/lib/beaker/test_suite.rb +35 -39
- data/lib/beaker/test_suite_result.rb +52 -57
- data/lib/beaker/version.rb +1 -1
- data/lib/beaker.rb +5 -6
- data/spec/beaker/cli_spec.rb +135 -153
- data/spec/beaker/command_spec.rb +64 -58
- data/spec/beaker/dsl/assertions_spec.rb +38 -47
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +114 -135
- data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
- data/spec/beaker/dsl/helpers/web_helpers_spec.rb +30 -36
- data/spec/beaker/dsl/outcomes_spec.rb +15 -14
- data/spec/beaker/dsl/roles_spec.rb +170 -132
- data/spec/beaker/dsl/structure_spec.rb +181 -163
- data/spec/beaker/dsl/test_tagging_spec.rb +94 -95
- data/spec/beaker/dsl/wrappers_spec.rb +39 -40
- data/spec/beaker/host/aix_spec.rb +14 -14
- data/spec/beaker/host/cisco_spec.rb +92 -102
- data/spec/beaker/host/eos_spec.rb +15 -36
- data/spec/beaker/host/freebsd/exec_spec.rb +5 -8
- data/spec/beaker/host/freebsd/pkg_spec.rb +29 -29
- data/spec/beaker/host/mac/exec_spec.rb +4 -5
- data/spec/beaker/host/mac/group_spec.rb +47 -56
- data/spec/beaker/host/mac/user_spec.rb +53 -62
- data/spec/beaker/host/pswindows/exec_spec.rb +36 -35
- data/spec/beaker/host/pswindows/file_spec.rb +21 -18
- data/spec/beaker/host/pswindows/user_spec.rb +17 -23
- data/spec/beaker/host/pswindows_spec.rb +14 -14
- data/spec/beaker/host/unix/exec_spec.rb +87 -92
- data/spec/beaker/host/unix/file_spec.rb +76 -82
- data/spec/beaker/host/unix/pkg_spec.rb +165 -407
- data/spec/beaker/host/unix_spec.rb +11 -207
- data/spec/beaker/host/windows/exec_spec.rb +32 -34
- data/spec/beaker/host/windows/file_spec.rb +22 -23
- data/spec/beaker/host/windows/group_spec.rb +17 -19
- data/spec/beaker/host/windows/pkg_spec.rb +10 -13
- 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 +193 -341
- data/spec/beaker/host_spec.rb +241 -312
- data/spec/beaker/hypervisor/hypervisor_spec.rb +38 -63
- data/spec/beaker/localhost_connection_spec.rb +14 -13
- data/spec/beaker/logger_junit_spec.rb +22 -34
- data/spec/beaker/logger_spec.rb +174 -155
- data/spec/beaker/network_manager_spec.rb +27 -27
- data/spec/beaker/options/command_line_parser_spec.rb +20 -23
- data/spec/beaker/options/data/hosts_preserved.yml +395 -0
- data/spec/beaker/options/hosts_file_parser_spec.rb +36 -31
- data/spec/beaker/options/options_file_parser_spec.rb +4 -7
- data/spec/beaker/options/options_hash_spec.rb +7 -9
- data/spec/beaker/options/parser_spec.rb +187 -187
- data/spec/beaker/options/presets_spec.rb +8 -10
- data/spec/beaker/options/subcommand_options_parser_spec.rb +15 -15
- data/spec/beaker/options/validator_spec.rb +27 -28
- data/spec/beaker/perf_spec.rb +32 -34
- data/spec/beaker/platform_spec.rb +27 -37
- data/spec/beaker/shared/error_handler_spec.rb +8 -17
- data/spec/beaker/shared/fog_credentials_spec.rb +30 -30
- data/spec/beaker/shared/host_manager_spec.rb +55 -89
- data/spec/beaker/shared/options_resolver_spec.rb +9 -12
- data/spec/beaker/shared/repetition_spec.rb +24 -31
- data/spec/beaker/shared/semvar_spec.rb +21 -26
- data/spec/beaker/ssh_connection_spec.rb +85 -90
- data/spec/beaker/subcommand/subcommand_util_spec.rb +40 -37
- data/spec/beaker/subcommand_spec.rb +89 -89
- data/spec/beaker/test_case_spec.rb +33 -62
- data/spec/beaker/test_suite_spec.rb +153 -160
- data/spec/helpers.rb +48 -53
- data/spec/matchers.rb +9 -8
- data/spec/mocks.rb +6 -11
- data/spec/spec_helper.rb +0 -4
- metadata +60 -85
- 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
- data/spec/mock_fission.rb +0 -60
- data/spec/mock_vsphere.rb +0 -314
- data/spec/mock_vsphere_helper.rb +0 -183
@@ -9,91 +9,94 @@ end
|
|
9
9
|
describe ClassMixedWithDSLStructure do
|
10
10
|
include Beaker::DSL::Assertions
|
11
11
|
|
12
|
-
let
|
13
|
-
let
|
12
|
+
let(:logger) { double }
|
13
|
+
let(:metadata) { @metadata ||= {} }
|
14
14
|
|
15
|
-
before
|
16
|
-
allow(
|
15
|
+
before do
|
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
|
it 'throws an error' do
|
55
|
-
expect(
|
56
|
+
expect(Readline).not_to receive(:readline)
|
56
57
|
expect { subject.manual_step 'blah' do; end }.to raise_error StandardError
|
57
58
|
end
|
58
59
|
end
|
59
60
|
|
60
61
|
context 'with exec manual test option' do
|
61
|
-
let(
|
62
|
+
let(:options) { { exec_manual_tests: nil } }
|
63
|
+
|
62
64
|
it 'requires a name' do
|
63
|
-
expect { subject.manual_step
|
65
|
+
expect { subject.manual_step { ; } }.to raise_error ArgumentError
|
64
66
|
end
|
65
67
|
|
66
68
|
it 'notifies the logger' do
|
67
69
|
subject.instance_variable_set(:@options, options)
|
68
|
-
allow(
|
69
|
-
expect(
|
70
|
-
expect(
|
71
|
-
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')
|
72
74
|
subject.manual_step 'blah'
|
73
75
|
end
|
74
76
|
end
|
75
77
|
|
76
78
|
context 'with exec manual test option set to true' do
|
77
|
-
let(
|
79
|
+
let(:options) { { exec_manual_tests: true } }
|
80
|
+
|
78
81
|
it 'requires a name' do
|
79
|
-
expect { subject.manual_step
|
82
|
+
expect { subject.manual_step { ; } }.to raise_error ArgumentError
|
80
83
|
end
|
81
84
|
|
82
85
|
it 'pass when user enters Y' do
|
83
86
|
subject.instance_variable_set(:@options, options)
|
84
|
-
allow(
|
85
|
-
allow(
|
86
|
-
allow(
|
87
|
-
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')
|
88
91
|
subject.manual_step 'blahblah'
|
89
92
|
end
|
90
93
|
|
91
94
|
it 'fails when user enters n and uses default error when no message is entered' do
|
92
95
|
subject.instance_variable_set(:@options, options)
|
93
|
-
allow(
|
94
|
-
allow(
|
95
|
-
allow(
|
96
|
-
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')
|
97
100
|
expect { subject.manual_step 'blah two' do; end }.to raise_error(Beaker::DSL::FailTest, 'step failed')
|
98
101
|
end
|
99
102
|
end
|
@@ -101,39 +104,41 @@ describe ClassMixedWithDSLStructure do
|
|
101
104
|
|
102
105
|
describe '#manual_test' do
|
103
106
|
context 'without exec manual test option' do
|
104
|
-
let(
|
107
|
+
let(:options) { {} }
|
108
|
+
|
105
109
|
it 'requires a name' do
|
106
|
-
expect { subject.manual_test
|
110
|
+
expect { subject.manual_test { ; } }.to raise_error ArgumentError
|
107
111
|
end
|
108
112
|
|
109
113
|
it 'raises a skip test' do
|
110
114
|
subject.instance_variable_set(:@options, options)
|
111
|
-
allow(
|
112
|
-
allow(
|
115
|
+
allow(subject).to receive(:logger).and_return(logger)
|
116
|
+
allow(logger).to receive(:notify)
|
113
117
|
test_name = 'random test name'
|
114
118
|
expect { subject.manual_test test_name do; end }.to raise_error Beaker::DSL::SkipTest
|
115
119
|
end
|
116
120
|
end
|
117
121
|
|
118
122
|
context 'with exec manual test option' do
|
119
|
-
let(
|
123
|
+
let(:options) { { exec_manual_tests: true } }
|
124
|
+
|
120
125
|
it 'requires a name' do
|
121
|
-
expect { subject.manual_test
|
126
|
+
expect { subject.manual_test { ; } }.to raise_error ArgumentError
|
122
127
|
end
|
123
128
|
|
124
129
|
it 'notifies the logger' do
|
125
130
|
subject.instance_variable_set(:@options, options)
|
126
|
-
expect(
|
127
|
-
expect(
|
131
|
+
expect(subject).to receive(:logger).and_return(logger)
|
132
|
+
expect(logger).to receive(:notify)
|
128
133
|
subject.manual_test 'blah blah'
|
129
134
|
end
|
130
135
|
|
131
136
|
it 'yields if a block is given' do
|
132
137
|
subject.instance_variable_set(:@options, options)
|
133
|
-
expect(
|
134
|
-
expect(
|
135
|
-
allow(
|
136
|
-
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)
|
137
142
|
subject.manual_test 'blah' do
|
138
143
|
subject.foo
|
139
144
|
end
|
@@ -141,43 +146,42 @@ describe ClassMixedWithDSLStructure do
|
|
141
146
|
|
142
147
|
it 'sets the metadata' do
|
143
148
|
subject.instance_variable_set(:@options, options)
|
144
|
-
allow(
|
145
|
-
allow(
|
149
|
+
allow(subject).to receive(:logger).and_return(logger)
|
150
|
+
allow(logger).to receive(:notify)
|
146
151
|
test_name = 'test is setting metadata yay!'
|
147
152
|
subject.manual_test test_name
|
148
|
-
expect(
|
153
|
+
expect(metadata[:case][:name]).to be === test_name
|
149
154
|
end
|
150
155
|
end
|
151
156
|
end
|
152
157
|
|
153
158
|
describe '#test_name' do
|
154
|
-
|
155
159
|
it 'requires a name' do
|
156
|
-
expect { subject.test_name
|
160
|
+
expect { subject.test_name { ; } }.to raise_error ArgumentError
|
157
161
|
end
|
158
162
|
|
159
163
|
it 'notifies the logger' do
|
160
|
-
expect(
|
161
|
-
expect(
|
164
|
+
expect(subject).to receive(:logger).and_return(logger)
|
165
|
+
expect(logger).to receive(:notify)
|
162
166
|
subject.test_name 'blah'
|
163
167
|
end
|
164
168
|
|
165
169
|
it 'yields if a block is given' do
|
166
|
-
expect(
|
167
|
-
expect(
|
168
|
-
allow(
|
169
|
-
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)
|
170
174
|
subject.test_name 'blah' do
|
171
175
|
subject.foo
|
172
176
|
end
|
173
177
|
end
|
174
178
|
|
175
179
|
it 'sets the metadata' do
|
176
|
-
allow(
|
177
|
-
allow(
|
180
|
+
allow(subject).to receive(:logger).and_return(logger)
|
181
|
+
allow(logger).to receive(:notify)
|
178
182
|
test_name = '15-05-08\'s weather is beautiful'
|
179
183
|
subject.test_name test_name
|
180
|
-
expect(
|
184
|
+
expect(metadata[:case][:name]).to be === test_name
|
181
185
|
end
|
182
186
|
end
|
183
187
|
|
@@ -185,200 +189,214 @@ describe ClassMixedWithDSLStructure do
|
|
185
189
|
it 'append a block to the @teardown var' do
|
186
190
|
teardown_array = double
|
187
191
|
subject.instance_variable_set :@teardown_procs, teardown_array
|
188
|
-
block =
|
189
|
-
expect(
|
190
|
-
subject.teardown
|
192
|
+
block = -> { 'blah' }
|
193
|
+
expect(teardown_array).to receive(:<<).with(block)
|
194
|
+
subject.teardown(&block)
|
191
195
|
end
|
192
196
|
end
|
193
197
|
|
194
198
|
describe '#expect_failure' do
|
195
199
|
it 'passes when a MiniTest assertion is raised' do
|
196
|
-
expect(
|
197
|
-
expect(
|
200
|
+
expect(subject).to receive(:logger).and_return(logger)
|
201
|
+
expect(logger).to receive(:notify)
|
198
202
|
# We changed this lambda to use the simplest assert possible; using assert_equal
|
199
203
|
# caused an error in minitest 5.9.0 trying to write to the file system.
|
200
|
-
block =
|
201
|
-
expect{ subject.expect_failure 'this is an expected failure', &block }.
|
204
|
+
block = -> { assert(false, 'this assertion should be caught') }
|
205
|
+
expect { subject.expect_failure 'this is an expected failure', &block }.not_to raise_error
|
202
206
|
end
|
203
207
|
|
204
208
|
it 'passes when a Beaker assertion is raised' do
|
205
|
-
expect(
|
206
|
-
expect(
|
207
|
-
block =
|
208
|
-
expect{ subject.expect_failure 'this is an expected failure', &block }.
|
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
|
209
213
|
end
|
210
214
|
|
211
215
|
it 'fails when a non-Beaker, non-MiniTest assertion is raised' do
|
212
|
-
block =
|
213
|
-
expect{ subject.expect_failure 'this has a non-Beaker, non-MiniTest exception', &block }.to raise_error(RuntimeError, /not a Beaker or MiniTest error/)
|
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/)
|
214
218
|
end
|
215
219
|
|
216
220
|
it 'fails when no assertion is raised' do
|
217
|
-
block =
|
218
|
-
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/)
|
219
223
|
end
|
220
224
|
end
|
221
225
|
|
222
|
-
describe 'confine' do
|
226
|
+
describe '#confine' do
|
223
227
|
let(:logger) { double.as_null_object }
|
228
|
+
|
224
229
|
before do
|
225
|
-
allow(
|
230
|
+
allow(subject).to receive(:logger).and_return(logger)
|
226
231
|
end
|
227
232
|
|
228
233
|
it ':to - skips the test if there are no applicable hosts' do
|
229
|
-
allow(
|
230
|
-
allow(
|
231
|
-
expect(
|
232
|
-
expect(
|
233
|
-
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, {})
|
234
239
|
end
|
235
240
|
|
236
241
|
it ':except - skips the test if there are no applicable hosts' do
|
237
|
-
allow(
|
238
|
-
allow(
|
239
|
-
expect(
|
240
|
-
expect(
|
241
|
-
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, {})
|
242
247
|
end
|
243
248
|
|
244
249
|
it ':to - uses a provided host subset when no criteria is provided' do
|
245
|
-
subset = [
|
250
|
+
subset = %w[host1 host2]
|
246
251
|
hosts = subset.dup << 'host3'
|
247
|
-
allow(
|
248
|
-
expect(
|
252
|
+
allow(subject).to receive(:hosts).and_return(hosts).twice
|
253
|
+
expect(subject).to receive(:hosts=).with(subset)
|
249
254
|
subject.confine :to, {}, subset
|
250
255
|
end
|
251
256
|
|
252
257
|
it ':except - excludes provided host subset when no criteria is provided' do
|
253
|
-
subset = [
|
258
|
+
subset = %w[host1 host2]
|
254
259
|
hosts = subset.dup << 'host3'
|
255
|
-
allow(
|
256
|
-
expect(
|
260
|
+
allow(subject).to receive(:hosts).and_return(hosts).twice
|
261
|
+
expect(subject).to receive(:hosts=).with(hosts - subset)
|
257
262
|
subject.confine :except, {}, subset
|
258
263
|
end
|
259
264
|
|
260
265
|
it 'raises when given mode is not :to or :except' do
|
261
|
-
hosts = [
|
262
|
-
allow(
|
263
|
-
allow(
|
266
|
+
hosts = %w[host1 host2]
|
267
|
+
allow(subject).to receive(:hosts).and_return(hosts)
|
268
|
+
allow(subject).to receive(:hosts=)
|
264
269
|
|
265
|
-
expect
|
266
|
-
subject.confine(
|
267
|
-
|
270
|
+
expect do
|
271
|
+
subject.confine(:regardless, { :thing => 'value' })
|
272
|
+
end.to raise_error('Unknown option regardless')
|
268
273
|
end
|
269
274
|
|
270
275
|
it 'rejects hosts that do not meet simple hash criteria' do
|
271
|
-
hosts = [
|
276
|
+
hosts = [{ 'thing' => 'foo' }, { 'thing' => 'bar' }]
|
272
277
|
|
273
|
-
expect(
|
274
|
-
expect(
|
275
|
-
with(
|
278
|
+
expect(subject).to receive(:hosts).and_return(hosts).twice
|
279
|
+
expect(subject).to receive(:hosts=)
|
280
|
+
.with([{ 'thing' => 'foo' }])
|
276
281
|
|
277
282
|
subject.confine :to, :thing => 'foo'
|
278
283
|
end
|
279
284
|
|
280
285
|
it 'rejects hosts that match a list of criteria' do
|
281
|
-
hosts = [
|
286
|
+
hosts = [{ 'thing' => 'foo' }, { 'thing' => 'bar' }, { 'thing' => 'baz' }]
|
282
287
|
|
283
|
-
expect(
|
284
|
-
expect(
|
285
|
-
with(
|
288
|
+
expect(subject).to receive(:hosts).and_return(hosts).twice
|
289
|
+
expect(subject).to receive(:hosts=)
|
290
|
+
.with([{ 'thing' => 'bar' }])
|
286
291
|
|
287
|
-
subject.confine :except, :thing => [
|
292
|
+
subject.confine :except, :thing => %w[foo baz]
|
288
293
|
end
|
289
294
|
|
290
295
|
it 'rejects hosts when a passed block returns true' do
|
291
|
-
host1 = {'platform' => 'solaris'}
|
292
|
-
host2 = {'platform' => 'solaris'}
|
293
|
-
host3 = {'platform' => 'windows'}
|
296
|
+
host1 = { 'platform' => 'solaris' }
|
297
|
+
host2 = { 'platform' => 'solaris' }
|
298
|
+
host3 = { 'platform' => 'windows' }
|
294
299
|
ret1 = (Struct.new('Result1', :stdout)).new(':global')
|
295
300
|
ret2 = (Struct.new('Result2', :stdout)).new('a_zone')
|
296
|
-
hosts = [
|
301
|
+
hosts = [host1, host2, host3]
|
297
302
|
|
298
|
-
expect(
|
299
|
-
expect(
|
300
|
-
with(
|
301
|
-
and_return(
|
302
|
-
expect(
|
303
|
-
with(
|
304
|
-
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)
|
305
310
|
|
306
|
-
expect(
|
311
|
+
expect(subject).to receive(:hosts=).with([host1])
|
307
312
|
|
308
313
|
subject.confine :to, :platform => 'solaris' do |host|
|
309
|
-
subject.on(
|
314
|
+
subject.on(host, '/sbin/zonename').stdout.include?(':global')
|
310
315
|
end
|
311
316
|
end
|
312
317
|
|
313
318
|
it 'doesn\'t corrupt the global hosts hash when confining from a subset of hosts' do
|
314
|
-
host1 = {'platform' => 'solaris', :roles => ['master']}
|
315
|
-
host2 = {'platform' => 'solaris', :roles => ['agent']}
|
316
|
-
host3 = {'platform' => 'windows', :roles => ['agent']}
|
317
|
-
hosts = [
|
318
|
-
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]
|
319
324
|
|
320
|
-
expect(
|
321
|
-
expect(
|
322
|
-
confined_hosts = subject.confine :except, {:platform => 'windows'}, agents
|
323
|
-
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]
|
324
329
|
end
|
325
330
|
|
326
331
|
it 'can apply multiple confines correctly' do
|
327
|
-
host1 = {'platform' => 'solaris', :roles => ['master']}
|
328
|
-
host2 = {'platform' => 'solaris', :roles => ['agent']}
|
329
|
-
host3 = {'platform' => 'windows', :roles => ['agent']}
|
330
|
-
host4 = {'platform' => 'fedora', :roles => ['agent']}
|
331
|
-
host5 = {'platform' => 'fedora', :roles => ['agent']}
|
332
|
-
hosts = [
|
333
|
-
agents = [
|
334
|
-
|
335
|
-
expect(
|
336
|
-
expect(
|
337
|
-
hosts = subject.confine :except, {:platform => 'windows'}
|
338
|
-
expect(
|
339
|
-
expect(
|
340
|
-
hosts = subject.confine :to, {:platform => 'fedora'}, agents
|
341
|
-
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])
|
342
360
|
end
|
343
361
|
end
|
344
362
|
|
345
363
|
describe '#select_hosts' do
|
346
364
|
let(:logger) { double.as_null_object }
|
365
|
+
|
347
366
|
before do
|
348
|
-
allow(
|
367
|
+
allow(subject).to receive(:logger).and_return(logger)
|
349
368
|
end
|
350
369
|
|
351
|
-
it '
|
352
|
-
hosts = [
|
370
|
+
it 'returns an empty array if there are no applicable hosts' do
|
371
|
+
hosts = [{ 'thing' => 'foo' }, { 'thing' => 'bar' }]
|
353
372
|
|
354
|
-
expect(subject.select_hosts(
|
373
|
+
expect(subject.select_hosts({ 'thing' => 'nope' }, hosts)).to be == []
|
355
374
|
end
|
356
375
|
|
357
376
|
it 'selects hosts that match a list of criteria' do
|
358
|
-
hosts = [
|
377
|
+
hosts = [{ 'thing' => 'foo' }, { 'thing' => 'bar' }, { 'thing' => 'baz' }]
|
359
378
|
|
360
|
-
expect(subject.select_hosts(
|
379
|
+
expect(subject.select_hosts({ :thing => %w[foo baz] }, hosts)).to be == [{ 'thing' => 'foo' }, { 'thing' => 'baz' }]
|
361
380
|
end
|
362
381
|
|
363
382
|
it 'selects hosts when a passed block returns true' do
|
364
|
-
host1 = {'platform' => 'solaris1'}
|
365
|
-
host2 = {'platform' => 'solaris2'}
|
366
|
-
host3 = {'platform' => 'windows'}
|
383
|
+
host1 = { 'platform' => 'solaris1' }
|
384
|
+
host2 = { 'platform' => 'solaris2' }
|
385
|
+
host3 = { 'platform' => 'windows' }
|
367
386
|
ret1 = double('result1')
|
368
|
-
allow(
|
387
|
+
allow(ret1).to receive(:stdout).and_return(':global')
|
369
388
|
ret2 = double('result2')
|
370
|
-
allow(
|
371
|
-
hosts = [
|
372
|
-
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)
|
373
392
|
|
374
|
-
expect(
|
375
|
-
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)
|
376
395
|
|
377
396
|
selected_hosts = subject.select_hosts 'platform' => 'solaris' do |host|
|
378
|
-
|
397
|
+
subject.on(host, '/sbin/zonename').stdout.include?(':global')
|
379
398
|
end
|
380
|
-
expect(
|
399
|
+
expect(selected_hosts).to be == [host1]
|
381
400
|
end
|
382
401
|
end
|
383
|
-
|
384
402
|
end
|