beaker 4.40.1 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) 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 +13 -11
  8. data/Gemfile +12 -7
  9. data/Rakefile +99 -111
  10. data/acceptance/config/acceptance-options.rb +1 -1
  11. data/acceptance/config/base/acceptance-options.rb +2 -2
  12. data/acceptance/config/hypervisor/acceptance-options.rb +2 -2
  13. data/acceptance/config/subcommands/acceptance-options.rb +2 -2
  14. data/acceptance/fixtures/module/Rakefile +1 -1
  15. data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -12
  16. data/acceptance/fixtures/module/spec/classes/init_spec.rb +0 -1
  17. data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
  18. data/acceptance/lib/helpers/test_helper.rb +4 -3
  19. data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
  20. data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
  21. data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
  22. data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +1 -2
  23. data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
  24. data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +3 -1
  25. data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
  26. data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
  27. data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +19 -26
  28. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
  29. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
  30. data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +18 -13
  31. data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
  32. data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +22 -27
  33. data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +12 -16
  34. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +3 -4
  35. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +3 -3
  36. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +4 -4
  37. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -4
  38. data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +5 -5
  39. data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +3 -5
  40. data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
  41. data/acceptance/tests/base/dsl/structure_test.rb +5 -11
  42. data/acceptance/tests/base/host/file_test.rb +2 -2
  43. data/acceptance/tests/base/host/group_test.rb +0 -1
  44. data/acceptance/tests/base/host/host_test.rb +66 -63
  45. data/acceptance/tests/base/host/packages.rb +1 -2
  46. data/acceptance/tests/base/host/packages_unix.rb +0 -55
  47. data/acceptance/tests/base/host/user_test.rb +0 -1
  48. data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
  49. data/acceptance/tests/base/test_suite/export.rb +6 -9
  50. data/acceptance/tests/install/from_file.rb +2 -4
  51. data/acceptance/tests/load_path_bootstrap.rb +1 -1
  52. data/acceptance/tests/subcommands/destroy.rb +19 -21
  53. data/acceptance/tests/subcommands/exec.rb +0 -1
  54. data/acceptance/tests/subcommands/init.rb +2 -3
  55. data/acceptance/tests/subcommands/provision.rb +0 -1
  56. data/beaker.gemspec +4 -7
  57. data/docs/concepts/argument_processing_and_precedence.md +1 -10
  58. data/docs/how_to/debug_beaker_tests.md +12 -12
  59. data/docs/how_to/hosts/eos.md +2 -12
  60. data/docs/how_to/install_puppet.md +0 -18
  61. data/docs/how_to/the_beaker_dsl.md +0 -2
  62. data/lib/beaker/cli.rb +59 -68
  63. data/lib/beaker/command.rb +20 -28
  64. data/lib/beaker/command_factory.rb +3 -2
  65. data/lib/beaker/dsl/assertions.rb +6 -18
  66. data/lib/beaker/dsl/helpers/hocon_helpers.rb +3 -7
  67. data/lib/beaker/dsl/helpers/host_helpers.rb +62 -123
  68. data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
  69. data/lib/beaker/dsl/helpers/web_helpers.rb +19 -39
  70. data/lib/beaker/dsl/helpers.rb +2 -4
  71. data/lib/beaker/dsl/outcomes.rb +13 -15
  72. data/lib/beaker/dsl/patterns.rb +1 -3
  73. data/lib/beaker/dsl/roles.rb +17 -20
  74. data/lib/beaker/dsl/structure.rb +53 -65
  75. data/lib/beaker/dsl/test_tagging.rb +7 -10
  76. data/lib/beaker/dsl/wrappers.rb +15 -16
  77. data/lib/beaker/dsl.rb +2 -3
  78. data/lib/beaker/host/aix/exec.rb +1 -1
  79. data/lib/beaker/host/aix/file.rb +0 -1
  80. data/lib/beaker/host/aix/group.rb +1 -1
  81. data/lib/beaker/host/aix/user.rb +1 -1
  82. data/lib/beaker/host/aix.rb +3 -4
  83. data/lib/beaker/host/cisco.rb +27 -39
  84. data/lib/beaker/host/eos.rb +4 -30
  85. data/lib/beaker/host/freebsd/exec.rb +1 -1
  86. data/lib/beaker/host/freebsd/pkg.rb +3 -3
  87. data/lib/beaker/host/freebsd.rb +9 -12
  88. data/lib/beaker/host/mac/exec.rb +4 -4
  89. data/lib/beaker/host/mac/group.rb +7 -7
  90. data/lib/beaker/host/mac/pkg.rb +3 -106
  91. data/lib/beaker/host/mac/user.rb +2 -2
  92. data/lib/beaker/host/mac.rb +8 -9
  93. data/lib/beaker/host/pswindows/exec.rb +66 -70
  94. data/lib/beaker/host/pswindows/file.rb +3 -5
  95. data/lib/beaker/host/pswindows/group.rb +3 -3
  96. data/lib/beaker/host/pswindows/pkg.rb +12 -12
  97. data/lib/beaker/host/pswindows/user.rb +3 -3
  98. data/lib/beaker/host/pswindows.rb +4 -3
  99. data/lib/beaker/host/unix/exec.rb +80 -82
  100. data/lib/beaker/host/unix/file.rb +38 -43
  101. data/lib/beaker/host/unix/group.rb +1 -1
  102. data/lib/beaker/host/unix/pkg.rb +154 -417
  103. data/lib/beaker/host/unix/user.rb +2 -2
  104. data/lib/beaker/host/unix.rb +8 -11
  105. data/lib/beaker/host/windows/exec.rb +17 -17
  106. data/lib/beaker/host/windows/file.rb +3 -3
  107. data/lib/beaker/host/windows/group.rb +3 -3
  108. data/lib/beaker/host/windows/pkg.rb +3 -54
  109. data/lib/beaker/host/windows/user.rb +3 -3
  110. data/lib/beaker/host/windows.rb +12 -12
  111. data/lib/beaker/host.rb +76 -133
  112. data/lib/beaker/host_prebuilt_steps.rb +93 -198
  113. data/lib/beaker/hypervisor/noop.rb +2 -4
  114. data/lib/beaker/hypervisor.rb +44 -61
  115. data/lib/beaker/local_connection.rb +2 -4
  116. data/lib/beaker/logger.rb +68 -76
  117. data/lib/beaker/logger_junit.rb +21 -25
  118. data/lib/beaker/network_manager.rb +39 -42
  119. data/lib/beaker/options/command_line_parser.rb +12 -23
  120. data/lib/beaker/options/hosts_file_parser.rb +16 -24
  121. data/lib/beaker/options/options_file_parser.rb +3 -6
  122. data/lib/beaker/options/options_hash.rb +2 -7
  123. data/lib/beaker/options/parser.rb +86 -102
  124. data/lib/beaker/options/presets.rb +114 -123
  125. data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
  126. data/lib/beaker/options/validator.rb +26 -31
  127. data/lib/beaker/perf.rb +22 -27
  128. data/lib/beaker/platform.rb +38 -46
  129. data/lib/beaker/result.rb +7 -6
  130. data/lib/beaker/shared/error_handler.rb +8 -10
  131. data/lib/beaker/shared/fog_credentials.rb +5 -9
  132. data/lib/beaker/shared/host_manager.rb +36 -41
  133. data/lib/beaker/shared/options_resolver.rb +3 -7
  134. data/lib/beaker/shared/repetition.rb +2 -4
  135. data/lib/beaker/shared/semvar.rb +37 -41
  136. data/lib/beaker/shared/timed.rb +0 -3
  137. data/lib/beaker/shared.rb +1 -1
  138. data/lib/beaker/ssh_connection.rb +38 -47
  139. data/lib/beaker/subcommand.rb +17 -24
  140. data/lib/beaker/subcommands/subcommand_util.rb +4 -4
  141. data/lib/beaker/tasks/quick_start.rb +4 -9
  142. data/lib/beaker/tasks/rake_task.rb +25 -27
  143. data/lib/beaker/tasks/test.rb +4 -4
  144. data/lib/beaker/test_case.rb +15 -27
  145. data/lib/beaker/test_suite.rb +35 -39
  146. data/lib/beaker/test_suite_result.rb +45 -47
  147. data/lib/beaker/version.rb +1 -1
  148. data/lib/beaker.rb +5 -6
  149. data/spec/beaker/cli_spec.rb +121 -142
  150. data/spec/beaker/command_spec.rb +55 -59
  151. data/spec/beaker/dsl/assertions_spec.rb +36 -36
  152. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +110 -131
  153. data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
  154. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +22 -31
  155. data/spec/beaker/dsl/outcomes_spec.rb +14 -14
  156. data/spec/beaker/dsl/roles_spec.rb +125 -130
  157. data/spec/beaker/dsl/structure_spec.rb +169 -158
  158. data/spec/beaker/dsl/test_tagging_spec.rb +89 -90
  159. data/spec/beaker/dsl/wrappers_spec.rb +32 -33
  160. data/spec/beaker/host/aix_spec.rb +14 -14
  161. data/spec/beaker/host/cisco_spec.rb +84 -94
  162. data/spec/beaker/host/eos_spec.rb +15 -36
  163. data/spec/beaker/host/freebsd/exec_spec.rb +3 -6
  164. data/spec/beaker/host/freebsd/pkg_spec.rb +24 -27
  165. data/spec/beaker/host/mac/exec_spec.rb +2 -3
  166. data/spec/beaker/host/mac/group_spec.rb +47 -56
  167. data/spec/beaker/host/mac/user_spec.rb +53 -62
  168. data/spec/beaker/host/pswindows/exec_spec.rb +30 -32
  169. data/spec/beaker/host/pswindows/file_spec.rb +16 -16
  170. data/spec/beaker/host/pswindows/user_spec.rb +17 -23
  171. data/spec/beaker/host/pswindows_spec.rb +13 -13
  172. data/spec/beaker/host/unix/exec_spec.rb +75 -80
  173. data/spec/beaker/host/unix/file_spec.rb +66 -73
  174. data/spec/beaker/host/unix/pkg_spec.rb +155 -401
  175. data/spec/beaker/host/unix_spec.rb +11 -207
  176. data/spec/beaker/host/windows/exec_spec.rb +30 -32
  177. data/spec/beaker/host/windows/file_spec.rb +18 -19
  178. data/spec/beaker/host/windows/group_spec.rb +10 -12
  179. data/spec/beaker/host/windows/pkg_spec.rb +6 -9
  180. data/spec/beaker/host/windows/user_spec.rb +17 -23
  181. data/spec/beaker/host/windows_spec.rb +39 -39
  182. data/spec/beaker/host_prebuilt_steps_spec.rb +172 -326
  183. data/spec/beaker/host_spec.rb +204 -284
  184. data/spec/beaker/hypervisor/hypervisor_spec.rb +36 -61
  185. data/spec/beaker/localhost_connection_spec.rb +10 -11
  186. data/spec/beaker/logger_junit_spec.rb +19 -30
  187. data/spec/beaker/logger_spec.rb +153 -136
  188. data/spec/beaker/network_manager_spec.rb +23 -23
  189. data/spec/beaker/options/command_line_parser_spec.rb +20 -23
  190. data/spec/beaker/options/hosts_file_parser_spec.rb +30 -32
  191. data/spec/beaker/options/options_file_parser_spec.rb +4 -7
  192. data/spec/beaker/options/options_hash_spec.rb +4 -6
  193. data/spec/beaker/options/parser_spec.rb +167 -167
  194. data/spec/beaker/options/presets_spec.rb +7 -9
  195. data/spec/beaker/options/subcommand_options_parser_spec.rb +13 -14
  196. data/spec/beaker/options/validator_spec.rb +10 -11
  197. data/spec/beaker/perf_spec.rb +18 -21
  198. data/spec/beaker/platform_spec.rb +25 -36
  199. data/spec/beaker/shared/error_handler_spec.rb +7 -16
  200. data/spec/beaker/shared/fog_credentials_spec.rb +29 -29
  201. data/spec/beaker/shared/host_manager_spec.rb +50 -84
  202. data/spec/beaker/shared/options_resolver_spec.rb +9 -12
  203. data/spec/beaker/shared/repetition_spec.rb +17 -24
  204. data/spec/beaker/shared/semvar_spec.rb +21 -26
  205. data/spec/beaker/ssh_connection_spec.rb +76 -83
  206. data/spec/beaker/subcommand/subcommand_util_spec.rb +31 -33
  207. data/spec/beaker/subcommand_spec.rb +75 -77
  208. data/spec/beaker/test_case_spec.rb +25 -50
  209. data/spec/beaker/test_suite_spec.rb +147 -154
  210. data/spec/helpers.rb +48 -53
  211. data/spec/matchers.rb +8 -7
  212. data/spec/mocks.rb +1 -6
  213. data/spec/spec_helper.rb +0 -1
  214. metadata +7 -24
  215. data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
  216. data/acceptance/tests/base/external_resources_test.rb +0 -31
  217. 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( :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( :platform ) { @platform || 'unix' }
17
- let( :ip ) { "ip.address.0.0" }
18
- let( :stdout) { @stdout || ip }
19
- let( :hosts ) { hosts = make_hosts( { :stdout => stdout, :platform => platform } )
20
- hosts[0][:roles] = ['agent']
21
- hosts[1][:roles] = ['master', 'dashboard', 'agent', 'database']
22
- hosts[2][:roles] = ['agent']
23
- hosts }
24
- 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 } }
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( { :platform => platform, :is_cygwin => non_cygwin} )
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 | command |
37
- 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
38
36
  end
