beaker-puppet 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzZhZjg0NGIxMjBhNDkyMjQ5NGEyYmNjYzljMTYyZDVmZWFhMmM4YQ==
4
+ YTc4YzBjMDRiNWE2NGYwOWQzODViZTFkZjQ1OTk2ZmYwMGU3M2I1MA==
5
5
  data.tar.gz: !binary |-
6
- OTQ0YjQ4MTkzOTAzMWU5ZGYwZjZlNTE1ZTg5MGMxNzk0Y2VmNjBlYw==
6
+ ZTY3ZGFmZWJhZjJiODlkNTk1ZjA2YTk3NWZiMWJiMWFlOTYzNDYwMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NmY3YTljNDMxOGViNTFlYWM3MDJlNmQ3MmU4OTk0MjdkMjE2Y2RmOGU3OWU0
10
- Yjc0ZjRjN2I2YWYyZTU0NjJhNjYwZGMwMTBmNDJiYzg3OTBiMjA5ZGI5NDE0
11
- YmQ3NzNkY2NmNDhiNGJjNGY0NjRjMTg4Njg1MDU4YTI0Y2YxZGE=
9
+ OTNlZGU0NDBlNzllNzNlMWY5ZWRmOGMxYjVlNjEwNzFjYmZkOWIyODZhNzMw
10
+ ZTU0ODMxNDg5MDdiMTg0ODk3NDk3ZDA5NGRhNWNiYjBiYjZkYmExYjM3NGE2
11
+ ZWU0MTZjNjA5OWYzMmY0NzE4MmIyOTQ5YTY4Nzk3N2ExNWZlNjE=
12
12
  data.tar.gz: !binary |-
13
- ZjA3NmY0YTcyMDI3NmMxNjc2MWY2YzllODFjMjc0YTZiODE1MzUzZjc5YzFi
14
- YjcyZTcyMTljNmM1YTYyN2IwODI5Y2NkZGU5M2M3ZjgxMDc5OWJjYWY4YTRk
15
- ZWUwOTc2M2MwZTAwNjA0MmFmMWMxYjNiNDZkYzk4OTZlOTYyOWY=
13
+ YjM0Yzc1NmUwNWM4OWEwMjU2NDBjNTgyMTQyYTllYjliYTc0MWQwYjkyN2U4
14
+ ZmIxOGViZDZmODEwNDExMGJiYjcwZDE3ZmMxNjNkOTQ1OTllMTQ2NGI4Y2Rk
15
+ MjdmYjM2MDNkNDU1MDAxM2E3OTNhYzdjMWRhMjM3NTcyNzVmZDg=
data/HISTORY.md CHANGED
@@ -1,8 +1,42 @@
1
1
  # worker - History
2
2
  ## Tags
