beaker 4.38.1 → 4.40.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +12 -0
  3. data/.rubocop.yml +62 -0
  4. data/.rubocop_todo.yml +215 -0
  5. data/CHANGELOG.md +80 -33
  6. data/Gemfile +8 -1
  7. data/HISTORY.md +103 -0
  8. data/Rakefile +10 -9
  9. data/acceptance/fixtures/module/Gemfile +1 -1
  10. data/acceptance/fixtures/module/Rakefile +2 -2
  11. data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -11
  12. data/acceptance/fixtures/module/spec/classes/init_spec.rb +1 -1
  13. data/acceptance/lib/helpers/test_helper.rb +3 -3
  14. data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +6 -6
  15. data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +6 -6
  16. data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +6 -12
  17. data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +4 -4
  18. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +1 -1
  19. data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +7 -7
  20. data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +4 -4
  21. data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +4 -4
  22. data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +8 -11
  23. data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +2 -2
  24. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +6 -11
  25. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +5 -9
  26. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +2 -2
  27. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +1 -1
  28. data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +4 -4
  29. data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +1 -1
  30. data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +1 -1
  31. data/acceptance/tests/base/dsl/structure_test.rb +4 -10
  32. data/acceptance/tests/base/host/file_test.rb +7 -7
  33. data/acceptance/tests/base/host/group_test.rb +2 -2
  34. data/acceptance/tests/base/host/host_test.rb +5 -5
  35. data/acceptance/tests/base/host/packages.rb +26 -28
  36. data/acceptance/tests/base/host/packages_unix.rb +4 -4
  37. data/acceptance/tests/base/host/user_test.rb +2 -2
  38. data/acceptance/tests/install/from_file.rb +2 -2
  39. data/beaker.gemspec +8 -9
  40. data/docs/concepts/style_guide.md +1 -1
  41. data/docs/how_to/debug_beaker_tests.md +1 -1
  42. data/docs/how_to/test_arbitrary_beaker_versions.md +2 -2
  43. data/lib/beaker/cli.rb +6 -8
  44. data/lib/beaker/command.rb +3 -3
  45. data/lib/beaker/command_factory.rb +2 -2
  46. data/lib/beaker/dsl/assertions.rb +1 -1
  47. data/lib/beaker/dsl/helpers/hocon_helpers.rb +2 -2
  48. data/lib/beaker/dsl/helpers/host_helpers.rb +11 -11
  49. data/lib/beaker/dsl/helpers/web_helpers.rb +17 -5
  50. data/lib/beaker/dsl/outcomes.rb +4 -4
  51. data/lib/beaker/dsl/roles.rb +2 -2
  52. data/lib/beaker/dsl/structure.rb +10 -10
  53. data/lib/beaker/host/aix/group.rb +3 -3
  54. data/lib/beaker/host/aix/user.rb +3 -3
  55. data/lib/beaker/host/cisco.rb +11 -11
  56. data/lib/beaker/host/eos.rb +2 -2
  57. data/lib/beaker/host/mac/exec.rb +1 -1
  58. data/lib/beaker/host/mac/group.rb +7 -7
  59. data/lib/beaker/host/mac/pkg.rb +6 -6
  60. data/lib/beaker/host/mac/user.rb +6 -6
  61. data/lib/beaker/host/pswindows/exec.rb +8 -8
  62. data/lib/beaker/host/pswindows/file.rb +1 -1
  63. data/lib/beaker/host/pswindows/group.rb +3 -3
  64. data/lib/beaker/host/pswindows/pkg.rb +6 -6
  65. data/lib/beaker/host/pswindows/user.rb +2 -2
  66. data/lib/beaker/host/unix/exec.rb +6 -6
  67. data/lib/beaker/host/unix/file.rb +3 -4
  68. data/lib/beaker/host/unix/group.rb +3 -3
  69. data/lib/beaker/host/unix/pkg.rb +17 -17
  70. data/lib/beaker/host/unix/user.rb +3 -3
  71. data/lib/beaker/host/unix.rb +10 -9
  72. data/lib/beaker/host/windows/exec.rb +3 -3
  73. data/lib/beaker/host/windows/file.rb +2 -2
  74. data/lib/beaker/host/windows/group.rb +3 -3
  75. data/lib/beaker/host/windows/pkg.rb +6 -6
  76. data/lib/beaker/host/windows/user.rb +2 -2
  77. data/lib/beaker/host/windows.rb +2 -2
  78. data/lib/beaker/host.rb +7 -7
  79. data/lib/beaker/host_prebuilt_steps.rb +38 -45
  80. data/lib/beaker/hypervisor.rb +4 -4
  81. data/lib/beaker/local_connection.rb +3 -3
  82. data/lib/beaker/logger.rb +5 -11
  83. data/lib/beaker/logger_junit.rb +2 -2
  84. data/lib/beaker/network_manager.rb +2 -2
  85. data/lib/beaker/options/command_line_parser.rb +1 -1
  86. data/lib/beaker/options/hosts_file_parser.rb +21 -4
  87. data/lib/beaker/options/options_file_parser.rb +1 -1
  88. data/lib/beaker/options/options_hash.rb +1 -3
  89. data/lib/beaker/options/parser.rb +6 -6
  90. data/lib/beaker/options/presets.rb +2 -2
  91. data/lib/beaker/options/validator.rb +2 -2
  92. data/lib/beaker/perf.rb +9 -9
  93. data/lib/beaker/platform.rb +1 -1
  94. data/lib/beaker/shared/host_manager.rb +4 -5
  95. data/lib/beaker/shared/repetition.rb +4 -4
  96. data/lib/beaker/shared/semvar.rb +2 -2
  97. data/lib/beaker/shared/timed.rb +2 -2
  98. data/lib/beaker/ssh_connection.rb +9 -9
  99. data/lib/beaker/subcommand.rb +6 -6
  100. data/lib/beaker/tasks/quick_start.rb +2 -2
  101. data/lib/beaker/tasks/rake_task.rb +3 -3
  102. data/lib/beaker/test_suite.rb +2 -2
  103. data/lib/beaker/test_suite_result.rb +8 -11
  104. data/lib/beaker/version.rb +1 -1
  105. data/spec/beaker/cli_spec.rb +46 -43
  106. data/spec/beaker/command_spec.rb +17 -7
  107. data/spec/beaker/dsl/assertions_spec.rb +2 -11
  108. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +7 -7
  109. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +11 -8
  110. data/spec/beaker/dsl/outcomes_spec.rb +1 -0
  111. data/spec/beaker/dsl/roles_spec.rb +48 -5
  112. data/spec/beaker/dsl/structure_spec.rb +22 -15
  113. data/spec/beaker/dsl/test_tagging_spec.rb +16 -16
  114. data/spec/beaker/dsl/wrappers_spec.rb +7 -7
  115. data/spec/beaker/host/cisco_spec.rb +8 -8
  116. data/spec/beaker/host/freebsd/exec_spec.rb +3 -3
  117. data/spec/beaker/host/freebsd/pkg_spec.rb +6 -3
  118. data/spec/beaker/host/mac/exec_spec.rb +3 -3
  119. data/spec/beaker/host/mac_spec.rb +6 -6
  120. data/spec/beaker/host/pswindows/exec_spec.rb +8 -5
  121. data/spec/beaker/host/pswindows/file_spec.rb +6 -3
  122. data/spec/beaker/host/pswindows_spec.rb +1 -1
  123. data/spec/beaker/host/unix/exec_spec.rb +24 -24
  124. data/spec/beaker/host/unix/file_spec.rb +18 -17
  125. data/spec/beaker/host/unix/pkg_spec.rb +26 -22
  126. data/spec/beaker/host/unix_spec.rb +8 -8
  127. data/spec/beaker/host/windows/exec_spec.rb +4 -4
  128. data/spec/beaker/host/windows/file_spec.rb +4 -4
  129. data/spec/beaker/host/windows/group_spec.rb +12 -12
  130. data/spec/beaker/host/windows/pkg_spec.rb +5 -5
  131. data/spec/beaker/host_prebuilt_steps_spec.rb +26 -20
  132. data/spec/beaker/host_spec.rb +72 -63
  133. data/spec/beaker/hypervisor/hypervisor_spec.rb +14 -14
  134. data/spec/beaker/localhost_connection_spec.rb +6 -4
  135. data/spec/beaker/logger_junit_spec.rb +16 -17
  136. data/spec/beaker/logger_spec.rb +54 -52
  137. data/spec/beaker/network_manager_spec.rb +5 -5
  138. data/spec/beaker/options/command_line_parser_spec.rb +2 -2
  139. data/spec/beaker/options/data/hosts_preserved.yml +395 -0
  140. data/spec/beaker/options/hosts_file_parser_spec.rb +9 -2
  141. data/spec/beaker/options/options_file_parser_spec.rb +1 -1
  142. data/spec/beaker/options/options_hash_spec.rb +4 -4
  143. data/spec/beaker/options/parser_spec.rb +23 -23
  144. data/spec/beaker/options/presets_spec.rb +2 -2
  145. data/spec/beaker/options/subcommand_options_parser_spec.rb +4 -3
  146. data/spec/beaker/options/validator_spec.rb +18 -18
  147. data/spec/beaker/perf_spec.rb +29 -28
  148. data/spec/beaker/platform_spec.rb +3 -2
  149. data/spec/beaker/shared/error_handler_spec.rb +1 -1
  150. data/spec/beaker/shared/fog_credentials_spec.rb +12 -12
  151. data/spec/beaker/shared/host_manager_spec.rb +7 -7
  152. data/spec/beaker/shared/repetition_spec.rb +9 -9
  153. data/spec/beaker/ssh_connection_spec.rb +14 -12
  154. data/spec/beaker/subcommand/subcommand_util_spec.rb +9 -4
  155. data/spec/beaker/subcommand_spec.rb +30 -28
  156. data/spec/beaker/test_case_spec.rb +11 -15
  157. data/spec/beaker/test_suite_spec.rb +24 -24
  158. data/spec/matchers.rb +1 -1
  159. data/spec/mocks.rb +5 -5
  160. data/spec/spec_helper.rb +0 -3
  161. metadata +59 -73
  162. data/spec/mock_fission.rb +0 -60
  163. data/spec/mock_vsphere.rb +0 -314
  164. data/spec/mock_vsphere_helper.rb +0 -183
