beaker 4.41.2 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -3,32 +3,32 @@ require 'spec_helper'
3
3
  module PSWindows
4
4
  describe Host do
5
5
  let(:options) { @options ? @options : {} }
6
- let(:platform) {
6
+ let(:platform) do
7
7
  if @platform
8
- { :platform => Beaker::Platform.new( @platform) }
8
+ { :platform => Beaker::Platform.new(@platform) }
9
9
  else
10
- { :platform => Beaker::Platform.new( 'windows-vers-arch-extra' ) }
10
+ { :platform => Beaker::Platform.new('windows-vers-arch-extra') }
11
11
  end
12
- }
13
- let(:host) {
12
+ end
13
+ let(:host) do
14
14
  opts = options.merge(platform)
15
15
  opts[:is_cygwin] = false
16
- make_host( 'name', opts )
17
- }
16
+ make_host('name', opts)
17
+ end
18
18
 
19
19
  describe '#external_copy_base' do
20
20
  it 'returns previously calculated value if set' do
21
- external_copy_base_before = host.instance_variable_get( :@external_copy_base )
21
+ external_copy_base_before = host.instance_variable_get(:@external_copy_base)
22
22
  test_value = :testn8391
23
- host.instance_variable_set( :@external_copy_base, test_value )
23
+ host.instance_variable_set(:@external_copy_base, test_value)
24
24
 
25
- expect( host ).not_to receive( :execute )
26
- expect( host.external_copy_base ).to be === test_value
27
- host.instance_variable_set( :@external_copy_base, external_copy_base_before )
25
+ expect(host).not_to receive(:execute)
26
+ expect(host.external_copy_base).to be === test_value
27
+ host.instance_variable_set(:@external_copy_base, external_copy_base_before)
28
28
  end
29
29
 
30
30
  it 'calls the correct command if unset' do
31
- expect( host ).to receive( :execute ).with( /^for\ .*ALLUSERSPROFILE.*\%\~I$/ )
31
+ expect(host).to receive(:execute).with(/^for\ .*ALLUSERSPROFILE.*\%\~I$/)
32
32
  host.external_copy_base
33
33
  end
34
34
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Beaker
4
-
5
4
  describe Unix::Exec do
6
5
  class UnixExecTest
7
6
  include Unix::Exec
@@ -18,19 +17,17 @@ module Beaker
18
17
  def to_s
19
18
  "me"
20
19
  end
21
-
22
20
  end
23
21
 
24
22
  let(:opts) { @opts || {} }
25
- let(:logger) { double( 'logger' ).as_null_object }
23
+ let(:logger) { double('logger').as_null_object }
26
24
  let(:instance) { UnixExecTest.new(opts, logger) }
27
25
 
28
26
  context "rm" do
29
-
30
27
  it "deletes" do
31
28
  path = '/path/to/delete'
32
- expect( instance ).to receive(:execute).with("rm -rf #{path}").and_return(0)
33
- expect( instance.rm_rf(path) ).to be === 0
29
+ expect(instance).to receive(:execute).with("rm -rf #{path}").and_return(0)
30
+ expect(instance.rm_rf(path)).to be === 0
34
31
  end
35
32
  end
36
33
 
@@ -39,15 +36,14 @@ module Beaker
39
36
  let(:destination) { '/destination/path/of/content' }
40
37
 
41
38
  it 'rm first' do
42
- expect( instance ).to receive(:execute).with("rm -rf #{destination}").and_return(0)
43
- expect( instance ).to receive(:execute).with("mv #{origin} #{destination}").and_return(0)
44
- expect( instance.mv(origin, destination) ).to be === 0
45
-
39
+ expect(instance).to receive(:execute).with("rm -rf #{destination}").and_return(0)
40
+ expect(instance).to receive(:execute).with("mv #{origin} #{destination}").and_return(0)
41
+ expect(instance.mv(origin, destination)).to be === 0
46
42
  end
47
43
 
48
44
  it 'does not rm' do