39
37
 
40
- subject.enable_root_login( hosts, options )
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
- "sudo sed -i '' 's/#PermitRootLogin yes/PermitRootLogin Yes/g' /private/etc/ssh/sshd_config",
70
- "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",
71
69
  ]
72
70
 
73
71
  it_behaves_like 'enables_root_login', 'osx-10.13', [
74
- "sudo sed -i '' 's/#PermitRootLogin yes/PermitRootLogin Yes/g' /private/etc/ssh/sshd_config",
75
- "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",
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
- ['debian','ubuntu','cumulus'].each do | deb_like |
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 | redhat_like |
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( { :platform => 'unix' } )
106
+ hosts = make_hosts({ :platform => 'unix' })
110
107
 
111
- 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
112
109
 
113
- subject.timesync( hosts, options )
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( { :platform => 'unix', :exit_code => [1, 0] } )
118
- 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)
119
116
 
120
- 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
121
118
 
122
- subject.timesync( hosts, options )
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( { :platform => 'unix', :exit_code => 1 } )
127
- 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)
128
125
 
129
- 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
130
127
 
131
- 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/)
132
129
  end
133
130
 
134
131
  it "can sync time on windows hosts" do
135
- hosts = make_hosts( { :platform => 'windows' } )
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
- 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
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( { :platform => 'sles-13.1-x64' } )
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
- subject.timesync( hosts, options )
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( { :platform => 'unix' } )
169
+ hosts = make_hosts({ :platform => 'unix' })
175
170
 