@@ -24,9 +24,9 @@ module Beaker
24
24
 
25
25
  end
26
26
 
27
- let (:opts) { @opts || {} }
28
- let (:logger) { double( 'logger' ).as_null_object }
29
- let (:instance) { FreeBSDPkgTest.new(opts, logger) }
27
+ let(:opts) { @opts || {} }
28
+ let(:logger) { double( 'logger' ).as_null_object }
29
+ let(:instance) { FreeBSDPkgTest.new(opts, logger) }
30
30
  let(:cond) do
31
31
  'TMPDIR=/dev/null ASSUME_ALWAYS_YES=1 PACKAGESITE=file:///nonexist pkg info -x "pkg(-devel)?\\$" > /dev/null 2>&1'
32
32
  end
@@ -48,6 +48,7 @@ module Beaker
48
48
  expect( instance ).to receive(:exec).with('',{:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0}))
49
49
  expect( instance.pkgng_active? ).to be true
50
50
  end
51
+
51
52
  it "returns false if pkgng is unavailable" do
52
53
  expect( instance ).to receive(:check_pkgng_sh).once.and_return("do you have pkgng?")
53
54
  expect( Beaker::Command ).to receive(:new).with("/bin/sh -c 'do you have pkgng?'", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
@@ -65,6 +66,7 @@ module Beaker
65
66
  instance.install_package('rsync')
66
67
  end
67
68
  end
69
+
68
70
  context "with pkgng" do
69
71
  it "runs the correct install command" do
70
72
  expect( instance ).to receive(:pkgng_active?).once.and_return(true)
@@ -84,6 +86,7 @@ module Beaker
84
86
  instance.check_for_package('rsync')
85
87
  end
86
88
  end
89
+
87
90
  context "with pkgng" do
88
91
  it "runs the correct checking command" do
89
92
  expect( instance ).to receive(:pkgng_active?).once.and_return(true)
@@ -20,9 +20,9 @@ module Beaker
20
20
 
21
21
  end
22
22
 
23
- let (:opts) { @opts || {} }
24
- let (:logger) { double( 'logger' ).as_null_object }
25
- let (:instance) { MacExecTest.new(opts, logger) }
23
+ let(:opts) { @opts || {} }
24
+ let(:logger) { double( 'logger' ).as_null_object }
25
+ let(:instance) { MacExecTest.new(opts, logger) }
26
26
 
27
27
  describe '#selinux_enabled?' do
28
28
  it 'does not call selinuxenabled' do
@@ -26,28 +26,28 @@ module Mac
26
26
  end
27
27
 
28
28
  it 'returns two strings that include the passed parameters' do
29
- allow( host ).to receive( :link_exists? ) { true }
29
+ allow( host ).to receive( :link_exists? ).and_return(true)
30
30
  return1, return2 = host.puppet_agent_dev_package_info( 'pc1', 'pav1', :download_url => '' )
31
31
  expect( return1 ).to match( /pc1/ )
32
32
  expect( return2 ).to match( /pav1/ )
33
33
  end
34
34
 
35
35
  it 'gets the correct file type' do
36
- allow( host ).to receive( :link_exists? ) { true }
36
+ allow( host ).to receive( :link_exists? ).and_return(true)
37
37
  _, return2 = host.puppet_agent_dev_package_info( 'pc2', 'pav2', :download_url => '' )
38
38
  expect( return2 ).to match( /\.dmg$/ )
39
39
  end
40
40
 
41
41
  it 'adds the version dot correctly if not supplied' do
42
42
  @platform = 'osx-10.12-x86_64'
43
- allow( host ).to receive( :link_exists? ) { true }
43
+ allow( host ).to receive( :link_exists? ).and_return(true)
44
44
  release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC3', 'pav3', :download_url => '' )
45
45
  expect( release_path_end ).to match( /10\.12/ )
46
46
  expect( release_file ).to match( /10\.12/ )
47
47
  end
48
48
 
49
49
  it 'runs the correct install for osx platforms (newest link format)' do
50
- allow( host ).to receive( :link_exists? ) { true }
50
+ allow( host ).to receive( :link_exists? ).and_return(true)
51
51
 
52
52
  release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC4', 'pav4', :download_url => '' )
53
53
  # verify the mac package name starts the name correctly
@@ -71,7 +71,7 @@ module Mac
71
71
  end
72
72
 
73
73
  it 'runs the correct install for osx platforms (old link format)' do
74
- allow( host ).to receive( :link_exists? ) { false }
74
+ allow( host ).to receive( :link_exists? ).and_return(false)
75
75
 
76
76
  release_path_end, release_file = host.puppet_agent_dev_package_info( 'PC8', 'pav8', :download_url => '' )
77
77
  # verify the mac package name starts the name correctly
@@ -84,7 +84,7 @@ module Mac
84
84
  end
85
85
 
86
86
  describe '#pe_puppet_agent_promoted_package_info' do
87
- before :each do
87
+ before do
88
88
  @platform = "osx-10.15-x86_64"
89
89
  end
90
90
 
@@ -20,9 +20,9 @@ module Beaker
20
20
 
21
21
  end
22
22
 
23
- let (:opts) { @opts || {} }
24
- let (:logger) { double( 'logger' ).as_null_object }
25
- let (:instance) { PSWindowsExecTest.new(opts, logger) }
23
+ let(:opts) { @opts || {} }
24
+ let(:logger) { double( 'logger' ).as_null_object }
25
+ let(:instance) { PSWindowsExecTest.new(opts, logger) }
26
26
 
27
27
  context "rm" do
28
28
 
@@ -40,12 +40,12 @@ module Beaker
40
40
 
41
41
  it 'rm first' do
42
42
  expect(instance).to receive(:execute).with("del /s /q \"\\destination\\path\\of\\content\"").and_return(0)
43
- expect(instance).to receive(:execute).with("move /y #{origin.gsub(/\//, '\\')} #{destination.gsub(/\//, '\\')}").and_return(0)
43
+ expect(instance).to receive(:execute).with("move /y #{origin.tr('/', '\\')} #{destination.tr('/', '\\')}").and_return(0)
44
44
  expect(instance.mv(origin, destination)).to eq(0)
45
45
  end
46
46
 
47
47
  it 'does not rm' do
48
- expect( instance ).to receive(:execute).with("move /y #{origin.gsub(/\//, '\\')} #{destination.gsub(/\//, '\\')}").and_return(0)
48
+ expect( instance ).to receive(:execute).with("move /y #{origin.tr('/', '\\')} #{destination.tr('/', '\\')}").and_return(0)
49
49
  expect( instance.mv(origin, destination, false) ).to be === 0
50
50
  end
51
51
  end
@@ -57,6 +57,7 @@ module Beaker
57
57
 
58
58
  context 'file exists' do
59
59
  let(:stdout) { 'True' }
60
+
60
61
  it 'sets the modified_at date' do
61
62
  file = 'C:\path\to\file'
62
63
  expect(instance).to receive(:execute).with("powershell Test-Path #{file} -PathType Leaf")
@@ -69,6 +70,7 @@ module Beaker
69
70
 
70
71
  context 'file does not exist' do
71
72
  let(:stdout) { 'False' }
73
+
72
74
  it 'creates it and sets the modified_at date' do
73
75
  file = 'C:\path\to\file'
74
76
  expect(instance).to receive(:execute).with("powershell Test-Path #{file} -PathType Leaf")
@@ -104,6 +106,7 @@ module Beaker
104
106
  allow(instance).to receive(:execute)
105
107
  .with(where_command, :accept_all_exit_codes => true).and_return(result)
106
108
  end
109
+
107
110
  let(:where_command) { "cmd /C \"where ruby\"" }
108
111
 
109
112
  context 'when only the environment variable PATH is used' do
@@ -20,13 +20,14 @@ module Beaker
20
20
  end
21
21
  end
22
22
 
23
- let (:opts) { @opts || {} }
24
- let (:logger) { double( 'logger' ).as_null_object }
25
- let (:instance) { PSWindowsFileTest.new(opts, logger) }
23
+ let(:opts) { @opts || {} }
24
+ let(:logger) { double( 'logger' ).as_null_object }
25
+ let(:instance) { PSWindowsFileTest.new(opts, logger) }
26
26
 
27
27
  describe '#cat' do
28
28
  let(:path) { '/path/to/cat' }
29
29
  let(:content) { 'file content' }
30
+
30
31
  it 'reads output for file' do
31
32
  expect(instance).to receive(:exec).and_return(double(stdout: content))
32
33
  expect(Beaker::Command).to receive(:new).with('powershell.exe', array_including("-Command type #{path}"))
@@ -36,6 +37,7 @@ module Beaker
36
37
 
37
38
  describe '#file_exist?' do
38
39
  let(:path) { '/path/to/test/file.txt' }
40
+
39
41
  context 'file exists' do
40
42
  it 'returns true' do
41
43
  expect(instance).to receive(:exec).and_return(double(stdout: "true\n"))
@@ -63,6 +65,7 @@ module Beaker
63
65
 
64
66
  context 'with dirname sent' do
65
67
  let(:name) { 'my_dir' }
68
+
66
69
  it 'returns the path to my_dir' do
67
70
  expect(Beaker::Command).to receive(:new).
68
71
  with('powershell.exe', array_including('-Command [System.IO.Path]::GetTempPath()')).
@@ -12,7 +12,7 @@ module PSWindows
12
12
  }