49
- expect( instance ).to receive(:execute).with("mv #{origin} #{destination}").and_return(0)
50
- expect( instance.mv(origin, destination, false) ).to be === 0
45
+ expect(instance).to receive(:execute).with("mv #{origin} #{destination}").and_return(0)
46
+ expect(instance.mv(origin, destination, false)).to be === 0
51
47
  end
52
48
  end
53
49
 
@@ -55,36 +51,36 @@ module Beaker
55
51
  it 'calls execute with touch and timestamp' do
56
52
  time = '190101010000'
57
53
  path = '/path/to/file'
58
- expect( instance ).to receive(:execute).with("/bin/touch -mt #{time} #{path}").and_return(0)
54
+ expect(instance).to receive(:execute).with("/bin/touch -mt #{time} #{path}").and_return(0)
59
55
 
60
56
  instance.modified_at(path, time)
61
57
  end
62
58
  end
63
59
 
64
60
  describe '#environment_string' do
65
- let(:host) { {'pathseparator' => ':'} }
61
+ let(:host) { { 'pathseparator' => ':' } }
66
62
 
67
63
  it 'returns a blank string if theres no env' do
68
- expect( instance ).not_to receive( :is_powershell? )
69
- expect( instance.environment_string( {} ) ).to be == ''
64
+ expect(instance).not_to receive(:is_powershell?)
65
+ expect(instance.environment_string({})).to be == ''
70
66
  end
71
67
 
72
68
  it 'takes an env hash with var_name/value pairs' do
73
- expect( instance.environment_string( {:HOME => '/', :http_proxy => 'http://foo'} ) ).
74
- to be == 'env HOME="/" http_proxy="http://foo" HTTP_PROXY="http://foo"'
69
+ expect(instance.environment_string({ :HOME => '/', :http_proxy => 'http://foo' }))
70
+ .to be == 'env HOME="/" http_proxy="http://foo" HTTP_PROXY="http://foo"'
75
71
  end
76
72
 
77
73
  it 'takes an env hash with var_name/value[Array] pairs' do
78
- expect( instance.environment_string( {:LD_PATH => ['/', '/tmp']}) ).
79
- to be == "env LD_PATH=\"/:/tmp\""
74
+ expect(instance.environment_string({ :LD_PATH => ['/', '/tmp'] }))
75
+ .to be == "env LD_PATH=\"/:/tmp\""
80
76
  end
81
77
  end
82
78
 
83
79
  describe '#ssh_permit_user_environment' do
84
80
  context 'When called without error' do
85
- let(:directory) {'/directory'}
86
- let(:ssh_command) {"echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"}
87
- let(:ssh_move) {"mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"}
81
+ let(:directory) { '/directory' }
82
+ let(:ssh_command) { "echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit" }
83
+ let(:ssh_move) { "mv #{directory}/sshd_config.permit /etc/ssh/sshd_config" }
88
84
 
89
85
  platforms = PlatformHelpers::SYSTEMDPLATFORMS + PlatformHelpers::DEBIANPLATFORMS + PlatformHelpers::SYSTEMVPLATFORMS
90
86
 
@@ -96,16 +92,16 @@ module Beaker
96
92
  expect(Beaker::Command).to receive(:new).with(ssh_move)
97
93
  expect(Beaker::Command).to receive(:new).with(ssh_command)
98
94
  expect(instance).to receive(:ssh_service_restart)
99
- expect{instance.ssh_permit_user_environment}.not_to raise_error
95
+ expect { instance.ssh_permit_user_environment }.not_to raise_error
100
96
  end
101
97
  end
102
98
  end
103
99
 
104
100
  it 'raises an error on unsupported platforms' do
105
101
  opts['platform'] = 'notarealthing01-parts-arch'
