beaker 4.41.2 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +9 -0
  3. data/.github/workflows/release.yml +2 -2
  4. data/.github/workflows/test.yml +26 -13
  5. data/.rubocop.yml +23 -10
  6. data/.rubocop_todo.yml +34 -10
  7. data/CHANGELOG.md +16 -52
  8. data/Gemfile +12 -7
  9. data/HISTORY.md +605 -0
  10. data/Rakefile +99 -111
  11. data/acceptance/config/acceptance-options.rb +1 -1
  12. data/acceptance/config/base/acceptance-options.rb +2 -2
  13. data/acceptance/config/hypervisor/acceptance-options.rb +2 -2
  14. data/acceptance/config/subcommands/acceptance-options.rb +2 -2
  15. data/acceptance/fixtures/module/Rakefile +1 -1
  16. data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -12
  17. data/acceptance/fixtures/module/spec/classes/init_spec.rb +0 -1
  18. data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
  19. data/acceptance/lib/helpers/test_helper.rb +6 -5
  20. data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
  21. data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
  22. data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
  23. data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +1 -2
  24. data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
  25. data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +3 -1
  26. data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
  27. data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
  28. data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +19 -26
  29. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
  30. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
  31. data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +18 -13
  32. data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
  33. data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +22 -27
  34. data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +12 -16
  35. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +3 -4
  36. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +3 -3
  37. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +4 -4
  38. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -4
  39. data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +5 -5
  40. data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +3 -5
  41. data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
  42. data/acceptance/tests/base/dsl/structure_test.rb +5 -11
  43. data/acceptance/tests/base/host/file_test.rb +2 -2
  44. data/acceptance/tests/base/host/group_test.rb +0 -1
  45. data/acceptance/tests/base/host/host_test.rb +66 -63
  46. data/acceptance/tests/base/host/packages.rb +1 -2
  47. data/acceptance/tests/base/host/packages_unix.rb +0 -55
  48. data/acceptance/tests/base/host/user_test.rb +0 -1
  49. data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
  50. data/acceptance/tests/base/test_suite/export.rb +6 -9
  51. data/acceptance/tests/install/from_file.rb +2 -4
  52. data/acceptance/tests/load_path_bootstrap.rb +1 -1
  53. data/acceptance/tests/subcommands/destroy.rb +19 -21
  54. data/acceptance/tests/subcommands/exec.rb +0 -1
  55. data/acceptance/tests/subcommands/init.rb +2 -3
  56. data/acceptance/tests/subcommands/provision.rb +0 -1
  57. data/beaker.gemspec +4 -7
  58. data/docs/concepts/argument_processing_and_precedence.md +1 -10
  59. data/docs/how_to/debug_beaker_tests.md +12 -12
  60. data/docs/how_to/hosts/eos.md +2 -12
  61. data/docs/how_to/install_puppet.md +0 -18
  62. data/docs/how_to/the_beaker_dsl.md +0 -2
  63. data/lib/beaker/cli.rb +59 -68
  64. data/lib/beaker/command.rb +20 -28
  65. data/lib/beaker/command_factory.rb +3 -2
  66. data/lib/beaker/dsl/assertions.rb +6 -18
  67. data/lib/beaker/dsl/helpers/hocon_helpers.rb +3 -7
  68. data/lib/beaker/dsl/helpers/host_helpers.rb +62 -123
  69. data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
  70. data/lib/beaker/dsl/helpers/web_helpers.rb +19 -39
  71. data/lib/beaker/dsl/helpers.rb +2 -4
  72. data/lib/beaker/dsl/outcomes.rb +13 -15
  73. data/lib/beaker/dsl/patterns.rb +1 -3
  74. data/lib/beaker/dsl/roles.rb +17 -20
  75. data/lib/beaker/dsl/structure.rb +53 -65
  76. data/lib/beaker/dsl/test_tagging.rb +7 -10
  77. data/lib/beaker/dsl/wrappers.rb +15 -16
  78. data/lib/beaker/dsl.rb +2 -3
  79. data/lib/beaker/host/aix/exec.rb +1 -1
  80. data/lib/beaker/host/aix/file.rb +0 -1
  81. data/lib/beaker/host/aix/group.rb +1 -1
  82. data/lib/beaker/host/aix/user.rb +1 -1
  83. data/lib/beaker/host/aix.rb +3 -4
  84. data/lib/beaker/host/cisco.rb +27 -39
  85. data/lib/beaker/host/eos.rb +4 -30
  86. data/lib/beaker/host/freebsd/exec.rb +1 -1
  87. data/lib/beaker/host/freebsd/pkg.rb +3 -3
  88. data/lib/beaker/host/freebsd.rb +9 -12
  89. data/lib/beaker/host/mac/exec.rb +4 -4
  90. data/lib/beaker/host/mac/group.rb +7 -7
  91. data/lib/beaker/host/mac/pkg.rb +3 -106
  92. data/lib/beaker/host/mac/user.rb +2 -2
  93. data/lib/beaker/host/mac.rb +8 -9
  94. data/lib/beaker/host/pswindows/exec.rb +66 -70
  95. data/lib/beaker/host/pswindows/file.rb +3 -5
  96. data/lib/beaker/host/pswindows/group.rb +3 -3
  97. data/lib/beaker/host/pswindows/pkg.rb +12 -12
  98. data/lib/beaker/host/pswindows/user.rb +3 -3
  99. data/lib/beaker/host/pswindows.rb +4 -3
  100. data/lib/beaker/host/unix/exec.rb +81 -83
  101. data/lib/beaker/host/unix/file.rb +40 -45
  102. data/lib/beaker/host/unix/group.rb +1 -1
  103. data/lib/beaker/host/unix/pkg.rb +138 -401
  104. data/lib/beaker/host/unix/user.rb +2 -2
  105. data/lib/beaker/host/unix.rb +8 -11
  106. data/lib/beaker/host/windows/exec.rb +17 -17
  107. data/lib/beaker/host/windows/file.rb +3 -3
  108. data/lib/beaker/host/windows/group.rb +3 -3
  109. data/lib/beaker/host/windows/pkg.rb +3 -54
  110. data/lib/beaker/host/windows/user.rb +3 -3
  111. data/lib/beaker/host/windows.rb +12 -12
  112. data/lib/beaker/host.rb +76 -133
  113. data/lib/beaker/host_prebuilt_steps.rb +88 -196
  114. data/lib/beaker/hypervisor/noop.rb +2 -4
  115. data/lib/beaker/hypervisor.rb +44 -61
  116. data/lib/beaker/local_connection.rb +2 -4
  117. data/lib/beaker/logger.rb +68 -76
  118. data/lib/beaker/logger_junit.rb +21 -25
  119. data/lib/beaker/network_manager.rb +39 -42
  120. data/lib/beaker/options/command_line_parser.rb +12 -23
  121. data/lib/beaker/options/hosts_file_parser.rb +16 -25
  122. data/lib/beaker/options/options_file_parser.rb +3 -6
  123. data/lib/beaker/options/options_hash.rb +2 -7
  124. data/lib/beaker/options/parser.rb +86 -102
  125. data/lib/beaker/options/presets.rb +114 -123
  126. data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
  127. data/lib/beaker/options/validator.rb +26 -31
  128. data/lib/beaker/perf.rb +25 -30
  129. data/lib/beaker/platform.rb +26 -37
  130. data/lib/beaker/result.rb +7 -6
  131. data/lib/beaker/shared/error_handler.rb +8 -10
  132. data/lib/beaker/shared/fog_credentials.rb +5 -9
  133. data/lib/beaker/shared/host_manager.rb +36 -41
  134. data/lib/beaker/shared/options_resolver.rb +3 -7
  135. data/lib/beaker/shared/repetition.rb +2 -4
  136. data/lib/beaker/shared/semvar.rb +37 -41
  137. data/lib/beaker/shared/timed.rb +0 -3
  138. data/lib/beaker/shared.rb +1 -1
  139. data/lib/beaker/ssh_connection.rb +38 -47
  140. data/lib/beaker/subcommand.rb +17 -24
  141. data/lib/beaker/subcommands/subcommand_util.rb +4 -4
  142. data/lib/beaker/tasks/quick_start.rb +4 -9
  143. data/lib/beaker/tasks/rake_task.rb +25 -27
  144. data/lib/beaker/tasks/test.rb +4 -4
  145. data/lib/beaker/test_case.rb +16 -28
  146. data/lib/beaker/test_suite.rb +35 -39
  147. data/lib/beaker/test_suite_result.rb +45 -47
  148. data/lib/beaker/version.rb +1 -1
  149. data/lib/beaker.rb +6 -7
  150. data/spec/beaker/cli_spec.rb +121 -142
  151. data/spec/beaker/command_spec.rb +55 -59
  152. data/spec/beaker/dsl/assertions_spec.rb +36 -36
  153. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +110 -131
  154. data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
  155. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +22 -31
  156. data/spec/beaker/dsl/outcomes_spec.rb +14 -14
  157. data/spec/beaker/dsl/roles_spec.rb +125 -130
  158. data/spec/beaker/dsl/structure_spec.rb +172 -161
  159. data/spec/beaker/dsl/test_tagging_spec.rb +89 -90
  160. data/spec/beaker/dsl/wrappers_spec.rb +32 -33
  161. data/spec/beaker/host/aix_spec.rb +14 -14
  162. data/spec/beaker/host/cisco_spec.rb +84 -94
  163. data/spec/beaker/host/eos_spec.rb +15 -36
  164. data/spec/beaker/host/freebsd/exec_spec.rb +3 -6
  165. data/spec/beaker/host/freebsd/pkg_spec.rb +24 -27
  166. data/spec/beaker/host/mac/exec_spec.rb +2 -3
  167. data/spec/beaker/host/mac/group_spec.rb +48 -57
  168. data/spec/beaker/host/mac/user_spec.rb +54 -63
  169. data/spec/beaker/host/pswindows/exec_spec.rb +30 -32
  170. data/spec/beaker/host/pswindows/file_spec.rb +16 -16
  171. data/spec/beaker/host/pswindows/user_spec.rb +17 -23
  172. data/spec/beaker/host/pswindows_spec.rb +13 -13
  173. data/spec/beaker/host/unix/exec_spec.rb +75 -80
  174. data/spec/beaker/host/unix/file_spec.rb +66 -71
  175. data/spec/beaker/host/unix/pkg_spec.rb +150 -411
  176. data/spec/beaker/host/unix_spec.rb +11 -207
  177. data/spec/beaker/host/windows/exec_spec.rb +30 -32
  178. data/spec/beaker/host/windows/file_spec.rb +18 -19
  179. data/spec/beaker/host/windows/group_spec.rb +10 -12
  180. data/spec/beaker/host/windows/pkg_spec.rb +6 -9
  181. data/spec/beaker/host/windows/user_spec.rb +17 -23
  182. data/spec/beaker/host/windows_spec.rb +39 -39
  183. data/spec/beaker/host_prebuilt_steps_spec.rb +168 -349
  184. data/spec/beaker/host_spec.rb +204 -284
  185. data/spec/beaker/hypervisor/hypervisor_spec.rb +36 -61
  186. data/spec/beaker/localhost_connection_spec.rb +10 -11
  187. data/spec/beaker/logger_junit_spec.rb +19 -30
  188. data/spec/beaker/logger_spec.rb +153 -136
  189. data/spec/beaker/network_manager_spec.rb +23 -23
  190. data/spec/beaker/options/command_line_parser_spec.rb +20 -23
  191. data/spec/beaker/options/hosts_file_parser_spec.rb +30 -32
  192. data/spec/beaker/options/options_file_parser_spec.rb +4 -7
  193. data/spec/beaker/options/options_hash_spec.rb +4 -6
  194. data/spec/beaker/options/parser_spec.rb +167 -167
  195. data/spec/beaker/options/presets_spec.rb +7 -9
  196. data/spec/beaker/options/subcommand_options_parser_spec.rb +13 -14
  197. data/spec/beaker/options/validator_spec.rb +10 -11
  198. data/spec/beaker/perf_spec.rb +18 -21
  199. data/spec/beaker/platform_spec.rb +25 -50
  200. data/spec/beaker/shared/error_handler_spec.rb +7 -16
  201. data/spec/beaker/shared/fog_credentials_spec.rb +29 -29
  202. data/spec/beaker/shared/host_manager_spec.rb +50 -84
  203. data/spec/beaker/shared/options_resolver_spec.rb +9 -12
  204. data/spec/beaker/shared/repetition_spec.rb +17 -24
  205. data/spec/beaker/shared/semvar_spec.rb +21 -26
  206. data/spec/beaker/ssh_connection_spec.rb +76 -83
  207. data/spec/beaker/subcommand/subcommand_util_spec.rb +31 -33
  208. data/spec/beaker/subcommand_spec.rb +75 -77
  209. data/spec/beaker/test_case_spec.rb +25 -50
  210. data/spec/beaker/test_suite_spec.rb +147 -154
  211. data/spec/helpers.rb +39 -45
  212. data/spec/matchers.rb +8 -7
  213. data/spec/mocks.rb +1 -6
  214. data/spec/spec_helper.rb +0 -1
  215. metadata +8 -24
  216. data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
  217. data/acceptance/tests/base/external_resources_test.rb +0 -31
  218. data/spec/beaker/host/mac_spec.rb +0 -113