13
13
  let(:host) {
14
14
  opts = options.merge(platform)
15
- opts.merge!({ :is_cygwin => false })
15
+ opts[:is_cygwin] = false
16
16
  make_host( 'name', opts )
17
17
  }
18
18
 
@@ -21,9 +21,9 @@ module Beaker
21
21
 
22
22
  end
23
23
 
24
- let (:opts) { @opts || {} }
25
- let (:logger) { double( 'logger' ).as_null_object }
26
- let (:instance) { UnixExecTest.new(opts, logger) }
24
+ let(:opts) { @opts || {} }
25
+ let(:logger) { double( 'logger' ).as_null_object }
26
+ let(:instance) { UnixExecTest.new(opts, logger) }
27
27
 
28
28
  context "rm" do
29
29
 
@@ -65,7 +65,7 @@ module Beaker
65
65
  let(:host) { {'pathseparator' => ':'} }
66
66
 
67
67
  it 'returns a blank string if theres no env' do
68
- expect( instance ).to receive( :is_powershell? ).never
68
+ expect( instance ).not_to receive( :is_powershell? )
69
69
  expect( instance.environment_string( {} ) ).to be == ''
70
70
  end
71
71
 
@@ -82,9 +82,9 @@ module Beaker
82
82
 
83
83
  describe '#ssh_permit_user_environment' do