106
- expect {
102
+ expect do
107
103
  instance.ssh_permit_user_environment
108
- }.to raise_error( ArgumentError, /#{opts['platform']}/ )
104
+ end.to raise_error(ArgumentError, /#{opts['platform']}/)
109
105
  end
110
106
  end
111
107
 
@@ -115,7 +111,7 @@ module Beaker
115
111
  opts['platform'] = platform
116
112
  expect(instance).to receive(:exec)
117
113
  expect(Beaker::Command).to receive(:new).with("systemctl restart sshd.service")
118
- expect{instance.ssh_service_restart}.not_to raise_error
114
+ expect { instance.ssh_service_restart }.not_to raise_error
119
115
  end
120
116
  end
121
117
 
@@ -124,7 +120,7 @@ module Beaker
124
120
  opts['platform'] = platform
125
121
  expect(instance).to receive(:exec)
126
122
  expect(Beaker::Command).to receive(:new).with("service ssh restart")
127
- expect{instance.ssh_service_restart}.not_to raise_error
123
+ expect { instance.ssh_service_restart }.not_to raise_error
128
124
  end
129
125
  end
130
126
 
@@ -133,37 +129,37 @@ module Beaker
133
129
  opts['platform'] = "#{platform}-arch"
134
130
  expect(instance).to receive(:exec)
135
131
  expect(Beaker::Command).to receive(:new).with("/sbin/service sshd restart")
136
- expect{instance.ssh_service_restart}.not_to raise_error
132
+ expect { instance.ssh_service_restart }.not_to raise_error
137
133
  end
138
134
  end
139
135
 
140
136
  it 'raises an error on unsupported platforms' do
141
137
  opts['platform'] = 'notarealthing02-parts-arch'
142
- expect {
138
+ expect do
143
139
  instance.ssh_service_restart
144
- }.to raise_error( ArgumentError, /#{opts['platform']}/ )
140
+ end.to raise_error(ArgumentError, /#{opts['platform']}/)
145
141
  end
146
142
  end
147
143
 
148
144
  describe '#prepend_commands' do
149
145
  it 'returns the pc parameter unchanged for non-cisco platforms' do
150
- allow( instance ).to receive( :[] ).with( :platform ).and_return( 'notcisco' )
146
+ allow(instance).to receive(:[]).with(:platform).and_return('notcisco')
151
147
  answer_prepend_commands = 'pc_param_unchanged_13579'
152
- answer_test = instance.prepend_commands( 'fake_cmd', answer_prepend_commands )
153
- expect( answer_test ).to be === answer_prepend_commands
148
+ answer_test = instance.prepend_commands('fake_cmd', answer_prepend_commands)
149
+ expect(answer_test).to be === answer_prepend_commands
154
150
  end
155
151
  end
156
152
 
157
153
  describe '#selinux_enabled?' do
158
154
  it 'calls selinuxenabled and selinux is enabled' do
159
155
  expect(Beaker::Command).to receive(:new).with("sudo selinuxenabled").and_return(0)
160
- expect(instance).to receive(:exec).with(0, :accept_all_exit_codes => true).and_return(generate_result("test", {:exit_code => 0}))
156
+ expect(instance).to receive(:exec).with(0, :accept_all_exit_codes => true).and_return(generate_result("test", { :exit_code => 0 }))
161
157
  expect(instance.selinux_enabled?).to be === true
162
158
  end
163
159
 
164
160
  it 'calls selinuxenabled and selinux is not enabled' do
165
161
  expect(Beaker::Command).to receive(:new).with("sudo selinuxenabled").and_return(1)
166
- expect(instance).to receive(:exec).with(1, :accept_all_exit_codes => true).and_return(generate_result("test", {:exit_code => 1}))
162
+ expect(instance).to receive(:exec).with(1, :accept_all_exit_codes => true).and_return(generate_result("test", { :exit_code => 1 }))
167
163
  expect(instance.selinux_enabled?).to be === false
168
164
  end
169
165
  end
@@ -178,14 +174,14 @@ module Beaker
178
174
  :success => " system boot #{year}-05-13 03:52",
179
175
  },
180
176
  :last => {
181
- :initial => <<~LAST_F,
177
+ :initial => <<~LAST_F,
182
178
  reboot system boot 2.6.32-754.29.1. Tue May 5 17:34:52 #{year} - Tue May 5 17:52:48 #{year} (00:17)
183
179
  reboot system boot 2.6.32-754.29.1. Mon May 4 18:45:43 #{year} - Mon May 5 05:35:44 #{year} (4+01:50)
184
- LAST_F
185
- :success => <<~LAST_F,
180
+ LAST_F
181
+ :success => <<~LAST_F,
186
182
  reboot system boot 2.6.32-754.29.1. Tue May 5 17:52:48 #{year} - Tue May 5 17:52:49 #{year} (00:17)
187
183
  reboot system boot 2.6.32-754.29.1. Mon May 4 18:45:43 #{year} - Mon May 5 05:35:44 #{year} (4+01:50)
188
- LAST_F
184
+ LAST_F
189
185
  },
190
186
  },
191
187
  :centos7 => {
@@ -194,14 +190,14 @@ module Beaker
194
190
  :success => " system boot #{year}-05-13 03:52",
195
191
  },
196
192
  :last => {
197
- :initial => <<~LAST_F,
193
+ :initial => <<~LAST_F,
198
194
  reboot system boot 3.10.0-1127.el7. Tue May 5 17:34:52 #{year} - Tue May 5 17:52:48 #{year} (00:17)
199
195
  reboot system boot 3.10.0-1127.el7. Mon May 4 18:45:43 #{year} - Mon May 5 05:35:44 #{year} (4+01:50)
200
- LAST_F
201
- :success => <<~LAST_F,
196
+ LAST_F
197
+ :success => <<~LAST_F,
202
198
  reboot system boot 3.10.0-1127.el7. Tue May 5 17:52:48 #{year} - Tue May 5 17:52:49 #{year} (00:17)
203
199
  reboot system boot 3.10.0-1127.el7. Mon May 4 18:45:43 #{year} - Mon May 5 05:35:44 #{year} (4+01:50)
204
- LAST_F
200
+ LAST_F
205
201
  },
206
202
  },
207
203
  :centos8 => {
@@ -210,14 +206,14 @@ module Beaker
210
206
  :success => " system boot #{year}-05-13 03:52",
211
207
  },
212
208
  :last => {
213
- :initial => <<~LAST_F,
209
+ :initial => <<~LAST_F,
214
210
  reboot system boot 4.18.0-147.8.1.e Tue May 5 17:34:52 #{year} still running
215
211
  reboot system boot 4.18.0-147.8.1.e Mon May 4 17:41:27 #{year} - Tue May 5 17:00:00 #{year} (5+00:11)
216
- LAST_F
217
- :success => <<~LAST_F,
212
+ LAST_F
213
+ :success => <<~LAST_F,
218
214
  reboot system boot 4.18.0-147.8.1.e Tue May 5 17:34:53 #{year} still running
219
215
  reboot system boot 4.18.0-147.8.1.e Mon May 4 17:41:27 #{year} - Tue May 5 17:00:00 #{year} (5+00:11)
220
- LAST_F
216
+ LAST_F
221
217
  },
222
218
  },
