beaker 4.42.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/release.yml +2 -2
- data/.github/workflows/test.yml +26 -13
- data/.rubocop.yml +23 -10
- data/.rubocop_todo.yml +34 -10
- data/CHANGELOG.md +16 -61
- 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 +41 -46
- 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 +27 -39
- 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 +65 -78
- 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 -55
- 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
@@ -1,44 +1,41 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Beaker do
|
4
|
-
let(
|
5
|
-
let(
|
6
|
-
let(
|
7
|
-
let(
|
8
|
-
let(
|
9
|
-
let(
|
10
|
-
let(
|
11
|
-
let(
|
12
|
-
let(
|
13
|
-
let(
|
14
|
-
let(
|
15
|
-
let(
|
16
|
-
let(:
|
17
|
-
let(
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
let( :dummy_class ) { Class.new { include Beaker::HostPrebuiltSteps } }
|
4
|
+
let(:options) { make_opts.merge({ 'logger' => double.as_null_object }) }
|
5
|
+
let(:ntpserver_set) { "ntp_server_set" }
|
6
|
+
let(:options_ntp) { make_opts.merge({ 'ntp_server' => ntpserver_set }) }
|
7
|
+
let(:ntpserver) { Beaker::HostPrebuiltSteps::NTPSERVER }
|
8
|
+
let(:sync_cmd) { Beaker::HostPrebuiltSteps::ROOT_KEYS_SYNC_CMD }
|
9
|
+
let(:windows_pkgs) { Beaker::HostPrebuiltSteps::WINDOWS_PACKAGES }
|
10
|
+
let(:unix_only_pkgs) { Beaker::HostPrebuiltSteps::UNIX_PACKAGES }
|
11
|
+
let(:sles_only_pkgs) { Beaker::HostPrebuiltSteps::SLES_PACKAGES }
|
12
|
+
let(:rhel8_packages) { Beaker::HostPrebuiltSteps::RHEL8_PACKAGES }
|
13
|
+
let(:fedora_packages) { Beaker::HostPrebuiltSteps::FEDORA_PACKAGES }
|
14
|
+
let(:platform) { @platform || 'unix' }
|
15
|
+
let(:ip) { "ip.address.0.0" }
|
16
|
+
let(:stdout) { @stdout || ip }
|
17
|
+
let(:hosts) do
|
18
|
+
hosts = make_hosts({ :stdout => stdout, :platform => platform })
|
19
|
+
hosts[0][:roles] = ['agent']
|
20
|
+
hosts[1][:roles] = %w[master dashboard agent database]
|
21
|
+
hosts[2][:roles] = ['agent']
|
22
|
+
hosts
|
23
|
+
end
|
24
|
+
let(:dummy_class) { Class.new { include Beaker::HostPrebuiltSteps } }
|
26
25
|
|
27
26
|
shared_examples 'enables_root_login' do |platform, commands, non_cygwin|
|
28
27
|
subject { dummy_class.new }
|
29
28
|
|
30
29
|
it "can enable root login on #{platform}" do
|
31
|
-
hosts = make_hosts(
|
30
|
+
hosts = make_hosts({ :platform => platform, :is_cygwin => non_cygwin })
|
32
31
|
|
33
|
-
if commands.empty?
|
34
|
-
expect( Beaker::Command ).to receive( :new ).exactly( 0 ).times
|
35
|
-
end
|
32
|
+
expect(Beaker::Command).to receive(:new).exactly(0).times if commands.empty?
|
36
33
|
|
37
|
-
commands.each do |
|
38
|
-
expect(
|
34
|
+
commands.each do |command|
|
35
|
+
expect(Beaker::Command).to receive(:new).with(command).exactly(3).times
|
39
36
|
end
|
40
37
|
|
41
|
-
subject.enable_root_login(
|
38
|
+
subject.enable_root_login(hosts, options)
|
42
39
|
end
|
43
40
|
end
|
44
41
|
|
@@ -48,105 +45,98 @@ describe Beaker do
|
|
48
45
|
|
49
46
|
# Non-cygwin Windows
|
50
47
|
it_behaves_like 'enables_root_login', 'windows', [
|
51
|
-
"sed -ri 's/^#?PermitRootLogin /PermitRootLogin yes/' /etc/sshd_config"
|
48
|
+
"sed -ri 's/^#?PermitRootLogin /PermitRootLogin yes/' /etc/sshd_config",
|
52
49
|
], true
|
53
50
|
|
54
51
|
# FreeBSD
|
55
52
|
it_behaves_like 'enables_root_login', 'freesbd', [
|
56
|
-
"sudo su -c \"sed -ri 's/^#?PermitRootLogin no|^#?PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config\""
|
53
|
+
"sudo su -c \"sed -ri 's/^#?PermitRootLogin no|^#?PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config\"",
|
57
54
|
], true
|
58
55
|
|
59
56
|
it_behaves_like 'enables_root_login', 'osx-10.10', [
|
60
57
|
"sudo sed -i '' 's/#PermitRootLogin yes/PermitRootLogin Yes/g' /etc/sshd_config",
|
61
|
-
"sudo sed -i '' 's/#PermitRootLogin no/PermitRootLogin Yes/g' /etc/sshd_config"
|
58
|
+
"sudo sed -i '' 's/#PermitRootLogin no/PermitRootLogin Yes/g' /etc/sshd_config",
|
62
59
|
]
|
63
60
|
|
64
61
|
it_behaves_like 'enables_root_login', 'osx-10.11', [
|
65
62
|
"sudo sed -i '' 's/#PermitRootLogin yes/PermitRootLogin Yes/g' /private/etc/ssh/sshd_config",
|
66
|
-
"sudo sed -i '' 's/#PermitRootLogin no/PermitRootLogin Yes/g' /private/etc/ssh/sshd_config"
|
63
|
+
"sudo sed -i '' 's/#PermitRootLogin no/PermitRootLogin Yes/g' /private/etc/ssh/sshd_config",
|
67
64
|
]
|
68
65
|
|
69
66
|
it_behaves_like 'enables_root_login', 'osx-10.12', [
|
70
|
-
|
71
|
-
|
67
|
+
"sudo sed -i '' 's/#PermitRootLogin yes/PermitRootLogin Yes/g' /private/etc/ssh/sshd_config",
|
68
|
+
"sudo sed -i '' 's/#PermitRootLogin no/PermitRootLogin Yes/g' /private/etc/ssh/sshd_config",
|
72
69
|
]
|
73
70
|
|
74
71
|
it_behaves_like 'enables_root_login', 'osx-10.13', [
|
75
|
-
|
76
|
-
|
72
|
+
"sudo sed -i '' 's/#PermitRootLogin yes/PermitRootLogin Yes/g' /private/etc/ssh/sshd_config",
|
73
|
+
"sudo sed -i '' 's/#PermitRootLogin no/PermitRootLogin Yes/g' /private/etc/ssh/sshd_config",
|
77
74
|
]
|
78
75
|
|
79
76
|
# Solaris
|
80
77
|
it_behaves_like 'enables_root_login', 'solaris-10', [
|
81
78
|
"sudo -E svcadm restart network/ssh",
|
82
|
-
"sudo gsed -i -e 's/#PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config"
|
79
|
+
"sudo gsed -i -e 's/#PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config",
|
83
80
|
], true
|
84
81
|
|
85
82
|
it_behaves_like 'enables_root_login', 'solaris-11', [
|
86
83
|
"sudo -E svcadm restart network/ssh",
|
87
84
|
"sudo gsed -i -e 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config",
|
88
|
-
"if grep \"root::::type=role\" /etc/user_attr; then sudo rolemod -K type=normal root; else echo \"root user already type=normal\"; fi"
|
85
|
+
"if grep \"root::::type=role\" /etc/user_attr; then sudo rolemod -K type=normal root; else echo \"root user already type=normal\"; fi",
|
89
86
|
], true
|
90
87
|
|
91
|
-
it_behaves_like 'enables_root_login', 'amazon-2023', [
|
92
|
-
"sudo -E systemctl restart sshd.service",
|
93
|
-
"sudo su -c \"sed -ri 's/^#?PermitRootLogin no|^#?PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config\"",
|
94
|
-
]
|
95
|
-
|
96
88
|
%w[debian ubuntu cumulus].each do |deb_like|
|
97
89
|
it_behaves_like 'enables_root_login', deb_like, [
|
98
90
|
"sudo su -c \"sed -ri 's/^#?PermitRootLogin no|^#?PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config\"",
|
99
|
-
"sudo su -c \"service ssh restart\""
|
91
|
+
"sudo su -c \"service ssh restart\"",
|
100
92
|
]
|
101
93
|
end
|
102
94
|
|
103
|
-
['centos','el-','redhat','fedora','eos'].each do |
|
95
|
+
['centos', 'el-', 'redhat', 'fedora', 'eos'].each do |redhat_like|
|
104
96
|
it_behaves_like 'enables_root_login', redhat_like, [
|
105
97
|
"sudo su -c \"sed -ri 's/^#?PermitRootLogin no|^#?PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config\"",
|
106
|
-
"sudo -E /sbin/service sshd reload"
|
98
|
+
"sudo -E /sbin/service sshd reload",
|
107
99
|
]
|
108
100
|
end
|
109
101
|
|
110
102
|
context 'timesync' do
|
111
|
-
|
112
103
|
subject { dummy_class.new }
|
113
104
|
|
114
105
|
it "can sync time on unix hosts" do
|
115
|
-
hosts = make_hosts(
|
106
|
+
hosts = make_hosts({ :platform => 'unix' })
|
116
107
|
|
117
|
-
expect(
|
108
|
+
expect(Beaker::Command).to receive(:new).with("ntpdate -u -t 20 #{ntpserver}").exactly(3).times
|
118
109
|
|
119
|
-
subject.timesync(
|
110
|
+
subject.timesync(hosts, options)
|
120
111
|
end
|
121
112
|
|
122
113
|
it "can retry on failure on unix hosts" do
|
123
|
-
hosts = make_hosts(
|
124
|
-
allow(
|
114
|
+
hosts = make_hosts({ :platform => 'unix', :exit_code => [1, 0] })
|
115
|
+
allow(subject).to receive(:sleep).and_return(true)
|
125
116
|
|
126
|
-
expect(
|
117
|
+
expect(Beaker::Command).to receive(:new).with("ntpdate -u -t 20 #{ntpserver}").exactly(6).times
|
127
118
|
|
128
|
-
subject.timesync(
|
119
|
+
subject.timesync(hosts, options)
|
129
120
|
end
|
130
121
|
|
131
122
|
it "eventually gives up and raises an error when unix hosts can't be synched" do
|
132
|
-
hosts = make_hosts(
|
133
|
-
allow(
|
123
|
+
hosts = make_hosts({ :platform => 'unix', :exit_code => 1 })
|
124
|
+
allow(subject).to receive(:sleep).and_return(true)
|
134
125
|
|
135
|
-
expect(
|
126
|
+
expect(Beaker::Command).to receive(:new).with("ntpdate -u -t 20 #{ntpserver}").exactly(5).times
|
136
127
|
|
137
|
-
expect{ subject.timesync(
|
128
|
+
expect { subject.timesync(hosts, options) }.to raise_error(/NTP date was not successful after/)
|
138
129
|
end
|
139
130
|
|
140
131
|
it "can sync time on windows hosts" do
|
141
|
-
hosts = make_hosts(
|
132
|
+
hosts = make_hosts({ :platform => 'windows' })
|
142
133
|
|
143
|
-
expect(
|
144
|
-
expect(
|
145
|
-
expect(
|
146
|
-
expect(
|
147
|
-
|
148
|
-
subject.timesync( hosts, options )
|
134
|
+
expect(Beaker::Command).to receive(:new).with("w32tm /register").exactly(3).times
|
135
|
+
expect(Beaker::Command).to receive(:new).with("net start w32time").exactly(3).times
|
136
|
+
expect(Beaker::Command).to receive(:new).with("w32tm /config /manualpeerlist:#{ntpserver} /syncfromflags:manual /update").exactly(3).times
|
137
|
+
expect(Beaker::Command).to receive(:new).with("w32tm /resync").exactly(3).times
|
149
138
|
|
139
|
+
subject.timesync(hosts, options)
|
150
140
|
end
|
151
141
|
|
152
142
|
it "can sync time on Sles hosts" do
|
@@ -157,15 +147,6 @@ describe Beaker do
|
|
157
147
|
subject.timesync(hosts, options)
|
158
148
|
end
|
159
149
|
|
160
|
-
it "can sync time on amazon2023 hosts" do
|
161
|
-
hosts = make_hosts(:platform => 'amazon-2023-x86_64')
|
162
|
-
expect(Beaker::Command).to receive(:new)
|
163
|
-
.with("chronyc add server #{ntpserver} prefer trust;chronyc makestep;chronyc burst 1/2")
|
164
|
-
.exactly(3)
|
165
|
-
.times
|
166
|
-
subject.timesync(hosts, options)
|
167
|
-
end
|
168
|
-
|
169
150
|
it "can sync time on RHEL8 hosts" do
|
170
151
|
hosts = make_hosts(:platform => 'el-8-x86_x64')
|
171
152
|
expect(Beaker::Command).to receive(:new)
|
@@ -185,32 +166,30 @@ describe Beaker do
|
|
185
166
|
end
|
186
167
|
|
187
168
|
it "can set time server on unix hosts" do
|
188
|
-
hosts = make_hosts(
|
169
|
+
hosts = make_hosts({ :platform => 'unix' })
|
189
170
|
|
190
|
-
expect(
|
171
|
+
expect(Beaker::Command).to receive(:new).with("ntpdate -u -t 20 #{ntpserver_set}").exactly(3).times
|
191
172
|
|
192
|
-
subject.timesync(
|
173
|
+
subject.timesync(hosts, options_ntp)
|
193
174
|
end
|
194
175
|
|
195
176
|
it "can set time server on windows hosts" do
|
196
|
-
hosts = make_hosts(
|
197
|
-
|
198
|
-
expect( Beaker::Command ).to receive( :new ).with("w32tm /register").exactly( 3 ).times
|
199
|
-
expect( Beaker::Command ).to receive( :new ).with("net start w32time").exactly( 3 ).times
|
200
|
-
expect( Beaker::Command ).to receive( :new ).with("w32tm /config /manualpeerlist:#{ntpserver_set} /syncfromflags:manual /update").exactly( 3 ).times
|
201
|
-
expect( Beaker::Command ).to receive( :new ).with("w32tm /resync").exactly( 3 ).times
|
177
|
+
hosts = make_hosts({ :platform => 'windows' })
|
202
178
|
|
203
|
-
|
179
|
+
expect(Beaker::Command).to receive(:new).with("w32tm /register").exactly(3).times
|
180
|
+
expect(Beaker::Command).to receive(:new).with("net start w32time").exactly(3).times
|
181
|
+
expect(Beaker::Command).to receive(:new).with("w32tm /config /manualpeerlist:#{ntpserver_set} /syncfromflags:manual /update").exactly(3).times
|
182
|
+
expect(Beaker::Command).to receive(:new).with("w32tm /resync").exactly(3).times
|
204
183
|
|
184
|
+
subject.timesync(hosts, options_ntp)
|
205
185
|
end
|
206
186
|
|
207
187
|
it "can set time server on Sles hosts" do
|
208
|
-
hosts = make_hosts(
|
209
|
-
|
210
|
-
expect( Beaker::Command ).to receive( :new ).with("sntp #{ntpserver_set}").exactly( 3 ).times
|
188
|
+
hosts = make_hosts({ :platform => 'sles-13.1-x64' })
|
211
189
|
|
212
|
-
|
190
|
+
expect(Beaker::Command).to receive(:new).with("sntp #{ntpserver_set}").exactly(3).times
|
213
191
|
|
192
|
+
subject.timesync(hosts, options_ntp)
|
214
193
|
end
|
215
194
|
|
216
195
|
it "can set time server on RHEL8 hosts" do
|
@@ -227,41 +206,36 @@ describe Beaker do
|
|
227
206
|
subject { dummy_class.new }
|
228
207
|
|
229
208
|
it "can perform apt-get on ubuntu hosts" do
|
230
|
-
host = make_host(
|
209
|
+
host = make_host('testhost', { :platform => 'ubuntu' })
|
231
210
|
|
232
|
-
expect(
|
233
|
-
|
234
|
-
subject.apt_get_update( host )
|
211
|
+
expect(Beaker::Command).to receive(:new).with("apt-get update").once
|
235
212
|
|
213
|
+
subject.apt_get_update(host)
|
236
214
|
end
|
237
215
|
|
238
216
|
it "can perform apt-get on debian hosts" do
|
239
|
-
host = make_host(
|
240
|
-
|
241
|
-
expect( Beaker::Command ).to receive( :new ).with("apt-get update").once
|
217
|
+
host = make_host('testhost', { :platform => 'debian' })
|
242
218
|
|
243
|
-
|
219
|
+
expect(Beaker::Command).to receive(:new).with("apt-get update").once
|
244
220
|
|
221
|
+
subject.apt_get_update(host)
|
245
222
|
end
|
246
223
|
|
247
224
|
it "can perform apt-get on cumulus hosts" do
|
248
|
-
host = make_host(
|
225
|
+
host = make_host('testhost', { :platform => 'cumulus' })
|
249
226
|
|
250
|
-
expect(
|
251
|
-
|
252
|
-
subject.apt_get_update( host )
|
227
|
+
expect(Beaker::Command).to receive(:new).with("apt-get update").once
|
253
228
|
|
229
|
+
subject.apt_get_update(host)
|
254
230
|
end
|
255
231
|
|
256
232
|
it "does nothing on non debian/ubuntu/cumulus hosts" do
|
257
|
-
host = make_host(
|
258
|
-
|
259
|
-
expect( Beaker::Command ).not_to receive( :new )
|
233
|
+
host = make_host('testhost', { :platform => 'windows' })
|
260
234
|
|
261
|
-
|
235
|
+
expect(Beaker::Command).not_to receive(:new)
|
262
236
|
|
237
|
+
subject.apt_get_update(host)
|
263
238
|
end
|
264
|
-
|
265
239
|
end
|
266
240
|
|
267
241
|
context "copy_file_to_remote" do
|
@@ -271,125 +245,17 @@ describe Beaker do
|
|
271
245
|
content = "this is the content"
|
272
246
|
tempfilepath = "/path/to/tempfile"
|
273
247
|
filepath = "/path/to/file"
|
274
|
-
host = make_host(
|
275
|
-
tempfile = double(
|
276
|
-
allow(
|
277
|
-
allow(
|
278
|
-
file = double(
|
279
|
-
allow(
|
248
|
+
host = make_host('testhost', { :platform => 'windows' })
|
249
|
+
tempfile = double('tempfile')
|
250
|
+
allow(tempfile).to receive(:path).and_return(tempfilepath)
|
251
|
+
allow(Tempfile).to receive(:open).and_yield(tempfile)
|
252
|
+
file = double('file')
|
253
|
+
allow(File).to receive(:open).and_yield(file)
|
280
254
|
|
281
|
-
expect(
|
282
|
-
expect(
|
255
|
+
expect(file).to receive(:puts).with(content).once
|
256
|
+
expect(host).to receive(:do_scp_to).with(tempfilepath, filepath, subject.instance_variable_get(:@options)).once
|
283
257
|
|
284
258
|
subject.copy_file_to_remote(host, filepath, content)
|
285
|
-
|
286
|
-
end
|
287
|
-
|
288
|
-
end
|
289
|
-
|
290
|
-
context "proxy_config" do
|
291
|
-
subject { dummy_class.new }
|
292
|
-
|
293
|
-
it "correctly configures ubuntu hosts" do
|
294
|
-
hosts = make_hosts( { :platform => 'ubuntu', :exit_code => 1 } )
|
295
|
-
|
296
|
-
expect( Beaker::Command ).to receive( :new ).with( "if test -f /etc/apt/apt.conf; then mv /etc/apt/apt.conf /etc/apt/apt.conf.bk; fi" ).exactly( 3 )
|
297
|
-
hosts.each do |host|
|
298
|
-
expect( subject ).to receive( :copy_file_to_remote ).with( host, '/etc/apt/apt.conf', apt_cfg ).once
|
299
|
-
expect( subject ).to receive( :apt_get_update ).with( host ).once
|
300
|
-
end
|
301
|
-
|
302
|
-
subject.proxy_config( hosts, options )
|
303
|
-
|
304
|
-
end
|
305
|
-
|
306
|
-
it "correctly configures debian hosts" do
|
307
|
-
hosts = make_hosts( { :platform => 'debian' } )
|
308
|
-
|
309
|
-
expect( Beaker::Command ).to receive( :new ).with( "if test -f /etc/apt/apt.conf; then mv /etc/apt/apt.conf /etc/apt/apt.conf.bk; fi" ).exactly( 3 ).times
|
310
|
-
hosts.each do |host|
|
311
|
-
expect( subject ).to receive( :copy_file_to_remote ).with( host, '/etc/apt/apt.conf', apt_cfg ).once
|
312
|
-
expect( subject ).to receive( :apt_get_update ).with( host ).once
|
313
|
-
end
|
314
|
-
|
315
|
-
subject.proxy_config( hosts, options )
|
316
|
-
|
317
|
-
end
|
318
|
-
|
319
|
-
it "correctly configures cumulus hosts" do
|
320
|
-
hosts = make_hosts( { :platform => 'cumulus' } )
|
321
|
-
|
322
|
-
expect( Beaker::Command ).to receive( :new ).with( "if test -f /etc/apt/apt.conf; then mv /etc/apt/apt.conf /etc/apt/apt.conf.bk; fi" ).exactly( 3 ).times
|
323
|
-
hosts.each do |host|
|
324
|
-
expect( subject ).to receive( :copy_file_to_remote ).with( host, '/etc/apt/apt.conf', apt_cfg ).once
|
325
|
-
expect( subject ).to receive( :apt_get_update ).with( host ).once
|
326
|
-
end
|
327
|
-
|
328
|
-
subject.proxy_config( hosts, options )
|
329
|
-
|
330
|
-
end
|
331
|
-
|
332
|
-
it "correctly configures solaris-11 hosts" do
|
333
|
-
hosts = make_hosts( { :platform => 'solaris-11' } )
|
334
|
-
|
335
|
-
expect( Beaker::Command ).to receive( :new ).with( "/usr/bin/pkg unset-publisher solaris || :" ).exactly( 3 ).times
|
336
|
-
hosts.each do |_host|
|
337
|
-
expect( Beaker::Command ).to receive( :new ).with( "/usr/bin/pkg set-publisher -g %s solaris" % ips_pkg_repo ).once
|
338
|
-
end
|
339
|
-
|
340
|
-
subject.proxy_config( hosts, options )
|
341
|
-
|
342
|
-
end
|
343
|
-
|
344
|
-
it "does nothing for non ubuntu/debian/cumulus/solaris-11 hosts" do
|
345
|
-
hosts = make_hosts( { :platform => 'windows' } )
|
346
|
-
|
347
|
-
expect( Beaker::Command ).not_to receive( :new )
|
348
|
-
|
349
|
-
subject.proxy_config( hosts, options )
|
350
|
-
|
351
|
-
end
|
352
|
-
end
|
353
|
-
|
354
|
-
context "add_el_extras" do
|
355
|
-
subject { dummy_class.new }
|
356
|
-
|
357
|
-
it 'adds extras for el-6 hosts' do
|
358
|
-
|
359
|
-
hosts = make_hosts( { :platform => Beaker::Platform.new('el-6-arch'), :exit_code => 1 }, 4 )
|
360
|
-
hosts[1][:platform] = Beaker::Platform.new('centos-6-arch')
|
361
|
-
hosts[2][:platform] = Beaker::Platform.new('scientific-6-arch')
|
362
|
-
hosts[3][:platform] = Beaker::Platform.new('redhat-6-arch')
|
363
|
-
|
364
|
-
expect( Beaker::Command ).to receive( :new ).with(
|
365
|
-
"rpm -qa | grep epel-release"
|
366
|
-
).exactly( hosts.count ).times
|
367
|
-
hosts.each do |host|
|
368
|
-
expect(host).to receive( :install_package_with_rpm ).with(
|
369
|
-
"http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm", "--replacepkgs", {:package_proxy => false}
|
370
|
-
).once
|
371
|
-
end
|
372
|
-
expect( Beaker::Command ).to receive( :new ).with(
|
373
|
-
"sed -i -e 's;#baseurl.*$;baseurl=http://dl\\.fedoraproject\\.org/pub/epel/6/$basearch;' /etc/yum.repos.d/epel.repo"
|
374
|
-
).exactly( hosts.count ).times
|
375
|
-
expect( Beaker::Command ).to receive( :new ).with(
|
376
|
-
"sed -i -e '/mirrorlist/d' /etc/yum.repos.d/epel.repo"
|
377
|
-
).exactly( hosts.count ).times
|
378
|
-
expect( Beaker::Command ).to receive( :new ).with(
|
379
|
-
"yum clean all && yum makecache"
|
380
|
-
).exactly( hosts.count ).times
|
381
|
-
|
382
|
-
subject.add_el_extras( hosts, options )
|
383
|
-
|
384
|
-
end
|
385
|
-
|
386
|
-
it "does nothing for non el-5/6 hosts" do
|
387
|
-
hosts = make_hosts( { :platform => Beaker::Platform.new('windows-version-arch') } )
|
388
|
-
|
389
|
-
expect( Beaker::Command ).not_to receive( :new )
|
390
|
-
|
391
|
-
subject.add_el_extras( hosts, options )
|
392
|
-
|
393
259
|
end
|
394
260
|
end
|
395
261
|
|
@@ -399,36 +265,30 @@ describe Beaker do
|
|
399
265
|
it "can sync keys on a solaris/eos host" do
|
400
266
|
@platform = 'solaris'
|
401
267
|
|
402
|
-
expect(
|
403
|
-
|
404
|
-
subject.sync_root_keys( hosts, options )
|
268
|
+
expect(Beaker::Command).to receive(:new).with(sync_cmd % "bash").exactly(3).times
|
405
269
|
|
270
|
+
subject.sync_root_keys(hosts, options)
|
406
271
|
end
|
407
272
|
|
408
273
|
it "can sync keys on a non-solaris host" do
|
274
|
+
expect(Beaker::Command).to receive(:new).with(sync_cmd % "env PATH=\"/usr/gnu/bin:$PATH\" bash").exactly(3).times
|
409
275
|
|
410
|
-
|
411
|
-
|
412
|
-
subject.sync_root_keys( hosts, options )
|
413
|
-
|
276
|
+
subject.sync_root_keys(hosts, options)
|
414
277
|
end
|
415
|
-
|
416
278
|
end
|
417
279
|
|
418
280
|
context "validate_host" do
|
419
281
|
subject { dummy_class.new }
|
420
282
|
|
421
283
|
it "can validate unix hosts" do
|
422
|
-
|
423
284
|
hosts.each do |host|
|
424
285
|
unix_only_pkgs.each do |pkg|
|
425
|
-
expect(
|
426
|
-
expect(
|
286
|
+
expect(host).to receive(:check_for_package).with(pkg).once.and_return(false)
|
287
|
+
expect(host).to receive(:install_package).with(pkg).once
|
427
288
|
end
|
428
289
|
end
|
429
290
|
|
430
291
|
subject.validate_host(hosts, options)
|
431
|
-
|
432
292
|
end
|
433
293
|
|
434
294
|
it "can validate windows hosts" do
|
@@ -436,15 +296,14 @@ describe Beaker do
|
|
436
296
|
|
437
297
|
hosts.each do |host|
|
438
298
|
windows_pkgs.each do |pkg|
|
439
|
-
allow(
|
440
|
-
allow(
|
441
|
-
expect(
|
442
|
-
expect(
|
299
|
+
allow(host).to receive(:cygwin_installed?).and_return(true)
|
300
|
+
allow(host).to receive(:is_cygwin?).and_return(true)
|
301
|
+
expect(host).to receive(:check_for_package).with(pkg).once.and_return(false)
|
302
|
+
expect(host).to receive(:install_package).with(pkg).once
|
443
303
|
end
|
444
304
|
end
|
445
305
|
|
446
306
|
subject.validate_host(hosts, options)
|
447
|
-
|
448
307
|
end
|
449
308
|
|
450
309
|
it "can validate SLES hosts" do
|
@@ -452,14 +311,12 @@ describe Beaker do
|
|
452
311
|
|
453
312
|
hosts.each do |host|
|
454
313
|
sles_only_pkgs.each do |pkg|
|
455
|
-
expect(
|
456
|
-
expect(
|
314
|
+
expect(host).to receive(:check_for_package).with(pkg).once.and_return(false)
|
315
|
+
expect(host).to receive(:install_package).with(pkg).once
|
457
316
|
end
|
458
|
-
|
459
317
|
end
|
460
318
|
|
461
319
|
subject.validate_host(hosts, options)
|
462
|
-
|
463
320
|
end
|
464
321
|
|
465
322
|
it "can validate opensuse hosts" do
|
@@ -467,14 +324,12 @@ describe Beaker do
|
|
467
324
|
|
468
325
|
hosts.each do |host|
|
469
326
|
sles_only_pkgs.each do |pkg|
|
470
|
-
expect(
|
471
|
-
expect(
|
327
|
+
expect(host).to receive(:check_for_package).with(pkg).once.and_return(false)
|
328
|
+
expect(host).to receive(:install_package).with(pkg).once
|
472
329
|
end
|
473
|
-
|
474
330
|
end
|
475
331
|
|
476
332
|
subject.validate_host(hosts, options)
|
477
|
-
|
478
333
|
end
|
479
334
|
|
480
335
|
it "can validate RHEL8 hosts" do
|
@@ -503,22 +358,9 @@ describe Beaker do
|
|
503
358
|
subject.validate_host(hosts, options)
|
504
359
|
end
|
505
360
|
|
506
|
-
it "can validate Amazon hosts" do
|
507
|
-
@platform = 'amazon-2023-x86_64'
|
508
|
-
|
509
|
-
hosts.each do |host|
|
510
|
-
amazon2023_packages.each do |pkg|
|
511
|
-
expect(host).to receive(:check_for_package).with(pkg).once.and_return(false)
|
512
|
-
expect(host).to receive(:install_package).with(pkg).once
|
513
|
-
end
|
514
|
-
end
|
515
|
-
|
516
|
-
subject.validate_host(hosts, options)
|
517
|
-
end
|
518
|
-
|
519
361
|
it 'skips validation on cisco hosts' do
|
520
362
|
host = make_host('cisco-7', { stdout: stdout, platform: 'cisco_nexus-7-x86_64' })
|
521
|
-
expect(
|
363
|
+
expect(subject).to receive(:check_and_install_packages_if_needed).with(host, []).once
|
522
364
|
subject.validate_host(host, options)
|
523
365
|
end
|
524
366
|
end
|
@@ -528,22 +370,24 @@ describe Beaker do
|
|
528
370
|
|
529
371
|
shared_examples 'find domain name' do
|
530
372
|
it "finds the domain name" do
|
531
|
-
expect(
|
373
|
+
expect(subject.get_domain_name(host)).to be === "labs.lan"
|
532
374
|
end
|
533
375
|
end
|
534
376
|
|
535
377
|
context "on windows" do
|
536
|
-
let(:host)
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
378
|
+
let(:host) do
|
379
|
+
make_host('name', {
|
380
|
+
:platform => 'windows',
|
381
|
+
:is_cygwin => cygwin,
|
382
|
+
:stdout => "domain labs.lan d.labs.net dc1.labs.net labs.com\nnameserver 10.16.22.10\nnameserver 10.16.22.11",
|
383
|
+
})
|
384
|
+
end
|
541
385
|
|
542
386
|
context "with cygwin" do
|
543
387
|
let(:cygwin) { true }
|
544
388
|
|
545
389
|
before do
|
546
|
-
expect(
|
390
|
+
expect(Beaker::Command).to receive(:new).with("cat /cygdrive/c/Windows/System32/drivers/etc/hosts").once
|
547
391
|
end
|
548
392
|
|
549
393
|
include_examples 'find domain name'
|
@@ -553,22 +397,24 @@ describe Beaker do
|
|
553
397
|
let(:cygwin) { false }
|
554
398
|
|
555
399
|
before do
|
556
|
-
expect(
|
400
|
+
expect(Beaker::Command).to receive(:new).with('type C:\Windows\System32\drivers\etc\hosts').once
|
557
401
|
end
|
558
402
|
|
559
403
|
include_examples 'find domain name'
|
560
404
|
end
|
561
405
|
end
|
562
406
|
|
563
|
-
%w[
|
407
|
+
%w[centos redhat].each do |platform|
|
564
408
|
context "on platform '#{platform}'" do
|
565
|
-
let(:host)
|
566
|
-
|
567
|
-
|
568
|
-
|
409
|
+
let(:host) do
|
410
|
+
make_host('name', {
|
411
|
+
:platform => platform,
|
412
|
+
:stdout => stdout,
|
413
|
+
})
|
414
|
+
end
|
569
415
|
|
570
416
|
before do
|
571
|
-
expect(
|
417
|
+
expect(Beaker::Command).to receive(:new).with("cat /etc/resolv.conf").once
|
572
418
|
end
|
573
419
|
|
574
420
|
context "with a domain entry" do
|
@@ -598,28 +444,6 @@ describe Beaker do
|
|
598
444
|
end
|
599
445
|
end
|
600
446
|
|
601
|
-
context "get_ip" do
|
602
|
-
subject { dummy_class.new }
|
603
|
-
|
604
|
-
it "can exec the get_ip command" do
|
605
|
-
host = make_host('name', { :stdout => "192.168.2.130\n" } )
|
606
|
-
|
607
|
-
expect( Beaker::Command ).to receive( :new ).with( "ip a | awk '/global/{print$2}' | cut -d/ -f1 | head -1", [], {:prepend_cmds=>nil, :cmdexe=>false} ).once
|
608
|
-
|
609
|
-
expect( subject.get_ip( host ) ).to be === "192.168.2.130"
|
610
|
-
|
611
|
-
end
|
612
|
-
|
613
|
-
it "can exec the get_ip command with tail with vagrant hypervisor" do
|
614
|
-
host = make_host('name', { :stdout => "192.168.2.131\n", :hypervisor => "vagrant" } )
|
615
|
-
|
616
|
-
expect( Beaker::Command ).to receive( :new ).with( "ip a | awk '/global/{print$2}' | cut -d/ -f1 | tail -1", [], {:prepend_cmds=>nil, :cmdexe=>false} ).once
|
617
|
-
|
618
|
-
expect( subject.get_ip( host ) ).to be === "192.168.2.131"
|
619
|
-
end
|
620
|
-
|
621
|
-
end
|
622
|
-
|
623
447
|
context "set_etc_hosts" do
|
624
448
|
subject { dummy_class.new }
|
625
449
|
|
@@ -627,49 +451,46 @@ describe Beaker do
|
|
627
451
|
host = make_host('name', {})
|
628
452
|
etc_hosts = "127.0.0.1 localhost\n192.168.2.130 pe-ubuntu-lucid\n192.168.2.128 pe-centos6\n192.168.2.131 pe-debian6"
|
629
453
|
|
630
|
-
expect(
|
631
|
-
expect(
|
454
|
+
expect(Beaker::Command).to receive(:new).with("echo '#{etc_hosts}' >> /etc/hosts").once
|
455
|
+
expect(host).to receive(:exec).once
|
632
456
|
|
633
457
|
subject.set_etc_hosts(host, etc_hosts)
|
634
458
|
end
|
635
|
-
|
636
459
|
end
|
637
460
|
|
638
461
|
context "copy_ssh_to_root" do
|
639
462
|
subject { dummy_class.new }
|
640
463
|
|
641
464
|
it "can copy ssh to root in windows hosts with no cygwin" do
|
642
|
-
host = make_host(
|
643
|
-
expect(
|
465
|
+
host = make_host('testhost', { :platform => 'windows', :is_cygwin => false })
|
466
|
+
expect(Beaker::Command).to receive(:new).with("if exist .ssh (xcopy .ssh C:\\Users\\Administrator\\.ssh /s /e /y /i)").once
|
644
467
|
|
645
468
|
subject.copy_ssh_to_root(host, options)
|
646
469
|
end
|
647
|
-
|
648
470
|
end
|
649
471
|
|
650
472
|
context "package_proxy" do
|
651
|
-
|
652
473
|
subject { dummy_class.new }
|
653
474
|
|
654
475
|
proxyurl = "http://192.168.2.100:3128"
|
655
476
|
|
656
477
|
it "can set proxy config on a debian/ubuntu/cumulus host" do
|
657
|
-
host = make_host('name', { :platform => 'cumulus' }
|
478
|
+
host = make_host('name', { :platform => 'cumulus' })
|
658
479
|
|
659
|
-
expect(
|
660
|
-
expect(
|
480
|
+
expect(Beaker::Command).to receive(:new).with("echo 'Acquire::http::Proxy \"#{proxyurl}/\";' >> /etc/apt/apt.conf.d/10proxy").once
|
481
|
+
expect(host).to receive(:exec).once
|
661
482
|
|
662
|
-
subject.package_proxy(host, options.merge(
|
483
|
+
subject.package_proxy(host, options.merge({ 'package_proxy' => proxyurl }))
|
663
484
|
end
|
664
485
|
|
665
|
-
%w[
|
486
|
+
%w[centos redhat].each do |platform|
|
666
487
|
it "can set proxy config on a '#{platform}' host" do
|
667
|
-
host = make_host('name', { :platform => platform }
|
488
|
+
host = make_host('name', { :platform => platform })
|
668
489
|
|
669
|
-
expect(
|
670
|
-
expect(
|
490
|
+
expect(Beaker::Command).to receive(:new).with("echo 'proxy=#{proxyurl}/' >> /etc/yum.conf").once
|
491
|
+
expect(host).to receive(:exec).once
|
671
492
|
|
672
|
-
subject.package_proxy(host, options.merge(
|
493
|
+
subject.package_proxy(host, options.merge({ 'package_proxy' => proxyurl }))
|
673
494
|
end
|
674
495
|
end
|
675
496
|
end
|
@@ -723,70 +544,68 @@ describe Beaker do
|
|
723
544
|
|
724
545
|
it "skips an f5 host correctly" do
|
725
546
|
host = make_host('name', {
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
547
|
+
:platform => 'f5-stuff',
|
548
|
+
:ssh_env_file => 'ssh_env_file',
|
549
|
+
:is_cygwin => true,
|
550
|
+
})
|
730
551
|
opts = {
|
731
552
|
:env1_key => :env1_value,
|
732
|
-
:env2_key => :env2_value
|
553
|
+
:env2_key => :env2_value,
|
733
554
|
}
|
734
|
-
allow(
|
555
|
+
allow(host).to receive(:skip_set_env?).and_return('f5 say NO')
|
735
556
|
|
736
|
-
expect(
|
737
|
-
expect(
|
738
|
-
expect(
|
557
|
+
expect(subject).to receive(:construct_env).exactly(0).times
|
558
|
+
expect(Beaker::Command).to receive(:new).exactly(0).times
|
559
|
+
expect(host).to receive(:add_env_var).exactly(0).times
|
739
560
|
opts.each_pair do |key, value|
|
740
|
-
expect(
|
561
|
+
expect(host).to receive(:add_env_var).with(key, value).exactly(0).times
|
741
562
|
end
|
742
|
-
expect(
|
563
|
+
expect(host).to receive(:exec).exactly(0).times
|
743
564
|
|
744
|
-
subject.set_env(host, options.merge(
|
565
|
+
subject.set_env(host, options.merge(opts))
|
745
566
|
end
|
746
567
|
|
747
568
|
it 'skips a cisco host correctly' do
|
748
569
|
host = make_host('name', {
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
570
|
+
:platform => 'cisco_nexus-7-x86_64',
|
571
|
+
:ssh_env_file => 'ssh_env_file',
|
572
|
+
:is_cygwin => true,
|
573
|
+
})
|
753
574
|
opts = {
|
754
575
|
:env1_key => :env1_value,
|
755
|
-
:env2_key => :env2_value
|
576
|
+
:env2_key => :env2_value,
|
756
577
|
}
|
757
|
-
allow(
|
578
|
+
allow(host).to receive(:skip_set_env?).and_return('cisco say NO')
|
758
579
|
|
759
|
-
expect(
|
760
|
-
expect(
|
761
|
-
expect(
|
580
|
+
expect(subject).to receive(:construct_env).exactly(0).times
|
581
|
+
expect(Beaker::Command).to receive(:new).exactly(0).times
|
582
|
+
expect(host).to receive(:add_env_var).exactly(0).times
|
762
583
|
opts.each_pair do |key, value|
|
763
|
-
expect(
|
584
|
+
expect(host).to receive(:add_env_var).with(key, value).exactly(0).times
|
764
585
|
end
|
765
|
-
expect(
|
586
|
+
expect(host).to receive(:exec).exactly(0).times
|
766
587
|
|
767
|
-
subject.set_env(host, options.merge(
|
588
|
+
subject.set_env(host, options.merge(opts))
|
768
589
|
end
|
769
590
|
|
770
591
|
def test_host_ssh_calls(platform_name)
|
771
592
|
host = make_host('name', {
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
593
|
+
:platform => platform_name,
|
594
|
+
:ssh_env_file => 'ssh_env_file',
|
595
|
+
:is_cygwin => true,
|
596
|
+
})
|
776
597
|
opts = {
|
777
598
|
:env1_key => :env1_value,
|
778
|
-
:env2_key => :env2_value
|
599
|
+
:env2_key => :env2_value,
|
779
600
|
}
|
780
601
|
|
781
|
-
allow(
|
782
|
-
expect(
|
602
|
+
allow(host).to receive(:skip_set_env?).and_return(nil)
|
603
|
+
expect(subject).to receive(:construct_env).and_return(opts)
|
783
604
|
|
784
|
-
expect(
|
785
|
-
expect(
|
605
|
+
expect(host).to receive(:ssh_permit_user_environment)
|
606
|
+
expect(host).to receive(:ssh_set_user_environment)
|
786
607
|
|
787
|
-
subject.set_env(host, options.merge(
|
608
|
+
subject.set_env(host, options.merge(opts))
|
788
609
|
end
|
789
|
-
|
790
610
|
end
|
791
|
-
|
792
611
|
end
|