84
84
  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"}
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"}
88
88
 
89
89
  platforms = PlatformHelpers::SYSTEMDPLATFORMS + PlatformHelpers::DEBIANPLATFORMS + PlatformHelpers::SYSTEMVPLATFORMS
90
90
 
@@ -96,7 +96,7 @@ module Beaker
96
96
  expect(Beaker::Command).to receive(:new).with(ssh_move)
97
97
  expect(Beaker::Command).to receive(:new).with(ssh_command)
98
98
  expect(instance).to receive(:ssh_service_restart)
99
- expect{instance.ssh_permit_user_environment}.to_not raise_error
99
+ expect{instance.ssh_permit_user_environment}.not_to raise_error
100
100
  end
101
101
  end
102
102
  end
@@ -115,7 +115,7 @@ module Beaker
115
115
  opts['platform'] = platform
116
116
  expect(instance).to receive(:exec)
117
117
  expect(Beaker::Command).to receive(:new).with("systemctl restart sshd.service")
118
- expect{instance.ssh_service_restart}.to_not raise_error
118
+ expect{instance.ssh_service_restart}.not_to raise_error
119
119
  end
120
120
  end
121
121
 
@@ -124,7 +124,7 @@ module Beaker
124
124
  opts['platform'] = platform
125
125
  expect(instance).to receive(:exec)