@@ -23,258 +23,178 @@ module Beaker
23
23
  end
24
24
 
25
25
  def exec
26
- #noop
26
+ # noop
27
27
  end
28
-
29
28
  end
30
29
 
31
30
  let(:opts) { @opts || {} }
32
- let(:logger) { double( 'logger' ).as_null_object }
31
+ let(:logger) { double('logger').as_null_object }
33
32
  let(:instance) { UnixPkgTest.new(opts, logger) }
34
33
 
35
- context 'Package deployment tests' do
36
- path = '/some/file/path'
37
- name = 'package_name'
38
- version = '1.0.0'
39
-
40
- describe '#deploy_package_repo' do
41
-
42
- it 'returns a warning if there is no file at the path specified' do
43
- expect(logger).to receive(:warn)
44
- allow(File).to receive(:exist?).with(path).and_return(false)
45
- instance.deploy_package_repo(path,name,version)
46
- end
47
-
48
- it 'calls #deploy_apt_repo for huaweios systems' do
49
- @opts = {'platform' => 'huaweios-is-me'}
50
- expect(instance).to receive(:deploy_apt_repo)
51
- allow(File).to receive(:exist?).with(path).and_return(true)
52
- instance.deploy_package_repo(path,name,version)
53
- end
54
-
55
- it 'calls #deploy_apt_repo for debian systems' do
56
- @opts = {'platform' => 'ubuntu-is-me'}
57
- expect(instance).to receive(:deploy_apt_repo)
58
- allow(File).to receive(:exist?).with(path).and_return(true)
59
- instance.deploy_package_repo(path,name,version)
60
- end
61
-
62
- it 'calls #deploy_yum_repo for el systems' do
63
- @opts = {'platform' => 'el-is-me'}
64
- expect(instance).to receive(:deploy_yum_repo)
65
- allow(File).to receive(:exist?).with(path).and_return(true)
66
- instance.deploy_package_repo(path,name,version)
67
- end
68
-
69
- it 'calls #deploy_zyp_repo for sles systems' do
70
- @opts = {'platform' => 'sles-is-me'}
71
- expect(instance).to receive(:deploy_zyp_repo)
72
- allow(File).to receive(:exist?).with(path).and_return(true)
73
- instance.deploy_package_repo(path,name,version)
74
- end
75
-
76
- it 'calls #deploy_zyp_repo for opensuse systems' do
77
- @opts = {'platform' => 'opensuse-is-me'}
78
- expect(instance).to receive(:deploy_zyp_repo)
79
- allow(File).to receive(:exist?).with(path).and_return(true)
80
- instance.deploy_package_repo(path,name,version)
81
- end
82
-
83
- it 'raises an error for unsupported systems' do
84
- @opts = {'platform' => 'windows-is-me'}
85
- allow(File).to receive(:exist?).with(path).and_return(true)
86
- expect{instance.deploy_package_repo(path,name,version)}.to raise_error(RuntimeError)
87
- end
88
- end
89
-
90
- describe '#deploy_apt_repo' do
91
-
92
- it 'warns and exits when no codename exists for the debian platform' do
93
- @opts = {'platform' => 'ubuntu-is-me'}
94
- expect(logger).to receive(:warn)
95
- allow(@opts['platform']).to receive(:codename).and_return(nil)
96
- expect(instance).to receive(:deploy_apt_repo).and_return(instance.deploy_apt_repo(path,name,version))
97
- allow(File).to receive(:exist?).with(path).and_return(true)
98
- instance.deploy_package_repo(path,name,version)
99
- end
100
- end
101
- end
102
-
103
34
  context "check_for_package" do
