beaker 4.39.0 → 5.1.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 +6 -21
- data/.rubocop_todo.yml +34 -10
- data/CHANGELOG.md +22 -0
- data/Gemfile +12 -7
- 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 +4 -3
- 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 -8
- 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 -27
- 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 +80 -82
- data/lib/beaker/host/unix/file.rb +38 -43
- data/lib/beaker/host/unix/group.rb +1 -1
- data/lib/beaker/host/unix/pkg.rb +154 -417
- 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 +93 -198
- 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 -24
- 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 +22 -27
- 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 +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 +15 -27
- 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 +5 -6
- data/rubocop.yml +39 -0
- 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 +28 -34
- 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 +169 -158
- 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 +47 -56
- data/spec/beaker/host/mac/user_spec.rb +53 -62
- 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 -73
- data/spec/beaker/host/unix/pkg_spec.rb +155 -401
- 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 +172 -326
- 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 -36
- 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 +48 -53
- data/spec/matchers.rb +8 -7
- data/spec/mocks.rb +1 -6
- data/spec/spec_helper.rb +0 -1
- metadata +13 -37
- data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
- data/acceptance/tests/base/external_resources_test.rb +0 -31
- data/spec/beaker/host/mac_spec.rb +0 -113
@@ -2,115 +2,111 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Cisco
|
4
4
|
describe Host do
|
5
|
-
let(:options)
|
6
|
-
:
|
7
|
-
|
8
|
-
|
5
|
+
let(:options) do
|
6
|
+
@options ? @options : {
|
7
|
+
:user => 'root',
|
8
|
+
}
|
9
|
+
end
|
10
|
+
let(:platform) do
|
9
11
|
if @platform
|
10
|
-
{ :platform => Beaker::Platform.new(
|
12
|
+
{ :platform => Beaker::Platform.new(@platform) }
|
11
13
|
else
|
12
|
-
{ :platform => Beaker::Platform.new(
|
14
|
+
{ :platform => Beaker::Platform.new('cisco_nexus-vers-arch-extra') }
|
13
15
|
end
|
14
|
-
|
15
|
-
let(:host)
|
16
|
+
end
|
17
|
+
let(:host) { make_host('name', options.merge(platform)) }
|
16
18
|
|
17
19
|
describe '#prepend_commands' do
|
18
|
-
|
19
20
|
context 'for cisco_nexus-7' do
|
20
|
-
|
21
21
|
before do
|
22
22
|
@platform = 'cisco_nexus-7-x86_64'
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'starts with sourcing the /etc/profile script' do
|
26
26
|
answer_correct = 'source /etc/profile;'
|
27
|
-
answer_test = host.prepend_commands(
|
28
|
-
expect(
|
27
|
+
answer_test = host.prepend_commands('fake_command')
|
28
|
+
expect(answer_test).to be === answer_correct
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'uses `sudo` if not root' do
|
32
32
|
@options = { :user => 'notroot' }
|
33
33
|
answer_correct = "source /etc/profile; sudo -E sh -c \""
|
34
|
-
answer_test = host.prepend_commands(
|
35
|
-
expect(
|
34
|
+
answer_test = host.prepend_commands('fake_command')
|
35
|
+
expect(answer_test).to be === answer_correct
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'ends with the :vrf host parameter' do
|
39
39
|
vrf_answer = 'vrf_answer_135246'
|
40
40
|
@options = {
|
41
|
-
:vrf
|
41
|
+
:vrf => vrf_answer,
|
42
42
|
}
|
43
|
-
answer_test = host.prepend_commands(
|
44
|
-
expect(
|
43
|
+
answer_test = host.prepend_commands('fake_command')
|
44
|
+
expect(answer_test).to match(/ip netns exec #{vrf_answer}$/)
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'guards against "vsh" usage (scenario we never want prefixing)' do
|
48
48
|
answer_user_pc = 'pc_param_unchanged_13584'
|
49
|
-
answer_test = host.prepend_commands(
|
50
|
-
expect(
|
49
|
+
answer_test = host.prepend_commands('fake/vsh/command', answer_user_pc)
|
50
|
+
expect(answer_test).to be === answer_user_pc
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'guards against "ntpdate" usage (we dont want prefixing on nexus)' do
|
54
54
|
answer_user_pc = 'user_pc_param_54321'
|
55
|
-
answer_test = host.prepend_commands(
|
56
|
-
expect(
|
55
|
+
answer_test = host.prepend_commands('fake/ntpdate/command', answer_user_pc)
|
56
|
+
expect(answer_test).to be === answer_user_pc
|
57
57
|
end
|
58
58
|
|
59
|
-
|
60
59
|
it 'retains user-specified prepend commands when adding vrf' do
|
61
60
|
@options = {
|
62
|
-
:vrf
|
61
|
+
:vrf => 'fakevrf',
|
63
62
|
:user => 'root',
|
64
63
|
}
|
65
64
|
answer_prepend_commands = 'prepend'
|
66
65
|
answer_correct = 'source /etc/profile;ip netns exec fakevrf prepend'
|
67
|
-
answer_test = host.prepend_commands(
|
68
|
-
expect(
|
66
|
+
answer_test = host.prepend_commands('fake_command', answer_prepend_commands)
|
67
|
+
expect(answer_test).to be === answer_correct
|
69
68
|
end
|
70
69
|
end
|
71
70
|
|
72
71
|
context 'for cisco_ios_xr-6' do
|
73
|
-
|
74
72
|
before do
|
75
73
|
@platform = 'cisco_ios_xr-6-x86_64'
|
76
74
|
end
|
77
75
|
|
78
76
|
it 'starts with sourcing the /etc/profile script' do
|
79
77
|
answer_correct = 'source /etc/profile;'
|
80
|
-
answer_test = host.prepend_commands(
|
81
|
-
expect(
|
78
|
+
answer_test = host.prepend_commands('fake_command')
|
79
|
+
expect(answer_test).to be === answer_correct
|
82
80
|
end
|
83
81
|
|
84
82
|
it 'does use the :vrf host parameter if provided' do
|
85
83
|
@options = { :vrf => 'tpnns' }
|
86
|
-
answer_test = host.prepend_commands(
|
87
|
-
expect(
|
84
|
+
answer_test = host.prepend_commands('fake_command')
|
85
|
+
expect(answer_test).to match(/ip netns exec tpnns/)
|
88
86
|
end
|
89
87
|
|
90
88
|
it 'does not guard "ntpdate" usage' do
|
91
89
|
answer_user_pc = 'user_pc_param_54321'
|
92
90
|
answer_correct = 'source /etc/profile;user_pc_param_54321'
|
93
|
-
answer_test = host.prepend_commands(
|
94
|
-
expect(
|
91
|
+
answer_test = host.prepend_commands('fake/ntpdate/command', answer_user_pc)
|
92
|
+
expect(answer_test).to be === answer_correct
|
95
93
|
end
|
96
94
|
|
97
95
|
it 'retains user-specified prepend commands when adding vrf' do
|
98
|
-
@options = {
|
99
|
-
:vrf
|
96
|
+
@options = {
|
97
|
+
:vrf => 'fakevrf',
|
100
98
|
:user => 'root',
|
101
99
|
}
|
102
100
|
answer_prepend_commands = 'prepend'
|
103
101
|
answer_correct = 'source /etc/profile;ip netns exec fakevrf prepend'
|
104
|
-
answer_test = host.prepend_commands(
|
105
|
-
expect(
|
102
|
+
answer_test = host.prepend_commands('fake_command', answer_prepend_commands)
|
103
|
+
expect(answer_test).to be === answer_correct
|
106
104
|
end
|
107
105
|
end
|
108
106
|
end
|
109
107
|
|
110
108
|
describe '#append_commands' do
|
111
|
-
|
112
109
|
context 'for cisco_nexus-7' do
|
113
|
-
|
114
110
|
before do
|
115
111
|
@platform = 'cisco_nexus-7-x86_64'
|
116
112
|
@options = { :user => 'non_root' }
|
@@ -118,38 +114,37 @@ module Cisco
|
|
118
114
|
|
119
115
|
it 'appends `"` for commands' do
|
120
116
|
answer_correct = '"'
|
121
|
-
answer_test = host.append_commands(
|
122
|
-
expect(
|
117
|
+
answer_test = host.append_commands('fake_command')
|
118
|
+
expect(answer_test).to be === answer_correct
|
123
119
|
end
|
124
120
|
|
125
121
|
it 'returns nil for root user commands' do
|
126
122
|
@options = { :user => 'root' }
|
127
123
|
answer_correct = nil
|
128
|
-
answer_test = host.append_commands(
|
129
|
-
expect(
|
124
|
+
answer_test = host.append_commands('fake_command')
|
125
|
+
expect(answer_test).to be === answer_correct
|
130
126
|
end
|
131
127
|
|
132
128
|
it 'returns nil when vsh command' do
|
133
129
|
answer_correct = nil
|
134
|
-
answer_test = host.append_commands(
|
135
|
-
expect(
|
130
|
+
answer_test = host.append_commands('/isan/bin/vsh -c foo')
|
131
|
+
expect(answer_test).to be === answer_correct
|
136
132
|
end
|
137
133
|
|
138
134
|
it 'returns `"` when command contains vsh' do
|
139
135
|
answer_correct = '"'
|
140
|
-
answer_test = host.append_commands(
|
141
|
-
expect(
|
136
|
+
answer_test = host.append_commands('fake_command -c foo vsh')
|
137
|
+
expect(answer_test).to be === answer_correct
|
142
138
|
end
|
143
139
|
|
144
140
|
it 'returns nil when ntpdate command' do
|
145
141
|
answer_correct = nil
|
146
|
-
answer_test = host.append_commands(
|
147
|
-
expect(
|
142
|
+
answer_test = host.append_commands('fake/ntpdate/command foo')
|
143
|
+
expect(answer_test).to be === answer_correct
|
148
144
|
end
|
149
145
|
end
|
150
146
|
|
151
147
|
context 'for cisco_ios_xr-6' do
|
152
|
-
|
153
148
|
before do
|
154
149
|
@platform = 'cisco_ios_xr-6-x86_64'
|
155
150
|
@options = { :user => 'non_root' }
|
@@ -157,41 +152,39 @@ module Cisco
|
|
157
152
|
|
158
153
|
it 'appends `"` for commands' do
|
159
154
|
answer_correct = '"'
|
160
|
-
answer_test = host.append_commands(
|
161
|
-
expect(
|
155
|
+
answer_test = host.append_commands('fake_command')
|
156
|
+
expect(answer_test).to be === answer_correct
|
162
157
|
end
|
163
158
|
|
164
159
|
it 'returns nil for root user commands' do
|
165
160
|
@options = { :user => 'root' }
|
166
161
|
answer_correct = nil
|
167
|
-
answer_test = host.append_commands(
|
168
|
-
expect(
|
162
|
+
answer_test = host.append_commands('fake_command')
|
163
|
+
expect(answer_test).to be === answer_correct
|
169
164
|
end
|
170
165
|
|
171
166
|
it 'returns nil when vsh command' do
|
172
167
|
answer_correct = nil
|
173
|
-
answer_test = host.append_commands(
|
174
|
-
expect(
|
168
|
+
answer_test = host.append_commands('/isan/bin/vsh -c foo')
|
169
|
+
expect(answer_test).to be === answer_correct
|
175
170
|
end
|
176
171
|
|
177
172
|
it 'returns `"` when command contains vsh' do
|
178
173
|
answer_correct = '"'
|
179
|
-
answer_test = host.append_commands(
|
180
|
-
expect(
|
174
|
+
answer_test = host.append_commands('fake_command -c foo vsh')
|
175
|
+
expect(answer_test).to be === answer_correct
|
181
176
|
end
|
182
177
|
|
183
178
|
it 'returns nil when ntpdate command' do
|
184
179
|
answer_correct = nil
|
185
|
-
answer_test = host.append_commands(
|
186
|
-
expect(
|
180
|
+
answer_test = host.append_commands('fake/ntpdate/command foo')
|
181
|
+
expect(answer_test).to be === answer_correct
|
187
182
|
end
|
188
183
|
end
|
189
184
|
end
|
190
185
|
|
191
186
|
describe '#environment_string' do
|
192
|
-
|
193
187
|
context 'for cisco_nexus-7' do
|
194
|
-
|
195
188
|
before do
|
196
189
|
@platform = 'cisco_nexus-7-x86_64'
|
197
190
|
end
|
@@ -200,22 +193,22 @@ module Cisco
|
|
200
193
|
@options = { :user => 'root' }
|
201
194
|
env_map = { 'PATH' => '/opt/pants/2' }
|
202
195
|
answer_correct = ' export PATH="/opt/pants/2";'
|
203
|
-
answer_test = host.environment_string(
|
204
|
-
expect(
|
196
|
+
answer_test = host.environment_string(env_map)
|
197
|
+
expect(answer_test).to be === answer_correct
|
205
198
|
end
|
206
199
|
|
207
200
|
it 'ends with a semi-colon' do
|
208
201
|
env_map = { 'PATH' => '/opt/pants/3' }
|
209
|
-
answer_test = host.environment_string(
|
210
|
-
expect(
|
202
|
+
answer_test = host.environment_string(env_map)
|
203
|
+
expect(answer_test).to match(/\;$/)
|
211
204
|
end
|
212
205
|
|
213
206
|
it 'turns env maps into paired strings correctly' do
|
214
207
|
@options = { :user => 'root' }
|
215
208
|
env_map = { 'var1' => 'ans1', 'VAR2' => 'ans2' }
|
216
209
|
answer_correct = ' export var1="ans1" VAR1="ans1" VAR2="ans2";'
|
217
|
-
answer_test = host.environment_string(
|
218
|
-
expect(
|
210
|
+
answer_test = host.environment_string(env_map)
|
211
|
+
expect(answer_test).to be === answer_correct
|
219
212
|
end
|
220
213
|
end
|
221
214
|
|
@@ -228,80 +221,77 @@ module Cisco
|
|
228
221
|
@options = { :user => 'notroot' }
|
229
222
|
env_map = { 'PATH' => '/opt/pants/2' }
|
230
223
|
answer_correct = ' env PATH="/opt/pants/2"'
|
231
|
-
answer_test = host.environment_string(
|
232
|
-
expect(
|
224
|
+
answer_test = host.environment_string(env_map)
|
225
|
+
expect(answer_test).to be === answer_correct
|
233
226
|
end
|
234
227
|
|
235
228
|
it 'uses `env` if root' do
|
236
229
|
@options = { :user => 'root' }
|
237
230
|
env_map = { 'PATH' => '/opt/pants/1' }
|
238
231
|
answer_correct = ' env PATH="/opt/pants/1"'
|
239
|
-
answer_test = host.environment_string(
|
240
|
-
expect(
|
232
|
+
answer_test = host.environment_string(env_map)
|
233
|
+
expect(answer_test).to be === answer_correct
|
241
234
|
end
|
242
235
|
|
243
236
|
it 'does not end with a semi-colon' do
|
244
237
|
env_map = { 'PATH' => '/opt/pants/3' }
|
245
|
-
answer_test = host.environment_string(
|
246
|
-
expect(
|
238
|
+
answer_test = host.environment_string(env_map)
|
239
|
+
expect(answer_test).not_to match(/\;$/)
|
247
240
|
end
|
248
241
|
|
249
242
|
it 'turns env maps into paired strings correctly' do
|
250
243
|
@options = { :user => 'root' }
|
251
244
|
env_map = { 'VAR1' => 'ans1', 'var2' => 'ans2' }
|
252
245
|
answer_correct = ' env VAR1="ans1" var2="ans2" VAR2="ans2"'
|
253
|
-
answer_test = host.environment_string(
|
254
|
-
expect(
|
246
|
+
answer_test = host.environment_string(env_map)
|
247
|
+
expect(answer_test).to be === answer_correct
|
255
248
|
end
|
256
249
|
end
|
257
250
|
end
|
258
251
|
|
259
252
|
describe '#package_config_dir' do
|
260
|
-
|
261
253
|
it 'returns correctly for cisco platforms' do
|
262
254
|
@platform = 'cisco_nexus-7-x86_64'
|
263
|
-
expect(
|
255
|
+
expect(host.package_config_dir).to be === '/etc/yum/repos.d/'
|
264
256
|
end
|
265
257
|
end
|
266
258
|
|
267
259
|
describe '#repo_type' do
|
268
|
-
|
269
260
|
it 'returns correctly for cisco platforms' do
|
270
261
|
@platform = 'cisco_nexus-7-x86_64'
|
271
|
-
expect(
|
262
|
+
expect(host.repo_type).to be === 'rpm'
|
272
263
|
end
|
273
264
|
end
|
274
265
|
|
275
266
|
describe '#validate_setup' do
|
276
|
-
|
277
267
|
context 'on the cisco_nexus-7 platform' do
|
278
268
|
before do
|
279
269
|
@platform = 'cisco_nexus-7-x86_64'
|
280
270
|
end
|
281
271
|
|
282
272
|
it 'errors when no :vrf value is provided' do
|
283
|
-
expect
|
273
|
+
expect do
|
284
274
|
host.validate_setup
|
285
|
-
|
275
|
+
end.to raise_error(ArgumentError, /provided\ with\ a\ \:vrf\ value/)
|
286
276
|
end
|
287
277
|
|
288
278
|
it 'errors when no :user value is provided' do
|
289
279
|
@options = {
|
290
|
-
:vrf
|
280
|
+
:vrf => 'fake_vrf',
|
291
281
|
:user => nil,
|
292
282
|
}
|
293
|
-
expect
|
283
|
+
expect do
|
294
284
|
host.validate_setup
|
295
|
-
|
285
|
+
end.to raise_error(ArgumentError, /provided\ with\ a\ \:user\ value/)
|
296
286
|
end
|
297
287
|
|
298
288
|
it 'does nothing if the host is setup correctly' do
|
299
289
|
@options = {
|
300
|
-
:vrf
|
290
|
+
:vrf => 'fake_vrf',
|
301
291
|
:user => 'notroot',
|
302
292
|
}
|
303
293
|
validate_test = host.validate_setup
|
304
|
-
expect(
|
294
|
+
expect(validate_test).to be_nil
|
305
295
|
end
|
306
296
|
end
|
307
297
|
|
@@ -312,29 +302,29 @@ module Cisco
|
|
312
302
|
|
313
303
|
it 'does nothing if no :vrf value is provided' do
|
314
304
|
@options = {
|
315
|
-
|
305
|
+
:user => 'notroot',
|
316
306
|
}
|
317
307
|
validate_test = host.validate_setup
|
318
|
-
expect(
|
308
|
+
expect(validate_test).to be_nil
|
319
309
|
end
|
320
310
|
|
321
311
|
it 'errors when no user is provided' do
|
322
312
|
@options = {
|
323
|
-
:vrf
|
313
|
+
:vrf => 'fake_vrf',
|
324
314
|
:user => nil,
|
325
315
|
}
|
326
|
-
expect
|
316
|
+
expect do
|
327
317
|
host.validate_setup
|
328
|
-
|
318
|
+
end.to raise_error(ArgumentError, /provided\ with\ a\ \:user\ value/)
|
329
319
|
end
|
330
320
|
|
331
321
|
it 'does nothing if the host is setup correctly' do
|
332
322
|
@options = {
|
333
|
-
:vrf
|
323
|
+
:vrf => 'fake_vrf',
|
334
324
|
:user => 'notroot',
|
335
325
|
}
|
336
326
|
validate_test = host.validate_setup
|
337
|
-
expect(
|
327
|
+
expect(validate_test).to be_nil
|
338
328
|
end
|
339
329
|
end
|
340
330
|
end
|
@@ -3,63 +3,42 @@ require 'spec_helper'
|
|
3
3
|
module Eos
|
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(
|
11
|
-
end
|
12
|
-
}
|
13
|
-
let(:host) { make_host( 'name', options.merge(platform) ) }
|
14
|
-
|
15
|
-
describe '#puppet_agent_dev_package_info' do
|
16
|
-
it 'raises an error if puppet_collection isn\'t passed' do
|
17
|
-
expect { host.puppet_agent_dev_package_info(nil, 'maybe') }.to raise_error(ArgumentError)
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'raises as error if puppet_agent_version isn\'t passed' do
|
21
|
-
expect { host.puppet_agent_dev_package_info('maybe', nil) }.to raise_error(ArgumentError)
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'returns two strings that include the passed parameters' do
|
25
|
-
return1, return2 = host.puppet_agent_dev_package_info('pc1', 'pav1')
|
26
|
-
expect( return1 ).to match(/pc1/)
|
27
|
-
expect( return2 ).to match(/pav1/)
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'gets the correct file type' do
|
31
|
-
_, return2 = host.puppet_agent_dev_package_info('pc1', 'pav1')
|
32
|
-
expect( return2 ).to match(/swix/)
|
10
|
+
{ :platform => Beaker::Platform.new('eos-vers-arch-extra') }
|
33
11
|
end
|
34
12
|
end
|
13
|
+
let(:host) { make_host('name', options.merge(platform)) }
|
35
14
|
|
36
15
|
describe '#get_remote_file' do
|
37
16
|
it 'calls enable first' do
|
38
|
-
expect(
|
39
|
-
host.get_remote_file(
|
17
|
+
expect(host).to receive(:execute).with(/enable/)
|
18
|
+
host.get_remote_file('remote_url')
|
40
19
|
end
|
41
20
|
|
42
21
|
it 'begins second line with the copy command' do
|
43
|
-
expect(
|
44
|
-
host.get_remote_file(
|
22
|
+
expect(host).to receive(:execute).with(/\ncopy/)
|
23
|
+
host.get_remote_file('remote_url')
|
45
24
|
end
|
46
25
|
|
47
26
|
it 'ends second line with particular extension location' do
|
48
|
-
expect(
|
49
|
-
host.get_remote_file(
|
27
|
+
expect(host).to receive(:execute).with(/extension\:\'$/)
|
28
|
+
host.get_remote_file('remote_url')
|
50
29
|
end
|
51
30
|
end
|
52
31
|
|
53
32
|
describe '#install_from_file' do
|
54
33
|
it 'calls enable first' do
|
55
|
-
expect(
|
56
|
-
host.install_from_file(
|
34
|
+
expect(host).to receive(:execute).with(/enable/)
|
35
|
+
host.install_from_file('local_file')
|
57
36
|
end
|
58
37
|
|
59
38
|
it 'begins second line with the extension command' do
|
60
|
-
expect(
|
61
|
-
host.install_from_file(
|
39
|
+
expect(host).to receive(:execute).with(/\nextension/)
|
40
|
+
host.install_from_file('local_file')
|
62
41
|
end
|
63
42
|
end
|
64
43
|
end
|
65
|
-
end
|
44
|
+
end
|
@@ -20,18 +20,15 @@ module Beaker
|
|
20
20
|
end
|
21
21
|
|
22
22
|
let(:opts) { @opts || {} }
|
23
|
-
let(:logger) { double(
|
23
|
+
let(:logger) { double('logger').as_null_object }
|
24
24
|
let(:instance) { FreeBSDExecTest.new(opts, logger) }
|
25
25
|
|
26
26
|
context "echo_to_file" do
|
27
|
-
|
28
27
|
it "runs the correct echo command" do
|
29
|
-
expect(
|
30
|
-
expect(
|
28
|
+
expect(Beaker::Command).to receive(:new).with('printf "127.0.0.1\tlocalhost localhost.localdomain\n10.255.39.23\tfreebsd-10-x64\n" > /etc/hosts').and_return('')
|
29
|
+
expect(instance).to receive(:exec).with('').and_return(generate_result("hello", { :exit_code => 0 }))
|
31
30
|
instance.echo_to_file('127.0.0.1\tlocalhost localhost.localdomain\n10.255.39.23\tfreebsd-10-x64\n', '/etc/hosts')
|
32
31
|
end
|
33
|
-
|
34
32
|
end
|
35
33
|
end
|
36
34
|
end
|
37
|
-
|
@@ -19,13 +19,12 @@ module Beaker
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def exec
|
22
|
-
#noop
|
22
|
+
# noop
|
23
23
|
end
|
24
|
-
|
25
24
|
end
|
26
25
|
|
27
26
|
let(:opts) { @opts || {} }
|
28
|
-
let(:logger) { double(
|
27
|
+
let(:logger) { double('logger').as_null_object }
|
29
28
|
let(:instance) { FreeBSDPkgTest.new(opts, logger) }
|
30
29
|
let(:cond) do
|
31
30
|
'TMPDIR=/dev/null ASSUME_ALWAYS_YES=1 PACKAGESITE=file:///nonexist pkg info -x "pkg(-devel)?\\$" > /dev/null 2>&1'
|
@@ -33,45 +32,45 @@ module Beaker
|
|
33
32
|
|
34
33
|
context "pkg_info_patten" do
|
35
34
|
it "returns correct patterns" do
|
36
|
-
expect(
|
35
|
+
expect(instance.pkg_info_pattern('rsync')).to eq '^rsync-[0-9][0-9a-zA-Z_\\.,]*$'
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
40
39
|
context "check_pkgng_sh" do
|
41
|
-
it { expect(
|
40
|
+
it { expect(instance.check_pkgng_sh).to eq cond }
|
42
41
|
end
|
43
42
|
|
44
43
|
context "pkgng_active?" do
|
45
44
|
it "returns true if pkgng is available" do
|
46
|
-
expect(
|
47
|
-
expect(
|
48
|
-
expect(
|
49
|
-
expect(
|
45
|
+
expect(instance).to receive(:check_pkgng_sh).once.and_return("do you have pkgng?")
|
46
|
+
expect(Beaker::Command).to receive(:new).with("/bin/sh -c 'do you have pkgng?'", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
|
47
|
+
expect(instance).to receive(:exec).with('', { :accept_all_exit_codes => true }).and_return(generate_result("hello", { :exit_code => 0 }))
|
48
|
+
expect(instance.pkgng_active?).to be true
|
50
49
|
end
|
51
50
|
|
52
51
|
it "returns false if pkgng is unavailable" do
|
53
|
-
expect(
|
54
|
-
expect(
|
55
|
-
expect(
|
56
|
-
expect(
|
52
|
+
expect(instance).to receive(:check_pkgng_sh).once.and_return("do you have pkgng?")
|
53
|
+
expect(Beaker::Command).to receive(:new).with("/bin/sh -c 'do you have pkgng?'", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
|
54
|
+
expect(instance).to receive(:exec).with('', { :accept_all_exit_codes => true }).and_return(generate_result("hello", { :exit_code => 127 }))
|
55
|
+
expect(instance.pkgng_active?).to be false
|
57
56
|
end
|
58
57
|
end
|
59
58
|
|
60
59
|
context "install_package" do
|
61
60
|
context "without pkgng" do
|
62
61
|
it "runs the correct install command" do
|
63
|
-
expect(
|
64
|
-
expect(
|
65
|
-
expect(
|
62
|
+
expect(instance).to receive(:pkgng_active?).once.and_return(false)
|
63
|
+
expect(Beaker::Command).to receive(:new).with("pkg_add -r rsync", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
|
64
|
+
expect(instance).to receive(:exec).with('', {}).and_return(generate_result("hello", { :exit_code => 0 }))
|
66
65
|
instance.install_package('rsync')
|
67
66
|
end
|
68
67
|
end
|
69
68
|
|
70
69
|
context "with pkgng" do
|
71
70
|
it "runs the correct install command" do
|
72
|
-
expect(
|
73
|
-
expect(
|
74
|
-
expect(
|
71
|
+
expect(instance).to receive(:pkgng_active?).once.and_return(true)
|
72
|
+
expect(Beaker::Command).to receive(:new).with("pkg install -y rsync", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
|
73
|
+
expect(instance).to receive(:exec).with('', {}).and_return(generate_result("hello", { :exit_code => 0 }))
|
75
74
|
instance.install_package('rsync')
|
76
75
|
end
|
77
76
|
end
|
@@ -80,23 +79,21 @@ module Beaker
|
|
80
79
|
context "check_for_package" do
|
81
80
|
context "without pkgng" do
|
82
81
|
it "runs the correct checking command" do
|
83
|
-
expect(
|
84
|
-
expect(
|
85
|
-
expect(
|
82
|
+
expect(instance).to receive(:pkgng_active?).once.and_return(false)
|
83
|
+
expect(Beaker::Command).to receive(:new).with("pkg_info -Ix '^rsync-[0-9][0-9a-zA-Z_\\.,]*$'", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
|
84
|
+
expect(instance).to receive(:exec).with('', { :accept_all_exit_codes => true }).and_return(generate_result("hello", { :exit_code => 0 }))
|
86
85
|
instance.check_for_package('rsync')
|
87
86
|
end
|
88
87
|
end
|
89
88
|
|
90
89
|
context "with pkgng" do
|
91
90
|
it "runs the correct checking command" do
|
92
|
-
expect(
|
93
|
-
expect(
|
94
|
-
expect(
|
91
|
+
expect(instance).to receive(:pkgng_active?).once.and_return(true)
|
92
|
+
expect(Beaker::Command).to receive(:new).with("pkg info rsync", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
|
93
|
+
expect(instance).to receive(:exec).with('', { :accept_all_exit_codes => true }).and_return(generate_result("hello", { :exit_code => 0 }))
|
95
94
|
instance.check_for_package('rsync')
|
96
95
|
end
|
97
96
|
end
|
98
97
|
end
|
99
|
-
|
100
98
|
end
|
101
99
|
end
|
102
|
-
|
@@ -17,11 +17,10 @@ module Beaker
|
|
17
17
|
def to_s
|
18
18
|
"me"
|
19
19
|
end
|
20
|
-
|
21
20
|
end
|
22
21
|
|
23
22
|
let(:opts) { @opts || {} }
|
24
|
-
let(:logger) { double(
|
23
|
+
let(:logger) { double('logger').as_null_object }
|
25
24
|
let(:instance) { MacExecTest.new(opts, logger) }
|
26
25
|
|
27
26
|
describe '#selinux_enabled?' do
|
@@ -36,7 +35,7 @@ module Beaker
|
|
36
35
|
it 'calls execute with touch and timestamp' do
|
37
36
|
time = '190101010000'
|
38
37
|
path = '/path/to/file'
|
39
|
-
expect(
|
38
|
+
expect(instance).to receive(:execute).with("touch -mt #{time} #{path}").and_return(0)
|
40
39
|
|
41
40
|
instance.modified_at(path, time)
|
42
41
|
end
|