beaker 4.41.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/release.yml +2 -2
- data/.github/workflows/test.yml +26 -13
- data/.rubocop.yml +23 -10
- data/.rubocop_todo.yml +34 -10
- data/CHANGELOG.md +16 -52
- data/Gemfile +12 -7
- data/HISTORY.md +605 -0
- data/Rakefile +99 -111
- data/acceptance/config/acceptance-options.rb +1 -1
- data/acceptance/config/base/acceptance-options.rb +2 -2
- data/acceptance/config/hypervisor/acceptance-options.rb +2 -2
- data/acceptance/config/subcommands/acceptance-options.rb +2 -2
- data/acceptance/fixtures/module/Rakefile +1 -1
- data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -12
- data/acceptance/fixtures/module/spec/classes/init_spec.rb +0 -1
- data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
- data/acceptance/lib/helpers/test_helper.rb +6 -5
- data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
- data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
- data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +1 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +3 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
- data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +19 -26
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +18 -13
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +22 -27
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +12 -16
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +3 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +5 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +3 -5
- data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
- data/acceptance/tests/base/dsl/structure_test.rb +5 -11
- data/acceptance/tests/base/host/file_test.rb +2 -2
- data/acceptance/tests/base/host/group_test.rb +0 -1
- data/acceptance/tests/base/host/host_test.rb +66 -63
- data/acceptance/tests/base/host/packages.rb +1 -2
- data/acceptance/tests/base/host/packages_unix.rb +0 -55
- data/acceptance/tests/base/host/user_test.rb +0 -1
- data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
- data/acceptance/tests/base/test_suite/export.rb +6 -9
- data/acceptance/tests/install/from_file.rb +2 -4
- data/acceptance/tests/load_path_bootstrap.rb +1 -1
- data/acceptance/tests/subcommands/destroy.rb +19 -21
- data/acceptance/tests/subcommands/exec.rb +0 -1
- data/acceptance/tests/subcommands/init.rb +2 -3
- data/acceptance/tests/subcommands/provision.rb +0 -1
- data/beaker.gemspec +4 -7
- data/docs/concepts/argument_processing_and_precedence.md +1 -10
- data/docs/how_to/debug_beaker_tests.md +12 -12
- data/docs/how_to/hosts/eos.md +2 -12
- data/docs/how_to/install_puppet.md +0 -18
- data/docs/how_to/the_beaker_dsl.md +0 -2
- data/lib/beaker/cli.rb +59 -68
- data/lib/beaker/command.rb +20 -28
- data/lib/beaker/command_factory.rb +3 -2
- data/lib/beaker/dsl/assertions.rb +6 -18
- data/lib/beaker/dsl/helpers/hocon_helpers.rb +3 -7
- data/lib/beaker/dsl/helpers/host_helpers.rb +62 -123
- data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
- data/lib/beaker/dsl/helpers/web_helpers.rb +19 -39
- data/lib/beaker/dsl/helpers.rb +2 -4
- data/lib/beaker/dsl/outcomes.rb +13 -15
- data/lib/beaker/dsl/patterns.rb +1 -3
- data/lib/beaker/dsl/roles.rb +17 -20
- data/lib/beaker/dsl/structure.rb +53 -65
- data/lib/beaker/dsl/test_tagging.rb +7 -10
- data/lib/beaker/dsl/wrappers.rb +15 -16
- data/lib/beaker/dsl.rb +2 -3
- data/lib/beaker/host/aix/exec.rb +1 -1
- data/lib/beaker/host/aix/file.rb +0 -1
- data/lib/beaker/host/aix/group.rb +1 -1
- data/lib/beaker/host/aix/user.rb +1 -1
- data/lib/beaker/host/aix.rb +3 -4
- data/lib/beaker/host/cisco.rb +27 -39
- data/lib/beaker/host/eos.rb +4 -30
- data/lib/beaker/host/freebsd/exec.rb +1 -1
- data/lib/beaker/host/freebsd/pkg.rb +3 -3
- data/lib/beaker/host/freebsd.rb +9 -12
- data/lib/beaker/host/mac/exec.rb +4 -4
- data/lib/beaker/host/mac/group.rb +7 -7
- data/lib/beaker/host/mac/pkg.rb +3 -106
- data/lib/beaker/host/mac/user.rb +2 -2
- data/lib/beaker/host/mac.rb +8 -9
- data/lib/beaker/host/pswindows/exec.rb +66 -70
- data/lib/beaker/host/pswindows/file.rb +3 -5
- data/lib/beaker/host/pswindows/group.rb +3 -3
- data/lib/beaker/host/pswindows/pkg.rb +12 -12
- data/lib/beaker/host/pswindows/user.rb +3 -3
- data/lib/beaker/host/pswindows.rb +4 -3
- data/lib/beaker/host/unix/exec.rb +81 -83
- data/lib/beaker/host/unix/file.rb +40 -45
- data/lib/beaker/host/unix/group.rb +1 -1
- data/lib/beaker/host/unix/pkg.rb +138 -401
- data/lib/beaker/host/unix/user.rb +2 -2
- data/lib/beaker/host/unix.rb +8 -11
- data/lib/beaker/host/windows/exec.rb +17 -17
- data/lib/beaker/host/windows/file.rb +3 -3
- data/lib/beaker/host/windows/group.rb +3 -3
- data/lib/beaker/host/windows/pkg.rb +3 -54
- data/lib/beaker/host/windows/user.rb +3 -3
- data/lib/beaker/host/windows.rb +12 -12
- data/lib/beaker/host.rb +76 -133
- data/lib/beaker/host_prebuilt_steps.rb +88 -196
- data/lib/beaker/hypervisor/noop.rb +2 -4
- data/lib/beaker/hypervisor.rb +44 -61
- data/lib/beaker/local_connection.rb +2 -4
- data/lib/beaker/logger.rb +68 -76
- data/lib/beaker/logger_junit.rb +21 -25
- data/lib/beaker/network_manager.rb +39 -42
- data/lib/beaker/options/command_line_parser.rb +12 -23
- data/lib/beaker/options/hosts_file_parser.rb +16 -25
- data/lib/beaker/options/options_file_parser.rb +3 -6
- data/lib/beaker/options/options_hash.rb +2 -7
- data/lib/beaker/options/parser.rb +86 -102
- data/lib/beaker/options/presets.rb +114 -123
- data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
- data/lib/beaker/options/validator.rb +26 -31
- data/lib/beaker/perf.rb +25 -30
- data/lib/beaker/platform.rb +26 -37
- data/lib/beaker/result.rb +7 -6
- data/lib/beaker/shared/error_handler.rb +8 -10
- data/lib/beaker/shared/fog_credentials.rb +5 -9
- data/lib/beaker/shared/host_manager.rb +36 -41
- data/lib/beaker/shared/options_resolver.rb +3 -7
- data/lib/beaker/shared/repetition.rb +2 -4
- data/lib/beaker/shared/semvar.rb +37 -41
- data/lib/beaker/shared/timed.rb +0 -3
- data/lib/beaker/shared.rb +1 -1
- data/lib/beaker/ssh_connection.rb +38 -47
- data/lib/beaker/subcommand.rb +17 -24
- data/lib/beaker/subcommands/subcommand_util.rb +4 -4
- data/lib/beaker/tasks/quick_start.rb +4 -9
- data/lib/beaker/tasks/rake_task.rb +25 -27
- data/lib/beaker/tasks/test.rb +4 -4
- data/lib/beaker/test_case.rb +16 -28
- data/lib/beaker/test_suite.rb +35 -39
- data/lib/beaker/test_suite_result.rb +45 -47
- data/lib/beaker/version.rb +1 -1
- data/lib/beaker.rb +6 -7
- data/spec/beaker/cli_spec.rb +121 -142
- data/spec/beaker/command_spec.rb +55 -59
- data/spec/beaker/dsl/assertions_spec.rb +36 -36
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +110 -131
- data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
- data/spec/beaker/dsl/helpers/web_helpers_spec.rb +22 -31
- data/spec/beaker/dsl/outcomes_spec.rb +14 -14
- data/spec/beaker/dsl/roles_spec.rb +125 -130
- data/spec/beaker/dsl/structure_spec.rb +172 -161
- data/spec/beaker/dsl/test_tagging_spec.rb +89 -90
- data/spec/beaker/dsl/wrappers_spec.rb +32 -33
- data/spec/beaker/host/aix_spec.rb +14 -14
- data/spec/beaker/host/cisco_spec.rb +84 -94
- data/spec/beaker/host/eos_spec.rb +15 -36
- data/spec/beaker/host/freebsd/exec_spec.rb +3 -6
- data/spec/beaker/host/freebsd/pkg_spec.rb +24 -27
- data/spec/beaker/host/mac/exec_spec.rb +2 -3
- data/spec/beaker/host/mac/group_spec.rb +48 -57
- data/spec/beaker/host/mac/user_spec.rb +54 -63
- data/spec/beaker/host/pswindows/exec_spec.rb +30 -32
- data/spec/beaker/host/pswindows/file_spec.rb +16 -16
- data/spec/beaker/host/pswindows/user_spec.rb +17 -23
- data/spec/beaker/host/pswindows_spec.rb +13 -13
- data/spec/beaker/host/unix/exec_spec.rb +75 -80
- data/spec/beaker/host/unix/file_spec.rb +66 -71
- data/spec/beaker/host/unix/pkg_spec.rb +150 -411
- data/spec/beaker/host/unix_spec.rb +11 -207
- data/spec/beaker/host/windows/exec_spec.rb +30 -32
- data/spec/beaker/host/windows/file_spec.rb +18 -19
- data/spec/beaker/host/windows/group_spec.rb +10 -12
- data/spec/beaker/host/windows/pkg_spec.rb +6 -9
- data/spec/beaker/host/windows/user_spec.rb +17 -23
- data/spec/beaker/host/windows_spec.rb +39 -39
- data/spec/beaker/host_prebuilt_steps_spec.rb +168 -349
- data/spec/beaker/host_spec.rb +204 -284
- data/spec/beaker/hypervisor/hypervisor_spec.rb +36 -61
- data/spec/beaker/localhost_connection_spec.rb +10 -11
- data/spec/beaker/logger_junit_spec.rb +19 -30
- data/spec/beaker/logger_spec.rb +153 -136
- data/spec/beaker/network_manager_spec.rb +23 -23
- data/spec/beaker/options/command_line_parser_spec.rb +20 -23
- data/spec/beaker/options/hosts_file_parser_spec.rb +30 -32
- data/spec/beaker/options/options_file_parser_spec.rb +4 -7
- data/spec/beaker/options/options_hash_spec.rb +4 -6
- data/spec/beaker/options/parser_spec.rb +167 -167
- data/spec/beaker/options/presets_spec.rb +7 -9
- data/spec/beaker/options/subcommand_options_parser_spec.rb +13 -14
- data/spec/beaker/options/validator_spec.rb +10 -11
- data/spec/beaker/perf_spec.rb +18 -21
- data/spec/beaker/platform_spec.rb +25 -50
- data/spec/beaker/shared/error_handler_spec.rb +7 -16
- data/spec/beaker/shared/fog_credentials_spec.rb +29 -29
- data/spec/beaker/shared/host_manager_spec.rb +50 -84
- data/spec/beaker/shared/options_resolver_spec.rb +9 -12
- data/spec/beaker/shared/repetition_spec.rb +17 -24
- data/spec/beaker/shared/semvar_spec.rb +21 -26
- data/spec/beaker/ssh_connection_spec.rb +76 -83
- data/spec/beaker/subcommand/subcommand_util_spec.rb +31 -33
- data/spec/beaker/subcommand_spec.rb +75 -77
- data/spec/beaker/test_case_spec.rb +25 -50
- data/spec/beaker/test_suite_spec.rb +147 -154
- data/spec/helpers.rb +39 -45
- data/spec/matchers.rb +8 -7
- data/spec/mocks.rb +1 -6
- data/spec/spec_helper.rb +0 -1
- metadata +8 -24
- data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
- data/acceptance/tests/base/external_resources_test.rb +0 -31
- data/spec/beaker/host/mac_spec.rb +0 -113
|
@@ -12,155 +12,154 @@ describe ClassMixedWithDSLStructure do
|
|
|
12
12
|
let(:metadata) { @metadata ||= {} }
|
|
13
13
|
|
|
14
14
|
before do
|
|
15
|
-
allow(
|
|
15
|
+
allow(subject).to receive(:metadata).and_return(metadata)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
describe '#tag' do
|
|
19
|
-
let(
|
|
20
|
-
let(
|
|
21
|
-
let(
|
|
22
|
-
let(
|
|
19
|
+
let(:test_tag_and) { @test_tag_and || [] }
|
|
20
|
+
let(:test_tag_or) { @test_tag_or || [] }
|
|
21
|
+
let(:test_tag_exclude) { @test_tag_exclude || [] }
|
|
22
|
+
let(:options) do
|
|
23
23
|
opts = Beaker::Options::OptionsHash.new
|
|
24
24
|
opts[:test_tag_and] = test_tag_and
|
|
25
25
|
opts[:test_tag_or] = test_tag_or
|
|
26
26
|
opts[:test_tag_exclude] = test_tag_exclude
|
|
27
27
|
opts
|
|
28
|
-
|
|
28
|
+
end
|
|
29
29
|
|
|
30
30
|
before do
|
|
31
|
-
allow(
|
|
31
|
+
allow(subject).to receive(:platform_specific_tag_confines)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
it 'sets tags on the TestCase\'s metadata object' do
|
|
35
35
|
subject.instance_variable_set(:@options, options)
|
|
36
|
-
tags = [
|
|
36
|
+
tags = %w[pants jayjay moguely]
|
|
37
37
|
subject.tag(*tags)
|
|
38
|
-
expect(
|
|
38
|
+
expect(metadata[:case][:tags]).to be === tags
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
it 'lowercases the tags' do
|
|
42
42
|
subject.instance_variable_set(:@options, options)
|
|
43
|
-
tags_upper = [
|
|
43
|
+
tags_upper = %w[pANTs jAYJAy moGUYly]
|
|
44
44
|
tags_lower = tags_upper.map(&:downcase)
|
|
45
45
|
subject.tag(*tags_upper)
|
|
46
|
-
expect(
|
|
46
|
+
expect(metadata[:case][:tags]).to be === tags_lower
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
it 'skips the test if any of the requested tags isn\'t included in this test' do
|
|
50
|
-
test_tags = [
|
|
50
|
+
test_tags = %w[pants jayjay moguely]
|
|
51
51
|
@test_tag_and = test_tags.compact.push('needed_tag_not_in_test')
|
|
52
52
|
subject.instance_variable_set(:@options, options)
|
|
53
53
|
|
|
54
|
-
allow(
|
|
55
|
-
expect(
|
|
54
|
+
allow(subject).to receive(:path)
|
|
55
|
+
expect(subject).to receive(:skip_test)
|
|
56
56
|
subject.tag(*test_tags)
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
it 'runs the test if all requested tags are included in this test' do
|
|
60
|
-
@test_tag_and = [
|
|
60
|
+
@test_tag_and = %w[pants_on_head jayjay_jayjay mo]
|
|
61
61
|
test_tags = @test_tag_and.compact.push('extra_asdf')
|
|
62
62
|
subject.instance_variable_set(:@options, options)
|
|
63
63
|
|
|
64
|
-
allow(
|
|
65
|
-
expect(
|
|
64
|
+
allow(subject).to receive(:path)
|
|
65
|
+
expect(subject).not_to receive(:skip_test)
|
|
66
66
|
subject.tag(*test_tags)
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
it 'skips the test if any of the excluded tags are included in this test' do
|
|
70
|
-
test_tags = [
|
|
70
|
+
test_tags = %w[ports jay_john_mary mog_the_dog]
|
|
71
71
|
@test_tag_exclude = [test_tags[0]]
|
|
72
72
|
subject.instance_variable_set(:@options, options)
|
|
73
73
|
|
|
74
|
-
allow(
|
|
75
|
-
expect(
|
|
74
|
+
allow(subject).to receive(:path)
|
|
75
|
+
expect(subject).to receive(:skip_test)
|
|
76
76
|
subject.tag(*test_tags)
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
it 'skips the test if an and-included & excluded tag are in this test' do
|
|
80
|
-
test_tags = [
|
|
80
|
+
test_tags = %w[ports jay_john_mary mog_the_dog]
|
|
81
81
|
@test_tag_and = [test_tags[1]]
|
|
82
82
|
@test_tag_exclude = [test_tags[0]]
|
|
83
83
|
subject.instance_variable_set(:@options, options)
|
|
84
84
|
|
|
85
|
-
allow(
|
|
86
|
-
expect(
|
|
85
|
+
allow(subject).to receive(:path)
|
|
86
|
+
expect(subject).to receive(:skip_test)
|
|
87
87
|
subject.tag(*test_tags)
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
it 'runs the test if none of the excluded tags are included in this test' do
|
|
91
|
-
@test_tag_exclude = [
|
|
92
|
-
test_tags = [
|
|
91
|
+
@test_tag_exclude = %w[pants_on_head jayjay_jayjay mo]
|
|
92
|
+
test_tags = %w[pants_at_head jayj00_jayjay motly_crew]
|
|
93
93
|
subject.instance_variable_set(:@options, options)
|
|
94
94
|
|
|
95
|
-
allow(
|
|
96
|
-
expect(
|
|
95
|
+
allow(subject).to receive(:path)
|
|
96
|
+
expect(subject).not_to receive(:skip_test)
|
|
97
97
|
subject.tag(*test_tags)
|
|
98
98
|
end
|
|
99
99
|
|
|
100
100
|
it 'skips the test if none of the OR tags are included in this test' do
|
|
101
|
-
test_tags = [
|
|
102
|
-
@test_tag_or = [
|
|
101
|
+
test_tags = %w[portmanteau foolios]
|
|
102
|
+
@test_tag_or = %w[fish crayons parkas]
|
|
103
103
|
subject.instance_variable_set(:@options, options)
|
|
104
104
|
|
|
105
|
-
allow(
|
|
106
|
-
expect(
|
|
105
|
+
allow(subject).to receive(:path)
|
|
106
|
+
expect(subject).to receive(:skip_test)
|
|
107
107
|
subject.tag(*test_tags)
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
it 'runs the test if only one of the OR tags are included in this test' do
|
|
111
|
-
test_tags = [
|
|
112
|
-
@test_tag_or = [
|
|
111
|
+
test_tags = %w[portmanteau foolios]
|
|
112
|
+
@test_tag_or = %w[foolios crayons parkas]
|
|
113
113
|
subject.instance_variable_set(:@options, options)
|
|
114
114
|
|
|
115
|
-
allow(
|
|
116
|
-
expect(
|
|
115
|
+
allow(subject).to receive(:path)
|
|
116
|
+
expect(subject).not_to receive(:skip_test)
|
|
117
117
|
subject.tag(*test_tags)
|
|
118
118
|
end
|
|
119
119
|
|
|
120
120
|
it 'skips the test if an or-included & excluded tag are included in this test' do
|
|
121
|
-
test_tags = [
|
|
121
|
+
test_tags = %w[ports jay_john_mary mog_the_dog]
|
|
122
122
|
@test_tag_or = [test_tags[1]]
|
|
123
123
|
@test_tag_exclude = [test_tags[0]]
|
|
124
124
|
subject.instance_variable_set(:@options, options)
|
|
125
125
|
|
|
126
|
-
allow(
|
|
127
|
-
expect(
|
|
126
|
+
allow(subject).to receive(:path)
|
|
127
|
+
expect(subject).to receive(:skip_test)
|
|
128
128
|
subject.tag(*test_tags)
|
|
129
129
|
end
|
|
130
130
|
end
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
describe Beaker::DSL::TestTagging::PlatformTagConfiner do
|
|
134
|
-
let(
|
|
135
|
-
let(
|
|
136
|
-
described_class.new(
|
|
137
|
-
|
|
134
|
+
let(:confines_array) { @confines_array || [] }
|
|
135
|
+
let(:confiner) do
|
|
136
|
+
described_class.new(confines_array)
|
|
137
|
+
end
|
|
138
138
|
|
|
139
139
|
describe '#initialize' do
|
|
140
140
|
it 'transforms one entry' do
|
|
141
141
|
platform_regex = /^ubuntu$/
|
|
142
142
|
tag_reason_hash = {
|
|
143
143
|
'tag1' => 'reason1',
|
|
144
|
-
'tag2' => 'reason2'
|
|
144
|
+
'tag2' => 'reason2',
|
|
145
145
|
}
|
|
146
|
-
@confines_array = [
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
]
|
|
146
|
+
@confines_array = [{
|
|
147
|
+
:platform => platform_regex,
|
|
148
|
+
:tag_reason_hash => tag_reason_hash,
|
|
149
|
+
}]
|
|
151
150
|
|
|
152
|
-
internal_hash = confiner.instance_variable_get(
|
|
153
|
-
expect(
|
|
154
|
-
expect(
|
|
155
|
-
expect(
|
|
151
|
+
internal_hash = confiner.instance_variable_get(:@tag_confine_details_hash)
|
|
152
|
+
expect(internal_hash.keys).to include('tag1')
|
|
153
|
+
expect(internal_hash.keys).to include('tag2')
|
|
154
|
+
expect(internal_hash.keys.length).to be === 2
|
|
156
155
|
|
|
157
156
|
tag_reason_hash.each do |tag, reason|
|
|
158
157
|
tag_array = internal_hash[tag]
|
|
159
|
-
expect(
|
|
158
|
+
expect(tag_array.length).to be === 1
|
|
160
159
|
tag_hash = tag_array[0]
|
|
161
|
-
expect(
|
|
162
|
-
expect(
|
|
163
|
-
expect(
|
|
160
|
+
expect(tag_hash[:platform_regex]).to eql(platform_regex)
|
|
161
|
+
expect(tag_hash[:log_message]).to match(/#{reason}/)
|
|
162
|
+
expect(tag_hash[:type]).to be === :except
|
|
164
163
|
end
|
|
165
164
|
end
|
|
166
165
|
|
|
@@ -170,25 +169,25 @@ describe Beaker::DSL::TestTagging::PlatformTagConfiner do
|
|
|
170
169
|
:platform => /^el-/,
|
|
171
170
|
:tag_reason_hash => {
|
|
172
171
|
'tag1' => 'reason el 1',
|
|
173
|
-
'tag2' => 'reason2'
|
|
174
|
-
}
|
|
172
|
+
'tag2' => 'reason2',
|
|
173
|
+
},
|
|
175
174
|
}, {
|
|
176
175
|
:platform => /^cisco-/,
|
|
177
176
|
:tag_reason_hash => {
|
|
178
177
|
'tag1' => 'reason cisco 1',
|
|
179
|
-
'tag3' => 'reason3'
|
|
180
|
-
}
|
|
181
|
-
}
|
|
178
|
+
'tag3' => 'reason3',
|
|
179
|
+
},
|
|
180
|
+
},
|
|
182
181
|
]
|
|
183
182
|
|
|
184
|
-
internal_hash = confiner.instance_variable_get(
|
|
185
|
-
expect(
|
|
186
|
-
expect(
|
|
187
|
-
expect(
|
|
188
|
-
expect(
|
|
183
|
+
internal_hash = confiner.instance_variable_get(:@tag_confine_details_hash)
|
|
184
|
+
expect(internal_hash.keys).to include('tag1')
|
|
185
|
+
expect(internal_hash.keys).to include('tag2')
|
|
186
|
+
expect(internal_hash.keys).to include('tag3')
|
|
187
|
+
expect(internal_hash.keys.length).to be === 3
|
|
189
188
|
|
|
190
189
|
shared_tag_array = internal_hash['tag1']
|
|
191
|
-
expect(
|
|
190
|
+
expect(shared_tag_array.length).to be === 2
|
|
192
191
|
|
|
193
192
|
platform_el_found = false
|
|
194
193
|
platform_cisco_found = false
|
|
@@ -205,40 +204,40 @@ describe Beaker::DSL::TestTagging::PlatformTagConfiner do
|
|
|
205
204
|
else
|
|
206
205
|
log_msg = "unexpected log message for confine_details: "
|
|
207
206
|
log_msg << confine_details[:log_message]
|
|
208
|
-
fail(
|
|
207
|
+
fail(log_msg)
|
|
209
208
|
end
|
|
210
209
|
|
|
211
|
-
expect(
|
|
212
|
-
expect(
|
|
210
|
+
expect(confine_details[:platform_regex]).to eql(platform_to_match)
|
|
211
|
+
expect(confine_details[:log_message]).to match(reason_to_match)
|
|
213
212
|
end
|
|
214
|
-
expect(
|
|
215
|
-
expect(
|
|
213
|
+
expect(platform_el_found).to be === true
|
|
214
|
+
expect(platform_cisco_found).to be === true
|
|
216
215
|
end
|
|
217
216
|
end
|
|
218
217
|
|
|
219
218
|
describe '#confine_details' do
|
|
220
219
|
it 'returns an empty array if no tags match' do
|
|
221
|
-
fake_confine_details_hash = { 'tag1' => [
|
|
220
|
+
fake_confine_details_hash = { 'tag1' => [{ :type => 1 }, { :type => 2 }] }
|
|
222
221
|
confiner.instance_variable_set(
|
|
223
222
|
:@tag_confine_details_hash, fake_confine_details_hash
|
|
224
223
|
)
|
|
225
|
-
expect(
|
|
224
|
+
expect(confiner.confine_details(%w[tag2 tag3])).to be === []
|
|
226
225
|
end
|
|
227
226
|
|
|
228
227
|
context 'descriminates on tag name' do
|
|
229
228
|
fake_confine_details_hash = {
|
|
230
|
-
'tag0' => [
|
|
231
|
-
'tag1' => [
|
|
232
|
-
'tag2' => [
|
|
233
|
-
'tag3' => [
|
|
234
|
-
'tag4' => [
|
|
229
|
+
'tag0' => [10, 20, 30, 40],
|
|
230
|
+
'tag1' => [41, 51, 61, 71],
|
|
231
|
+
'tag2' => [22, 32, 42, 52],
|
|
232
|
+
'tag3' => [63, 73, 83, 93],
|
|
233
|
+
'tag4' => [34, 44, 54, 64],
|
|
235
234
|
}
|
|
236
235
|
|
|
237
236
|
key_combos_to_test = fake_confine_details_hash.keys.map { |key| [key] }
|
|
238
|
-
key_combos_to_test << [
|
|
239
|
-
key_combos_to_test << [
|
|
240
|
-
key_combos_to_test << [
|
|
241
|
-
key_combos_to_test << fake_confine_details_hash.keys
|
|
237
|
+
key_combos_to_test << %w[tag0 tag2]
|
|
238
|
+
key_combos_to_test << %w[tag1 tag4]
|
|
239
|
+
key_combos_to_test << %w[tag2 tag3 tag4]
|
|
240
|
+
key_combos_to_test << fake_confine_details_hash.keys
|
|
242
241
|
|
|
243
242
|
before do
|
|
244
243
|
confiner.instance_variable_set(
|
|
@@ -252,23 +251,23 @@ describe Beaker::DSL::TestTagging::PlatformTagConfiner do
|
|
|
252
251
|
key_combo_to_have.each do |key_to_have|
|
|
253
252
|
haves += fake_confine_details_hash[key_to_have]
|
|
254
253
|
end
|
|
255
|
-
keys_not_to_have = fake_confine_details_hash.keys.reject
|
|
256
|
-
key_combo_to_have.include?(
|
|
257
|
-
|
|
254
|
+
keys_not_to_have = fake_confine_details_hash.keys.reject do |key_trial|
|
|
255
|
+
key_combo_to_have.include?(key_trial)
|
|
256
|
+
end
|
|
258
257
|
have_nots = []
|
|
259
258
|
keys_not_to_have.each do |key_not_to_have|
|
|
260
259
|
have_nots += fake_confine_details_hash[key_not_to_have]
|
|
261
260
|
end
|
|
262
261
|
|
|
263
|
-
details = confiner.confine_details(
|
|
262
|
+
details = confiner.confine_details(key_combo_to_have)
|
|
264
263
|
have_nots.each do |confine_details|
|
|
265
|
-
expect(
|
|
264
|
+
expect(details).not_to include(confine_details)
|
|
266
265
|
end
|
|
267
266
|
haves.each do |confine_details|
|
|
268
|
-
expect(
|
|
267
|
+
expect(details).to include(confine_details)
|
|
269
268
|
end
|
|
270
269
|
end
|
|
271
270
|
end
|
|
272
271
|
end
|
|
273
272
|
end
|
|
274
|
-
end
|
|
273
|
+
end
|
|
@@ -7,73 +7,72 @@ end
|
|
|
7
7
|
describe ClassMixedWithDSLWrappers do
|
|
8
8
|
describe '#host_command' do
|
|
9
9
|
it 'delegates to HostCommand.new' do
|
|
10
|
-
expect(
|
|
11
|
-
subject.host_command(
|
|
10
|
+
expect(Beaker::HostCommand).to receive(:new).with('blah')
|
|
11
|
+
subject.host_command('blah')
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
describe '#powershell' do
|
|
16
16
|
it 'passes "powershell.exe <args> -Command <command>" to Command' do
|
|
17
17
|
command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'")
|
|
18
|
-
expect(command.command
|
|
19
|
-
expect(
|
|
20
|
-
expect(
|
|
18
|
+
expect(command.command).to be === 'powershell.exe'
|
|
19
|
+
expect(command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command Set-Content -path 'fu.txt' -value 'fu'"]
|
|
20
|
+
expect(command.options).to be === {}
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it 'merges the arguments provided with the defaults' do
|
|
24
|
-
command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", {'ExecutionPolicy' => 'Unrestricted'})
|
|
25
|
-
expect(
|
|
26
|
-
expect(
|
|
27
|
-
expect(
|
|
24
|
+
command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", { 'ExecutionPolicy' => 'Unrestricted' })
|
|
25
|
+
expect(command.command).to be === 'powershell.exe'
|
|
26
|
+
expect(command.args).to be === ["-ExecutionPolicy Unrestricted", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command Set-Content -path 'fu.txt' -value 'fu'"]
|
|
27
|
+
expect(command.options).to be === {}
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it 'uses EncodedCommand when EncodedCommand => true' do
|
|
31
31
|
cmd = "Set-Content -path 'fu.txt' -value 'fu'"
|
|
32
32
|
cmd = subject.encode_command(cmd)
|
|
33
|
-
command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", {'EncodedCommand' => true})
|
|
34
|
-
expect(command.command
|
|
35
|
-
expect(
|
|
36
|
-
expect(
|
|
33
|
+
command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", { 'EncodedCommand' => true })
|
|
34
|
+
expect(command.command).to be === 'powershell.exe'
|
|
35
|
+
expect(command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand #{cmd}"]
|
|
36
|
+
expect(command.options).to be === {}
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
it 'uses EncodedCommand when EncodedCommand => ""' do
|
|
40
40
|
cmd = "Set-Content -path 'fu.txt' -value 'fu'"
|
|
41
41
|
cmd = subject.encode_command(cmd)
|
|
42
|
-
command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", {'EncodedCommand' => ""})
|
|
43
|
-
expect(command.command
|
|
44
|
-
expect(
|
|
45
|
-
expect(
|
|
42
|
+
command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", { 'EncodedCommand' => "" })
|
|
43
|
+
expect(command.command).to be === 'powershell.exe'
|
|
44
|
+
expect(command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand #{cmd}"]
|
|
45
|
+
expect(command.options).to be === {}
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
it 'uses EncodedCommand when EncodedCommand => nil' do
|
|
49
49
|
cmd = "Set-Content -path 'fu.txt' -value 'fu'"
|
|
50
50
|
cmd = subject.encode_command(cmd)
|
|
51
|
-
command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", {'EncodedCommand' => nil})
|
|
52
|
-
expect(command.command
|
|
53
|
-
expect(
|
|
54
|
-
expect(
|
|
51
|
+
command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", { 'EncodedCommand' => nil })
|
|
52
|
+
expect(command.command).to be === 'powershell.exe'
|
|
53
|
+
expect(command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand #{cmd}"]
|
|
54
|
+
expect(command.options).to be === {}
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
it 'does not use EncodedCommand when EncodedCommand => false' do
|
|
58
|
-
command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", {'EncodedCommand' => false})
|
|
59
|
-
expect(command.command
|
|
60
|
-
expect(
|
|
61
|
-
expect(
|
|
58
|
+
command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", { 'EncodedCommand' => false })
|
|
59
|
+
expect(command.command).to be === 'powershell.exe'
|
|
60
|
+
expect(command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command Set-Content -path 'fu.txt' -value 'fu'"]
|
|
61
|
+
expect(command.options).to be === {}
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
it 'does not use EncodedCommand when EncodedCommand not present' do
|
|
65
65
|
command = subject.powershell("Set-Content -path 'fu.txt' -value 'fu'", {})
|
|
66
|
-
expect(command.command
|
|
67
|
-
expect(
|
|
68
|
-
expect(
|
|
66
|
+
expect(command.command).to be === 'powershell.exe'
|
|
67
|
+
expect(command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command Set-Content -path 'fu.txt' -value 'fu'"]
|
|
68
|
+
expect(command.options).to be === {}
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
it 'has no -Command/-EncodedCommand when command is empty' do
|
|
72
|
-
command = subject.powershell("", {"File" => 'myfile.ps1'})
|
|
73
|
-
expect(command.command
|
|
74
|
-
expect(
|
|
75
|
-
expect(
|
|
76
|
-
|
|
72
|
+
command = subject.powershell("", { "File" => 'myfile.ps1' })
|
|
73
|
+
expect(command.command).to be === 'powershell.exe'
|
|
74
|
+
expect(command.args).to be === ["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-File myfile.ps1"]
|
|
75
|
+
expect(command.options).to be === {}
|
|
77
76
|
end
|
|
78
77
|
end
|
|
79
78
|
end
|
|
@@ -3,49 +3,49 @@ require 'spec_helper'
|
|
|
3
3
|
module Aix
|
|
4
4
|
describe Host do
|
|
5
5
|
let(:options) { @options ? @options : {} }
|
|
6
|
-
let(:platform)
|
|
6
|
+
let(:platform) do
|
|
7
7
|
if @platform
|
|
8
|
-
{ :platform => Beaker::Platform.new(
|
|
8
|
+
{ :platform => Beaker::Platform.new(@platform) }
|
|
9
9
|
else
|
|
10
|
-
{ :platform => Beaker::Platform.new(
|
|
10
|
+
{ :platform => Beaker::Platform.new('aix-vers-arch-extra') }
|
|
11
11
|
end
|
|
12
|
-
|
|
13
|
-
let(:host)
|
|
12
|
+
end
|
|
13
|
+
let(:host) { make_host('name', options.merge(platform)) }
|
|
14
14
|
|
|
15
15
|
describe '#ssh_service_restart' do
|
|
16
16
|
it 'invokes the correct commands on the host' do
|
|
17
|
-
expect(
|
|
18
|
-
expect(
|
|
17
|
+
expect(Beaker::Command).to receive(:new).with('stopsrc -g ssh').once.ordered
|
|
18
|
+
expect(Beaker::Command).to receive(:new).with('startsrc -g ssh').once.ordered
|
|
19
19
|
host.ssh_service_restart
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
describe '#ssh_permit_user_environment' do
|
|
24
24
|
it 'calls echo to set PermitUserEnvironment' do
|
|
25
|
-
expect(
|
|
26
|
-
allow(
|
|
25
|
+
expect(Beaker::Command).to receive(:new).with(/^echo\ /).once.ordered
|
|
26
|
+
allow(host).to receive(:ssh_service_restart)
|
|
27
27
|
host.ssh_permit_user_environment
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it 'uses the correct ssh config file' do
|
|
31
|
-
expect(
|
|
32
|
-
allow(
|
|
31
|
+
expect(Beaker::Command).to receive(:new).with(/#{Regexp.escape(' >> /etc/ssh/sshd_config')}$/).once
|
|
32
|
+
allow(host).to receive(:ssh_service_restart)
|
|
33
33
|
host.ssh_permit_user_environment
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
describe '#reboot' do
|
|
38
38
|
it 'invokes the correct command on the host' do
|
|
39
|
-
expect(
|
|
39
|
+
expect(Beaker::Command).to receive(:new).with('shutdown -Fr').once
|
|
40
40
|
host.reboot
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
describe '#get_ip' do
|
|
45
45
|
it 'invokes the correct command on the host' do
|
|
46
|
-
expect(
|
|
46
|
+
expect(host).to receive(:execute).with(/^ifconfig\ \-a\ inet\|\ /).once.and_return('')
|
|
47
47
|
host.get_ip
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
|
-
end
|
|
51
|
+
end
|