104
35
  it "checks correctly on sles" do
105
- @opts = {'platform' => 'sles-is-me'}
36
+ @opts = { 'platform' => 'sles-is-me' }
106
37
  pkg = 'sles_package'
107
- expect( Beaker::Command ).to receive( :new ).with( /^rpmkeys.*nightlies.puppetlabs.com.*/, anything, anything ).and_return('').ordered.once
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})).twice
110
- expect( instance.check_for_package(pkg) ).to be === true
38
+ expect(Beaker::Command).to receive(:new).with(/^rpmkeys.*nightlies.puppetlabs.com.*/, anything, anything).and_return('').ordered.once
39
+ 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
40
+ expect(instance).to receive(:exec).with('', { :accept_all_exit_codes => true }).and_return(generate_result("hello", { :exit_code => 0 })).twice
41
+ expect(instance.check_for_package(pkg)).to be === true
111
42
  end
112
43
 
113
44
  it "checks correctly on opensuse" do
114
- @opts = {'platform' => 'opensuse-is-me'}
45
+ @opts = { 'platform' => 'opensuse-is-me' }
115
46
  pkg = 'sles_package'
116
- expect( Beaker::Command ).to receive( :new ).with( /^rpmkeys.*nightlies.puppetlabs.com.*/, anything, anything ).and_return('').ordered.once
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
118
- expect( instance ).to receive(:exec).with('', {:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0})).twice
119
- expect( instance.check_for_package(pkg) ).to be === true
47
+ expect(Beaker::Command).to receive(:new).with(/^rpmkeys.*nightlies.puppetlabs.com.*/, anything, anything).and_return('').ordered.once
48
+ 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
49
+ expect(instance).to receive(:exec).with('', { :accept_all_exit_codes => true }).and_return(generate_result("hello", { :exit_code => 0 })).twice
50
+ expect(instance.check_for_package(pkg)).to be === true
120
51
  end
121
52
 
122
53
  it "checks correctly on fedora" do
123
- @opts = {'platform' => 'fedora-is-me'}
54
+ @opts = { 'platform' => 'fedora-is-me' }
124
55
  pkg = 'fedora_package'