223
219
  :freebsd => {
@@ -225,15 +221,15 @@ module Beaker
225
221
  :who => {
226
222
  :initial => ' system boot May 13 03:51',
227
223
  :success => ' system boot May 13 03:52',
228
- }
224
+ },
229
225
  },
230
226
  }
231
227
 
232
228
  # no-op response
233
- let(:response) { double( 'response' ) }
234
- let(:boot_time_initial_response) { double( 'response' ) }
229
+ let(:response) { double('response') }
230
+ let(:boot_time_initial_response) { double('response') }
235
231
 
236
- let(:boot_time_success_response) { double( 'response' ) }
232
+ let(:boot_time_success_response) { double('response') }
237
233
  let(:sleep_time) { 10 }
238
234
 
239
235
  before do
@@ -259,46 +255,46 @@ module Beaker
259
255
  it 'passes with defaults' do
260
256
  expect(instance).to receive(:sleep).with(sleep_time)
261
257
  # bypass shutdown command itself
262
- expect(instance).to receive( :exec ).with(:shutdown_command_stub, anything).and_return(response)
263
- expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
258
+ expect(instance).to receive(:exec).with(:shutdown_command_stub, anything).and_return(response)
259
+ expect(instance).to receive(:exec).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
264
260
  # allow the second boot_time and the hash arguments in exec