176
- 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
177
172
 
178
- subject.timesync( hosts, options_ntp )
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( { :platform => 'windows' } )
177
+ hosts = make_hosts({ :platform => 'windows' })
183
178
 
184
- expect( Beaker::Command ).to receive( :new ).with("w32tm /register").exactly( 3 ).times
185
- expect( Beaker::Command ).to receive( :new ).with("net start w32time").exactly( 3 ).times
186
- expect( Beaker::Command ).to receive( :new ).with("w32tm /config /manualpeerlist:#{ntpserver_set} /syncfromflags:manual /update").exactly( 3 ).times
187
- expect( Beaker::Command ).to receive( :new ).with("w32tm /resync").exactly( 3 ).times
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( { :platform => 'sles-13.1-x64' } )
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
- subject.timesync( hosts, options_ntp )
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( 'testhost', { :platform => 'ubuntu' } )
217
-
218
- expect( Beaker::Command ).to receive( :new ).with("apt-get update").once
209
+ host = make_host('testhost', { :platform => 'ubuntu' })
219
210
 
220
- subject.apt_get_update( host )
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( 'testhost', { :platform => 'debian' } )
217
+ host = make_host('testhost', { :platform => 'debian' })
226
218
 
227
- expect( Beaker::Command ).to receive( :new ).with("apt-get update").once
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( 'testhost', { :platform => 'cumulus' } )
235
-
236
- expect( Beaker::Command ).to receive( :new ).with("apt-get update").once
225
+ host = make_host('testhost', { :platform => 'cumulus' })
237
226
 
