beaker 2.7.1 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +8 -8
  2. data/HISTORY.md +121 -2
  3. data/lib/beaker/dsl.rb +2 -2
  4. data/lib/beaker/dsl/helpers.rb +13 -1429
  5. data/lib/beaker/dsl/helpers/facter_helpers.rb +48 -0
  6. data/lib/beaker/dsl/helpers/hiera_helpers.rb +71 -0
  7. data/lib/beaker/dsl/helpers/host_helpers.rb +506 -0
  8. data/lib/beaker/dsl/helpers/puppet_helpers.rb +698 -0
  9. data/lib/beaker/dsl/helpers/tk_helpers.rb +101 -0
  10. data/lib/beaker/dsl/helpers/web_helpers.rb +115 -0
  11. data/lib/beaker/dsl/install_utils.rb +8 -1570
  12. data/lib/beaker/dsl/install_utils/ezbake_utils.rb +256 -0
  13. data/lib/beaker/dsl/install_utils/module_utils.rb +237 -0
  14. data/lib/beaker/dsl/install_utils/pe_utils.rb +518 -0
  15. data/lib/beaker/dsl/install_utils/puppet_utils.rb +722 -0
  16. data/lib/beaker/dsl/outcomes.rb +0 -4
  17. data/lib/beaker/dsl/roles.rb +0 -3
  18. data/lib/beaker/dsl/structure.rb +127 -4
  19. data/lib/beaker/dsl/wrappers.rb +0 -4
  20. data/lib/beaker/host.rb +23 -0
  21. data/lib/beaker/host/unix/pkg.rb +4 -4
  22. data/lib/beaker/host_prebuilt_steps.rb +11 -5
  23. data/lib/beaker/hypervisor/vagrant.rb +1 -0
  24. data/lib/beaker/hypervisor/vmpooler.rb +38 -0
  25. data/lib/beaker/logger.rb +10 -4
  26. data/lib/beaker/network_manager.rb +5 -4
  27. data/lib/beaker/options/command_line_parser.rb +7 -0
  28. data/lib/beaker/shared.rb +2 -1
  29. data/lib/beaker/shared/semvar.rb +41 -0
  30. data/lib/beaker/test_suite.rb +20 -6
  31. data/lib/beaker/version.rb +1 -1
  32. data/spec/beaker/dsl/helpers/facter_helpers_spec.rb +59 -0
  33. data/spec/beaker/dsl/helpers/hiera_helpers_spec.rb +96 -0
  34. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +413 -0
  35. data/spec/beaker/dsl/{helpers_spec.rb → helpers/puppet_helpers_spec.rb} +2 -611
  36. data/spec/beaker/dsl/helpers/tk_helpers_spec.rb +83 -0
  37. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +60 -0
  38. data/spec/beaker/dsl/install_utils/module_utils_spec.rb +241 -0
  39. data/spec/beaker/dsl/install_utils/pe_utils_spec.rb +475 -0
  40. data/spec/beaker/dsl/install_utils/puppet_utils_spec.rb +523 -0
  41. data/spec/beaker/dsl/structure_spec.rb +108 -0
  42. data/spec/beaker/host_prebuilt_steps_spec.rb +44 -0
  43. data/spec/beaker/host_spec.rb +41 -0
  44. data/spec/beaker/hypervisor/vagrant_spec.rb +2 -1
  45. data/spec/beaker/logger_spec.rb +9 -2
  46. data/spec/beaker/network_manager_spec.rb +7 -1
  47. data/spec/beaker/options/command_line_parser_spec.rb +3 -2
  48. data/spec/beaker/shared/semvar_spec.rb +36 -0
  49. data/spec/beaker/test_suite_spec.rb +48 -0
  50. data/spec/mocks.rb +10 -0
  51. metadata +23 -5
  52. data/lib/beaker/dsl/ezbake_utils.rb +0 -259
  53. data/spec/beaker/dsl/install_utils_spec.rb +0 -1242