125
- expect( Beaker::Command ).to receive(:new).with("rpm -q #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
126
- expect( instance ).to receive(:exec).with('', {:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0}))
127
- expect( instance.check_for_package(pkg) ).to be === true
56
+ expect(Beaker::Command).to receive(:new).with("rpm -q #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
57
+ expect(instance).to receive(:exec).with('', { :accept_all_exit_codes => true }).and_return(generate_result("hello", { :exit_code => 0 }))
58
+ expect(instance.check_for_package(pkg)).to be === true
128
59
  end
129
60
 
130
- %w[amazon centos redhat].each do |platform|
61
+ %w[centos redhat].each do |platform|
131
62
  it "checks correctly on #{platform}" do
132
- @opts = {'platform' => "#{platform}-is-me"}
63
+ @opts = { 'platform' => "#{platform}-is-me" }
133
64
  pkg = "#{platform}_package"
134
- expect( Beaker::Command ).to receive(:new).with("rpm -q #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
135
- expect( instance ).to receive(:exec).with('', {:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0}))
136
- expect( instance.check_for_package(pkg) ).to be === true
65
+ expect(Beaker::Command).to receive(:new).with("rpm -q #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
66
+ expect(instance).to receive(:exec).with('', { :accept_all_exit_codes => true }).and_return(generate_result("hello", { :exit_code => 0 }))
67
+ expect(instance.check_for_package(pkg)).to be === true
137
68
  end
138
69
  end
139
70
 
140
71
  it "checks correctly on EOS" do
141
- @opts = {'platform' => 'eos-is-me'}
72
+ @opts = { 'platform' => 'eos-is-me' }
142
73
  pkg = 'eos-package'
143
- expect( Beaker::Command ).to receive(:new).with("rpm -q #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
144
- expect( instance ).to receive(:exec).with('', {:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0}))
145
- expect( instance.check_for_package(pkg) ).to be === true
74
+ expect(Beaker::Command).to receive(:new).with("rpm -q #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
75
+ expect(instance).to receive(:exec).with('', { :accept_all_exit_codes => true }).and_return(generate_result("hello", { :exit_code => 0 }))
76
+ expect(instance.check_for_package(pkg)).to be === true
146
77
  end
147
78
 
148
79
  it "checks correctly on el-" do
149
- @opts = {'platform' => 'el-is-me'}
80
+ @opts = { 'platform' => 'el-is-me' }
150
81
  pkg = 'el_package'
151
- expect( Beaker::Command ).to receive(:new).with("rpm -q #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
152
- expect( instance ).to receive(:exec).with('', {:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0}))
153
- expect( instance.check_for_package(pkg) ).to be === true
82
+ expect(Beaker::Command).to receive(:new).with("rpm -q #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
83
+ expect(instance).to receive(:exec).with('', { :accept_all_exit_codes => true }).and_return(generate_result("hello", { :exit_code => 0 }))
84
+ expect(instance.check_for_package(pkg)).to be === true
154
85
  end
155
86
 
156
87
  it "checks correctly on huaweios" do
157
- @opts = {'platform' => 'huaweios-is-me'}
88
+ @opts = { 'platform' => 'huaweios-is-me' }
158
89
  pkg = 'debian_package'
159
- expect( Beaker::Command ).to receive(:new).with("dpkg -s #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
160
- expect( instance ).to receive(:exec).with('', {:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0}))
161
- expect( instance.check_for_package(pkg) ).to be === true
90
+ expect(Beaker::Command).to receive(:new).with("dpkg -s #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
91
+ expect(instance).to receive(:exec).with('', { :accept_all_exit_codes => true }).and_return(generate_result("hello", { :exit_code => 0 }))
92
+ expect(instance.check_for_package(pkg)).to be === true
162
93
  end
163
94
 
164
95
  it "checks correctly on debian" do
165
- @opts = {'platform' => 'debian-is-me'}
96
+ @opts = { 'platform' => 'debian-is-me' }
166
97
  pkg = 'debian_package'
167
- expect( Beaker::Command ).to receive(:new).with("dpkg -s #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
168
- expect( instance ).to receive(:exec).with('', {:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0}))
169
- expect( instance.check_for_package(pkg) ).to be === true
98
+ expect(Beaker::Command).to receive(:new).with("dpkg -s #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
99
+ expect(instance).to receive(:exec).with('', { :accept_all_exit_codes => true }).and_return(generate_result("hello", { :exit_code => 0 }))
100
+ expect(instance.check_for_package(pkg)).to be === true
170
101
  end
171
102
 
172
103
  it "checks correctly on ubuntu" do
173
- @opts = {'platform' => 'ubuntu-is-me'}
104
+ @opts = { 'platform' => 'ubuntu-is-me' }
174
105
  pkg = 'ubuntu_package'
175
- expect( Beaker::Command ).to receive(:new).with("dpkg -s #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
176
- expect( instance ).to receive(:exec).with('', {:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0}))
177
- expect( instance.check_for_package(pkg) ).to be === true
106
+ expect(Beaker::Command).to receive(:new).with("dpkg -s #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
107
+ expect(instance).to receive(:exec).with('', { :accept_all_exit_codes => true }).and_return(generate_result("hello", { :exit_code => 0 }))
108
+ expect(instance.check_for_package(pkg)).to be === true
178
109
  end
179
110
 
180
111
  it "checks correctly on cumulus" do
181
- @opts = {'platform' => 'cumulus-is-me'}
112
+ @opts = { 'platform' => 'cumulus-is-me' }
182
113
  pkg = 'cumulus_package'
183
- expect( Beaker::Command ).to receive(:new).with("dpkg -s #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
184
- expect( instance ).to receive(:exec).with('', {:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0}))
185
- expect( instance.check_for_package(pkg) ).to be === true
114
+ expect(Beaker::Command).to receive(:new).with("dpkg -s #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
115
+ expect(instance).to receive(:exec).with('', { :accept_all_exit_codes => true }).and_return(generate_result("hello", { :exit_code => 0 }))
116
+ expect(instance.check_for_package(pkg)).to be === true
186
117
  end
187
118
 
188
119
  it "checks correctly on solaris-11" do
189
- @opts = {'platform' => 'solaris-11-is-me'}
120
+ @opts = { 'platform' => 'solaris-11-is-me' }
190
121
  pkg = 'solaris-11_package'
191
- expect( Beaker::Command ).to receive(:new).with("pkg info #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
192
- expect( instance ).to receive(:exec).with('', {:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0}))
193
- expect( instance.check_for_package(pkg) ).to be === true
122
+ expect(Beaker::Command).to receive(:new).with("pkg info #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
123
+ expect(instance).to receive(:exec).with('', { :accept_all_exit_codes => true }).and_return(generate_result("hello", { :exit_code => 0 }))
124
+ expect(instance.check_for_package(pkg)).to be === true
194
125
  end
195
126
 
196
127
  it "checks correctly on solaris-10" do
197
- @opts = {'platform' => 'solaris-10-is-me'}
128
+ @opts = { 'platform' => 'solaris-10-is-me' }
198
129
  pkg = 'solaris-10_package'
199
- expect( Beaker::Command ).to receive(:new).with("pkginfo #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
200
- expect( instance ).to receive(:exec).with('', {:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0}))
201
- expect( instance.check_for_package(pkg) ).to be === true
130
+ expect(Beaker::Command).to receive(:new).with("pkginfo #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
131
+ expect(instance).to receive(:exec).with('', { :accept_all_exit_codes => true }).and_return(generate_result("hello", { :exit_code => 0 }))
132
+ expect(instance.check_for_package(pkg)).to be === true
202
133
  end
203
134
 
204
135
  it "checks correctly on archlinux" do
205
- @opts = {'platform' => 'archlinux-is-me'}
136
+ @opts = { 'platform' => 'archlinux-is-me' }
206
137
  pkg = 'archlinux_package'
207
- expect( Beaker::Command ).to receive(:new).with("pacman -Q #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
208
- expect( instance ).to receive(:exec).with('', {:accept_all_exit_codes => true}).and_return(generate_result("hello", {:exit_code => 0}))
209
- expect( instance.check_for_package(pkg) ).to be === true
138
+ expect(Beaker::Command).to receive(:new).with("pacman -Q #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
139
+ expect(instance).to receive(:exec).with('', { :accept_all_exit_codes => true }).and_return(generate_result("hello", { :exit_code => 0 }))
140
+ expect(instance.check_for_package(pkg)).to be === true
210
141
  end
211
142
 
212
143
  it "returns false for el-4" do
213
- @opts = {'platform' => 'el-4-is-me'}
144
+ @opts = { 'platform' => 'el-4-is-me' }
214
145
  pkg = 'el-4_package'
215
- expect( instance.check_for_package(pkg) ).to be === false
146
+ expect(instance.check_for_package(pkg)).to be === false
216
147
  end
217
148
 
218
149
  it "raises on unknown platform" do
219
- @opts = {'platform' => 'nope-is-me'}
150
+ @opts = { 'platform' => 'nope-is-me' }
220
151
  pkg = 'nope_package'
221
- expect{ instance.check_for_package(pkg) }.to raise_error
222
-
152
+ expect { instance.check_for_package(pkg) }.to raise_error
223
153
  end
224
-
225
154
  end
226
155
 
227
156
  describe '#update_apt_if_needed' do
228
157
  PlatformHelpers::DEBIANPLATFORMS.each do |platform|
229
158
  it "calls update for #{platform}" do
230
- @opts = {'platform' => platform}
159
+ @opts = { 'platform' => platform }
231
160
  instance.instance_variable_set(:@apt_needs_update, true)
232
161
  expect(instance).to receive('execute').with("apt-get update")
233
- expect{instance.update_apt_if_needed}.not_to raise_error
162
+ expect { instance.update_apt_if_needed }.not_to raise_error
234
163
  end
235
164
  end
236
165
  end
237
166
 
238
167
  context "install_package" do
239
-
240
168
  PlatformHelpers::DEBIANPLATFORMS.each do |platform|
241
169
  it "uses apt-get for #{platform}" do
242
- @opts = {'platform' => platform}
170
+ @opts = { 'platform' => platform }
243
171
  pkg = 'pkg'
244
- expect( Beaker::Command ).to receive(:new).with("apt-get install --force-yes -y #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
245
- expect( instance ).to receive(:exec).with('', {}).and_return(generate_result("hello", {:exit_code => 0}))
246
- expect( instance.install_package(pkg) ).to be == "hello"
172
+ expect(Beaker::Command).to receive(:new).with("apt-get install --force-yes -y #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
173
+ expect(instance).to receive(:exec).with('', {}).and_return(generate_result("hello", { :exit_code => 0 }))
174
+ expect(instance.install_package(pkg)).to be == "hello"
247
175
  end
248
176
  end
249
177
 
250
- (1..21).to_a.each do | fedora_release |
178
+ (1..21).to_a.each do |fedora_release|
251
179
  it "uses yum on fedora-#{fedora_release}" do
252
- @opts = {'platform' => "fedora-#{fedora_release}-is-me"}
180
+ @opts = { 'platform' => "fedora-#{fedora_release}-is-me" }
253
181
  pkg = 'fedora_package'
254
- expect( Beaker::Command ).to receive(:new).with("yum -y install #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
255
- expect( instance ).to receive(:exec).with('', {}).and_return(generate_result("hello", {:exit_code => 0}))
256
- expect( instance.install_package(pkg) ).to be == "hello"
182
+ expect(Beaker::Command).to receive(:new).with("yum -y install #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
183
+ expect(instance).to receive(:exec).with('', {}).and_return(generate_result("hello", { :exit_code => 0 }))
184
+ expect(instance.install_package(pkg)).to be == "hello"
257
185
  end
258
186
  end
259
187
 
260
- (22..39).to_a.each do | fedora_release |
188
+ (22..39).to_a.each do |fedora_release|
261
189
  it "uses dnf on fedora-#{fedora_release}" do
262
- @opts = {'platform' => "fedora-#{fedora_release}-is-me"}
190
+ @opts = { 'platform' => "fedora-#{fedora_release}-is-me" }
263
191
  pkg = 'fedora_package'
264
- expect( Beaker::Command ).to receive(:new).with("dnf -y install #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
265
- expect( instance ).to receive(:exec).with('', {}).and_return(generate_result("hello", {:exit_code => 0}))
266
- expect( instance.install_package(pkg) ).to be == "hello"
192
+ expect(Beaker::Command).to receive(:new).with("dnf -y install #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
193
+ expect(instance).to receive(:exec).with('', {}).and_return(generate_result("hello", { :exit_code => 0 }))
194
+ expect(instance.install_package(pkg)).to be == "hello"
267
195
  end
268
196
  end
269
197
 
270
- it "uses dnf on amazon-2023" do
271
- @opts = { 'platform' => "amazon-2023-is-me" }
272
- pkg = 'amazon_package'
273
- expect(Beaker::Command).to receive(:new).with("dnf -y install #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
274
- expect(instance).to receive(:exec).with('', {}).and_return(generate_result("hello", { :exit_code => 0 }))
275
- expect(instance.install_package(pkg)).to be == "hello"
276
- end
277
-
278
198
  it "uses pacman on archlinux" do
279
199
  @opts = { 'platform' => 'archlinux-is-me' }
280
200
  pkg = 'archlinux_package'
@@ -287,275 +207,96 @@ module Beaker
287
207
  describe '#uninstall_package' do
288
208
  PlatformHelpers::DEBIANPLATFORMS.each do |platform|
289
209
  it "calls pkg uninstall for #{platform}" do
290
- @opts = {'platform' => platform}
291
- expect( Beaker::Command ).to receive(:new).with("apt-get purge -y pkg", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
292
- expect( instance ).to receive(:exec).with('', {}).and_return(generate_result("hello", {:exit_code => 0}))
210
+ @opts = { 'platform' => platform }
211
+ expect(Beaker::Command).to receive(:new).with("apt-get purge -y pkg", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
212
+ expect(instance).to receive(:exec).with('', {}).and_return(generate_result("hello", { :exit_code => 0 }))
293
213
  expect(instance.uninstall_package('pkg')).to be == "hello"
294
214
  end
295
215
 
296
- (1..21).to_a.each do | fedora_release |
216
+ (1..21).to_a.each do |fedora_release|
297
217
  it "uses yum on fedora-#{fedora_release}" do
298
- @opts = {'platform' => "fedora-#{fedora_release}-is-me"}
218
+ @opts = { 'platform' => "fedora-#{fedora_release}-is-me" }
299
219
  pkg = 'fedora_package'
300
- expect( Beaker::Command ).to receive(:new).with("yum -y remove #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
301
- expect( instance ).to receive(:exec).with('', {}).and_return(generate_result("hello", {:exit_code => 0}))
302
- expect( instance.uninstall_package(pkg) ).to be == "hello"
220
+ expect(Beaker::Command).to receive(:new).with("yum -y remove #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
221
+ expect(instance).to receive(:exec).with('', {}).and_return(generate_result("hello", { :exit_code => 0 }))
222
+ expect(instance.uninstall_package(pkg)).to be == "hello"
303
223
  end
304
224
  end
305
225
 
306
- (22..39).to_a.each do | fedora_release |
226
+ (22..39).to_a.each do |fedora_release|
307
227
  it "uses dnf on fedora-#{fedora_release}" do
308
- @opts = {'platform' => "fedora-#{fedora_release}-is-me"}
228
+ @opts = { 'platform' => "fedora-#{fedora_release}-is-me" }
309
229
  pkg = 'fedora_package'
310
- expect( Beaker::Command ).to receive(:new).with("dnf -y remove #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
311
- expect( instance ).to receive(:exec).with('', {}).and_return(generate_result("hello", {:exit_code => 0}))
312
- expect( instance.uninstall_package(pkg) ).to be == "hello"
230
+ expect(Beaker::Command).to receive(:new).with("dnf -y remove #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
231
+ expect(instance).to receive(:exec).with('', {}).and_return(generate_result("hello", { :exit_code => 0 }))
232
+ expect(instance.uninstall_package(pkg)).to be == "hello"
313
233
  end
314
234
  end
315
235
  end
316
236
  end
317
237
 
318
- describe '#puppet_agent_dev_package_info' do
319
- let(:download_opts) {{download_url: 'http://trust.me'}}
320
-
321
- # These platforms are consistent across puppet collections
322
- shared_examples 'consistent platforms' do |puppet_collection, puppet_agent_version|
323
- platforms = { 'solaris-10-x86_64' => ["solaris/10/#{puppet_collection}", "puppet-agent-#{puppet_agent_version}-1.i386.pkg.gz"],
324
- 'solaris-11-x86_64' => ["solaris/11/#{puppet_collection}", "puppet-agent@#{puppet_agent_version},5.11-1.i386.p5p"],
325
- 'sles-11-x86_64' => ["sles/11/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.sles11.x86_64.rpm"],
326
- 'opensuse-15-x86_64' => ["sles/15/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.sles15.x86_64.rpm"],
327
- 'aix-6.1-power' => ["aix/6.1/#{puppet_collection}/ppc", "puppet-agent-#{puppet_agent_version}-1.aix6.1.ppc.rpm"],
328
- 'el-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
329
- 'centos-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
330
- 'oracle-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
331
- 'redhat-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
332
- 'scientific-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
333
- 'el-8-x86_64' => ["el/8/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el8.x86_64.rpm"],
334
- 'centos-8-x86_64' => ["el/8/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el8.x86_64.rpm"],
335
- 'oracle-8-x86_64' => ["el/8/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el8.x86_64.rpm"],
336
- 'redhat-8-x86_64' => ["el/8/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el8.x86_64.rpm"],
337
- }
338
- platforms.each do |p, v|
339
- it "accomodates platform #{p} without erroring" do
340
- @opts = {'platform' => Beaker::Platform.new(p)}
341
- allow( instance ).to receive(:link_exists?).and_return(true)
342
- expect( instance.puppet_agent_dev_package_info(puppet_collection, puppet_agent_version, download_opts) ).to eq(v)
343
- end
344
- end
345
- end
346
-
347
- # AIX platform/package pairs differ accross collections
348
- shared_examples 'aix platform' do |package_version, platform_version, puppet_collection, puppet_agent_version|
349
- it "selects AIX #{package_version} packages for AIX #{platform_version}" do
350
- @opts = { 'platform' => Beaker::Platform.new("aix-#{platform_version}-power") }
351
- allow( instance ).to receive(:link_exists?).and_return(true)
352
- expect( instance.puppet_agent_dev_package_info(puppet_collection, puppet_agent_version, download_opts) )
353
- .to eq(["aix/#{package_version}/#{puppet_collection}/ppc", "puppet-agent-#{puppet_agent_version}-1.aix#{package_version}.ppc.rpm"])
354
- end
355
- end
356
-
357
- context 'with puppet-agent 1.y.z' do
358
- puppet_collection = 'PC1'
359
- puppet_agent_version = '1.2.3'
360
-
361
- include_examples 'consistent platforms', puppet_collection, puppet_agent_version
362
- include_examples 'aix platform', '5.3', '5.3', puppet_collection, puppet_agent_version
363
- include_examples 'aix platform', '7.1', '7.1', puppet_collection, puppet_agent_version
364
- include_examples 'aix platform', '7.1', '7.2', puppet_collection, puppet_agent_version
365
- end
366
-
367
- context 'with puppet-agent 5.y.z' do
368
- puppet_collection = 'puppet5'
369
- puppet_agent_version = '5.4.3'
370
-
371
- include_examples 'consistent platforms', puppet_collection, puppet_agent_version
372
- include_examples 'aix platform', '7.1', '7.1', puppet_collection, puppet_agent_version
373
- include_examples 'aix platform', '7.1', '7.2', puppet_collection, puppet_agent_version
374
- end
375
-
376
- context 'with puppet-agent 5.99.z' do
377
- puppet_collection = 'puppet6'
378
- puppet_agent_version = '5.99.0'
379
-
380
- include_examples 'consistent platforms', puppet_collection, puppet_agent_version
381
- include_examples 'aix platform', '6.1', '7.1', puppet_collection, puppet_agent_version
382
- include_examples 'aix platform', '6.1', '7.2', puppet_collection, puppet_agent_version
383
- end
384
-
385
- context 'with puppet6' do
386
- puppet_collection = 'puppet6'
387
- puppet_agent_version = '6.6.6'
388
-
389
- include_examples 'consistent platforms', puppet_collection, puppet_agent_version
390
- include_examples 'aix platform', '6.1', '7.1', puppet_collection, puppet_agent_version
391
- include_examples 'aix platform', '6.1', '7.2', puppet_collection, puppet_agent_version
392
- end
393
- end
394
-
395
238
  describe '#upgrade_package' do
396
239
  PlatformHelpers::DEBIANPLATFORMS.each do |platform|
397
240
  it "calls the correct apt-get incantation for #{platform}" do
398
- @opts = {'platform' => platform}
399
- expect( Beaker::Command ).to receive(:new).with("apt-get install -o Dpkg::Options::='--force-confold' -y --force-yes pkg", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
400
- expect( instance ).to receive(:exec).with('', {}).and_return(generate_result("hello", {:exit_code => 0}))
241
+ @opts = { 'platform' => platform }
242
+ expect(Beaker::Command).to receive(:new).with("apt-get install -o Dpkg::Options::='--force-confold' -y --force-yes pkg", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
243
+ expect(instance).to receive(:exec).with('', {}).and_return(generate_result("hello", { :exit_code => 0 }))
401
244
  expect(instance.upgrade_package('pkg')).to be == "hello"
402
245
  end
403
246
  end
404
247
  end
405
248
 
406
249
  context "install_package_with_rpm" do
407
-
408
250
  it "accepts a package as a single argument" do
409
- @opts = {'platform' => 'el-is-me'}
251
+ @opts = { 'platform' => 'el-is-me' }
410
252
  pkg = 'redhat_package'
411
- expect( Beaker::Command ).to receive(:new).with("rpm -Uvh #{pkg} ", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
412
- expect( instance ).to receive(:exec).with('', {}).and_return(generate_result("hello", {:exit_code => 0}))
413
- expect( instance.install_package_with_rpm(pkg) ).to be == "hello"
253
+ expect(Beaker::Command).to receive(:new).with("rpm -Uvh #{pkg} ", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
254
+ expect(instance).to receive(:exec).with('', {}).and_return(generate_result("hello", { :exit_code => 0 }))
255
+ expect(instance.install_package_with_rpm(pkg)).to be == "hello"
414
256
  end
415
257
 
416
258
  it "accepts a package and additional options" do
417
- @opts = {'platform' => 'el-is-me'}
259
+ @opts = { 'platform' => 'el-is-me' }
418
260
  pkg = 'redhat_package'
419
261
  cmdline_args = '--foo'
420
- expect( Beaker::Command ).to receive(:new).with("rpm #{cmdline_args} -Uvh #{pkg} ", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
421
- expect( instance ).to receive(:exec).with('', {}).and_return(generate_result("hello", {:exit_code => 0}))
422
- expect( instance.install_package_with_rpm(pkg, cmdline_args) ).to be == "hello"
262
+ expect(Beaker::Command).to receive(:new).with("rpm #{cmdline_args} -Uvh #{pkg} ", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
263
+ expect(instance).to receive(:exec).with('', {}).and_return(generate_result("hello", { :exit_code => 0 }))
264
+ expect(instance.install_package_with_rpm(pkg, cmdline_args)).to be == "hello"
423
265
  end
424
-
425
266
  end
426
267
 
427
268
  context 'extract_rpm_proxy_options' do
428
-
429
- [ 'http://myproxy.com:3128/',
430
- 'https://myproxy.com:3128/',
431
- 'https://myproxy.com:3128',
432
- 'http://myproxy.com:3128',
433
- ].each do |url|
269
+ ['http://myproxy.com:3128/',
270
+ 'https://myproxy.com:3128/',
271
+ 'https://myproxy.com:3128',
272
+ 'http://myproxy.com:3128',].each do |url|
434
273
  it "correctly extracts rpm proxy options for #{url}" do
435
- expect( instance.extract_rpm_proxy_options(url) ).to be == '--httpproxy myproxy.com --httpport 3128'
274
+ expect(instance.extract_rpm_proxy_options(url)).to be == '--httpproxy myproxy.com --httpport 3128'
436
275
  end
437
276
  end
438
277
 
439
278
  url = 'http:/myproxy.com:3128'
440
279
  it "fails to extract rpm proxy options for #{url}" do
441
- expect{
280
+ expect do
442
281
  instance.extract_rpm_proxy_options(url)
443
- }.to raise_error(RuntimeError, /Cannot extract host and port/)
444
- end
445
-
446
- end
447
-
448
- describe '#pe_puppet_agent_promoted_package_install' do
449
- context 'on solaris platforms' do
450
- before do
451
- allow( subject ).to receive( :fetch_http_file )
452
- allow( subject ).to receive( :scp_to )
453
- allow( subject ).to receive( :configure_type_defaults_on )
454
- end
455
-
456
- context 'version support' do
457
- (7..17).each do |version|
458
- supported_version = version == 10 || version == 11
459
- supported_str = ( supported_version ? '' : 'not ')
460
- test_title = "does #{supported_str}support version #{version}"
461
-
462
- it "#{test_title}" do
463
- solaris_platform = Beaker::Platform.new("solaris-#{version}-x86_64")
464
- @opts = {'platform' => solaris_platform}
465
- allow( instance ).to receive( :execute )
466
- allow( instance ).to receive( :exec )
467
- if supported_version
468
- if version == 10
469
- allow( instance ).to receive( :noask_file_text )
470
- allow( instance ).to receive( :create_remote_file )
471
- allow( instance ).to receive( :execute ).with('/opt/csw/bin/pkgutil -y -i pkgutil')
472
- end
473
- # only expect diff in the last line: .not_to vs .to raise_error
474
- expect{
475
- instance.pe_puppet_agent_promoted_package_install(
476
- 'oh_cp_base', 'oh_cp_dl', 'oh_cp_fl', 'dl_fl', {}
477
- )
478
- }.not_to raise_error
479
- else
480
- expect{
481
- instance.pe_puppet_agent_promoted_package_install(
482
- 'oh_cp_base', 'oh_cp_dl', 'oh_cp_fl', 'dl_fl', {}
483
- )
484
- }.to raise_error(ArgumentError, /^Solaris #{version} is not supported/ )
485
- end
486
- end
487
- end
488
-
489
- end
490
-
491
- context 'on solaris 10' do
492
- before do
493
- solaris_platform = Beaker::Platform.new('solaris-10-x86_64')
494
- @opts = {'platform' => solaris_platform}
495
- end
496
-
497
- it 'sets a noask file' do
498
- allow( instance ).to receive( :execute )
499
- allow( instance ).to receive( :exec )
500
- expect( instance ).to receive( :noask_file_text )
501
- expect( instance ).to receive( :create_remote_file )
502
- instance.pe_puppet_agent_promoted_package_install('', '', '', '', {})
503
- end
504
-
505
- it 'calls the correct install command' do
506
- allow( instance ).to receive( :noask_file_text )
507
- allow( instance ).to receive( :create_remote_file )
508
- # a number of `execute` calls before the one we're looking for
509
- allow( instance ).to receive( :execute )
510
- allow( instance ).to receive( :exec )
511
- # actual gunzip call to
512
- expect( Beaker::Command ).to receive( :new ).with( /^gunzip\ \-c\ / )
513
- instance.pe_puppet_agent_promoted_package_install(
514
- 'oh_cp_base', 'oh_cp_dl', 'oh_cp_fl', 'dl_fl', {}
515
- )
516
- end
517
- end
518
-
519
- context 'on solaris 11' do
520
- before do
521
- solaris_platform = Beaker::Platform.new('solaris-11-x86_64')
522
- @opts = {'platform' => solaris_platform}
523
- end
524
-
525
- it 'calls the correct install command' do
526
- allow( instance ).to receive( :execute )
527
- allow( instance ).to receive( :exec )
528
- expect( Beaker::Command ).to receive( :new ).with( /^pkg\ install\ \-g / )
529
- instance.pe_puppet_agent_promoted_package_install(
530
- 'oh_cp_base', 'oh_cp_dl', 'oh_cp_fl', 'dl_fl', {}
531
- )
532
- end
533
- end
282
+ end.to raise_error(RuntimeError, /Cannot extract host and port/)
534
283
  end
535
284
  end
536
285
 
537
286
  describe '#install_local_package' do
538
- let( :platform ) { @platform || 'fedora' }
539
- let( :version ) { @version || 6 }
287
+ let(:platform) { @platform || 'fedora' }
288
+ let(:version) { @version || 6 }
540
289
 
541
290
  before do
542
291
  allow(instance).to receive(:[]).with('platform') { Beaker::Platform.new("#{platform}-#{version}-x86_64") }
543
292
  end
544
293
 
545
- it 'amazon-2023: uses dnf' do
546
- @platform = platform
547
- @version = '2023'
548
- package_file = 'test_123.yay'
549
- expect(instance).to receive(:execute).with(/^dnf.*#{package_file}$/)
550
- instance.install_local_package(package_file)
551
- end
552
-
553
294
  it 'Fedora 22-39: uses dnf' do
554
295
  (22...39).each do |version|
555
296
  @version = version
556
297
  package_file = 'test_123.yay'
557
- expect( instance ).to receive( :execute ).with( /^dnf.*#{package_file}$/ )
558
- instance.install_local_package( package_file )
298
+ expect(instance).to receive(:execute).with(/^dnf.*#{package_file}$/)
299
+ instance.install_local_package(package_file)
559
300
  end
560
301
  end
561
302
 
@@ -563,109 +304,107 @@ module Beaker
563
304
  package_file = 'testing_456.yay'
564
305
  [21].each do |version|
565
306
  @version = version
566
- expect( instance ).to receive( :execute ).with( /^yum.*#{package_file}$/ )
567
- instance.install_local_package( package_file )
307
+ expect(instance).to receive(:execute).with(/^yum.*#{package_file}$/)
308
+ instance.install_local_package(package_file)
568
309
  end
569
310
  end
570
311
 
571
312
  it 'Centos & EL: uses yum' do
572
313
  package_file = 'testing_789.yay'
573
- ['centos','redhat'].each do |platform|
314
+ %w[centos redhat].each do |platform|
574
315
  @platform = platform
575
- expect( instance ).to receive( :execute ).with( /^yum.*#{package_file}$/ )
576
- instance.install_local_package( package_file )
316
+ expect(instance).to receive(:execute).with(/^yum.*#{package_file}$/)
317
+ instance.install_local_package(package_file)
577
318
  end
578
319
  end
579
320
 
580
321
  it 'Debian, Ubuntu, Cumulus: uses dpkg' do
581
322
  package_file = 'testing_012.yay'
582
- ['debian', 'ubuntu', 'cumulus'].each do |platform|
323
+ %w[debian ubuntu cumulus].each do |platform|
583
324
  @platform = platform
584
- expect( instance ).to receive( :execute ).with( /^dpkg.*#{package_file}$/ )
585
- expect( instance ).to receive( :execute ).with( 'apt-get update' )
586
- instance.install_local_package( package_file )
325
+ expect(instance).to receive(:execute).with(/^dpkg.*#{package_file}$/)
326
+ expect(instance).to receive(:execute).with('apt-get update')
327
+ instance.install_local_package(package_file)
587
328
  end
588
329
  end
589
330
 
590
331
  it 'Solaris: calls solaris-specific install method' do
591
332
  package_file = 'testing_345.yay'
592
333
  @platform = 'solaris'
593
- expect( instance ).to receive( :solaris_install_local_package ).with( package_file, anything )
594
- instance.install_local_package( package_file )
334
+ expect(instance).to receive(:solaris_install_local_package).with(package_file, anything)
335
+ instance.install_local_package(package_file)
595
336
  end
596
337
 
597
338
  it 'OSX: calls host.install_package' do
598
339
  package_file = 'testing_678.yay'
599
340
  @platform = 'osx'
600
- expect( instance ).to receive( :install_package ).with( package_file )
601
- instance.install_local_package( package_file )
341
+ expect(instance).to receive(:install_package).with(package_file)
342
+ instance.install_local_package(package_file)
602
343
  end
603
344
  end
604
345
 
605
346
  describe '#uncompress_local_tarball' do
606
- let( :platform ) { @platform || 'fedora' }
607
- let( :version ) { @version || 6 }
608
- let( :tar_file ) { 'test.tar.gz' }
609
- let( :base_dir ) { '/base/dir/fake' }
610
- let( :download_file ) { 'download_file.txt' }
347
+ let(:platform) { @platform || 'fedora' }
348
+ let(:version) { @version || 6 }
349
+ let(:tar_file) { 'test.tar.gz' }
350
+ let(:base_dir) { '/base/dir/fake' }
351
+ let(:download_file) { 'download_file.txt' }
611
352
 
612
353
  before do
613
- allow( instance ).to receive( :[] ).with( 'platform' ) { Beaker::Platform.new("#{platform}-#{version}-x86_64") }
354
+ allow(instance).to receive(:[]).with('platform') { Beaker::Platform.new("#{platform}-#{version}-x86_64") }
614
355
  end
615
356
 
616
357
  it 'rejects unsupported platforms' do
617
358
  @platform = 'cisco_nexus'
618
- expect {
619
- instance.uncompress_local_tarball( tar_file, base_dir, download_file )
620
- }.to raise_error(
621
- /^Platform #{platform} .* not supported .* uncompress_local_tarball$/
359
+ expect do
360
+ instance.uncompress_local_tarball(tar_file, base_dir, download_file)
361
+ end.to raise_error(
362
+ /^Platform #{platform} .* not supported .* uncompress_local_tarball$/,
622
363
  )
623
364
  end
624
365
 
625
366
  it 'untars the file given' do
626
367
  @platform = 'sles'
627
- expect( instance ).to receive( :execute ).with(
628
- /^tar .* #{tar_file} .* #{base_dir}$/
368
+ expect(instance).to receive(:execute).with(
369
+ /^tar .* #{tar_file} .* #{base_dir}$/,
629
370
  )
630
- instance.uncompress_local_tarball( tar_file, base_dir, download_file )
371
+ instance.uncompress_local_tarball(tar_file, base_dir, download_file)
631
372
  end
632
373
 
633
374
  it 'untars the file given' do
634
375
  @platform = 'opensuse'
635
- expect( instance ).to receive( :execute ).with(
636
- /^tar .* #{tar_file} .* #{base_dir}$/
376
+ expect(instance).to receive(:execute).with(
377
+ /^tar .* #{tar_file} .* #{base_dir}$/,
637
378
  )
638
- instance.uncompress_local_tarball( tar_file, base_dir, download_file )
379
+ instance.uncompress_local_tarball(tar_file, base_dir, download_file)
639
380
  end
640
381
 
641
382
  context 'on solaris' do
642
-
643
383
  before do
644
384
  @platform = 'solaris'
645
385
  end
646
386
 
647
387
  it 'rejects unsupported versions' do
648
388
  @version = '12'
649
- expect {
650
- instance.uncompress_local_tarball( tar_file, base_dir, download_file )
651
- }.to raise_error(
652
- /^Solaris #{version} .* not supported .* uncompress_local_tarball$/
389
+ expect do
390
+ instance.uncompress_local_tarball(tar_file, base_dir, download_file)
391
+ end.to raise_error(
392
+ /^Solaris #{version} .* not supported .* uncompress_local_tarball$/,
653
393
  )
654
394
  end
655
395
 
656
396
  it 'v10: gunzips before untaring' do
657
397
  @version = '10'
658
- expect( instance ).to receive( :execute ).with( /^gunzip #{tar_file}$/ )
659
- expect( instance ).to receive( :execute ).with( /^tar .* #{download_file}$/ )
660
- instance.uncompress_local_tarball( tar_file, base_dir, download_file )
398
+ expect(instance).to receive(:execute).with(/^gunzip #{tar_file}$/)
399
+ expect(instance).to receive(:execute).with(/^tar .* #{download_file}$/)
400
+ instance.uncompress_local_tarball(tar_file, base_dir, download_file)
661
401
  end
662
402
 
663
403
  it 'v11: untars only' do
664
404
  @version = '11'
665
- expect( instance ).to receive( :execute ).with( /^tar .* #{tar_file}$/ )
666
- instance.uncompress_local_tarball( tar_file, base_dir, download_file )
405
+ expect(instance).to receive(:execute).with(/^tar .* #{tar_file}$/)
406
+ instance.uncompress_local_tarball(tar_file, base_dir, download_file)
667
407
  end
668
-
669
408
  end
670
409
  end
671
410
  end