3
- * [LATEST - 16 Jun, 2017 (310921d4)](#LATEST)
3
+ * [LATEST - 28 Jun, 2017 (63cbd942)](#LATEST)
4
+ * [0.1.0 - 16 Jun, 2017 (e9be23b0)](#0.1.0)
4
5
 
5
6
  ## Details
6
- ### <a name = "LATEST">LATEST - 16 Jun, 2017 (310921d4)
7
+ ### <a name = "LATEST">LATEST - 28 Jun, 2017 (63cbd942)
8
+
9
+ * (GEM) update beaker-puppet version to 0.2.0 (63cbd942)
10
+
11
+ * Merge pull request #7 from johnduarte/issues/master/bkr-1147/fail-to-pkg-install-on-ec2-el (dd8d640f)
12
+
13
+
14
+ ```
15
+ Merge pull request #7 from johnduarte/issues/master/bkr-1147/fail-to-pkg-install-on-ec2-el
16
+
17
+ (BKR-1147) Fail to pkg install on ec2 for dev-repo
18
+ ```
19
+ * (BKR-1147) Fail to pkg install on ec2 for dev-repo (89909fa7)
20
+
21
+
22
+ ```
23
+ (BKR-1147) Fail to pkg install on ec2 for dev-repo
24
+
25
+ This commit modifies the `install_puppet_agent_dev_repo_on` method
26
+ to install the puppet-agent package if the host is on ec2 and el.
27
+ This is done because the ec2 instance does not have access to the
28
+ default dev repo.
29
+ ```
30
+ * Merge pull request #5 from kevpl/bkr895_installutils_tests (e54d7fd2)
31
+
32
+
33
+ ```
34
+ Merge pull request #5 from kevpl/bkr895_installutils_tests
35
+
36
+ (BKR-895) add missing install_utils tests
37
+ ```
38
+ * (BKR-895) add missing install_utils tests (d6f243ed)
39
+
40
+ ### <a name = "0.1.0">0.1.0 - 16 Jun, 2017 (e9be23b0)
7
41
 
8
42
  * Initial release.
@@ -1114,8 +1114,8 @@ module Beaker
1114
1114
 
1115
1115
  case variant
1116
1116
  when /^(fedora|el|centos|debian|ubuntu|cumulus|huaweios|cisco_nexus|cisco_ios_xr)$/
1117
- if arch == 's390x'
1118
- logger.trace("#install_puppet_agent_dev_repo_on: s390x arch detected for host #{host}. using dev package")
1117
+ if arch== 's390x' || host['hypervisor'] == 'ec2'
1118
+ logger.trace("#install_puppet_agent_dev_repo_on: unsupported host #{host} for repo detected. using dev package")
1119
1119
  else
1120
1120
  opts[:dev_builds_repos] ||= [ opts[:puppet_collection] ]
1121
1121
  install_puppetlabs_dev_repo( host, 'puppet-agent', puppet_agent_version, nil, opts )
@@ -1125,7 +1125,7 @@ module Beaker
1125
1125
  end
1126
1126
  when /^(eos|osx|windows|solaris|sles|aix)$/
1127
1127
  # Download installer package file & run install manually.
1128
- # Done below, so that el hosts with s390x arch can use this
1128
+ # Done below, so that el hosts with s390x arch or on ec2 can use this
1129
1129
  # workflow as well
1130
1130
  else
1131
1131
  raise "No repository installation step for #{variant} yet..."
@@ -1147,7 +1147,7 @@ module Beaker
1147
1147
  case variant
1148
1148
  when /^eos/
1149
1149
  host.install_from_file( release_file )
1150
- when /^(sles|aix|el)$/
1150
+ when /^(sles|aix|fedora|el|centos)$/
1151
1151
  # NOTE: AIX does not support repo management. This block assumes
1152
1152
  # that the desired rpm has been mirrored to the 'repos' location.
1153
1153
  # NOTE: the AIX 7.1 package will only install on 7.2 with
@@ -1,3 +1,3 @@
1
1
  module BeakerPuppet
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -0,0 +1,1332 @@
1
+ require 'spec_helper'
2
+
3
+ class ClassMixedWithDSLInstallUtils
4
+ include Beaker::DSL::InstallUtils
5
+ include Beaker::DSL::Wrappers
6
+ include Beaker::DSL::Helpers
7
+ include Beaker::DSL::Structure
8
+ include Beaker::DSL::Roles
9
+ include Beaker::DSL::Patterns
10
+
11
+ def logger
12
+ @logger ||= RSpec::Mocks::Double.new('logger').as_null_object
13
+ end
14
+ end
15
+
16
+ describe ClassMixedWithDSLInstallUtils do
17
+ let(:metadata) { @metadata ||= {} }
18
+ let(:presets) { Beaker::Options::Presets.new }
19
+ let(:opts) { presets.presets.merge(presets.env_vars).merge({ :type => 'foss' }) }
20
+ let(:basic_hosts) { make_hosts( { :pe_ver => '3.0',
21
+ :platform => 'linux',
22
+ :roles => [ 'agent' ],
23
+ :type => 'foss' }, 4 ) }
24
+ let(:hosts) { basic_hosts[0][:roles] = ['master', 'database', 'dashboard']
25
+ basic_hosts[1][:platform] = 'windows'
26
+ basic_hosts[2][:platform] = 'osx-10.9-x86_64'
27
+ basic_hosts[3][:platform] = 'eos'
28
+ basic_hosts }
29
+ let(:hosts_sorted) { [ hosts[1], hosts[0], hosts[2], hosts[3] ] }
30
+ let(:winhost) { make_host( 'winhost', { :platform => 'windows',
31
+ :pe_ver => '3.0',
32
+ :working_dir => '/tmp',
33
+ :type => 'foss',
34
+ :is_cygwin => true} ) }
35
+ let(:winhost_non_cygwin) { make_host( 'winhost_non_cygwin', { :platform => 'windows',
36
+ :pe_ver => '3.0',
37
+ :working_dir => '/tmp',
38
+ :type => 'foss',
39
+ :is_cygwin => 'false' } ) }
40
+ let(:machost) { make_host( 'machost', { :platform => 'osx-10.9-x86_64',
41
+ :pe_ver => '3.0',
42
+ :type => 'foss',
43
+ :working_dir => '/tmp' } ) }
44
+ let(:freebsdhost9) { make_host( 'freebsdhost9', { :platform => 'freebsd-9-x64',
45
+ :pe_ver => '3.0',
46
+ :working_dir => '/tmp' } ) }
47
+ let(:freebsdhost10) { make_host( 'freebsdhost10', { :platform => 'freebsd-10-x64',
48
+ :pe_ver => '3.0',
49
+ :working_dir => '/tmp' } ) }
50
+ let(:unixhost) { make_host( 'unixhost', { :platform => 'linux',
51
+ :pe_ver => '3.0',
52
+ :working_dir => '/tmp',
53
+ :type => 'foss',
54
+ :dist => 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-debian-7-i386' } ) }
55
+ let(:eoshost) { make_host( 'eoshost', { :platform => 'eos',
56
+ :pe_ver => '3.0',
57
+ :working_dir => '/tmp',
58
+ :type => 'foss',
59
+ :dist => 'puppet-enterprise-3.7.1-rc0-78-gffc958f-eos-4-i386' } ) }
60
+ let(:el6hostaio) { make_host( 'el6hostaio', { :platform => Beaker::Platform.new('el-6-i386'),
61
+ :pe_ver => '3.0',
62
+ :working_dir => '/tmp',
63
+ :type => 'aio',
64
+ :dist => 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-centos-6-i386' } ) }
65
+ let(:el6hostfoss) { make_host( 'el6hostfoss', { :platform => Beaker::Platform.new('el-6-i386'),
66
+ :pe_ver => '3.0',
67
+ :working_dir => '/tmp',
68
+ :type => 'foss',
69
+ :dist => 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-centos-6-i386' } ) }
70
+
71
+ let(:win_temp) { 'C:\\Windows\\Temp' }
72
+
73
+
74
+ context '#configure_foss_defaults_on' do
75
+ it 'uses aio paths for hosts with role aio' do
76
+ hosts.each do |host|
77
+ host[:pe_ver] = nil
78
+ host[:version] = nil
79
+ host[:roles] = host[:roles] | ['aio']
80
+ end
81
+ expect(subject).to receive(:add_foss_defaults_on).exactly(hosts.length).times
82
+ expect(subject).to receive(:add_aio_defaults_on).exactly(hosts.length).times
83
+ expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
84
+
85
+ subject.configure_foss_defaults_on( hosts )
86
+ end
87
+
88
+ it 'uses no paths for hosts with no type' do
89
+ hosts.each do |host|
90
+ host[:type] = nil
91
+ end
92
+ expect(subject).to receive(:add_aio_defaults_on).never
93
+ expect(subject).to receive(:add_foss_defaults_on).never
94
+ expect(subject).to receive(:add_puppet_paths_on).never
95
+
96
+ subject.configure_foss_defaults_on( hosts )
97
+ end
98
+
99
+ it 'uses aio paths for hosts with aio type (backwards compatability)' do
100
+ hosts.each do |host|
101
+ host[:pe_ver] = nil
102
+ host[:version] = nil
103
+ host[:type] = 'aio'
104
+ end
105
+ expect(subject).to receive(:add_aio_defaults_on).exactly(hosts.length).times
106
+ expect(subject).to receive(:add_foss_defaults_on).never
107
+ expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
108
+
109
+ subject.configure_foss_defaults_on( hosts )
110
+ end
111
+
112
+ it 'uses aio paths for hosts of version >= 4.0' do
113
+ hosts.each do |host|
114
+ host[:version] = '4.0'
115
+ host[:pe_ver] = nil
116
+ host[:roles] = host[:roles] - ['aio']
117
+ end
118
+ expect(subject).to receive(:add_aio_defaults_on).exactly(hosts.length).times
119
+ expect(subject).to receive(:add_foss_defaults_on).exactly(hosts.length).times
120
+ expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
121
+
122
+ subject.configure_foss_defaults_on( hosts )
123
+ end
124
+
125
+ it 'uses foss paths for hosts of version < 4.0' do
126
+ hosts.each do |host|
127
+ host[:version] = '3.8'
128
+ host[:pe_ver] = nil
129
+ end
130
+ expect(subject).to receive(:add_foss_defaults_on).exactly(hosts.length).times
131
+ expect(subject).to receive(:add_aio_defaults_on).never
132
+ expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
133
+
134
+ subject.configure_foss_defaults_on( hosts )
135
+ end
136
+
137
+ it 'uses foss paths for foss-like type foss-package' do
138
+ hosts.each do |host|
139
+ host[:type] = 'foss-package'
140
+ host[:version] = '3.8'
141
+ host[:pe_ver] = nil
142
+ end
143
+ expect(subject).to receive(:add_foss_defaults_on).exactly(hosts.length).times
144
+ expect(subject).to receive(:add_aio_defaults_on).never
145
+ expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
146
+
147
+ subject.configure_foss_defaults_on( hosts )
148
+ end
149
+
150
+ end
151
+
152
+ context 'lookup_in_env' do
153
+ it 'returns a default properly' do
154
+ env_var = subject.lookup_in_env('noway', 'nonesuch', 'returnme')
155
+ expect(env_var).to be == 'returnme'
156
+ env_var = subject.lookup_in_env('noway', nil, 'returnme')
157
+ expect(env_var).to be == 'returnme'
158
+ end
159
+ it 'finds correct env variable' do
160
+ allow(ENV).to receive(:[]).with(nil).and_return(nil)
161
+ allow(ENV).to receive(:[]).with('REALLYNONE').and_return(nil)
162
+ allow(ENV).to receive(:[]).with('NONESUCH').and_return('present')
163
+ allow(ENV).to receive(:[]).with('NOWAY_PROJ_NONESUCH').and_return('exists')
164
+ env_var = subject.lookup_in_env('nonesuch', 'noway-proj', 'fail')
165
+ expect(env_var).to be == 'exists'
166
+ env_var = subject.lookup_in_env('nonesuch')
167
+ expect(env_var).to be == 'present'
168
+ env_var = subject.lookup_in_env('reallynone')
169
+ expect(env_var).to be == nil
170
+ env_var = subject.lookup_in_env('reallynone',nil,'default')
171
+ expect(env_var).to be == 'default'
172
+ end
173
+ end
174
+
175
+ context 'build_giturl' do
176
+ it 'returns urls properly' do
177
+ allow(ENV).to receive(:[]).with('SERVER').and_return(nil)
178
+ allow(ENV).to receive(:[]).with('FORK').and_return(nil)
179
+ allow(ENV).to receive(:[]).with('PUPPET_FORK').and_return(nil)
180
+ allow(ENV).to receive(:[]).with('PUPPET_SERVER').and_return(nil)
181
+ url = subject.build_giturl('puppet')
182
+ expect(url).to be == 'https://github.com/puppetlabs/puppet.git'
183
+ url = subject.build_giturl('puppet', 'er0ck')
184
+ expect(url).to be == 'https://github.com/er0ck/puppet.git'
185
+ url = subject.build_giturl('puppet', 'er0ck', 'bitbucket.com')
186
+ expect(url).to be == 'https://bitbucket.com/er0ck-puppet.git'
187
+ url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'https://')
188
+ expect(url).to be == 'https://github.com/er0ck/puppet.git'
189
+ url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'https')
190
+ expect(url).to be == 'https://github.com/er0ck/puppet.git'
191
+ url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'git@')
192
+ expect(url).to be == 'git@github.com:er0ck/puppet.git'
193
+ url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'git')
194
+ expect(url).to be == 'git@github.com:er0ck/puppet.git'
195
+ url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'ssh')
196
+ expect(url).to be == 'git@github.com:er0ck/puppet.git'
197
+ end
198
+
199
+ it 'uses ENV to build urls properly' do
200
+ allow(ENV).to receive(:[]).with('SERVER').and_return(nil)
201
+ allow(ENV).to receive(:[]).with('FORK').and_return(nil)
202
+ allow(ENV).to receive(:[]).with('PUPPET_FORK').and_return('er0ck/repo')
203
+ allow(ENV).to receive(:[]).with('PUPPET_SERVER').and_return('gitlab.com')
204
+ url = subject.build_giturl('puppet')
205
+ expect(url).to be == 'https://gitlab.com/er0ck/repo-puppet.git'
206
+ url = subject.build_giturl('puppet', 'er0ck')
207
+ expect(url).to be == 'https://gitlab.com/er0ck-puppet.git'
208
+ url = subject.build_giturl('puppet', 'er0ck', 'bitbucket.com')
209
+ expect(url).to be == 'https://bitbucket.com/er0ck-puppet.git'
210
+ url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'https://')
211
+ expect(url).to be == 'https://github.com/er0ck/puppet.git'
212
+ url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'https')
213
+ expect(url).to be == 'https://github.com/er0ck/puppet.git'
214
+ url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'git@')
215
+ expect(url).to be == 'git@github.com:er0ck/puppet.git'
216
+ url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'git')
217
+ expect(url).to be == 'git@github.com:er0ck/puppet.git'
218
+ url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'ssh')
219
+ expect(url).to be == 'git@github.com:er0ck/puppet.git'
220
+ end
221
+ end
222
+
223
+ context 'extract_repo_info_from' do
224
+ [{ :protocol => 'git', :path => 'git://github.com/puppetlabs/project.git' },
225
+ { :protocol => 'ssh', :path => 'git@github.com:puppetlabs/project.git' },
226
+ { :protocol => 'https', :path => 'https://github.com:puppetlabs/project' },
227
+ { :protocol => 'file', :path => 'file:///home/example/project' }
228
+ ].each do |type|
229
+ it "handles #{ type[:protocol] } uris" do
230
+ uri = "#{ type[:path] }#master"
231
+ repo_info = subject.extract_repo_info_from uri
232
+ expect( repo_info[:name] ).to be == 'project'
233
+ expect( repo_info[:path] ).to be == type[:path]
234
+ expect( repo_info[:rev] ).to be == 'master'
235
+ end
236
+ end
237
+ end
238
+
239
+ context 'order_packages' do
240
+ it 'orders facter, hiera before puppet, before anything else' do
241
+ named_repos = [
242
+ { :name => 'puppet_plugin' }, { :name => 'puppet' }, { :name => 'facter' }
243
+ ]
244
+ ordered_repos = subject.order_packages named_repos
245
+ expect( ordered_repos[0][:name] ).to be == 'facter'
246
+ expect( ordered_repos[1][:name] ).to be == 'puppet'
247
+ expect( ordered_repos[2][:name] ).to be == 'puppet_plugin'
248
+ end
249
+ end
250
+
251
+ context 'find_git_repo_versions' do
252
+ it 'returns a hash of :name => version' do
253
+ host = double( 'Host' )
254
+ repository = { :name => 'name' }
255
+ path = '/path/to/repo'
256
+ cmd = 'cd /path/to/repo/name && git describe || true'
257
+ logger = double.as_null_object
258
+
259
+ allow( subject ).to receive( :metadata ).and_return( metadata )
260
+ expect( subject ).to receive( :logger ).and_return( logger )
261
+ expect( subject ).to receive( :on ).with( host, cmd ).and_yield
262
+ expect( subject ).to receive( :stdout ).and_return( '2' )
263
+
264
+ subject.instance_variable_set( :@metadata, {} )
265
+ version = subject.find_git_repo_versions( host, path, repository )
266
+
267
+ expect( version ).to be == { 'name' => '2' }
268
+ end
269
+ end
270
+
271
+ context 'install_puppet_from_rpm_on' do
272
+ it 'installs PC1 release repo when AIO' do
273
+ expect(subject).to receive(:install_puppetlabs_release_repo).with(el6hostaio,'pc1',{})
274
+
275
+ subject.install_puppet_from_rpm_on( el6hostaio, {} )
276
+ end
277
+
278
+ it 'installs non-PC1 package when not-AIO' do
279
+ expect(subject).to receive(:install_puppetlabs_release_repo).with(el6hostfoss,nil,{})
280
+
281
+ subject.install_puppet_from_rpm_on( el6hostfoss, {} )
282
+ end
283
+ end
284
+
285
+ context 'install_puppet_from_freebsd_ports_on' do
286
+ it 'installs puppet on FreeBSD 9' do
287
+ expect(freebsdhost9).to receive(:install_package).with('puppet')
288
+
289
+ subject.install_puppet_from_freebsd_ports_on( freebsdhost9, {} )
290
+ end
291
+
292
+ it 'installs puppet on FreeBSD 10' do
293
+ expect(freebsdhost10).to receive(:install_package).with('sysutils/puppet')
294
+
295
+ subject.install_puppet_from_freebsd_ports_on( freebsdhost10, {} )
296
+ end
297
+ end
298
+
299
+ context 'install_puppet_from_msi' do
300
+ before :each do
301
+ [winhost, winhost_non_cygwin].each do |host|
302
+ allow(host).to receive(:system_temp_path).and_return(win_temp)
303
+ end
304
+ end
305
+
306
+ it 'installs puppet on cygwin windows' do
307
+ allow(subject).to receive(:link_exists?).and_return( true )
308
+ expect(subject).to receive(:on).with(winhost, "curl -o \"#{win_temp}\\puppet-3.7.1.msi\" -O http://downloads.puppetlabs.com/windows/puppet-3.7.1.msi")
309
+ expect(subject).to receive(:on).with(winhost, " echo 'export PATH=$PATH:\"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin\":\"/cygdrive/c/Program Files/Puppet Labs/Puppet/bin\"' > /etc/bash.bashrc ")
310
+ expect(subject).to receive(:install_msi_on).with(winhost, "#{win_temp}\\puppet-3.7.1.msi", {}, {:debug => nil})
311
+
312
+ subject.install_puppet_from_msi( winhost, {:version => '3.7.1', :win_download_url => 'http://downloads.puppetlabs.com/windows'} )
313
+ end
314
+
315
+ it 'installs puppet on non-cygwin windows' do
316
+ allow(subject).to receive(:link_exists?).and_return( true )
317
+
318
+ expect(winhost_non_cygwin).to receive(:mkdir_p).with('C:\\ProgramData\\PuppetLabs\\puppet\\etc\\modules')
319
+
320
+ expect(subject).to receive(:on).with(winhost_non_cygwin, instance_of( Beaker::Command )) do |host, beaker_command|
321
+ expect(beaker_command.command).to eq('powershell.exe')
322
+ expect(beaker_command.args).to eq(["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command $webclient = New-Object System.Net.WebClient; $webclient.DownloadFile('http://downloads.puppetlabs.com/windows/puppet-3.7.1.msi','#{win_temp}\\puppet-3.7.1.msi')"])
323
+ end.once
324
+
325
+ expect(subject).to receive(:install_msi_on).with(winhost_non_cygwin, "#{win_temp}\\puppet-3.7.1.msi", {}, {:debug => nil})
326
+
327
+ subject.install_puppet_from_msi( winhost_non_cygwin, {:version => '3.7.1', :win_download_url => 'http://downloads.puppetlabs.com/windows'} )
328
+ end
329
+ end
330
+
331
+ context 'clone_git_repo_on' do
332
+ it 'does a ton of stuff it probably shouldnt' do
333
+ repo = { :name => 'puppet',
334
+ :path => 'git://my.server.net/puppet.git',
335
+ :rev => 'master' }
336
+ path = '/path/to/repos'
337
+ host = { 'platform' => 'debian' }
338
+ logger = double.as_null_object
339
+
340
+ allow( subject ).to receive( :metadata ).and_return( metadata )
341
+ allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
342
+
343
+ expect( subject ).to receive( :logger ).exactly( 2 ).times.and_return( logger )
344
+ expect( subject ).to receive( :on ).exactly( 3 ).times
345
+
346
+ subject.instance_variable_set( :@metadata, {} )
347
+ subject.clone_git_repo_on( host, path, repo )
348
+ end
349
+
350
+ it 'allows a checkout depth of 1' do
351
+ repo = { :name => 'puppet',
352
+ :path => 'git://my.server.net/puppet.git',
353
+ :rev => 'master',
354
+ :depth => 1 }
355
+
356
+ path = '/path/to/repos'
357
+ cmd = "test -d #{path}/#{repo[:name]} || git clone --branch #{repo[:rev]} --depth #{repo[:depth]} #{repo[:path]} #{path}/#{repo[:name]}"
358
+ host = { 'platform' => 'debian' }
359
+ logger = double.as_null_object
360
+ allow( subject ).to receive( :metadata ).and_return( metadata )
361
+ allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
362
+ expect( subject ).to receive( :logger ).exactly( 2 ).times.and_return( logger )
363
+ expect( subject ).to receive( :on ).with( host, "test -d #{path} || mkdir -p #{path}", {:accept_all_exit_codes=>true} ).exactly( 1 ).times
364
+ # this is the the command we want to test
365
+ expect( subject ).to receive( :on ).with( host, cmd, {:accept_all_exit_codes=>true} ).exactly( 1 ).times
366
+ expect( subject ).to receive( :on ).with( host, "cd #{path}/#{repo[:name]} && git remote rm origin && git remote add origin #{repo[:path]} && git fetch origin +refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/* && git clean -fdx && git checkout -f #{repo[:rev]}", {:accept_all_exit_codes=>true} ).exactly( 1 ).times
367
+
368
+ subject.instance_variable_set( :@metadata, {} )
369
+ subject.clone_git_repo_on( host, path, repo )
370
+ end
371
+
372
+ it 'allows a checkout depth with a rev from a specific branch' do
373
+ repo = { :name => 'puppet',
374
+ :path => 'git://my.server.net/puppet.git',
375
+ :rev => 'a2340acddadfeafd234230faf',
376
+ :depth => 50,
377
+ :depth_branch => 'master' }
378
+
379
+ path = '/path/to/repos'
380
+ cmd = "test -d #{path}/#{repo[:name]} || git clone --branch #{repo[:depth_branch]} --depth #{repo[:depth]} #{repo[:path]} #{path}/#{repo[:name]}"
381
+ host = { 'platform' => 'debian' }
382
+ allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
383
+ logger = double.as_null_object
384
+ allow( subject ).to receive( :metadata ).and_return( metadata )
385
+ expect( subject ).to receive( :logger ).exactly( 2 ).times.and_return( logger )
386
+ expect( subject ).to receive( :on ).with( host, "test -d #{path} || mkdir -p #{path}", {:accept_all_exit_codes=>true} ).exactly( 1 ).times
387
+ # this is the the command we want to test
388
+ expect( subject ).to receive( :on ).with( host, cmd, {:accept_all_exit_codes=>true} ).exactly( 1 ).times
389
+ expect( subject ).to receive( :on ).with( host, "cd #{path}/#{repo[:name]} && git remote rm origin && git remote add origin #{repo[:path]} && git fetch origin +refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/* && git clean -fdx && git checkout -f #{repo[:rev]}", {:accept_all_exit_codes=>true} ).exactly( 1 ).times
390
+
391
+ subject.instance_variable_set( :@metadata, {} )
392
+ subject.clone_git_repo_on( host, path, repo )
393
+ end
394
+ end
395
+
396
+ context 'install_from_git' do
397
+ it 'does a ton of stuff it probably shouldnt' do
398
+ repo = { :name => 'puppet',
399
+ :path => 'git://my.server.net/puppet.git',
400
+ :rev => 'master' }
401
+ path = '/path/to/repos'
402
+ host = { 'platform' => 'debian' }
403
+ logger = double.as_null_object
404
+
405
+ allow( subject ).to receive( :metadata ).and_return( metadata )
406
+ allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
407
+
408
+ expect( subject ).to receive( :logger ).exactly( 3 ).times.and_return( logger )
409
+ expect( subject ).to receive( :on ).exactly( 4 ).times
410
+
411
+ subject.instance_variable_set( :@metadata, {} )
412
+ subject.install_from_git( host, path, repo )
413
+ end
414
+
415
+ it 'should attempt to install ruby code' do
416
+ repo = { :name => 'puppet',
417
+ :path => 'git://my.server.net/puppet.git',
418
+ :rev => 'master',
419
+ :depth => 1 }
420
+
421
+ path = '/path/to/repos'
422
+ cmd = "test -d #{path}/#{repo[:name]} || git clone --branch #{repo[:rev]} --depth #{repo[:depth]} #{repo[:path]} #{path}/#{repo[:name]}"
423
+ host = { 'platform' => 'debian' }
424
+ logger = double.as_null_object
425
+ allow( subject ).to receive( :metadata ).and_return( metadata )
426
+ allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
427
+ expect( subject ).to receive( :logger ).exactly( 3 ).times.and_return( logger )
428
+ expect( subject ).to receive( :on ).with( host, "test -d #{path} || mkdir -p #{path}", {:accept_all_exit_codes=>true} ).exactly( 1 ).times
429
+ expect( subject ).to receive( :on ).with( host, cmd, {:accept_all_exit_codes=>true} ).exactly( 1 ).times
430
+ expect( subject ).to receive( :on ).with( host, "cd #{path}/#{repo[:name]} && git remote rm origin && git remote add origin #{repo[:path]} && git fetch origin +refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/* && git clean -fdx && git checkout -f #{repo[:rev]}", {:accept_all_exit_codes=>true} ).exactly( 1 ).times
431
+ expect( subject ).to receive( :on ).with( host, "cd #{path}/#{repo[:name]} && if [ -f install.rb ]; then ruby ./install.rb ; else true; fi", {:accept_all_exit_codes=>true} ).exactly( 1 ).times
432
+
433
+ subject.instance_variable_set( :@metadata, {} )
434
+ subject.install_from_git_on( host, path, repo )
435
+ end
436
+ end
437
+
438
+ describe '#install_puppet' do
439
+ let(:hosts) do
440
+ make_hosts({:platform => platform })
441
+ end
442
+
443
+ before do
444
+ allow( subject ).to receive(:options).and_return(opts)
445
+ allow( subject ).to receive(:hosts).and_return(hosts)
446
+ allow( subject ).to receive(:on).and_return(Beaker::Result.new({},''))
447
+ end
448
+ context 'on el-6' do
449
+ let(:platform) { Beaker::Platform.new('el-6-i386') }
450
+ it 'installs' do
451
+ expect(hosts[0]).to receive(:install_package_with_rpm).with(/puppetlabs-release-el-6\.noarch\.rpm/, '--replacepkgs', {:package_proxy=>false})
452
+ expect(hosts[0]).to receive(:install_package).with('puppet')
453
+ subject.install_puppet
454
+ end
455
+ it 'installs in parallel' do
456
+ InParallel::InParallelExecutor.logger = logger
457
+ FakeFS.deactivate!
458
+ hosts.each{ |host|
459
+ allow(host).to receive(:install_package_with_rpm).with(/puppetlabs-release-el-6\.noarch\.rpm/, '--replacepkgs', {:package_proxy=>false})
460
+ allow(host).to receive(:install_package).with('puppet')
461
+ }
462
+ opts[:run_in_parallel] = true
463
+ # This will only get hit if forking processes is supported and at least 2 items are being submitted to run in parallel
464
+ expect( InParallel::InParallelExecutor ).to receive(:_execute_in_parallel).with(any_args).and_call_original.exactly(3).times
465
+ subject.install_puppet(opts)
466
+ end
467
+ it 'installs specific version of puppet when passed :version' do
468
+ expect(hosts[0]).to receive(:install_package).with('puppet-3')
469
+ subject.install_puppet( :version => '3' )
470
+ end
471
+ it 'can install specific versions of puppets dependencies' do
472
+ expect(hosts[0]).to receive(:install_package).with('puppet-3')
473
+ expect(hosts[0]).to receive(:install_package).with('hiera-2001')
474
+ expect(hosts[0]).to receive(:install_package).with('facter-1999')
475
+ subject.install_puppet( :version => '3', :facter_version => '1999', :hiera_version => '2001' )
476
+ end
477
+ end
478
+ context 'on el-5' do
479
+ let(:platform) { Beaker::Platform.new('el-5-i386') }
480
+ it 'installs' do
481
+ expect(hosts[0]).to receive(:install_package_with_rpm).with(/puppetlabs-release-el-5\.noarch\.rpm/, '--replacepkgs', {:package_proxy=>false})
482
+ expect(hosts[0]).to receive(:install_package).with('puppet')
483
+ subject.install_puppet
484
+ end
485
+ end
486
+ context 'on fedora' do
487
+ let(:platform) { Beaker::Platform.new('fedora-18-x86_84') }
488
+ it 'installs' do
489
+ expect(hosts[0]).to receive(:install_package_with_rpm).with(/puppetlabs-release-fedora-18\.noarch\.rpm/, '--replacepkgs', {:package_proxy=>false})
490
+ expect(hosts[0]).to receive(:install_package).with('puppet')
491
+ subject.install_puppet
492
+ end
493
+ end
494
+ context 'on archlinux' do
495
+ let(:platform) { Beaker::Platform.new('archlinux-2015.09.01-x86_84') }
496
+ it 'installs' do
497
+ expect(hosts[0]).to receive(:install_package).with('puppet')
498
+ subject.install_puppet
499
+ end
500
+ end
501
+ context 'on debian' do
502
+ PlatformHelpers::DEBIANPLATFORMS.each do |platform|
503
+ let(:platform) { Beaker::Platform.new("#{platform}-ver-arch") }
504
+ it "installs latest on #{platform} if given no version info" do
505
+ hosts.each do |host|
506
+ expect(subject).to receive(:install_puppetlabs_release_repo).with(host)
507
+ end
508
+ expect(hosts[0]).to receive(:install_package).with('puppet')
509
+ subject.install_puppet
510
+ end
511
+ end
512
+ it 'installs specific version of puppet when passed :version' do
513
+ expect(hosts[0]).to receive(:install_package).with('puppet=3-1puppetlabs1')
514
+ expect(hosts[0]).to receive(:install_package).with('puppet-common=3-1puppetlabs1')
515
+ subject.install_puppet( :version => '3' )
516
+ end
517
+ it 'can install specific versions of puppets dependencies' do
518
+ expect(hosts[0]).to receive(:install_package).with('facter=1999-1puppetlabs1')
519
+ expect(hosts[0]).to receive(:install_package).with('hiera=2001-1puppetlabs1')
520
+ expect(hosts[0]).to receive(:install_package).with('puppet-common=3-1puppetlabs1')
521
+ expect(hosts[0]).to receive(:install_package).with('puppet=3-1puppetlabs1')
522
+ subject.install_puppet( :version => '3', :facter_version => '1999', :hiera_version => '2001' )
523
+ end
524
+ end
525
+ context 'on windows' do
526
+ let(:platform) { Beaker::Platform.new('windows-2008r2-i386') }
527
+
528
+ before :each do
529
+ allow(winhost).to receive(:tmpdir).and_return(win_temp)
530
+ allow(winhost).to receive(:is_cygwin?).and_return(true)
531
+ allow(subject).to receive(:link_exists?).and_return( true )
532
+ allow(subject).to receive(:install_msi_on).with(any_args)
533
+ end
534
+
535
+ it 'installs specific version of puppet when passed :version' do
536
+ hosts.each do |host|
537
+ if host != winhost
538
+ allow(subject).to receive(:on).with(host, anything)
539
+ else
540
+ expect(subject).to receive(:on).with(winhost, "curl -o \"#{win_temp}\\puppet-3.msi\" -O http://downloads.puppetlabs.com/windows/puppet-3.msi")
541
+ expect(subject).to receive(:on).with(winhost, " echo 'export PATH=$PATH:\"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin\":\"/cygdrive/c/Program Files/Puppet Labs/Puppet/bin\"' > /etc/bash.bashrc ")
542
+ expect(subject).to receive(:install_msi_on).with(winhost, "#{win_temp}\\puppet-3.msi", {}, {:debug => nil}).exactly(1).times
543
+ end
544
+ end
545
+ subject.install_puppet(:version => '3')
546
+ end
547
+ it 'installs from custom url when passed :win_download_url' do
548
+ hosts.each do |host|
549
+ if host != winhost
550
+ allow(subject).to receive(:on).with(host, anything)
551
+ else
552
+ expect(subject).to receive(:on).with(winhost, "curl -o \"#{win_temp}\\puppet-3.msi\" -O http://nightlies.puppetlabs.com/puppet-latest/repos/windows/puppet-3.msi")
553
+ expect(subject).to receive(:install_msi_on).with(winhost, "#{win_temp}\\puppet-3.msi", {}, {:debug => nil})
554
+ end
555
+ end
556
+ subject.install_puppet( :version => '3', :win_download_url => 'http://nightlies.puppetlabs.com/puppet-latest/repos/windows' )
557
+ end
558
+ end
559
+ describe 'on unsupported platforms' do
560
+ let(:platform) { Beaker::Platform.new('solaris-11-x86_64') }
561
+ let(:host) { make_host('henry', :platform => 'solaris-11-x86_64') }
562
+ let(:hosts) { [host] }
563
+ it 'by default raises an error' do
564
+ expect(subject).to_not receive(:on)
565
+ expect { subject.install_puppet }.to raise_error(/unsupported platform/)
566
+ end
567
+ it 'falls back to installing from gem when given :default_action => "gem_install"' do
568
+ result = double
569
+ gem_env_string = '{"RubyGems Environment": [ {"GEM PATHS": [], "EXECUTABLE DIRECTORY": "/does/not/exist" } ] }'
570
+ allow( result ).to receive(:stdout).and_return gem_env_string
571
+ allow(subject).to receive(:on).with(host, /gem environment/).and_return result
572
+ expect(subject).to receive(:on).with(host, /gem install/)
573
+ subject.install_puppet :default_action => 'gem_install'
574
+ end
575
+ end
576
+ end
577
+
578
+ describe 'configure_puppet_on' do
579
+ context 'on debian' do
580
+ PlatformHelpers::DEBIANPLATFORMS.each do |platform|
581
+ let(:platform) { Beaker::Platform.new("#{platform}-ver-arch") }
582
+ let(:host) { make_host('testbox.test.local', :platform => "#{platform}") }
583
+ it "it sets the puppet.conf file to the provided config on #{platform}" do
584
+ config = { 'main' => {'server' => 'testbox.test.local'} }
585
+ expected_config_string = "[main]\nserver=testbox.test.local\n\n"
586
+
587
+ expect( subject ).to receive( :create_remote_file ).with(
588
+ host, anything, expected_config_string
589
+ )
590
+ subject.configure_puppet_on(host, config)
591
+ end
592
+ end
593
+ end
594
+ context 'on windows' do
595
+ let(:platform) { 'windows-2008R2-amd64' }
596
+ let(:host) { make_host('testbox.test.local', :platform => 'windows-2008R2-amd64') }
597
+
598
+ it 'it sets the puppet.conf file to the provided config' do
599
+ config = { 'main' => {'server' => 'testbox.test.local'} }
600
+ expected_config_string = "[main]\nserver=testbox.test.local\n\n"
601
+
602
+ expect( subject ).to receive( :create_remote_file ).with(
603
+ host, anything, expected_config_string
604
+ )
605
+ subject.configure_puppet_on(host, config)
606
+ end
607
+ end
608
+ end
609
+
610
+ describe 'configure_puppet' do
611
+ let(:hosts) do
612
+ make_hosts({:platform => platform })
613
+ end
614
+
615
+ before do
616
+ allow( subject ).to receive(:hosts).and_return(hosts)
617
+ allow( subject ).to receive(:on).and_return(Beaker::Result.new({},''))
618
+ end
619
+
620
+ context 'on debian' do
621
+ PlatformHelpers::DEBIANPLATFORMS.each do |platform|
622
+ let(:platform) { Beaker::Platform.new("#{platform}-ver-arch") }
623
+ it "calls configure_puppet_on correctly on #{platform}" do
624
+ config = { 'main' => {'server' => 'testbox.test.local'} }
625
+ expect( subject ).to receive( :configure_puppet_on ).with(
626
+ anything, config
627
+ ).exactly( hosts.length ).times
628
+ subject.configure_puppet(config)
629
+ end
630
+ end
631
+ end
632
+
633
+ context 'on windows' do
634
+ let(:platform) { 'windows-2008R2-amd64' }
635
+
636
+ it 'calls configure_puppet_on correctly' do
637
+ config = { 'main' => {'server' => 'testbox.test.local'} }
638
+ expect( subject ).to receive( :configure_puppet_on ).with(
639
+ anything, config
640
+ ).exactly( hosts.length ).times
641
+ subject.configure_puppet(config)
642
+ end
643
+ end
644
+ end
645
+
646
+ describe "#install_puppetlabs_release_repo" do
647
+ let( :platform ) { Beaker::Platform.new('solaris-7-i386') }
648
+ let( :host ) do
649
+ FakeHost.create('fakevm', platform.to_s)
650
+ end
651
+
652
+ before do
653
+ allow(subject).to receive(:options) { opts }
654
+ allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
655
+ end
656
+
657
+ describe "When host is unsupported platform" do
658
+ let( :platform ) { Beaker::Platform.new('solaris-7-i386') }
659
+
660
+ it "raises an exception." do
661
+ expect{
662
+ subject.install_puppetlabs_release_repo host
663
+ }.to raise_error(RuntimeError, /No repository installation step for/)
664
+ end
665
+ end
666
+
667
+ describe "When host is a debian-like platform" do
668
+ let( :platform ) { Beaker::Platform.new('debian-7-i386') }
669
+
670
+ it "downloads a deb file, installs, and updates the apt cache." do
671
+ expect(subject).to receive(:on).with( host, /wget .*/ ).ordered
672
+ expect(subject).to receive(:on).with( host, /dpkg .*/ ).ordered
673
+ expect(subject).to receive(:on).with( host, "apt-get update" ).ordered
674
+ subject.install_puppetlabs_release_repo host
675
+ end
676
+
677
+ end
678
+
679
+ end
680
+
681
+ describe '#install_puppetlabs_release_repo_on' do
682
+ let( :host ) do
683
+ FakeHost.create( 'fakevm', platform.to_s )
684
+ end
685
+
686
+ before :each do
687
+ allow( subject ).to receive( :options ) { opts }
688
+ end
689
+
690
+ context 'on cisco platforms' do
691
+ context 'version 5' do
692
+ let( :platform ) { Beaker::Platform.new( 'cisco_nexus-7-x86_64' ) }
693
+
694
+ it 'calls host.install_package' do
695
+ expect( host ).to receive( :install_package ).with( /\.rpm$/ )
696
+ subject.install_puppetlabs_release_repo_on( host )
697
+ end
698
+ end
699
+
700
+ context 'version 7' do
701
+ let( :platform ) { Beaker::Platform.new( 'cisco_ios_xr-6-x86_64' ) }
702
+
703
+ it 'uses yum localinstall to install the package' do
704
+ expect( subject ).to receive( :on ).with( host, /^yum.*localinstall.*\.rpm$/ )
705
+ subject.install_puppetlabs_release_repo_on( host )
706
+ end
707
+ end
708
+ end
709
+
710
+ end
711
+
712
+ describe "#install_puppetlabs_dev_repo" do
713
+ let( :package_name ) { "puppet" }
714
+ let( :package_version ) { "7.5.6" }
715
+ let( :host ) do
716
+ h = FakeHost.create('fakvm', platform.to_s, opts)
717
+ allow( h ).to receive( :link_exists? ).and_return( true )
718
+ h
719
+ end
720
+ let( :logger_double ) do
721
+ logger_double = Object.new
722
+ allow(logger_double).to receive(:debug)
723
+ allow(logger_double).to receive(:trace)
724
+ allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
725
+ subject.instance_variable_set(:@logger, logger_double)
726
+ logger_double
727
+ end
728
+
729
+ RSpec.shared_examples "install-dev-repo" do
730
+
731
+ it "scp's files to SUT then modifies them with find-and-sed 2-hit combo" do
732
+ allow(rez).to receive(:exit_code) { 0 }
733
+ allow(subject).to receive(:link_exists?).and_return(true)
734
+ expect(subject).to receive(:scp_to).with( host, repo_config, /.*/ ).ordered
735
+ subject.install_puppetlabs_dev_repo host, package_name, package_version
736
+ end
737
+
738
+ end
739
+
740
+ describe "When host is unsupported platform" do
741
+ let( :platform ) { Beaker::Platform.new('solaris-7-i386') }
742
+
743
+ it "raises an exception." do
744
+ # expect(subject).to receive(:on).with( host, /^mkdir -p .*$/ ).ordered
745
+ allow(subject).to receive(:options) { opts }
746
+ expect{
747
+ subject.install_puppetlabs_dev_repo host, package_name, package_version
748
+ }.to raise_error(RuntimeError, /No repository installation step for/)
749
+ end
750
+ end
751
+
752
+ describe 'When on supported platforms' do
753
+ # These are not factored into the `before` block above because they
754
+ # are expectations in the share examples, but aren't interesting
755
+ # beyond those basic tests
756
+ def stub_uninteresting_portions_of_install_puppetlabs_dev_repo!
757
+ allow(subject).to receive(:scp_to).with( host, repo_config, /.*/ ).ordered
758
+ end
759
+
760
+ let( :repo_config ) { "repoconfig" }
761
+ let( :repo_dir ) { "repodir" }
762
+ let( :rez ) { double }
763
+
764
+ before do
765
+ allow(subject).to receive(:fetch_http_file) { repo_config }
766
+ allow(subject).to receive(:fetch_http_dir) { repo_dir }
767
+ allow(subject).to receive(:on).with(host, "apt-get update") { }
768
+ allow(subject).to receive(:options) { opts }
769
+ allow(subject).to receive(:on).with( host, /^.* -d .*/, {:acceptable_exit_codes =>[0,1]} ).and_return(rez)
770
+ end
771
+
772
+ describe "that are debian-like" do
773
+ PlatformHelpers::DEBIANPLATFORMS.each do |platform|
774
+ let(:platform) { Beaker::Platform.new("#{platform}-ver-arch") }
775
+ before { allow(subject).to receive(:link_exists?).and_return(true) }
776
+
777
+ include_examples "install-dev-repo"
778
+
779
+ end
780
+ end
781
+
782
+ describe "that are redhat-like" do
783
+ let( :platform ) { Beaker::Platform.new('el-7-i386') }
784
+ include_examples "install-dev-repo"
785
+ end
786
+ end
787
+ end
788
+
789
+ describe '#install_packages_from_local_dev_repo' do
790
+ let( :package_name ) { 'puppet-agent' }
791
+ let( :platform ) { @platform || 'other' }
792
+ let( :host ) do
793
+ FakeHost.create('fakvm', platform, opts)
794
+ end
795
+
796
+ before :each do
797
+ allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
798
+ end
799
+
800
+ it 'sets the find command correctly for el-based systems' do
801
+ @platform = 'el-1-3'
802
+ expect( subject ).to receive( :on ).with( host, /\*\.rpm.+rpm\s-ivh/ )
803
+ subject.install_packages_from_local_dev_repo( host, package_name )
804
+ end
805
+
806
+ it 'sets the find command correctly for debian-based systems' do
807
+ @platform = 'debian-1-3'
808
+ expect( subject ).to receive( :on ).with( host, /\*\.deb.+dpkg\s-i/ )
809
+ subject.install_packages_from_local_dev_repo( host, package_name )
810
+ end
811
+
812
+ it 'fails correctly for systems not accounted for' do
813
+ @platform = 'eos-1-3'
814
+ expect{ subject.install_packages_from_local_dev_repo( host, package_name ) }.to raise_error RuntimeError
815
+ end
816
+
817
+ end
818
+
819
+ describe '#install_puppet_agent_from_msi_on' do
820
+ let( :opts ) { { :puppet_agent_version => 'VERSION', :win_download_url => 'http://downloads.puppetlabs.com/windows' } }
821
+ let( :platform ) { 'windows' }
822
+ let( :host ) { { :platform => platform } }
823
+
824
+ it 'returns error when link incorrect' do
825
+ allow(subject).to receive(:link_exists?).with(anything()).and_return( false )
826
+ expect( host ).to receive( :is_x86_64? ).and_return( true )
827
+
828
+ expect{
829
+ subject.install_puppet_agent_from_msi_on( host, opts )
830
+ }.to raise_error(RuntimeError, /Puppet MSI at http:\/\/downloads.puppetlabs.com\/windows\/puppet-agent-VERSION-x64.msi does not exist!/)
831
+ end
832
+
833
+ it 'uses x86 msi when host is_x86_64 and install_32 is set on the host' do
834
+ host['install_32'] = true
835
+
836
+ expect( host ).to receive( :is_x86_64? ).and_return( true )
837
+ expect( subject ).to receive( :install_a_puppet_msi_on ).with( host, opts )
838
+
839
+ subject.install_puppet_agent_from_msi_on( host, opts )
840
+ expect( host['dist'] ).to be == "puppet-agent-VERSION-x86"
841
+
842
+ end
843
+
844
+ it 'uses x86 msi when host is_x86_64 and install_32 is set on the options' do
845
+ opts['install_32'] = true
846
+
847
+ expect( host ).to receive( :is_x86_64? ).and_return( true )
848
+ expect( subject ).to receive( :install_a_puppet_msi_on ).with( host, opts )
849
+
850
+ subject.install_puppet_agent_from_msi_on( host, opts )
851
+ expect( host['dist'] ).to be == "puppet-agent-VERSION-x86"
852
+
853
+ end
854
+
855
+ it 'uses x86 msi when host is_x86_64 and ruby_arch is x86 on the host' do
856
+ host['ruby_arch'] = 'x86'
857
+
858
+ expect( host ).to receive( :is_x86_64? ).and_return( true )
859
+ expect( subject ).to receive( :install_a_puppet_msi_on ).with( host, opts )
860
+
861
+ subject.install_puppet_agent_from_msi_on( host, opts )
862
+ expect( host['dist'] ).to be == "puppet-agent-VERSION-x86"
863
+
864
+ end
865
+
866
+ it 'uses x86 msi when host !is_x86_64' do
867
+
868
+ expect( host ).to receive( :is_x86_64? ).and_return( false )
869
+ expect( subject ).to receive( :install_a_puppet_msi_on ).with( host, opts )
870
+
871
+ subject.install_puppet_agent_from_msi_on( host, opts )
872
+ expect( host['dist'] ).to be == "puppet-agent-VERSION-x86"
873
+
874
+ end
875
+
876
+ it 'uses x64 msi when host is_x86_64, no install_32 and ruby_arch != x86' do
877
+
878
+ expect( host ).to receive( :is_x86_64? ).and_return( true )
879
+ expect( subject ).to receive( :install_a_puppet_msi_on ).with( host, opts )
880
+
881
+ subject.install_puppet_agent_from_msi_on( host, opts )
882
+ expect( host['dist'] ).to be == "puppet-agent-VERSION-x64"
883
+
884
+ end
885
+ end
886
+
887
+ describe '#install_puppet_agent_pe_promoted_repo_on' do
888
+
889
+
890
+
891
+ end
892
+
893
+ describe '#install_cert_on_windows' do
894
+ before do
895
+ allow(subject).to receive(:on).and_return(Beaker::Result.new({},''))
896
+ end
897
+
898
+ context 'on windows' do
899
+ let(:platform) { 'windows-2008R2-amd64' }
900
+ let(:host) { make_host('testbox.test.local', :platform => 'windows-2008R2-amd64') }
901
+
902
+ it 'should install all 3 certs' do
903
+ cert = 'geotrust_global_ca'
904
+ content = <<-EOM
905
+ -----BEGIN CERTIFICATE-----
906
+ MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT
907
+ MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i
908
+ YWwgQ0EwHhcNMDIwNTIxMDQwMDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQG
909
+ EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEbMBkGA1UEAxMSR2VvVHJ1c3Qg
910
+ R2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2swYYzD9
911
+ 9BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjoBbdq
912
+ fnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDv
913
+ iS2Aelet8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU
914
+ 1XupGc1V3sjs0l44U+VcT4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+
915
+ bw8HHa8sHo9gOeL6NlMTOdReJivbPagUvTLrGAMoUgRx5aszPeE4uwc2hGKceeoW
916
+ MPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTA
917
+ ephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVkDBF9qn1l
918
+ uMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKIn
919
+ Z57QzxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfS
920
+ tQWVYrmm3ok9Nns4d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcF
921
+ PseKUgzbFbS9bZvlxrFUaKnjaZC2mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Un
922
+ hw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6pXE0zX5IJL4hmXXeXxx12E6nV
923
+ 5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw==
924
+ -----END CERTIFICATE-----
925
+ EOM
926
+
927
+ expect(subject).to receive(:create_remote_file) do |host, file_path, file_content|
928
+ expect(file_path).to eq("C:\\Windows\\Temp\\#{cert}.pem")
929
+ end
930
+
931
+ expect(subject).to receive(:on) do |host, command|
932
+ expect(command).to eq("certutil -v -addstore Root C:\\Windows\\Temp\\#{cert}.pem")
933
+ end
934
+
935
+ subject.install_cert_on_windows(host, cert, content)
936
+ end
937
+ end
938
+ end
939
+
940
+ describe '#install_puppet_agent_dev_repo_on' do
941
+ let( :package_name ) { 'puppet-agent' }
942
+ let( :platform ) { @platform || 'other' }
943
+ let( :host ) do
944
+ FakeHost.create( 'fakvm', platform, opts )
945
+ end
946
+
947
+ before :each do
948
+ allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
949
+ end
950
+
951
+ it 'raises an exception when host platform is unsupported' do
952
+ platform = Object.new()
953
+ allow(platform).to receive(:to_array) { ['ptan', '5', 'x4']}
954
+ host = basic_hosts.first
955
+ host['platform'] = platform
956
+ opts = { :version => '0.1.0' }
957
+ allow( subject ).to receive( :options ).and_return( {} )
958
+
959
+ expect{
960
+ subject.install_puppet_agent_dev_repo_on( host, opts )
961
+ }.to raise_error(RuntimeError, /No repository installation step for/)
962
+ end
963
+
964
+ it 'runs the correct install for el-based platforms' do
965
+ platform = Object.new()
966
+ allow(platform).to receive(:to_array) { ['el', '5', 'x4']}
967
+ host = basic_hosts.first
968
+ host['platform'] = platform
969
+ sha_value = 'ereiuwoiur'
970
+ opts = { :version => '0.1.0', :puppet_agent_sha => sha_value }
971
+ allow( subject ).to receive( :options ).and_return( {} )
972
+
973
+ expect( subject ).to receive( :install_puppetlabs_dev_repo ).with(
974
+ host, 'puppet-agent', sha_value, nil, anything )
975
+ expect( host ).to receive( :install_package ).with( 'puppet-agent' )
976
+
977
+ subject.install_puppet_agent_dev_repo_on( host, opts )
978
+ end
979
+
980
+ it 'runs the correct install for el-based platforms on s390x architectures' do
981
+ platform = Object.new()
982
+ allow(platform).to receive(:to_array) { ['el', '5', 's390x'] }
983
+ host = basic_hosts.first
984
+ host['platform'] = platform
985
+ sha_value = 'ereiuwoiur'
986
+ opts = { :version => '0.1.0', :puppet_agent_sha => sha_value }
987
+ allow( subject ).to receive( :options ).and_return( {} )
988
+
989
+ release_path_end = 'fake_release_path_end'
990
+ release_file = 'fake_29835_release_file'
991
+ expect( host ).to receive( :puppet_agent_dev_package_info ).and_return(
992
+ [ release_path_end, release_file ] )
993
+
994
+ expect(subject).not_to receive(:install_puppetlabs_dev_repo)
995
+ expect(host).not_to receive(:install_package)
996
+
997
+ expect(subject).to receive(:fetch_http_file).once.with(/#{release_path_end}$/, release_file, /\/el$/)
998
+ expect(subject).to receive(:scp_to).once.with(host, /#{release_file}$/, anything)
999
+ expect(subject).to receive(:on).ordered.with(host, /rpm -ivh.*#{release_file}$/)
1000
+
1001
+ subject.install_puppet_agent_dev_repo_on( host, opts )
1002
+ end
1003
+
1004
+ it 'runs the correct agent install for el-based platforms on ec2 hypervisor' do
1005
+ platform = Object.new()
1006
+ allow(platform).to receive(:to_array) { ['el', '5', 'x4'] }
1007
+ host = basic_hosts.first
1008
+ host['platform'] = platform
1009
+ host['hypervisor'] = 'ec2'
1010
+ sha_value = 'ereiuwoiur'
1011
+ opts = { :version => '0.1.0', :puppet_agent_sha => sha_value }
1012
+ allow( subject ).to receive( :options ).and_return( {} )
1013
+
1014
+ release_path_end = 'fake_release_path_end'
1015
+ release_file = 'fake_29835_release_file'
1016
+ expect( host ).to receive( :puppet_agent_dev_package_info ).and_return(
1017
+ [ release_path_end, release_file ] )
1018
+
1019
+ expect(subject).not_to receive(:install_puppetlabs_dev_repo)
1020
+ expect(host).not_to receive(:install_package)
1021
+
1022
+ expect(subject).to receive(:fetch_http_file).once.with(/#{release_path_end}$/, release_file, /\/el$/)
1023
+ expect(subject).to receive(:scp_to).once.with(host, /#{release_file}$/, anything)
1024
+ expect(subject).to receive(:on).ordered.with(host, /rpm -ivh.*#{release_file}$/)
1025
+
1026
+ subject.install_puppet_agent_dev_repo_on( host, opts )
1027
+ end
1028
+
1029
+ it 'runs the correct install for debian-based platforms' do
1030
+ platform = Object.new()
1031
+ allow(platform).to receive(:to_array) { ['debian', '5', 'x4']}
1032
+ host = basic_hosts.first
1033
+ host['platform'] = platform
1034
+ sha_value = 'ereigregerge'
1035
+ opts = { :version => '0.1.0', :puppet_agent_sha => sha_value }
1036
+ allow( subject ).to receive( :options ).and_return( {} )
1037
+
1038
+ expect( subject ).to receive( :install_puppetlabs_dev_repo ).with(
1039
+ host, 'puppet-agent', sha_value, nil, anything )
1040
+ expect( host ).to receive( :install_package ).with( 'puppet-agent' )
1041
+
1042
+ subject.install_puppet_agent_dev_repo_on( host, opts )
1043
+ end
1044
+
1045
+ it 'runs the correct install for windows platforms' do
1046
+ platform = Object.new()
1047
+ allow(platform).to receive(:to_array) { ['windows', '5', 'x64']}
1048
+ host = winhost
1049
+ external_copy_base = 'tmp_install_windows_copy_base_1325'
1050
+ allow( host ).to receive( :external_copy_base ).and_return( external_copy_base )
1051
+ host['platform'] = platform
1052
+ opts = { :version => '0.1.0' }
1053
+ allow( subject ).to receive( :options ).and_return( {} )
1054
+ copied_path = "#{win_temp}\\puppet-agent-0.1.0-x86.msi"
1055
+ mock_echo = Object.new()
1056
+ allow( mock_echo ).to receive( :raw_output ).and_return( copied_path )
1057
+
1058
+ expect(subject).to receive(:fetch_http_file).once.with(/\/windows$/, 'puppet-agent-0.1.0-x86.msi', /\/windows$/)
1059
+ expect(subject).to receive(:scp_to).once.with(host, /\/puppet-agent-0.1.0-x86.msi$/, /#{external_copy_base}/)
1060
+ expect(subject).to receive(:install_msi_on).with(host, copied_path, {}, {:debug => nil}).once
1061
+ expect(subject).to receive(:on).ordered.with(host, /echo/).and_return(mock_echo)
1062
+
1063
+ subject.install_puppet_agent_dev_repo_on( host, opts )
1064
+ end
1065
+
1066
+ it 'runs the correct install for osx platforms' do
1067
+ platform = Object.new()
1068
+ allow(platform).to receive(:to_array) { ['osx', '10.9', 'x86_64', 'mavericks']}
1069
+ host = machost
1070
+ host['platform'] = platform
1071
+ sha_value = 'runs the correct install for osx platforms'
1072
+ copy_dir_external = 'fake_15_copy_dir_external'
1073
+ opts = {
1074
+ :version => '0.1.0',
1075
+ :puppet_agent_sha => sha_value,
1076
+ :copy_dir_external => copy_dir_external
1077
+ }
1078
+
1079
+ release_path_end = 'fake_release_path_end'
1080
+ release_file = 'fake_29835_release_file'
1081
+ expect( host ).to receive( :puppet_agent_dev_package_info ).and_return(
1082
+ [ release_path_end, release_file ] )
1083
+
1084
+ expect(subject).to receive(:fetch_http_file).once.with(/#{release_path_end}$/, release_file, /\/osx$/)
1085
+ expect(subject).to receive(:scp_to).once.with(host, /#{release_file}$/, copy_dir_external)
1086
+ # the star is necessary, as that's not the entire filename, & we rely on
1087
+ # the globbing to get this right on OSX SUTs
1088
+ expect(host).to receive( :install_package ).with( /^puppet-agent-0.1.0\*$/ )
1089
+
1090
+ subject.install_puppet_agent_dev_repo_on( host, opts )
1091
+ end
1092
+
1093
+ it 'runs the correct install for solaris platforms' do
1094
+ @platform = 'solaris-10-x86_64'
1095
+ opts = { :version => '0.1.0' }
1096
+ allow( subject ).to receive( :options ).and_return( {} )
1097
+
1098
+ release_path_end = 'fake_release_path_end'
1099
+ release_file = 'fake_sol10_8495_release_file'
1100
+ expect( host ).to receive( :puppet_agent_dev_package_info ).and_return(
1101
+ [ release_path_end, release_file ] )
1102
+
1103
+ expect( subject ).to receive( :fetch_http_file ).once.with(
1104
+ /#{release_path_end}$/, release_file, anything )
1105
+ expect( subject ).to receive( :scp_to ).once.with(
1106
+ host, /#{release_file}$/, anything )
1107
+
1108
+ expect( host ).to receive( :solaris_install_local_package )
1109
+
1110
+ allow( subject ).to receive( :configure_type_defaults_on )
1111
+ subject.install_puppet_agent_dev_repo_on( host, opts )
1112
+ end
1113
+
1114
+ it 'allows you to override the local copy directory' do
1115
+ # only applies to hosts that don't go down the
1116
+ # install_puppetlabs_dev_repo route
1117
+ platform = Object.new()
1118
+ allow( platform ).to receive( :to_array ) { ['eos', '5', 'x4'] }
1119
+ host = eoshost
1120
+ host['platform'] = platform
1121
+ sha_value = 'dahdahdahdah'
1122
+ copy_base_local_override = 'face'
1123
+ opts = {
1124
+ :version => '0.1.0',
1125
+ :copy_base_local => copy_base_local_override,
1126
+ :puppet_agent_sha => sha_value
1127
+ }
1128
+ allow( subject ).to receive( :options ).and_return( {} )
1129
+
1130
+ allow( host ).to receive( :puppet_agent_dev_package_info ).and_return( ['', ''] )
1131
+
1132
+ allow( host ).to receive( :get_remote_file).once.with(anything)
1133
+ allow( host ).to receive( :install_from_file )
1134
+
1135
+ subject.install_puppet_agent_dev_repo_on( host, opts )
1136
+ end
1137
+
1138
+ it 'allows you to override the external copy directory' do
1139
+ platform = Object.new()
1140
+ allow(platform).to receive(:to_array) { ['osx', '5', 'x4']}
1141
+ host = basic_hosts.first
1142
+ host['platform'] = platform
1143
+ copy_dir_custom = 'muppetsBB8-1435'
1144
+ opts = { :version => '0.1.0', :copy_dir_external => copy_dir_custom }
1145
+ allow( subject ).to receive( :options ).and_return( {} )
1146
+
1147
+ allow( host ).to receive( :puppet_agent_dev_package_info ).and_return( ['', ''] )
1148
+
1149
+ allow( subject ).to receive( :fetch_http_file ).once
1150
+ expect( subject ).to receive( :scp_to ).once.with(
1151
+ host, anything, /#{copy_dir_custom}/ )
1152
+ allow( host ).to receive( :install_package )
1153
+
1154
+ subject.install_puppet_agent_dev_repo_on( host, opts )
1155
+ end
1156
+
1157
+ it 'copies package to the cygwin root directory and installs it' do
1158
+ @platform = 'windows-7-x86_64'
1159
+ expect( subject ).to receive( :install_msi_on ).with( any_args )
1160
+ copy_base = 'copy_base_cygwin'
1161
+ allow( host ).to receive( :external_copy_base ).and_return( copy_base )
1162
+ expect( subject ).to receive( :scp_to ).with( host, /puppet-agent-1\.0\.0-x86\.msi/, /#{copy_base}/ )
1163
+ expect( subject ).to receive( :configure_type_defaults_on ).with(host)
1164
+ expect( subject ).to receive( :fetch_http_file ).with( /[^\/]\z/, anything, anything )
1165
+ subject.install_puppet_agent_dev_repo_on( host, opts.merge({ :puppet_agent_version => '1.0.0' }) )
1166
+ end
1167
+
1168
+ it 'installs on different hosts without erroring' do
1169
+ mhosts = hosts
1170
+ mhosts[3] = eoshost
1171
+
1172
+ mhosts.each_with_index do |host, index|
1173
+ platform = Object.new()
1174
+ if index == 0
1175
+ allow(platform).to receive(:to_array) { ['solaris', '5', 'x4']}
1176
+ allow(host).to receive(:external_copy_base) {'/host0'}
1177
+ elsif index == 1
1178
+ allow(platform).to receive(:to_array) { ['windows', '5', 'x4']}
1179
+ allow(host).to receive(:external_copy_base) {'/host1'}
1180
+ elsif index == 2
1181
+ allow(platform).to receive(:to_array) { ['osx', '5', 'x4']}
1182
+ allow(host).to receive(:external_copy_base) {'/host2'}
1183
+ elsif index == 3
1184
+ allow(platform).to receive(:to_array) { ['eos', '5', 'x4']}
1185
+ allow(host).to receive(:external_copy_base) {'/host3'}
1186
+ end
1187
+ host['platform'] = platform
1188
+ allow(host).to receive(:puppet_agent_dev_package_info).with(any_args).and_return(["test", "blah"])
1189
+ end
1190
+
1191
+ expect( subject ).to receive(:add_role).with( any_args ).exactly(mhosts.length).times
1192
+
1193
+ expect( subject ).to receive(:fetch_http_file).with( any_args ).exactly(3).times
1194
+ expect( subject ).to receive(:scp_to).with( any_args ).exactly(3).times
1195
+
1196
+ expect( subject ).to receive(:install_msi_on).with( mhosts[1], 'xyz', {}, anything).exactly(1).times
1197
+ expect( mhosts[0] ).to receive(:solaris_install_local_package).with( "blah", "/host0" ).exactly(1).times
1198
+ expect( mhosts[2] ).to receive(:install_package).with( any_args ).exactly(1).times
1199
+ expect( mhosts[3] ).to receive(:install_from_file).with( "blah" ).exactly(1).times
1200
+
1201
+ result = object_double(Beaker::Result.new({}, "foo"), :raw_output=> "xyz")
1202
+ allow(subject).to receive(:on).with(mhosts[1], anything).and_return(result)
1203
+
1204
+ expect( subject ).to receive(:configure_type_defaults_on).with( any_args ).exactly(mhosts.length).times
1205
+
1206
+ subject.install_puppet_agent_dev_repo_on( mhosts, opts.merge({:puppet_agent_version => '1.0.0' }) )
1207
+ end
1208
+
1209
+ it 'installs on different hosts with options specifying :copy_dir_external' do
1210
+ mhosts = hosts
1211
+ mhosts[3] = eoshost
1212
+
1213
+ mhosts.each_with_index do |host, index|
1214
+ platform = Object.new()
1215
+ if index == 0
1216
+ allow(platform).to receive(:to_array) { ['solaris', '5', 'x4']}
1217
+ allow(host).to receive(:external_copy_base) {'/host0'}
1218
+ elsif index == 1
1219
+ allow(platform).to receive(:to_array) { ['windows', '5', 'x4']}
1220
+ allow(host).to receive(:external_copy_base) {'/host1'}
1221
+ elsif index == 2
1222
+ allow(platform).to receive(:to_array) { ['osx', '5', 'x4']}
1223
+ allow(host).to receive(:external_copy_base) {'/host2'}
1224
+ elsif index == 3
1225
+ allow(platform).to receive(:to_array) { ['eos', '5', 'x4']}
1226
+ allow(host).to receive(:external_copy_base) {'/host3'}
1227
+ end
1228
+ allow(host).to receive(:puppet_agent_dev_package_info).with(any_args).and_return(["test", "/blah"])
1229
+ host['platform'] = platform
1230
+ end
1231
+
1232
+ expect( subject ).to receive(:add_role).with( any_args ).exactly(mhosts.length).times
1233
+
1234
+ expect( subject ).to receive(:fetch_http_file).with( any_args ).exactly(3).times
1235
+ expect( subject ).to receive(:scp_to).with( any_args ).exactly(3).times
1236
+
1237
+ expect( subject ).to receive(:install_msi_on).with(mhosts[1], 'xyz', {}, anything ).exactly(1).times
1238
+ expect( mhosts[0] ).to receive(:solaris_install_local_package).with( '/blah', '/tmp').exactly(1).times
1239
+ expect( mhosts[2] ).to receive(:install_package).with( any_args ).exactly(1).times
1240
+ expect( mhosts[3] ).to receive(:install_from_file).with( '/blah').exactly(1).times
1241
+ expect( mhosts[0] ).to receive(:external_copy_base).with( no_args ).exactly(0).times
1242
+ expect( mhosts[1] ).to receive(:external_copy_base).with( no_args ).exactly(0).times
1243
+ expect( mhosts[2] ).to receive(:external_copy_base).with( no_args ).exactly(0).times
1244
+ expect( mhosts[3] ).to receive(:external_copy_base).with( no_args ).exactly(0).times
1245
+
1246
+ result = object_double(Beaker::Result.new({}, "foo"), :raw_output=> "xyz")
1247
+ allow(subject).to receive(:on).with(mhosts[1], anything).and_return(result)
1248
+
1249
+ expect( subject ).to receive(:configure_type_defaults_on).with( any_args ).exactly(mhosts.length).times
1250
+
1251
+ subject.install_puppet_agent_dev_repo_on( mhosts, opts.merge({:puppet_agent_version => '1.0.0', :copy_dir_external => '/tmp' }) )
1252
+ end
1253
+ end
1254
+
1255
+ describe '#install_puppet_agent_pe_promoted_repo_on' do
1256
+ let( :package_name ) { 'puppet-agent' }
1257
+ let( :platform ) { @platform || 'other' }
1258
+ let( :host ) do
1259
+ FakeHost.create( 'fakvm', platform, opts )
1260
+ end
1261
+
1262
+ before :each do
1263
+ allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
1264
+ allow( subject ).to receive( :install_msi_on ).with( any_args )
1265
+ end
1266
+
1267
+ def test_fetch_http_file_no_ending_slash(platform)
1268
+ @platform = platform
1269
+ allow( subject ).to receive( :scp_to )
1270
+ allow( subject ).to receive( :configure_type_defaults_on ).with(host)
1271
+
1272
+ expect( subject ).to receive( :fetch_http_file ).with( /[^\/]\z/, anything, anything )
1273
+ subject.install_puppet_agent_pe_promoted_repo_on( host, opts )
1274
+ end
1275
+
1276
+ context 'on windows' do
1277
+
1278
+ it 'calls fetch_http_file with no ending slash' do
1279
+ test_fetch_http_file_no_ending_slash( 'windows-7-x86_64' )
1280
+ end
1281
+ end
1282
+
1283
+ it 'calls fetch_http_file with no ending slash' do
1284
+ test_fetch_http_file_no_ending_slash( 'debian-5-x86_64' )
1285
+ end
1286
+ end
1287
+
1288
+ describe '#remove_puppet_on' do
1289
+ supported_platforms = [ 'aix-53-power',
1290
+ 'aix-61-power',
1291
+ 'aix-71-power',
1292
+ 'solaris-10-x86_64',
1293
+ 'solaris-10-x86_64',
1294
+ 'solaris-11-x86_64',
1295
+ 'cumulus-2.2-amd64',
1296
+ 'el-6-x86_64',
1297
+ 'redhat-7-x86_64',
1298
+ 'centos-7-x86_64',
1299
+ 'oracle-7-x86_64',
1300
+ 'scientific-7-x86_64',
1301
+ 'sles-10-x86_64',
1302
+ 'sles-11-x86_64',
1303
+ 'sles-12-s390x'
1304
+ ]
1305
+
1306
+ supported_platforms.each do |platform|
1307
+ let(:host) { make_host(platform, :platform => platform) }
1308
+
1309
+ pkg_list = 'foo bar'
1310
+
1311
+ it "uninstalls packages on #{platform}" do
1312
+ result = Beaker::Result.new(host,'')
1313
+ result.stdout = pkg_list
1314
+
1315
+ expected_list = pkg_list
1316
+ cmd_args = ''
1317
+
1318
+ expect( subject ).to receive(:on).exactly(2).times.and_return(result, result)
1319
+ expect( host ).to receive(:uninstall_package).with(expected_list, cmd_args)
1320
+
1321
+ subject.remove_puppet_on( host )
1322
+ end
1323
+ end
1324
+
1325
+ let(:ubuntu12) { make_host('ubuntu-1204-amd64', :platform => 'ubuntu-1204-amd64') }
1326
+ it 'raises error on unsupported platforms' do
1327
+ expect { subject.remove_puppet_on( ubuntu12 ) }.to raise_error(RuntimeError, /unsupported platform/)
1328
+ end
1329
+
1330
+ end
1331
+
1332
+ end