126
126
  expect(Beaker::Command).to receive(:new).with("service ssh restart")
127
- expect{instance.ssh_service_restart}.to_not raise_error
127
+ expect{instance.ssh_service_restart}.not_to raise_error
128
128
  end
129
129
  end
130
130
 
@@ -133,7 +133,7 @@ module Beaker
133
133
  opts['platform'] = "#{platform}-arch"
134
134
  expect(instance).to receive(:exec)
135
135
  expect(Beaker::Command).to receive(:new).with("/sbin/service sshd restart")
136
- expect{instance.ssh_service_restart}.to_not raise_error
136
+ expect{instance.ssh_service_restart}.not_to raise_error
137
137
  end
138
138
  end
139
139
 
@@ -230,13 +230,13 @@ module Beaker
230
230
  }
231
231
 
232
232
  # no-op response
233
- let (:response) { double( 'response' ) }
234
- let (:boot_time_initial_response) { double( 'response' ) }
233
+ let(:response) { double( 'response' ) }
234
+ let(:boot_time_initial_response) { double( 'response' ) }
235
235
 
236
- let (:boot_time_success_response) { double( 'response' ) }
237
- let (:sleep_time) { 10 }
236
+ let(:boot_time_success_response) { double( 'response' ) }
237
+ let(:sleep_time) { 10 }
238
238
 
239
- before :each do
239
+ before do
240
240
  # stubs enough to survive the first boot_time call & output parsing
241
241
  # note: just stubs input-chain between calls, parsing methods still run
242
242
  allow(Beaker::Command).to receive(:new).with('last -F reboot || who -b').and_return(:boot_time_command_stub)
@@ -253,8 +253,8 @@ module Beaker
253
253
  check_cmd_output.each do |check_os, cmd_opts|
254
254
  cmd_opts.each do |cmd_name, cmd_outputs|
255
255
  context "on '#{check_os}' with the '#{cmd_name}' command" do
256
- let (:boot_time_initial_stdout) { cmd_outputs[:initial] }
257
- let (:boot_time_success_stdout) { cmd_outputs[:success] }
256
+ let(:boot_time_initial_stdout) { cmd_outputs[:initial] }
257
+ let(:boot_time_success_stdout) { cmd_outputs[:success] }
258
258
 
259
259
  it 'passes with defaults' do
260
260
  expect(instance).to receive(:sleep).with(sleep_time)
@@ -290,7 +290,7 @@ module Beaker
290
290
  end
291
291
 
292
292
  context 'command errors' do
293
- before :each do
293
+ before do
294
294
  allow(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).at_least(:once)
295
295
  end
296
296
 
@@ -310,7 +310,7 @@ module Beaker
310
310
 
311
311
  context 'incorrect time string' do
312
312
  context 'original time' do
313
- let (:boot_time_initial_stdout) { 'boot bad' }
313
+ let(:boot_time_initial_stdout) { 'boot bad' }
314
314
 
315
315
  it 'raises a reboot failure' do
316
316
  # Handle the 'retry'
@@ -323,7 +323,7 @@ module Beaker
323
323
  end
324
324
 
325
325
  context 'current time' do
326
- let (:boot_time_success_stdout) { 'boot bad' }
326
+ let(:boot_time_success_stdout) { 'boot bad' }
327
327
 
328
328
  it 'raises a reboot failure' do
329
329
  expect(instance).to receive(:exec).with(:shutdown_command_stub, anything).and_return(response).once
@@ -345,8 +345,8 @@ module Beaker
345
345
  check_cmd_output.each do |check_os, cmd_opts|
346
346
  cmd_opts.each do |cmd_name, cmd_outputs|
347
347
  context "on '#{check_os}' with the '#{cmd_name}' command" do
348
- let (:boot_time_initial_stdout) { cmd_outputs[:initial] }
349
- let (:boot_time_success_stdout) { cmd_outputs[:initial] }
348
+ let(:boot_time_initial_stdout) { cmd_outputs[:initial] }
349
+ let(:boot_time_success_stdout) { cmd_outputs[:initial] }
350
350
 
351
351
  it 'raises RebootFailure' do
352
352
  expect(instance).to receive(:sleep).with(sleep_time)
@@ -366,7 +366,7 @@ module Beaker
366
366
  expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
367
367
  expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_success_response).once
368
368
 
