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