beaker 4.41.2 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +9 -0
  3. data/.github/workflows/release.yml +2 -2
  4. data/.github/workflows/test.yml +26 -13
  5. data/.rubocop.yml +23 -10
  6. data/.rubocop_todo.yml +34 -10
  7. data/CHANGELOG.md +16 -52
  8. data/Gemfile +12 -7
  9. data/HISTORY.md +605 -0
  10. data/Rakefile +99 -111
  11. data/acceptance/config/acceptance-options.rb +1 -1
  12. data/acceptance/config/base/acceptance-options.rb +2 -2
  13. data/acceptance/config/hypervisor/acceptance-options.rb +2 -2
  14. data/acceptance/config/subcommands/acceptance-options.rb +2 -2
  15. data/acceptance/fixtures/module/Rakefile +1 -1
  16. data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -12
  17. data/acceptance/fixtures/module/spec/classes/init_spec.rb +0 -1
  18. data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
  19. data/acceptance/lib/helpers/test_helper.rb +6 -5
  20. data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
  21. data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
  22. data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
  23. data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +1 -2
  24. data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
  25. data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +3 -1
  26. data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
  27. data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
  28. data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +19 -26
  29. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
  30. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
  31. data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +18 -13
  32. data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
  33. data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +22 -27
  34. data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +12 -16
  35. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +3 -4
  36. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +3 -3
  37. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +4 -4
  38. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -4
  39. data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +5 -5
  40. data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +3 -5
  41. data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
  42. data/acceptance/tests/base/dsl/structure_test.rb +5 -11
  43. data/acceptance/tests/base/host/file_test.rb +2 -2
  44. data/acceptance/tests/base/host/group_test.rb +0 -1
  45. data/acceptance/tests/base/host/host_test.rb +66 -63
  46. data/acceptance/tests/base/host/packages.rb +1 -2
  47. data/acceptance/tests/base/host/packages_unix.rb +0 -55
  48. data/acceptance/tests/base/host/user_test.rb +0 -1
  49. data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
  50. data/acceptance/tests/base/test_suite/export.rb +6 -9
  51. data/acceptance/tests/install/from_file.rb +2 -4
  52. data/acceptance/tests/load_path_bootstrap.rb +1 -1
  53. data/acceptance/tests/subcommands/destroy.rb +19 -21
  54. data/acceptance/tests/subcommands/exec.rb +0 -1
  55. data/acceptance/tests/subcommands/init.rb +2 -3
  56. data/acceptance/tests/subcommands/provision.rb +0 -1
  57. data/beaker.gemspec +4 -7
  58. data/docs/concepts/argument_processing_and_precedence.md +1 -10
  59. data/docs/how_to/debug_beaker_tests.md +12 -12
  60. data/docs/how_to/hosts/eos.md +2 -12
  61. data/docs/how_to/install_puppet.md +0 -18
  62. data/docs/how_to/the_beaker_dsl.md +0 -2
  63. data/lib/beaker/cli.rb +59 -68
  64. data/lib/beaker/command.rb +20 -28
  65. data/lib/beaker/command_factory.rb +3 -2
  66. data/lib/beaker/dsl/assertions.rb +6 -18
  67. data/lib/beaker/dsl/helpers/hocon_helpers.rb +3 -7
  68. data/lib/beaker/dsl/helpers/host_helpers.rb +62 -123
  69. data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
  70. data/lib/beaker/dsl/helpers/web_helpers.rb +19 -39
  71. data/lib/beaker/dsl/helpers.rb +2 -4
  72. data/lib/beaker/dsl/outcomes.rb +13 -15
  73. data/lib/beaker/dsl/patterns.rb +1 -3
  74. data/lib/beaker/dsl/roles.rb +17 -20
  75. data/lib/beaker/dsl/structure.rb +53 -65
  76. data/lib/beaker/dsl/test_tagging.rb +7 -10
  77. data/lib/beaker/dsl/wrappers.rb +15 -16
  78. data/lib/beaker/dsl.rb +2 -3
  79. data/lib/beaker/host/aix/exec.rb +1 -1
  80. data/lib/beaker/host/aix/file.rb +0 -1
  81. data/lib/beaker/host/aix/group.rb +1 -1
  82. data/lib/beaker/host/aix/user.rb +1 -1
  83. data/lib/beaker/host/aix.rb +3 -4
  84. data/lib/beaker/host/cisco.rb +27 -39
  85. data/lib/beaker/host/eos.rb +4 -30
  86. data/lib/beaker/host/freebsd/exec.rb +1 -1
  87. data/lib/beaker/host/freebsd/pkg.rb +3 -3
  88. data/lib/beaker/host/freebsd.rb +9 -12
  89. data/lib/beaker/host/mac/exec.rb +4 -4
  90. data/lib/beaker/host/mac/group.rb +7 -7
  91. data/lib/beaker/host/mac/pkg.rb +3 -106
  92. data/lib/beaker/host/mac/user.rb +2 -2
  93. data/lib/beaker/host/mac.rb +8 -9
  94. data/lib/beaker/host/pswindows/exec.rb +66 -70
  95. data/lib/beaker/host/pswindows/file.rb +3 -5
  96. data/lib/beaker/host/pswindows/group.rb +3 -3
  97. data/lib/beaker/host/pswindows/pkg.rb +12 -12
  98. data/lib/beaker/host/pswindows/user.rb +3 -3
  99. data/lib/beaker/host/pswindows.rb +4 -3
  100. data/lib/beaker/host/unix/exec.rb +81 -83
  101. data/lib/beaker/host/unix/file.rb +40 -45
  102. data/lib/beaker/host/unix/group.rb +1 -1
  103. data/lib/beaker/host/unix/pkg.rb +138 -401
  104. data/lib/beaker/host/unix/user.rb +2 -2
  105. data/lib/beaker/host/unix.rb +8 -11
  106. data/lib/beaker/host/windows/exec.rb +17 -17
  107. data/lib/beaker/host/windows/file.rb +3 -3
  108. data/lib/beaker/host/windows/group.rb +3 -3
  109. data/lib/beaker/host/windows/pkg.rb +3 -54
  110. data/lib/beaker/host/windows/user.rb +3 -3
  111. data/lib/beaker/host/windows.rb +12 -12
  112. data/lib/beaker/host.rb +76 -133
  113. data/lib/beaker/host_prebuilt_steps.rb +88 -196
  114. data/lib/beaker/hypervisor/noop.rb +2 -4
  115. data/lib/beaker/hypervisor.rb +44 -61
  116. data/lib/beaker/local_connection.rb +2 -4
  117. data/lib/beaker/logger.rb +68 -76
  118. data/lib/beaker/logger_junit.rb +21 -25
  119. data/lib/beaker/network_manager.rb +39 -42
  120. data/lib/beaker/options/command_line_parser.rb +12 -23
  121. data/lib/beaker/options/hosts_file_parser.rb +16 -25
  122. data/lib/beaker/options/options_file_parser.rb +3 -6
  123. data/lib/beaker/options/options_hash.rb +2 -7
  124. data/lib/beaker/options/parser.rb +86 -102
  125. data/lib/beaker/options/presets.rb +114 -123
  126. data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
  127. data/lib/beaker/options/validator.rb +26 -31
  128. data/lib/beaker/perf.rb +25 -30
  129. data/lib/beaker/platform.rb +26 -37
  130. data/lib/beaker/result.rb +7 -6
  131. data/lib/beaker/shared/error_handler.rb +8 -10
  132. data/lib/beaker/shared/fog_credentials.rb +5 -9
  133. data/lib/beaker/shared/host_manager.rb +36 -41
  134. data/lib/beaker/shared/options_resolver.rb +3 -7
  135. data/lib/beaker/shared/repetition.rb +2 -4
  136. data/lib/beaker/shared/semvar.rb +37 -41
  137. data/lib/beaker/shared/timed.rb +0 -3
  138. data/lib/beaker/shared.rb +1 -1
  139. data/lib/beaker/ssh_connection.rb +38 -47
  140. data/lib/beaker/subcommand.rb +17 -24
  141. data/lib/beaker/subcommands/subcommand_util.rb +4 -4
  142. data/lib/beaker/tasks/quick_start.rb +4 -9
  143. data/lib/beaker/tasks/rake_task.rb +25 -27
  144. data/lib/beaker/tasks/test.rb +4 -4
  145. data/lib/beaker/test_case.rb +16 -28
  146. data/lib/beaker/test_suite.rb +35 -39
  147. data/lib/beaker/test_suite_result.rb +45 -47
  148. data/lib/beaker/version.rb +1 -1
  149. data/lib/beaker.rb +6 -7
  150. data/spec/beaker/cli_spec.rb +121 -142
  151. data/spec/beaker/command_spec.rb +55 -59
  152. data/spec/beaker/dsl/assertions_spec.rb +36 -36
  153. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +110 -131
  154. data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
  155. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +22 -31
  156. data/spec/beaker/dsl/outcomes_spec.rb +14 -14
  157. data/spec/beaker/dsl/roles_spec.rb +125 -130
  158. data/spec/beaker/dsl/structure_spec.rb +172 -161
  159. data/spec/beaker/dsl/test_tagging_spec.rb +89 -90
  160. data/spec/beaker/dsl/wrappers_spec.rb +32 -33
  161. data/spec/beaker/host/aix_spec.rb +14 -14
  162. data/spec/beaker/host/cisco_spec.rb +84 -94
  163. data/spec/beaker/host/eos_spec.rb +15 -36
  164. data/spec/beaker/host/freebsd/exec_spec.rb +3 -6
  165. data/spec/beaker/host/freebsd/pkg_spec.rb +24 -27
  166. data/spec/beaker/host/mac/exec_spec.rb +2 -3
  167. data/spec/beaker/host/mac/group_spec.rb +48 -57
  168. data/spec/beaker/host/mac/user_spec.rb +54 -63
  169. data/spec/beaker/host/pswindows/exec_spec.rb +30 -32
  170. data/spec/beaker/host/pswindows/file_spec.rb +16 -16
  171. data/spec/beaker/host/pswindows/user_spec.rb +17 -23
  172. data/spec/beaker/host/pswindows_spec.rb +13 -13
  173. data/spec/beaker/host/unix/exec_spec.rb +75 -80
  174. data/spec/beaker/host/unix/file_spec.rb +66 -71
  175. data/spec/beaker/host/unix/pkg_spec.rb +150 -411
  176. data/spec/beaker/host/unix_spec.rb +11 -207
  177. data/spec/beaker/host/windows/exec_spec.rb +30 -32
  178. data/spec/beaker/host/windows/file_spec.rb +18 -19
  179. data/spec/beaker/host/windows/group_spec.rb +10 -12
  180. data/spec/beaker/host/windows/pkg_spec.rb +6 -9
  181. data/spec/beaker/host/windows/user_spec.rb +17 -23
  182. data/spec/beaker/host/windows_spec.rb +39 -39
  183. data/spec/beaker/host_prebuilt_steps_spec.rb +168 -349
  184. data/spec/beaker/host_spec.rb +204 -284
  185. data/spec/beaker/hypervisor/hypervisor_spec.rb +36 -61
  186. data/spec/beaker/localhost_connection_spec.rb +10 -11
  187. data/spec/beaker/logger_junit_spec.rb +19 -30
  188. data/spec/beaker/logger_spec.rb +153 -136
  189. data/spec/beaker/network_manager_spec.rb +23 -23
  190. data/spec/beaker/options/command_line_parser_spec.rb +20 -23
  191. data/spec/beaker/options/hosts_file_parser_spec.rb +30 -32
  192. data/spec/beaker/options/options_file_parser_spec.rb +4 -7
  193. data/spec/beaker/options/options_hash_spec.rb +4 -6
  194. data/spec/beaker/options/parser_spec.rb +167 -167
  195. data/spec/beaker/options/presets_spec.rb +7 -9
  196. data/spec/beaker/options/subcommand_options_parser_spec.rb +13 -14
  197. data/spec/beaker/options/validator_spec.rb +10 -11
  198. data/spec/beaker/perf_spec.rb +18 -21
  199. data/spec/beaker/platform_spec.rb +25 -50
  200. data/spec/beaker/shared/error_handler_spec.rb +7 -16
  201. data/spec/beaker/shared/fog_credentials_spec.rb +29 -29
  202. data/spec/beaker/shared/host_manager_spec.rb +50 -84
  203. data/spec/beaker/shared/options_resolver_spec.rb +9 -12
  204. data/spec/beaker/shared/repetition_spec.rb +17 -24
  205. data/spec/beaker/shared/semvar_spec.rb +21 -26
  206. data/spec/beaker/ssh_connection_spec.rb +76 -83
  207. data/spec/beaker/subcommand/subcommand_util_spec.rb +31 -33
  208. data/spec/beaker/subcommand_spec.rb +75 -77
  209. data/spec/beaker/test_case_spec.rb +25 -50
  210. data/spec/beaker/test_suite_spec.rb +147 -154
  211. data/spec/helpers.rb +39 -45
  212. data/spec/matchers.rb +8 -7
  213. data/spec/mocks.rb +1 -6
  214. data/spec/spec_helper.rb +0 -1
  215. metadata +8 -24
  216. data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
  217. data/acceptance/tests/base/external_resources_test.rb +0 -31
  218. 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( :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( :apt_cfg ) { Beaker::HostPrebuiltSteps::APT_CFG }
9
- let( :ips_pkg_repo ) { Beaker::HostPrebuiltSteps::IPS_PKG_REPO }
10
- let( :sync_cmd ) { Beaker::HostPrebuiltSteps::ROOT_KEYS_SYNC_CMD }
11
- let( :windows_pkgs ) { Beaker::HostPrebuiltSteps::WINDOWS_PACKAGES }
12
- let( :unix_only_pkgs ) { Beaker::HostPrebuiltSteps::UNIX_PACKAGES }
13
- let( :sles_only_pkgs ) { Beaker::HostPrebuiltSteps::SLES_PACKAGES }
14
- let( :rhel8_packages ) { Beaker::HostPrebuiltSteps::RHEL8_PACKAGES }
15
- let( :fedora_packages) { Beaker::HostPrebuiltSteps::FEDORA_PACKAGES }
16
- let(:amazon2023_packages) { Beaker::HostPrebuiltSteps::AMAZON2023_PACKAGES }
17
- let( :platform ) { @platform || 'unix' }
18
- let( :ip ) { "ip.address.0.0" }
19
- let( :stdout) { @stdout || ip }
20
- let( :hosts ) { hosts = make_hosts( { :stdout => stdout, :platform => platform } )
21
- hosts[0][:roles] = ['agent']
22
- hosts[1][:roles] = ['master', 'dashboard', 'agent', 'database']
23
- hosts[2][:roles] = ['agent']
24
- hosts }
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( { :platform => platform, :is_cygwin => non_cygwin} )
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 | command |
38
- expect( Beaker::Command ).to receive( :new ).with(command).exactly( 3 ).times
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( hosts, options )
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
- "sudo sed -i '' 's/#PermitRootLogin yes/PermitRootLogin Yes/g' /private/etc/ssh/sshd_config",
71
- "sudo sed -i '' 's/#PermitRootLogin no/PermitRootLogin Yes/g' /private/etc/ssh/sshd_config"
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
- "sudo sed -i '' 's/#PermitRootLogin yes/PermitRootLogin Yes/g' /private/etc/ssh/sshd_config",
76
- "sudo sed -i '' 's/#PermitRootLogin no/PermitRootLogin Yes/g' /private/etc/ssh/sshd_config"
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 | redhat_like |
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( { :platform => 'unix' } )
106
+ hosts = make_hosts({ :platform => 'unix' })
116
107
 
117
- expect( Beaker::Command ).to receive( :new ).with("ntpdate -u -t 20 #{ntpserver}").exactly( 3 ).times
108
+ expect(Beaker::Command).to receive(:new).with("ntpdate -u -t 20 #{ntpserver}").exactly(3).times
118
109
 
119
- subject.timesync( hosts, options )
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( { :platform => 'unix', :exit_code => [1, 0] } )
124
- allow( subject ).to receive( :sleep ).and_return(true)
114
+ hosts = make_hosts({ :platform => 'unix', :exit_code => [1, 0] })
115
+ allow(subject).to receive(:sleep).and_return(true)
125
116
 
126
- expect( Beaker::Command ).to receive( :new ).with("ntpdate -u -t 20 #{ntpserver}").exactly( 6 ).times
117
+ expect(Beaker::Command).to receive(:new).with("ntpdate -u -t 20 #{ntpserver}").exactly(6).times
127
118
 
128
- subject.timesync( hosts, options )
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( { :platform => 'unix', :exit_code => 1 } )
133
- allow( subject ).to receive( :sleep ).and_return(true)
123
+ hosts = make_hosts({ :platform => 'unix', :exit_code => 1 })
124
+ allow(subject).to receive(:sleep).and_return(true)
134
125
 
135
- expect( Beaker::Command ).to receive( :new ).with("ntpdate -u -t 20 #{ntpserver}").exactly( 5 ).times
126
+ expect(Beaker::Command).to receive(:new).with("ntpdate -u -t 20 #{ntpserver}").exactly(5).times
136
127
 
137
- expect{ subject.timesync( hosts, options ) }.to raise_error(/NTP date was not successful after/)
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( { :platform => 'windows' } )
132
+ hosts = make_hosts({ :platform => 'windows' })
142
133
 
143
- expect( Beaker::Command ).to receive( :new ).with("w32tm /register").exactly( 3 ).times
144
- expect( Beaker::Command ).to receive( :new ).with("net start w32time").exactly( 3 ).times
145
- expect( Beaker::Command ).to receive( :new ).with("w32tm /config /manualpeerlist:#{ntpserver} /syncfromflags:manual /update").exactly( 3 ).times
146
- expect( Beaker::Command ).to receive( :new ).with("w32tm /resync").exactly( 3 ).times
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( { :platform => 'unix' } )
169
+ hosts = make_hosts({ :platform => 'unix' })
189
170
 
190
- expect( Beaker::Command ).to receive( :new ).with("ntpdate -u -t 20 #{ntpserver_set}").exactly( 3 ).times
171
+ expect(Beaker::Command).to receive(:new).with("ntpdate -u -t 20 #{ntpserver_set}").exactly(3).times
191
172
 
192
- subject.timesync( hosts, options_ntp )
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( { :platform => 'windows' } )
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
- 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
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( { :platform => 'sles-13.1-x64' } )
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
- subject.timesync( hosts, options_ntp )
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( 'testhost', { :platform => 'ubuntu' } )
209
+ host = make_host('testhost', { :platform => 'ubuntu' })
231
210
 
232
- expect( Beaker::Command ).to receive( :new ).with("apt-get update").once
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( 'testhost', { :platform => 'debian' } )
240
-
241
- expect( Beaker::Command ).to receive( :new ).with("apt-get update").once
217
+ host = make_host('testhost', { :platform => 'debian' })
242
218
 
243
- subject.apt_get_update( host )
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( 'testhost', { :platform => 'cumulus' } )
225
+ host = make_host('testhost', { :platform => 'cumulus' })
249
226
 
250
- expect( Beaker::Command ).to receive( :new ).with("apt-get update").once
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( 'testhost', { :platform => 'windows' } )
258
-
259
- expect( Beaker::Command ).not_to receive( :new )
233
+ host = make_host('testhost', { :platform => 'windows' })
260
234
 
261
- subject.apt_get_update( host )
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( 'testhost', { :platform => 'windows' })
275
- tempfile = double( 'tempfile' )
276
- allow( tempfile ).to receive( :path ).and_return( tempfilepath )
277
- allow( Tempfile ).to receive( :open ).and_yield( tempfile )
278
- file = double( 'file' )
279
- allow( File ).to receive( :open ).and_yield( file )
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( file ).to receive( :puts ).with( content ).once
282
- expect( host ).to receive( :do_scp_to ).with( tempfilepath, filepath, subject.instance_variable_get( :@options ) ).once
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( Beaker::Command ).to receive( :new ).with( sync_cmd % "bash" ).exactly( 3 ).times
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
- expect( Beaker::Command ).to receive( :new ).with( sync_cmd % "env PATH=\"/usr/gnu/bin:$PATH\" bash" ).exactly( 3 ).times
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( host ).to receive( :check_for_package ).with( pkg ).once.and_return( false )
426
- expect( host ).to receive( :install_package ).with( pkg ).once
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( host ).to receive( :cygwin_installed? ).and_return( true )
440
- allow( host ).to receive( :is_cygwin? ).and_return( true )
441
- expect( host ).to receive( :check_for_package ).with( pkg ).once.and_return( false )
442
- expect( host ).to receive( :install_package ).with( pkg ).once
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( host ).to receive( :check_for_package).with( pkg ).once.and_return( false )
456
- expect( host ).to receive( :install_package ).with( pkg ).once
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( host ).to receive( :check_for_package).with( pkg ).once.and_return( false )
471
- expect( host ).to receive( :install_package ).with( pkg ).once
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( subject ).to receive( :check_and_install_packages_if_needed ).with(host, []).once
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( subject.get_domain_name( host ) ).to be === "labs.lan"
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) { make_host( 'name', {
537
- :platform => 'windows',
538
- :is_cygwin => cygwin,
539
- :stdout => "domain labs.lan d.labs.net dc1.labs.net labs.com\nnameserver 10.16.22.10\nnameserver 10.16.22.11",
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( Beaker::Command ).to receive( :new ).with( "cat /cygdrive/c/Windows/System32/drivers/etc/hosts" ).once
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( Beaker::Command ).to receive( :new ).with( 'type C:\Windows\System32\drivers\etc\hosts' ).once
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[amazon centos redhat].each do |platform|
407
+ %w[centos redhat].each do |platform|
564
408
  context "on platform '#{platform}'" do
565
- let(:host) { make_host( 'name', {
566
- :platform => platform,
567
- :stdout => stdout,
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( Beaker::Command ).to receive( :new ).with( "cat /etc/resolv.conf" ).once
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( Beaker::Command ).to receive( :new ).with( "echo '#{etc_hosts}' >> /etc/hosts" ).once
631
- expect( host ).to receive( :exec ).once
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( 'testhost', { :platform => 'windows', :is_cygwin => false })
643
- expect( Beaker::Command ).to receive( :new ).with( "if exist .ssh (xcopy .ssh C:\\Users\\Administrator\\.ssh /s /e /y /i)" ).once
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( Beaker::Command ).to receive( :new ).with( "echo 'Acquire::http::Proxy \"#{proxyurl}/\";' >> /etc/apt/apt.conf.d/10proxy" ).once
660
- expect( host ).to receive( :exec ).once
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( {'package_proxy' => proxyurl}) )
483
+ subject.package_proxy(host, options.merge({ 'package_proxy' => proxyurl }))
663
484
  end
664
485
 
665
- %w[amazon centos redhat].each do |platform|
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( Beaker::Command ).to receive( :new ).with( "echo 'proxy=#{proxyurl}/' >> /etc/yum.conf" ).once
670
- expect( host ).to receive( :exec ).once
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( {'package_proxy' => proxyurl}) )
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
- :platform => 'f5-stuff',
727
- :ssh_env_file => 'ssh_env_file',
728
- :is_cygwin => true,
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( host ).to receive( :skip_set_env? ).and_return('f5 say NO' )
555
+ allow(host).to receive(:skip_set_env?).and_return('f5 say NO')
735
556
 
736
- expect( subject ).to receive( :construct_env ).exactly(0).times
737
- expect( Beaker::Command ).to receive( :new ).exactly(0).times
738
- expect( host ).to receive( :add_env_var ).exactly(0).times
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( host ).to receive( :add_env_var ).with( key, value ).exactly(0).times
561
+ expect(host).to receive(:add_env_var).with(key, value).exactly(0).times
741
562
  end
742
- expect( host ).to receive( :exec ).exactly(0).times
563
+ expect(host).to receive(:exec).exactly(0).times
743
564
 
744
- subject.set_env(host, options.merge( opts ))
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
- :platform => 'cisco_nexus-7-x86_64',
750
- :ssh_env_file => 'ssh_env_file',
751
- :is_cygwin => true,
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( host ).to receive( :skip_set_env? ).and_return('cisco say NO' )
578
+ allow(host).to receive(:skip_set_env?).and_return('cisco say NO')
758
579
 
759
- expect( subject ).to receive( :construct_env ).exactly(0).times
760
- expect( Beaker::Command ).to receive( :new ).exactly(0).times
761
- expect( host ).to receive( :add_env_var ).exactly(0).times
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( host ).to receive( :add_env_var ).with( key, value ).exactly(0).times
584
+ expect(host).to receive(:add_env_var).with(key, value).exactly(0).times
764
585
  end
765
- expect( host ).to receive( :exec ).exactly(0).times
586
+ expect(host).to receive(:exec).exactly(0).times
766
587
 
767
- subject.set_env(host, options.merge( opts ))
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
- :platform => platform_name,
773
- :ssh_env_file => 'ssh_env_file',
774
- :is_cygwin => true,
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( host ).to receive( :skip_set_env? ).and_return( nil )
782
- expect( subject ).to receive( :construct_env ).and_return( opts )
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( host ).to receive( :ssh_permit_user_environment )
785
- expect( host ).to receive( :ssh_set_user_environment )
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( opts ))
608
+ subject.set_env(host, options.merge(opts))
788
609
  end
789
-
790
610
  end
791
-
792
611
  end