@@ -0,0 +1,523 @@
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(:presets) { Beaker::Options::Presets.new }
18
+ let(:opts) { presets.presets.merge(presets.env_vars) }
19
+ let(:basic_hosts) { make_hosts( { :pe_ver => '3.0',
20
+ :platform => 'linux',
21
+ :roles => [ 'agent' ] }, 4 ) }
22
+ let(:hosts) { basic_hosts[0][:roles] = ['master', 'database', 'dashboard']
23
+ basic_hosts[1][:platform] = 'windows'
24
+ basic_hosts[2][:platform] = 'osx-10.9-x86_64'
25
+ basic_hosts[3][:platform] = 'eos'
26
+ basic_hosts }
27
+ let(:hosts_sorted) { [ hosts[1], hosts[0], hosts[2], hosts[3] ] }
28
+ let(:winhost) { make_host( 'winhost', { :platform => 'windows',
29
+ :pe_ver => '3.0',
30
+ :working_dir => '/tmp' } ) }
31
+ let(:machost) { make_host( 'machost', { :platform => 'osx-10.9-x86_64',
32
+ :pe_ver => '3.0',
33
+ :working_dir => '/tmp' } ) }
34
+ let(:unixhost) { make_host( 'unixhost', { :platform => 'linux',
35
+ :pe_ver => '3.0',
36
+ :working_dir => '/tmp',
37
+ :dist => 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-debian-7-i386' } ) }
38
+ let(:eoshost) { make_host( 'eoshost', { :platform => 'eos',
39
+ :pe_ver => '3.0',
40
+ :working_dir => '/tmp',
41
+ :dist => 'puppet-enterprise-3.7.1-rc0-78-gffc958f-eos-4-i386' } ) }
42
+
43
+
44
+ context 'extract_repo_info_from' do
45
+ [{ :protocol => 'git', :path => 'git://github.com/puppetlabs/project.git' },
46
+ { :protocol => 'ssh', :path => 'git@github.com:puppetlabs/project.git' },
47
+ { :protocol => 'https', :path => 'https://github.com:puppetlabs/project' },
48
+ { :protocol => 'file', :path => 'file:///home/example/project' }
49
+ ].each do |type|
50
+ it "handles #{ type[:protocol] } uris" do
51
+ uri = "#{ type[:path] }#master"
52
+ repo_info = subject.extract_repo_info_from uri
53
+ expect( repo_info[:name] ).to be == 'project'
54
+ expect( repo_info[:path] ).to be == type[:path]
55
+ expect( repo_info[:rev] ).to be == 'master'
56
+ end
57
+ end
58
+ end
59
+
60
+ context 'order_packages' do
61
+ it 'orders facter, hiera before puppet, before anything else' do
62
+ named_repos = [
63
+ { :name => 'puppet_plugin' }, { :name => 'puppet' }, { :name => 'facter' }
64
+ ]
65
+ ordered_repos = subject.order_packages named_repos
66
+ expect( ordered_repos[0][:name] ).to be == 'facter'
67
+ expect( ordered_repos[1][:name] ).to be == 'puppet'
68
+ expect( ordered_repos[2][:name] ).to be == 'puppet_plugin'
69
+ end
70
+ end
71
+
72
+ context 'find_git_repo_versions' do
73
+ it 'returns a hash of :name => version' do
74
+ host = double( 'Host' )
75
+ repository = { :name => 'name' }
76
+ path = '/path/to/repo'
77
+ cmd = 'cd /path/to/repo/name && git describe || true'
78
+ logger = double.as_null_object
79
+
80
+ expect( subject ).to receive( :logger ).and_return( logger )
81
+ expect( subject ).to receive( :on ).with( host, cmd ).and_yield
82
+ expect( subject ).to receive( :stdout ).and_return( '2' )
83
+
84
+ version = subject.find_git_repo_versions( host, path, repository )
85
+
86
+ expect( version ).to be == { 'name' => '2' }
87
+ end
88
+ end
89
+
90
+ context 'install_from_git' do
91
+ it 'does a ton of stuff it probably shouldnt' do
92
+ repo = { :name => 'puppet',
93
+ :path => 'git://my.server.net/puppet.git',
94
+ :rev => 'master' }
95
+ path = '/path/to/repos'
96
+ host = { 'platform' => 'debian' }
97
+ logger = double.as_null_object
98
+
99
+ expect( subject ).to receive( :logger ).exactly( 3 ).times.and_return( logger )
100
+ expect( subject ).to receive( :on ).exactly( 4 ).times
101
+
102
+ subject.install_from_git( host, path, repo )
103
+ end
104
+
105
+ it 'allows a checkout depth of 1' do
106
+ repo = { :name => 'puppet',
107
+ :path => 'git://my.server.net/puppet.git',
108
+ :rev => 'master',
109
+ :depth => 1 }
110
+
111
+ path = '/path/to/repos'
112
+ cmd = "test -d #{path}/#{repo[:name]} || git clone --branch #{repo[:rev]} --depth #{repo[:depth]} #{repo[:path]} #{path}/#{repo[:name]}"
113
+ host = { 'platform' => 'debian' }
114
+ logger = double.as_null_object
115
+ expect( subject ).to receive( :logger ).exactly( 3 ).times.and_return( logger )
116
+ expect( subject ).to receive( :on ).with( host,"test -d #{path} || mkdir -p #{path}").exactly( 1 ).times
117
+ # this is the the command we want to test
118
+ expect( subject ).to receive( :on ).with( host, cmd ).exactly( 1 ).times
119
+ 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]}" ).exactly( 1 ).times
120
+ expect( subject ).to receive( :on ).with( host, "cd #{path}/#{repo[:name]} && if [ -f install.rb ]; then ruby ./install.rb ; else true; fi" ).exactly( 1 ).times
121
+
122
+ subject.install_from_git( host, path, repo )
123
+ end
124
+
125
+ it 'allows a checkout depth with a rev from a specific branch' do
126
+ repo = { :name => 'puppet',
127
+ :path => 'git://my.server.net/puppet.git',
128
+ :rev => 'a2340acddadfeafd234230faf',
129
+ :depth => 50,
130
+ :depth_branch => 'master' }
131
+
132
+ path = '/path/to/repos'
133
+ cmd = "test -d #{path}/#{repo[:name]} || git clone --branch #{repo[:depth_branch]} --depth #{repo[:depth]} #{repo[:path]} #{path}/#{repo[:name]}"
134
+ host = { 'platform' => 'debian' }
135
+ logger = double.as_null_object
136
+ expect( subject ).to receive( :logger ).exactly( 3 ).times.and_return( logger )
137
+ expect( subject ).to receive( :on ).with( host,"test -d #{path} || mkdir -p #{path}").exactly( 1 ).times
138
+ # this is the the command we want to test
139
+ expect( subject ).to receive( :on ).with( host, cmd ).exactly( 1 ).times
140
+ 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]}" ).exactly( 1 ).times
141
+ expect( subject ).to receive( :on ).with( host, "cd #{path}/#{repo[:name]} && if [ -f install.rb ]; then ruby ./install.rb ; else true; fi" ).exactly( 1 ).times
142
+
143
+ subject.install_from_git( host, path, repo )
144
+ end
145
+ end
146
+
147
+ describe '#install_puppet' do
148
+ let(:hosts) do
149
+ make_hosts({:platform => platform })
150
+ end
151
+
152
+ before do
153
+ allow( subject ).to receive(:hosts).and_return(hosts)
154
+ allow( subject ).to receive(:on).and_return(Beaker::Result.new({},''))
155
+ end
156
+ context 'on el-6' do
157
+ let(:platform) { "el-6-i386" }
158
+ it 'installs' do
159
+ expect(subject).to receive(:on).with(hosts[0], /puppetlabs-release-el-6\.noarch\.rpm/)
160
+ expect(subject).to receive(:on).with(hosts[0], 'yum install -y puppet')
161
+ subject.install_puppet
162
+ end
163
+ it 'installs specific version of puppet when passed :version' do
164
+ expect(subject).to receive(:on).with(hosts[0], 'yum install -y puppet-3000')
165
+ subject.install_puppet( :version => '3000' )
166
+ end
167
+ it 'can install specific versions of puppets dependencies' do
168
+ expect(subject).to receive(:on).with(hosts[0], 'yum install -y puppet-3000')
169
+ expect(subject).to receive(:on).with(hosts[0], 'yum install -y hiera-2001')
170
+ expect(subject).to receive(:on).with(hosts[0], 'yum install -y facter-1999')
171
+ subject.install_puppet( :version => '3000', :facter_version => '1999', :hiera_version => '2001' )
172
+ end
173
+ end
174
+ context 'on el-5' do
175
+ let(:platform) { "el-5-i386" }
176
+ it 'installs' do
177
+ expect(subject).to receive(:on).with(hosts[0], /puppetlabs-release-el-5\.noarch\.rpm/)
178
+ expect(subject).to receive(:on).with(hosts[0], 'yum install -y puppet')
179
+ subject.install_puppet
180
+ end
181
+ end
182
+ context 'on fedora' do
183
+ let(:platform) { "fedora-18-x86_84" }
184
+ it 'installs' do
185
+ expect(subject).to receive(:on).with(hosts[0], /puppetlabs-release-fedora-18\.noarch\.rpm/)
186
+ expect(subject).to receive(:on).with(hosts[0], 'yum install -y puppet')
187
+ subject.install_puppet
188
+ end
189
+ end
190
+ context 'on debian' do
191
+ let(:platform) { "debian-7-amd64" }
192
+ it 'installs latest if given no version info' do
193
+ expect(subject).to receive(:on).with(hosts[0], /puppetlabs-release-\$\(lsb_release -c -s\)\.deb/)
194
+ expect(subject).to receive(:on).with(hosts[0], 'dpkg -i puppetlabs-release-$(lsb_release -c -s).deb')
195
+ expect(subject).to receive(:on).with(hosts[0], 'apt-get update')
196
+ expect(subject).to receive(:on).with(hosts[0], 'apt-get install -y puppet')
197
+ subject.install_puppet
198
+ end
199
+ it 'installs specific version of puppet when passed :version' do
200
+ expect(subject).to receive(:on).with(hosts[0], 'apt-get install -y puppet=3000-1puppetlabs1')
201
+ subject.install_puppet( :version => '3000' )
202
+ end
203
+ it 'can install specific versions of puppets dependencies' do
204
+ expect(subject).to receive(:on).with(hosts[0], 'apt-get install -y puppet=3000-1puppetlabs1')
205
+ expect(subject).to receive(:on).with(hosts[0], 'apt-get install -y hiera=2001-1puppetlabs1')
206
+ expect(subject).to receive(:on).with(hosts[0], 'apt-get install -y facter=1999-1puppetlabs1')
207
+ subject.install_puppet( :version => '3000', :facter_version => '1999', :hiera_version => '2001' )
208
+ end
209
+ end
210
+ context 'on windows' do
211
+ let(:platform) { "windows-2008r2-i386" }
212
+ it 'installs specific version of puppet when passed :version' do
213
+ allow(subject).to receive(:link_exists?).and_return( true )
214
+ expect(subject).to receive(:on).with(hosts[0], 'curl -O http://downloads.puppetlabs.com/windows/puppet-3000.msi')
215
+ expect(subject).to receive(:on).with(hosts[0], " echo 'export PATH=$PATH:\"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin\":\"/cygdrive/c/Program Files/Puppet Labs/Puppet/bin\"' > /etc/bash.bashrc ")
216
+ expect(subject).to receive(:on).with(hosts[0], 'cmd /C \'start /w msiexec.exe /qn /i puppet-3000.msi\'')
217
+ subject.install_puppet(:version => '3000')
218
+ end
219
+ it 'installs from custom url when passed :win_download_url' do
220
+ allow(subject).to receive(:link_exists?).and_return( true )
221
+ expect(subject).to receive(:on).with(hosts[0], 'curl -O http://nightlies.puppetlabs.com/puppet-latest/repos/windows/puppet-3000.msi')
222
+ expect(subject).to receive(:on).with(hosts[0], 'cmd /C \'start /w msiexec.exe /qn /i puppet-3000.msi\'')
223
+ subject.install_puppet( :version => '3000', :win_download_url => 'http://nightlies.puppetlabs.com/puppet-latest/repos/windows' )
224
+ end
225
+ end
226
+ describe 'on unsupported platforms' do
227
+ let(:platform) { 'solaris-11-x86_64' }
228
+ let(:host) { make_host('henry', :platform => 'solaris-11-x86_64') }
229
+ let(:hosts) { [host] }
230
+ it 'by default raises an error' do
231
+ expect(subject).to_not receive(:on)
232
+ expect { subject.install_puppet }.to raise_error(/unsupported platform/)
233
+ end
234
+ it 'falls back to installing from gem when given :default_action => "gem_install"' do
235
+ result = double
236
+ gem_env_string = '{"RubyGems Environment": [ {"GEM PATHS": [], "EXECUTABLE DIRECTORY": "/does/not/exist" } ] }'
237
+ allow( result ).to receive(:stdout).and_return gem_env_string
238
+ allow(subject).to receive(:on).with(host, /gem environment/).and_return result
239
+ expect(subject).to receive(:on).with(host, /gem install/)
240
+ subject.install_puppet :default_action => 'gem_install'
241
+ end
242
+ end
243
+ end
244
+
245
+ describe 'configure_puppet_on' do
246
+ before do
247
+ allow(subject).to receive(:on).and_return(Beaker::Result.new({},''))
248
+ end
249
+ context 'on debian' do
250
+ let(:platform) { 'debian-7-amd64' }
251
+ let(:host) { make_host('testbox.test.local', :platform => 'debian-7-amd64') }
252
+ it 'it sets the puppet.conf file to the provided config' do
253
+ config = { 'main' => {'server' => 'testbox.test.local'} }
254
+ expect(subject).to receive(:on).with(host, "echo \"[main]\nserver=testbox.test.local\n\n\" > #{host.puppet['config']}")
255
+ subject.configure_puppet_on(host, config)
256
+ end
257
+ end
258
+ context 'on windows' do
259
+ let(:platform) { 'windows-2008R2-amd64' }
260
+ let(:host) { make_host('testbox.test.local', :platform => 'windows-2008R2-amd64') }
261
+ it 'it sets the puppet.conf file to the provided config' do
262
+ config = { 'main' => {'server' => 'testbox.test.local'} }
263
+ expect(subject).to receive(:on) do |host, command|
264
+ expect(command.command).to eq('powershell.exe')
265
+ expect(command.args).to eq(["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command $text = \\\"[main]`nserver=testbox.test.local`n`n\\\"; Set-Content -path '#{host.puppet['config']}' -value $text"])
266
+ end
267
+ subject.configure_puppet_on(host, config)
268
+ end
269
+ end
270
+ end
271
+
272
+ describe 'configure_puppet' do
273
+ let(:hosts) do
274
+ make_hosts({:platform => platform })
275
+ end
276
+
277
+ before do
278
+ allow( subject ).to receive(:hosts).and_return(hosts)
279
+ allow( subject ).to receive(:on).and_return(Beaker::Result.new({},''))
280
+ end
281
+ context 'on debian' do
282
+ let(:platform) { 'debian-7-amd64' }
283
+ it 'it sets the puppet.conf file to the provided config' do
284
+ config = { 'main' => {'server' => 'testbox.test.local'} }
285
+ expect(subject).to receive(:on).with(hosts[0], "echo \"[main]\nserver=testbox.test.local\n\n\" > #{hosts[0].puppet['config']}")
286
+ subject.configure_puppet(config)
287
+ end
288
+ end
289
+ context 'on windows' do
290
+ let(:platform) { 'windows-2008R2-amd64' }
291
+ it 'it sets the puppet.conf file to the provided config' do
292
+ config = { 'main' => {'server' => 'testbox.test.local'} }
293
+ expect(subject).to receive(:on) do |host, command|
294
+ expect(command.command).to eq('powershell.exe')
295
+ expect(command.args).to eq(["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command $text = \\\"[main]`nserver=testbox.test.local`n`n\\\"; Set-Content -path '#{host.puppet['config']}' -value $text"])
296
+ end
297
+ subject.configure_puppet(config)
298
+ end
299
+ end
300
+ end
301
+
302
+ describe "#install_puppetlabs_release_repo" do
303
+ let( :platform ) { Beaker::Platform.new('solaris-7-i386') }
304
+ let( :host ) do
305
+ FakeHost.create('fakevm', platform.to_s)
306
+ end
307
+
308
+ before do
309
+ allow(subject).to receive(:options) { opts }
310
+ end
311
+
312
+ describe "When host is unsupported platform" do
313
+ let( :platform ) { Beaker::Platform.new('solaris-7-i386') }
314
+
315
+ it "raises an exception." do
316
+ expect{
317
+ subject.install_puppetlabs_release_repo host
318
+ }.to raise_error(RuntimeError, /No repository installation step for/)
319
+ end
320
+ end
321
+
322
+ describe "When host is a debian-like platform" do
323
+ let( :platform ) { Beaker::Platform.new('debian-7-i386') }
324
+
325
+ it "downloads a deb file, installs, and updates the apt cache." do
326
+ expect(subject).to receive(:on).with( host, /wget .*/ ).ordered
327
+ expect(subject).to receive(:on).with( host, /dpkg .*/ ).ordered
328
+ expect(subject).to receive(:on).with( host, "apt-get update" ).ordered
329
+ subject.install_puppetlabs_release_repo host
330
+ end
331
+
332
+ end
333
+
334
+ describe "When host is a redhat-like platform" do
335
+ let( :platform ) { Beaker::Platform.new('el-7-i386') }
336
+
337
+ it "installs an rpm" do
338
+ expect(subject).to receive(:on).with( host, /rpm .*/ ).ordered
339
+ subject.install_puppetlabs_release_repo host
340
+ end
341
+
342
+ end
343
+
344
+ end
345
+
346
+ RSpec.shared_examples "install-dev-repo" do
347
+ let( :repo_config ) { "repoconfig" }
348
+ let( :repo_dir ) { "repodir" }
349
+
350
+ before do
351
+ allow(subject).to receive(:fetch_http_file) { repo_config }
352
+ allow(subject).to receive(:fetch_http_dir) { repo_dir }
353
+ allow(subject).to receive(:on).with(host, "apt-get update") { }
354
+ allow(subject).to receive(:options) { opts }
355
+ allow(subject).to receive(:link_exists?) { true }
356
+ end
357
+
358
+ it "scp's files to SUT then modifies them with find-and-sed 2-hit combo" do
359
+ expect(subject).to receive(:on).with( host, /^mkdir -p .*$/ ).ordered
360
+ expect(subject).to receive(:scp_to).with( host, repo_config, /.*/ ).ordered
361
+ expect(subject).to receive(:scp_to).with( host, repo_dir, /.*/ ).ordered
362
+ expect(subject).to receive(:on).with( host, /^find .* sed .*/ ).ordered
363
+ subject.install_puppetlabs_dev_repo host, package_name, package_version
364
+ end
365
+
366
+ end
367
+
368
+ describe "#install_puppetlabs_dev_repo" do
369
+ let( :package_name ) { "puppet" }
370
+ let( :package_version ) { "7.5.6" }
371
+ let( :host ) do
372
+ FakeHost.create('fakvm', platform.to_s, opts)
373
+ end
374
+
375
+ describe "When host is unsupported platform" do
376
+ let( :platform ) { Beaker::Platform.new('solaris-7-i386') }
377
+
378
+ it "raises an exception." do
379
+ expect(subject).to receive(:on).with( host, /^mkdir -p .*$/ ).ordered
380
+ allow(subject).to receive(:options) { opts }
381
+ expect{
382
+ subject.install_puppetlabs_dev_repo host, package_name, package_version
383
+ }.to raise_error(RuntimeError, /No repository installation step for/)
384
+ end
385
+
386
+ end
387
+
388
+ describe "When host is a debian-like platform" do
389
+ let( :platform ) { Beaker::Platform.new('debian-7-i386') }
390
+ include_examples "install-dev-repo"
391
+ end
392
+
393
+ describe "When host is a redhat-like platform" do
394
+ let( :platform ) { Beaker::Platform.new('el-7-i386') }
395
+ include_examples "install-dev-repo"
396
+ end
397
+
398
+ end
399
+
400
+ describe '#install_packages_from_local_dev_repo' do
401
+ let( :package_name ) { 'puppet-agent' }
402
+ let( :platform ) { @platform || 'other' }
403
+ let( :host ) do
404
+ FakeHost.create('fakvm', platform, opts)
405
+ end
406
+
407
+ it 'sets the find command correctly for el-based systems' do
408
+ @platform = 'el-1-3'
409
+ expect( subject ).to receive( :on ).with( host, /\*\.rpm.+rpm\s-ivh/ )
410
+ subject.install_packages_from_local_dev_repo( host, package_name )
411
+ end
412
+
413
+ it 'sets the find command correctly for debian-based systems' do
414
+ @platform = 'debian-1-3'
415
+ expect( subject ).to receive( :on ).with( host, /\*\.deb.+dpkg\s-i/ )
416
+ subject.install_packages_from_local_dev_repo( host, package_name )
417
+ end
418
+
419
+ it 'fails correctly for systems not accounted for' do
420
+ @platform = 'eos-1-3'
421
+ expect{ subject.install_packages_from_local_dev_repo( host, package_name ) }.to raise_error RuntimeError
422
+ end
423
+
424
+ end
425
+
426
+ describe '#install_puppetagent_dev_repo' do
427
+
428
+ it 'raises an exception when host platform is unsupported' do
429
+ platform = Object.new()
430
+ allow(platform).to receive(:to_array) { ['ptan', '5', 'x4']}
431
+ host = basic_hosts.first
432
+ host['platform'] = platform
433
+ opts = { :version => '0.1.0' }
434
+ allow( subject ).to receive( :options ).and_return( {} )
435
+
436
+ expect{
437
+ subject.install_puppetagent_dev_repo( host, opts )
438
+ }.to raise_error(RuntimeError, /No repository installation step for/)
439
+ end
440
+
441
+ it 'runs the correct install for el-based platforms' do
442
+ platform = Object.new()
443
+ allow(platform).to receive(:to_array) { ['el', '5', 'x4']}
444
+ host = basic_hosts.first
445
+ host['platform'] = platform
446
+ opts = { :version => '0.1.0' }
447
+ allow( subject ).to receive( :options ).and_return( {} )
448
+
449
+ expect(subject).to receive(:fetch_http_file).once.with(/\/el\//, /-agent-/, /el/)
450
+ expect(subject).to receive(:scp_to).once.with(host, /-agent-/, "/root")
451
+ expect(subject).to receive(:on).once.with(host, /rpm\ -ivh/)
452
+
453
+ subject.install_puppetagent_dev_repo( host, opts )
454
+ end
455
+
456
+ it 'runs the correct install for debian-based platforms' do
457
+ platform = Object.new()
458
+ allow(platform).to receive(:to_array) { ['debian', '5', 'x4']}
459
+ host = basic_hosts.first
460
+ host['platform'] = platform
461
+ opts = { :version => '0.1.0' }
462
+ allow( subject ).to receive( :options ).and_return( {} )
463
+
464
+ expect(subject).to receive(:fetch_http_file).once.with(/\/deb\//, /-agent_/, /deb/)
465
+ expect(subject).to receive(:scp_to).once.with(host, /-agent_/, "/root")
466
+ expect(subject).to receive(:on).ordered.with(host, /dpkg\ -i\ --force-all/)
467
+ expect(subject).to receive(:on).ordered.with(host, /apt-get\ update/)
468
+
469
+ subject.install_puppetagent_dev_repo( host, opts )
470
+ end
471
+
472
+ it 'runs the correct install for windows platforms' do
473
+ platform = Object.new()
474
+ allow(platform).to receive(:to_array) { ['windows', '5', 'x64']}
475
+ host = basic_hosts.first
476
+ host['platform'] = platform
477
+ opts = { :version => '0.1.0' }
478
+ allow( subject ).to receive( :options ).and_return( {} )
479
+ mock_echo = Object.new()
480
+ allow( mock_echo ).to receive( :raw_output ).and_return( " " )
481
+
482
+ expect(subject).to receive(:fetch_http_file).once.with(/\/windows$/, 'puppet-agent-x64.msi', /\/windows$/)
483
+ expect(subject).to receive(:scp_to).once.with(host, /\/puppet-agent-x64.msi$/, /cygpath/)
484
+ expect(subject).to receive(:on).ordered.with(host, /echo/).and_return(mock_echo)
485
+ expect(subject).to receive(:on).ordered.with(host, anything)
486
+
487
+ subject.install_puppetagent_dev_repo( host, opts )
488
+ end
489
+
490
+ it 'allows you to override the local copy directory' do
491
+ platform = Object.new()
492
+ allow(platform).to receive(:to_array) { ['debian', '5', 'x4']}
493
+ host = basic_hosts.first
494
+ host['platform'] = platform
495
+ opts = { :version => '0.1.0', :copy_base_local => 'face' }
496
+ allow( subject ).to receive( :options ).and_return( {} )
497
+
498
+ expect(subject).to receive(:fetch_http_file).once.with(/\/deb\//, /-agent_/, /face/)
499
+ expect(subject).to receive(:scp_to).once.with(host, /face/, "/root")
500
+ expect(subject).to receive(:on).ordered.with(host, /dpkg\ -i\ --force-all/)
501
+ expect(subject).to receive(:on).ordered.with(host, /apt-get\ update/)
502
+
503
+ subject.install_puppetagent_dev_repo( host, opts )
504
+ end
505
+
506
+ it 'allows you to override the external copy directory' do
507
+ platform = Object.new()
508
+ allow(platform).to receive(:to_array) { ['debian', '5', 'x4']}
509
+ host = basic_hosts.first
510
+ host['platform'] = platform
511
+ opts = { :version => '0.1.0', :copy_dir_external => 'muppetsB' }
512
+ allow( subject ).to receive( :options ).and_return( {} )
513
+
514
+ expect(subject).to receive(:fetch_http_file).once.with(/\/deb\//, /-agent_/, /deb/)
515
+ expect(subject).to receive(:scp_to).once.with(host, /-agent_/, /muppetsB/)
516
+ expect(subject).to receive(:on).ordered.with(host, /dpkg\ -i\ --force-all/)
517
+ expect(subject).to receive(:on).ordered.with(host, /apt-get\ update/)
518
+
519
+ subject.install_puppetagent_dev_repo( host, opts )
520
+ end
521
+
522
+ end
523
+ end