265
- expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_success_response).once
261
+ expect(instance).to receive(:exec).with(:boot_time_command_stub, anything).and_return(boot_time_success_response).once
266
262
 
267
- expect(instance.reboot).to be(nil)
263
+ expect(instance.reboot).to be_nil
268
264
  end
269
265
 
270
266
  it 'passes with wait_time_parameter' do
271
267
  expect(instance).to receive(:sleep).with(10)
272
268
  # bypass shutdown command itself
273
- expect(instance).to receive( :exec ).with(:shutdown_command_stub, anything).and_return(response).once
274
- expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
269
+ expect(instance).to receive(:exec).with(:shutdown_command_stub, anything).and_return(response).once
270
+ expect(instance).to receive(:exec).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
275
271
  # allow the second boot_time and the hash arguments in exec
276
- expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_success_response).once
272
+ expect(instance).to receive(:exec).with(:boot_time_command_stub, anything).and_return(boot_time_success_response).once
277
273
 
278
- expect(instance.reboot(10)).to be(nil)
274
+ expect(instance.reboot(10)).to be_nil
279
275
  end
280
276
 
281
277
  it 'passes with max_connection_tries parameter' do
282
278
  expect(instance).to receive(:sleep).with(sleep_time)
283
279
  # bypass shutdown command itself
284
- expect(instance).to receive( :exec ).with(:shutdown_command_stub, anything).and_return(response).once
285
- expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
280
+ expect(instance).to receive(:exec).with(:shutdown_command_stub, anything).and_return(response).once
281
+ expect(instance).to receive(:exec).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
286
282
  # allow the second boot_time and the hash arguments in exec
287
- expect(instance).to receive( :exec ).with(:boot_time_command_stub, hash_including(:max_connection_tries => 20)).and_return(boot_time_success_response).once
283
+ expect(instance).to receive(:exec).with(:boot_time_command_stub, hash_including(:max_connection_tries => 20)).and_return(boot_time_success_response).once
288
284
 
289
- expect(instance.reboot(sleep_time, 20)).to be(nil)
285
+ expect(instance.reboot(sleep_time, 20)).to be_nil
290
286
  end
291
287
 
292
288
  context 'command errors' do
293
289
  before do
294
- allow(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).at_least(:once)
290
+ allow(instance).to receive(:exec).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).at_least(:once)
295
291
  end
296
292
 
297
293
  it 'raises a reboot failure when command fails' do
298
294
  expect(instance).to receive(:sleep).at_least(:once)
299
295
  expect(instance).to receive(:exec).with(:shutdown_command_stub, anything).and_raise(Host::CommandFailure).at_least(:once)
300
296
 
301
- expect{ instance.reboot }.to raise_error(Beaker::Host::CommandFailure)
297
+ expect { instance.reboot }.to raise_error(Beaker::Host::CommandFailure)
302
298
  end
303
299
 
304
300
  it 'raises a reboot failure when we receive an unexpected error' do
@@ -314,7 +310,7 @@ module Beaker
314
310
 
315
311
  it 'raises a reboot failure' do
316
312
  # Handle the 'retry'
317
- allow(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).at_least(:once)
313
+ allow(instance).to receive(:exec).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).at_least(:once)
318
314
 
319
315
  expect(instance).not_to receive(:sleep)
320
316
 
@@ -327,11 +323,11 @@ module Beaker
327
323
 
328
324
  it 'raises a reboot failure' do
329
325
  expect(instance).to receive(:exec).with(:shutdown_command_stub, anything).and_return(response).once