238
- subject.apt_get_update( host )
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( 'testhost', { :platform => 'windows' } )
233
+ host = make_host('testhost', { :platform => 'windows' })
244
234
 
245
- expect( Beaker::Command ).not_to receive( :new )
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( 'testhost', { :platform => 'windows' })
261
- tempfile = double( 'tempfile' )
262
- allow( tempfile ).to receive( :path ).and_return( tempfilepath )
263
- allow( Tempfile ).to receive( :open ).and_yield( tempfile )
264
- file = double( 'file' )
265
- 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)
266
254
 
267
- expect( file ).to receive( :puts ).with( content ).once
268
- 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
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( Beaker::Command ).to receive( :new ).with( sync_cmd % "bash" ).exactly( 3 ).times
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
- expect( Beaker::Command ).to receive( :new ).with( sync_cmd % "env PATH=\"/usr/gnu/bin:$PATH\" bash" ).exactly( 3 ).times
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( host ).to receive( :check_for_package ).with( pkg ).once.and_return( false )
412
- 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
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( host ).to receive( :cygwin_installed? ).and_return( true )
426
- allow( host ).to receive( :is_cygwin? ).and_return( true )
427
- expect( host ).to receive( :check_for_package ).with( pkg ).once.and_return( false )
428
- 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
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( host ).to receive( :check_for_package).with( pkg ).once.and_return( false )
442
- 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
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( host ).to receive( :check_for_package).with( pkg ).once.and_return( false )
457
- 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
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( 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
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( subject.get_domain_name( host ) ).to be === "labs.lan"
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) { make_host( 'name', {
510
- :platform => 'windows',
511
- :is_cygwin => cygwin,
512
- :stdout => "domain labs.lan d.labs.net dc1.labs.net labs.com\nnameserver 10.16.22.10\nnameserver 10.16.22.11",
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( 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
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( 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
530
401
  end
531
402
 
532
403
  include_examples 'find domain name'
533
404
  end
534
405
  end
535
406
 
536
- ['centos','redhat'].each do |platform|
407
+ %w[centos redhat].each do |platform|
537
408
  context "on platform '#{platform}'" do
538
- let(:host) { make_host( 'name', {
539
- :platform => platform,
540
- :stdout => stdout,
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( Beaker::Command ).to receive( :new ).with( "cat /etc/resolv.conf" ).once
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( Beaker::Command ).to receive( :new ).with( "echo '#{etc_hosts}' >> /etc/hosts" ).once
604
- 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
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( 'testhost', { :platform => 'windows', :is_cygwin => false })
616
- 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
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( Beaker::Command ).to receive( :new ).with( "echo 'Acquire::http::Proxy \"#{proxyurl}/\";' >> /etc/apt/apt.conf.d/10proxy" ).once
633
- 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
634
482
 
635
- subject.package_proxy(host, options.merge( {'package_proxy' => proxyurl}) )
483
+ subject.package_proxy(host, options.merge({ 'package_proxy' => proxyurl }))
636
484
  end
637
485
 
638
- ['centos','redhat'].each do |platform|
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( Beaker::Command ).to receive( :new ).with( "echo 'proxy=#{proxyurl}/' >> /etc/yum.conf" ).once
643
- 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
644
492
 
645
- subject.package_proxy(host, options.merge( {'package_proxy' => proxyurl}) )
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
- :platform => 'f5-stuff',
700
- :ssh_env_file => 'ssh_env_file',
701
- :is_cygwin => true,
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( host ).to receive( :skip_set_env? ).and_return('f5 say NO' )
555
+ allow(host).to receive(:skip_set_env?).and_return('f5 say NO')
708
556
 
709
- expect( subject ).to receive( :construct_env ).exactly(0).times
710
- expect( Beaker::Command ).to receive( :new ).exactly(0).times
711
- 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
712
560
  opts.each_pair do |key, value|
713
- 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
714
562
  end
715
- expect( host ).to receive( :exec ).exactly(0).times
563
+ expect(host).to receive(:exec).exactly(0).times
716
564
 
717
- subject.set_env(host, options.merge( opts ))
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
- :platform => 'cisco_nexus-7-x86_64',
723
- :ssh_env_file => 'ssh_env_file',
724
- :is_cygwin => true,
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( host ).to receive( :skip_set_env? ).and_return('cisco say NO' )
578
+ allow(host).to receive(:skip_set_env?).and_return('cisco say NO')
731
579
 
732
- expect( subject ).to receive( :construct_env ).exactly(0).times
733
- expect( Beaker::Command ).to receive( :new ).exactly(0).times
734
- 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
735
583
  opts.each_pair do |key, value|
736
- 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
737
585
  end
738
- expect( host ).to receive( :exec ).exactly(0).times
586
+ expect(host).to receive(:exec).exactly(0).times
739
587
 
740
- subject.set_env(host, options.merge( opts ))
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
- :platform => platform_name,
746
- :ssh_env_file => 'ssh_env_file',
747
- :is_cygwin => true,
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( host ).to receive( :skip_set_env? ).and_return( nil )
755
- 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)
756
604
 
757
- expect( host ).to receive( :ssh_permit_user_environment )
758
- 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)
759
607
 
760
- subject.set_env(host, options.merge( opts ))
608
+ subject.set_env(host, options.merge(opts))
761
609
  end
762
-
763
610
  end
764
-
765
611
  end