369
- expect { instance.reboot(wait_time=sleep_time, max_connection_tries=9, boot_time_retries=10) }.to raise_error(Beaker::Host::RebootFailure, /Boot time did not reset/)
369
+ expect { instance.reboot(sleep_time, 9, 10) }.to raise_error(Beaker::Host::RebootFailure, /Boot time did not reset/)
370
370
  end
371
371
  end
372
372
  end
@@ -24,16 +24,16 @@ module Beaker
24
24
 
25
25
  end
26
26
 
27
- let (:opts) { @opts || {} }
28
- let (:logger) { double( 'logger' ).as_null_object }
29
- let (:platform) {
27
+ let(:opts) { @opts || {} }
28
+ let(:logger) { double( 'logger' ).as_null_object }
29
+ let(:platform) {
30
30
  if @platform
31
31
  { 'platform' => Beaker::Platform.new( @platform) }
32
32
  else
33
33
  { 'platform' => Beaker::Platform.new( 'osx-10.9-x86_64' ) }
34
34
  end
35
35
  }
36
- let (:instance) { UnixFileTest.new(opts.merge(platform), logger) }
36
+ let(:instance) { UnixFileTest.new(opts.merge(platform), logger) }
37
37
 
38
38
  describe '#repo_type' do
39
39
 
@@ -94,7 +94,7 @@ module Beaker
94
94
  ['centos','redhat'].each do |platform|
95
95
  it "sets the el portion correctly for '#{platform}'" do
96
96
  @platform = "#{platform}-5-x86_64"
97
- allow( instance ).to receive( :is_pe? ) { false }
97
+ allow( instance ).to receive( :is_pe? ).and_return(false)
98
98
  filename = instance.repo_filename( 'pkg_name', 'pkg_version7' )
99
99
  expect( filename ).to match( /sion7\-el\-/ )
100
100
  end
@@ -102,21 +102,21 @@ module Beaker
102
102
 
103
103
  it 'sets the sles portion correctly for sles platforms' do
104
104
  @platform = 'sles-11-x86_64'
105
- allow( instance ).to receive( :is_pe? ) { false }
105
+ allow( instance ).to receive( :is_pe? ).and_return(false)
106
106
  filename = instance.repo_filename( 'pkg_name', 'pkg_version7' )
107
107
  expect( filename ).to match( /sion7\-sles\-/ )
108
108
  end
109
109
 
110
110
  it 'sets the opensuse portion correctly for opensuse platforms' do
111
111
  @platform = 'opensuse-15-x86_64'
112
- allow( instance ).to receive( :is_pe? ) { false }
112
+ allow( instance ).to receive( :is_pe? ).and_return(false)
113
113
  filename = instance.repo_filename( 'pkg_name', 'pkg_version7' )
114
114
  expect( filename ).to match( /sion7\-opensuse\-/ )
115
115
  end
116
116
 
117
117
  it 'builds the filename correctly for el-based platforms' do
118
118
  @platform = 'el-21-x86_64'
119
- allow( instance ).to receive( :is_pe? ) { false }
119
+ allow( instance ).to receive( :is_pe? ).and_return(false)
120
120
  filename = instance.repo_filename( 'pkg_name', 'pkg_version8' )
121
121
  correct = 'pl-pkg_name-pkg_version8-el-21-x86_64.repo'
122
122
  expect( filename ).to be === correct
@@ -125,7 +125,7 @@ module Beaker
125
125
  it 'builds the filename correctly for redhatfips platforms' do
126
126
  @platform = 'el-7-x86_64'
127
127
  allow(instance).to receive(:[]).with('platform') { platform['platform'] }
128
- expect(instance).to receive(:[]).with('packaging_platform') { 'redhatfips-7-x86_64' }
128
+ expect(instance).to receive(:[]).with('packaging_platform').and_return('redhatfips-7-x86_64')
129
129
  filename = instance.repo_filename('pkg_name', 'pkg_version')
130
130
  correct = 'pl-pkg_name-pkg_version-redhatfips-7-x86_64.repo'
131
131
  expect( filename ).to be === correct
@@ -133,7 +133,7 @@ module Beaker
133
133
 
134
134
  it 'adds in the PE portion of the filename correctly for el-based PE hosts' do
135
135
  @platform = 'el-21-x86_64'
136
- allow( instance ).to receive( :is_pe? ) { true }
136
+ allow( instance ).to receive( :is_pe? ).and_return(true)
137
137
  filename = instance.repo_filename( 'pkg_name', 'pkg_version9' )
138
138
  correct = 'pl-pkg_name-pkg_version9-el-21-x86_64.repo'
139
139
  expect( filename ).to be === correct
@@ -155,7 +155,7 @@ module Beaker
155
155
 
156
156
  it 'adds wrlinux to variant on cisco platforms' do
157
157
  @platform = 'cisco_nexus-7-x86_64'
158
- allow( instance ).to receive( :is_pe? ) { false }
158
+ allow( instance ).to receive( :is_pe? ).and_return(false)
159
159
  filename = instance.repo_filename( 'pkg_name', 'pkg_version12' )
160
160
  expect( filename ).to match( /sion12\-cisco\-wrlinux\-/ )
161
161
  end
@@ -194,8 +194,8 @@ module Beaker
194
194
  end
195
195
 
196
196
  describe '#chown' do
197
- let (:user) { 'someuser' }
198
- let (:path) { '/path/to/chown/on' }
197
+ let(:user) { 'someuser' }
198
+ let(:path) { '/path/to/chown/on' }
199
199
 
200
200
  it 'calls the system method' do
201
201
  expect( instance ).to receive( :execute ).with( "chown #{user} #{path}" ).and_return( 0 )
@@ -209,7 +209,8 @@ module Beaker
209
209
  end
210
210
 
211
211
  describe '#cat' do
212
- let (:path) { '/path/to/cat/on' }
212
+ let(:path) { '/path/to/cat/on' }
213
+
213
214
  it 'calls cat for path' do
214
215
  expect( instance ).to receive( :execute ).with( "cat #{path}" ).and_return( 0 )
215
216
  expect( instance.cat( path ) ).to be === 0
@@ -239,8 +240,8 @@ module Beaker
239
240
  end
240
241
 
241
242
  describe '#chgrp' do
242
- let (:group) { 'somegroup' }
243
- let (:path) { '/path/to/chgrp/on' }
243
+ let(:group) { 'somegroup' }
244
+ let(:path) { '/path/to/chgrp/on' }
244
245
 
245
246
  it 'calls the system method' do
246
247
  expect( instance ).to receive( :execute ).with( "chgrp #{group} #{path}" ).and_return( 0 )
@@ -254,7 +255,7 @@ module Beaker
254
255
  end
255
256
 
256
257
  describe '#ls_ld' do
257
- let (:path) { '/path/to/ls_ld' }
258
+ let(:path) { '/path/to/ls_ld' }
258
259
 
259
260
  it 'calls the system method' do
260
261
  expect( instance ).to receive( :execute ).with( "ls -ld #{path}" ).and_return( 0 )
@@ -28,9 +28,9 @@ module Beaker
28
28
 
29
29
  end
30
30
 
31
- let (:opts) { @opts || {} }
32
- let (:logger) { double( 'logger' ).as_null_object }
33
- let (:instance) { UnixPkgTest.new(opts, logger) }
31
+ let(:opts) { @opts || {} }
32
+ let(:logger) { double( 'logger' ).as_null_object }
33
+ let(:instance) { UnixPkgTest.new(opts, logger) }
34
34
 
35
35
  context 'Package deployment tests' do
36
36
  path = '/some/file/path'
@@ -41,48 +41,48 @@ module Beaker
41
41
 
42
42
  it 'returns a warning if there is no file at the path specified' do
43
43
  expect(logger).to receive(:warn)
44
- allow(File).to receive(:exists?).with(path).and_return(false)
44
+ allow(File).to receive(:exist?).with(path).and_return(false)
45
45
  instance.deploy_package_repo(path,name,version)
46
46
  end
47
47
 
48
48
  it 'calls #deploy_apt_repo for huaweios systems' do
49
49
  @opts = {'platform' => 'huaweios-is-me'}
50
50
  expect(instance).to receive(:deploy_apt_repo)
51
- allow(File).to receive(:exists?).with(path).and_return(true)
51
+ allow(File).to receive(:exist?).with(path).and_return(true)
52
52
  instance.deploy_package_repo(path,name,version)
53
53
  end
54
54
 
55
55
  it 'calls #deploy_apt_repo for debian systems' do
56
56
  @opts = {'platform' => 'ubuntu-is-me'}
57
57
  expect(instance).to receive(:deploy_apt_repo)
58
- allow(File).to receive(:exists?).with(path).and_return(true)
58
+ allow(File).to receive(:exist?).with(path).and_return(true)
59
59
  instance.deploy_package_repo(path,name,version)
60
60
  end
61
61
 
62
62
  it 'calls #deploy_yum_repo for el systems' do
63
63
  @opts = {'platform' => 'el-is-me'}
64
64
  expect(instance).to receive(:deploy_yum_repo)
65
- allow(File).to receive(:exists?).with(path).and_return(true)
65
+ allow(File).to receive(:exist?).with(path).and_return(true)
66
66
  instance.deploy_package_repo(path,name,version)
67
67
  end
68
68
 
69
69
  it 'calls #deploy_zyp_repo for sles systems' do
70
70
  @opts = {'platform' => 'sles-is-me'}
71
71
  expect(instance).to receive(:deploy_zyp_repo)
72
- allow(File).to receive(:exists?).with(path).and_return(true)
72
+ allow(File).to receive(:exist?).with(path).and_return(true)
73
73
  instance.deploy_package_repo(path,name,version)
74
74
  end
75
75
 
76
76
  it 'calls #deploy_zyp_repo for opensuse systems' do
77
77
  @opts = {'platform' => 'opensuse-is-me'}
78
78
  expect(instance).to receive(:deploy_zyp_repo)
79
- allow(File).to receive(:exists?).with(path).and_return(true)
79
+ allow(File).to receive(:exist?).with(path).and_return(true)
80
80
  instance.deploy_package_repo(path,name,version)
81
81
  end
82
82
 
83
83
  it 'raises an error for unsupported systems' do
84
84
  @opts = {'platform' => 'windows-is-me'}
85
- allow(File).to receive(:exists?).with(path).and_return(true)
85
+ allow(File).to receive(:exist?).with(path).and_return(true)
86
86
  expect{instance.deploy_package_repo(path,name,version)}.to raise_error(RuntimeError)
87
87
  end
88
88
  end
@@ -94,7 +94,7 @@ module Beaker
94
94
  expect(logger).to receive(:warn)
95
95
  allow(@opts['platform']).to receive(:codename).and_return(nil)
96
96
  expect(instance).to receive(:deploy_apt_repo).and_return(instance.deploy_apt_repo(path,name,version))
97
- allow(File).to receive(:exists?).with(path).and_return(true)
97
+ allow(File).to receive(:exist?).with(path).and_return(true)
98
98
  instance.deploy_package_repo(path,name,version)
99
99
  end
100
100
  end
@@ -106,15 +106,16 @@ module Beaker
106
106
  pkg = 'sles_package'
107
107
  expect( Beaker::Command ).to receive( :new ).with( /^rpmkeys.*nightlies.puppetlabs.com.*/, anything, anything ).and_return('').ordered.once
108
108
  expect( Beaker::Command ).to receive(:new).with("zypper --gpg-auto-import-keys se -i --match-exact #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('').ordered.once
109
- expect( instance ).to receive(:exec).with('', {:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0})).exactly(2).times
109
+ expect( instance ).to receive(:exec).with('', {:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0})).twice
110
110
  expect( instance.check_for_package(pkg) ).to be === true