330
- expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
326
+ expect(instance).to receive(:exec).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
331
327
  # allow the second boot_time and the hash arguments in exec, repeated 10 times by default
332
- expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_success_response).at_least(:once)
328
+ expect(instance).to receive(:exec).with(:boot_time_command_stub, anything).and_return(boot_time_success_response).at_least(:once)
333
329
 
334
- expect { instance.reboot(10,9,1) }.to raise_error(Beaker::Host::RebootWarning, /Found no valid times in .*/)
330
+ expect { instance.reboot(10, 9, 1) }.to raise_error(Beaker::Host::RebootWarning, /Found no valid times in .*/)
335
331
  end
336
332
  end
337
333
  end
@@ -351,10 +347,10 @@ module Beaker
351
347
  it 'raises RebootFailure' do
352
348
  expect(instance).to receive(:sleep).with(sleep_time)
353
349
  # bypass shutdown command itself
354
- expect(instance).to receive( :exec ).with(:shutdown_command_stub, anything).and_return(response).once
350
+ expect(instance).to receive(:exec).with(:shutdown_command_stub, anything).and_return(response).once
355
351
 
356
- expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
357
- expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_success_response).once
352
+ expect(instance).to receive(:exec).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
353
+ expect(instance).to receive(:exec).with(:boot_time_command_stub, anything).and_return(boot_time_success_response).once
358
354
 
359
355
  expect { instance.reboot }.to raise_error(Beaker::Host::RebootFailure, /Boot time did not reset/)
360
356
  end
@@ -362,9 +358,9 @@ module Beaker
362
358
  it 'raises RebootFailure if the number of retries is changed' do
363
359
  expect(instance).to receive(:sleep).with(sleep_time)
364
360
  # bypass shutdown command itself
365
- expect(instance).to receive( :exec ).with(:shutdown_command_stub, anything).and_return(response).once
366
- expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
367
- expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_success_response).once
361
+ expect(instance).to receive(:exec).with(:shutdown_command_stub, anything).and_return(response).once
362
+ expect(instance).to receive(:exec).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
363
+ expect(instance).to receive(:exec).with(:boot_time_command_stub, anything).and_return(boot_time_success_response).once
368
364
 
369
365
  expect { instance.reboot(sleep_time, 9, 10) }.to raise_error(Beaker::Host::RebootFailure, /Boot time did not reset/)
370
366
  end
@@ -382,7 +378,6 @@ module Beaker
382
378
  expect(Beaker::Command).to receive(:new).with("systemctl restart rsyslog")
383
379
  instance.enable_remote_rsyslog
384
380
  end
385
-
386
381
  end
387
382
 
388
383
  describe '#which' do
@@ -392,7 +387,7 @@ module Beaker
392
387
  .with('type -P true', :accept_all_exit_codes => true).and_return('/bin/true').once
393
388
 
394
389
  allow(instance).to receive(:execute)
395
- .with(where_command, :accept_all_exit_codes => true).and_return(result)
390
+ .with(where_command, :accept_all_exit_codes => true).and_return(result)
396
391
  end
397
392
 
398
393
  context 'when only the environment variable PATH is used' do
@@ -427,7 +422,7 @@ module Beaker
427
422
  .with('which true', :accept_all_exit_codes => true).and_return('/bin/true').once
428
423
 
429
424
  allow(instance).to receive(:execute)
430
- .with(where_command, :accept_all_exit_codes => true).and_return(result)
425
+ .with(where_command, :accept_all_exit_codes => true).and_return(result)
431
426
  end
432
427
 
433
428
  context 'when only the environment variable PATH is used' do
@@ -464,7 +459,7 @@ module Beaker
464
459
 
465
460
  context 'when only the environment variable PATH is used' do
466
461
  it 'fails correctly' do
467
- expect{instance.which('ruby')}.to raise_error(/suitable/)
462
+ expect { instance.which('ruby') }.to raise_error(/suitable/)
468
463
  end
469
464
  end
470
465
  end