beaker 4.40.0 → 5.0.0

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