111
111
  end
112
+
112
113
  it "checks correctly on opensuse" do
113
114
  @opts = {'platform' => 'opensuse-is-me'}
114
115
  pkg = 'sles_package'
115
116
  expect( Beaker::Command ).to receive( :new ).with( /^rpmkeys.*nightlies.puppetlabs.com.*/, anything, anything ).and_return('').ordered.once
116
117
  expect( Beaker::Command ).to receive(:new).with("zypper --gpg-auto-import-keys se -i --match-exact #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('').ordered.once
117
- expect( instance ).to receive(:exec).with('', {:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0})).exactly(2).times
118
+ expect( instance ).to receive(:exec).with('', {:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0})).twice
118
119
  expect( instance.check_for_package(pkg) ).to be === true
119
120
  end
120
121
 
@@ -159,6 +160,7 @@ module Beaker
159
160
  expect( instance ).to receive(:exec).with('', {:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0}))
160
161
  expect( instance.check_for_package(pkg) ).to be === true
161
162
  end
163
+
162
164
  it "checks correctly on debian" do
163
165
  @opts = {'platform' => 'debian-is-me'}
164
166
  pkg = 'debian_package'
@@ -226,12 +228,13 @@ module Beaker
226
228
  PlatformHelpers::DEBIANPLATFORMS.each do |platform|
227
229
  it "calls update for #{platform}" do
228
230
  @opts = {'platform' => platform}
229
- instance.instance_variable_set("@apt_needs_update", true)
231
+ instance.instance_variable_set(:@apt_needs_update, true)
230
232
  expect(instance).to receive('execute').with("apt-get update")
231
- expect{instance.update_apt_if_needed}.to_not raise_error
233
+ expect{instance.update_apt_if_needed}.not_to raise_error
232
234
  end
233
235
  end
234
236
  end
237
+
235
238
  context "install_package" do
236
239
 
237
240
  PlatformHelpers::DEBIANPLATFORMS.each do |platform|
@@ -391,6 +394,7 @@ module Beaker
391
394
  end
392
395
  end
393
396
  end
397
+
394
398
  context "install_package_with_rpm" do
395
399
 
396
400
  it "accepts a package as a single argument" do
@@ -433,9 +437,9 @@ module Beaker
433
437
 
434
438
  end
435
439
 
436
- context '#pe_puppet_agent_promoted_package_install' do
440
+ describe '#pe_puppet_agent_promoted_package_install' do
437
441
  context 'on solaris platforms' do
438
- before :each do
442
+ before do
439
443
  allow( subject ).to receive( :fetch_http_file )
440
444
  allow( subject ).to receive( :scp_to )
441
445
  allow( subject ).to receive( :configure_type_defaults_on )
@@ -477,7 +481,7 @@ module Beaker
477
481
  end
478
482
 
479
483
  context 'on solaris 10' do
480
- before :each do
484
+ before do
481
485
  solaris_platform = Beaker::Platform.new('solaris-10-x86_64')
482
486
  @opts = {'platform' => solaris_platform}
483
487
  end
@@ -505,7 +509,7 @@ module Beaker
505
509
  end
506
510
 
507
511
  context 'on solaris 11' do
508
- before :each do
512
+ before do
509
513
  solaris_platform = Beaker::Platform.new('solaris-11-x86_64')
510
514
  @opts = {'platform' => solaris_platform}
511
515
  end
@@ -526,7 +530,7 @@ module Beaker
526
530
  let( :platform ) { @platform || 'fedora' }
527
531
  let( :version ) { @version || 6 }
528
532
 
529
- before :each do
533
+ before do
530
534
  allow( instance ).to receive( :[] ).with( 'platform' ) { Beaker::Platform.new("#{platform}-#{version}-x86_64") }
531
535
  end
532
536
 
@@ -589,7 +593,7 @@ module Beaker
589
593
  let( :base_dir ) { '/base/dir/fake' }
590
594
  let( :download_file ) { 'download_file.txt' }
591
595
 
592
- before :each do
596
+ before do
593
597
  allow( instance ).to receive( :[] ).with( 'platform' ) { Beaker::Platform.new("#{platform}-#{version}-x86_64") }
594
598
  end
595
599
 
@@ -620,7 +624,7 @@ module Beaker
620
624
 
621
625
  context 'on solaris' do
622
626
 
623
- before :each do
627
+ before do
624
628
  @platform = 'solaris'
625
629
  end
626
630