beaker 2.35.0 → 2.36.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +0 -19
- data/HISTORY.md +89 -2
- data/beaker.gemspec +1 -0
- data/lib/beaker/dsl.rb +6 -0
- data/lib/beaker/dsl/install_utils.rb +3 -2
- data/lib/beaker/dsl/install_utils/foss_utils.rb +8 -2
- data/lib/beaker/host/unix/pkg.rb +2 -2
- data/lib/beaker/hypervisor/docker.rb +1 -1
- data/lib/beaker/hypervisor/vmpooler.rb +12 -0
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/dsl/install_utils/foss_utils_spec.rb +31 -0
- data/spec/beaker/host/unix/pkg_spec.rb +54 -1
- data/spec/beaker/hypervisor/docker_spec.rb +2 -0
- data/spec/beaker/hypervisor/vmpooler_spec.rb +11 -0
- metadata +16 -6
- data/lib/beaker/dsl/install_utils/pe_utils.rb +0 -728
- data/lib/beaker/options/pe_version_scraper.rb +0 -35
- data/spec/beaker/dsl/install_utils/pe_utils_spec.rb +0 -884
- data/spec/beaker/options/pe_version_scaper_spec.rb +0 -30
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'open-uri'
|
2
|
-
module Beaker
|
3
|
-
module Options
|
4
|
-
#A set of functions to determine the PE version to use during testing
|
5
|
-
module PEVersionScraper
|
6
|
-
# Scrape the PE version (such as 3.0) from the file at dist_dir/version_file
|
7
|
-
#
|
8
|
-
# Version file is of the format
|
9
|
-
#
|
10
|
-
# 3.0.1-3-g57b669e
|
11
|
-
#
|
12
|
-
# @param [String] dist_dir The directory containing the version_file
|
13
|
-
# @param [String] version_file The file to scrape
|
14
|
-
#
|
15
|
-
# @return [String, nil] The PE version in the version_file or nil if not found
|
16
|
-
# @raise [ArgumentError] Raises if version_file does not exist or cannot be opened
|
17
|
-
def self.load_pe_version dist_dir, version_file
|
18
|
-
version = nil
|
19
|
-
begin
|
20
|
-
open("#{dist_dir}/#{version_file}") do |file|
|
21
|
-
while line = file.gets
|
22
|
-
if /(\w.*)/ =~ line then
|
23
|
-
version = $1.strip
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
rescue Errno::ENOENT, OpenURI::HTTPError => e
|
28
|
-
raise ArgumentError, "Failure to examine #{dist_dir}/#{version_file}\n\t\t#{e.to_s}"
|
29
|
-
end
|
30
|
-
return version
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,884 +0,0 @@
|
|
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
|
-
attr_accessor :hosts
|
12
|
-
|
13
|
-
def logger
|
14
|
-
@logger ||= RSpec::Mocks::Double.new('logger').as_null_object
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe ClassMixedWithDSLInstallUtils do
|
19
|
-
let(:presets) { Beaker::Options::Presets.new }
|
20
|
-
let(:opts) { presets.presets.merge(presets.env_vars) }
|
21
|
-
let(:basic_hosts) { make_hosts( { :pe_ver => '3.0',
|
22
|
-
:platform => 'linux',
|
23
|
-
:roles => [ 'agent' ],
|
24
|
-
:type => 'pe'}, 4 ) }
|
25
|
-
let(:hosts) { basic_hosts[0][:roles] = ['master', 'database', 'dashboard']
|
26
|
-
basic_hosts[1][:platform] = 'windows'
|
27
|
-
basic_hosts[2][:platform] = 'osx-10.9-x86_64'
|
28
|
-
basic_hosts[3][:platform] = 'eos'
|
29
|
-
basic_hosts }
|
30
|
-
let(:hosts_sorted) { [ hosts[1], hosts[0], hosts[2], hosts[3] ] }
|
31
|
-
let(:winhost) { make_host( 'winhost', { :platform => 'windows',
|
32
|
-
:pe_ver => '3.0',
|
33
|
-
:type => 'pe',
|
34
|
-
:working_dir => '/tmp' } ) }
|
35
|
-
let(:machost) { make_host( 'machost', { :platform => 'osx-10.9-x86_64',
|
36
|
-
:pe_ver => '3.0',
|
37
|
-
:type => 'pe',
|
38
|
-
:working_dir => '/tmp' } ) }
|
39
|
-
let(:unixhost) { make_host( 'unixhost', { :platform => 'linux',
|
40
|
-
:pe_ver => '3.0',
|
41
|
-
:type => 'pe',
|
42
|
-
:working_dir => '/tmp',
|
43
|
-
:dist => 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-debian-7-i386' } ) }
|
44
|
-
let(:eoshost) { make_host( 'eoshost', { :platform => 'eos',
|
45
|
-
:pe_ver => '3.0',
|
46
|
-
:type => 'pe',
|
47
|
-
:working_dir => '/tmp',
|
48
|
-
:dist => 'puppet-enterprise-3.7.1-rc0-78-gffc958f-eos-4-i386' } ) }
|
49
|
-
context '#configure_pe_defaults_on' do
|
50
|
-
it 'uses aio paths for hosts of role aio' do
|
51
|
-
hosts.each do |host|
|
52
|
-
host[:pe_ver] = nil
|
53
|
-
host[:version] = nil
|
54
|
-
host[:roles] = host[:roles] | ['aio']
|
55
|
-
end
|
56
|
-
expect(subject).to receive(:add_pe_defaults_on).exactly(hosts.length).times
|
57
|
-
expect(subject).to receive(:add_aio_defaults_on).exactly(hosts.length).times
|
58
|
-
expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
|
59
|
-
|
60
|
-
subject.configure_pe_defaults_on( hosts )
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'uses pe paths for hosts of type pe' do
|
64
|
-
hosts.each do |host|
|
65
|
-
host[:type] = 'pe'
|
66
|
-
end
|
67
|
-
expect(subject).to receive(:add_pe_defaults_on).exactly(hosts.length).times
|
68
|
-
expect(subject).to receive(:add_aio_defaults_on).never
|
69
|
-
expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
|
70
|
-
|
71
|
-
subject.configure_pe_defaults_on( hosts )
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'uses aio paths for hosts of type aio' do
|
75
|
-
hosts.each do |host|
|
76
|
-
host[:pe_ver] = nil
|
77
|
-
host[:version] = nil
|
78
|
-
host[:type] = 'aio'
|
79
|
-
end
|
80
|
-
expect(subject).to receive(:add_aio_defaults_on).exactly(hosts.length).times
|
81
|
-
expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
|
82
|
-
|
83
|
-
subject.configure_pe_defaults_on( hosts )
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'uses no paths for hosts with no type' do
|
87
|
-
hosts.each do |host|
|
88
|
-
host[:type] = nil
|
89
|
-
end
|
90
|
-
expect(subject).to receive(:add_pe_defaults_on).never
|
91
|
-
expect(subject).to receive(:add_aio_defaults_on).never
|
92
|
-
expect(subject).to receive(:add_puppet_paths_on).never
|
93
|
-
|
94
|
-
subject.configure_pe_defaults_on( hosts )
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'uses aio paths for hosts of version >= 4.0' do
|
98
|
-
hosts.each do |host|
|
99
|
-
host[:pe_ver] = '4.0'
|
100
|
-
end
|
101
|
-
expect(subject).to receive(:add_pe_defaults_on).exactly(hosts.length).times
|
102
|
-
expect(subject).to receive(:add_aio_defaults_on).exactly(hosts.length).times
|
103
|
-
expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
|
104
|
-
|
105
|
-
subject.configure_pe_defaults_on( hosts )
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'uses pe paths for hosts of version < 4.0' do
|
109
|
-
hosts.each do |host|
|
110
|
-
host[:pe_ver] = '3.8'
|
111
|
-
end
|
112
|
-
expect(subject).to receive(:add_pe_defaults_on).exactly(hosts.length).times
|
113
|
-
expect(subject).to receive(:add_aio_defaults_on).never
|
114
|
-
expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
|
115
|
-
|
116
|
-
subject.configure_pe_defaults_on( hosts )
|
117
|
-
end
|
118
|
-
|
119
|
-
end
|
120
|
-
|
121
|
-
describe 'sorted_hosts' do
|
122
|
-
it 'can reorder so that the master comes first' do
|
123
|
-
allow( subject ).to receive( :hosts ).and_return( hosts_sorted )
|
124
|
-
expect( subject.sorted_hosts ).to be === hosts
|
125
|
-
end
|
126
|
-
|
127
|
-
it 'leaves correctly ordered hosts alone' do
|
128
|
-
allow( subject ).to receive( :hosts ).and_return( hosts )
|
129
|
-
expect( subject.sorted_hosts ).to be === hosts
|
130
|
-
end
|
131
|
-
|
132
|
-
it 'does not allow nil entries' do
|
133
|
-
allow( subject ).to receive( :options ).and_return( { :masterless => true } )
|
134
|
-
masterless_host = [basic_hosts[0]]
|
135
|
-
allow( subject ).to receive( :hosts ).and_return( masterless_host )
|
136
|
-
expect( subject.sorted_hosts ).to be === masterless_host
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
describe 'installer_cmd' do
|
141
|
-
|
142
|
-
it 'generates a unix PE install command for a unix host' do
|
143
|
-
the_host = unixhost.dup
|
144
|
-
the_host['pe_installer'] = 'puppet-enterprise-installer'
|
145
|
-
expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp/puppet-enterprise-3.1.0-rc0-230-g36c9e5c-debian-7-i386 && ./puppet-enterprise-installer -a /tmp/answers"
|
146
|
-
end
|
147
|
-
|
148
|
-
it 'generates a unix PE frictionless install command for a unix host with role "frictionless"' do
|
149
|
-
allow( subject ).to receive( :version_is_less ).and_return( false )
|
150
|
-
allow( subject ).to receive( :master ).and_return( 'testmaster' )
|
151
|
-
the_host = unixhost.dup
|
152
|
-
the_host['pe_installer'] = 'puppet-enterprise-installer'
|
153
|
-
the_host['roles'] = ['frictionless']
|
154
|
-
expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp && curl --tlsv1 -kO https://testmaster:8140/packages/3.0/install.bash && bash install.bash"
|
155
|
-
end
|
156
|
-
|
157
|
-
it 'generates a unix PE frictionless install command for a unix host with role "frictionless" and "frictionless_options"' do
|
158
|
-
allow( subject ).to receive( :version_is_less ).and_return( false )
|
159
|
-
allow( subject ).to receive( :master ).and_return( 'testmaster' )
|
160
|
-
the_host = unixhost.dup
|
161
|
-
the_host['pe_installer'] = 'puppet-enterprise-installer'
|
162
|
-
the_host['roles'] = ['frictionless']
|
163
|
-
the_host['frictionless_options'] = { 'main' => { 'dns_alt_names' => 'puppet' } }
|
164
|
-
expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp && curl --tlsv1 -kO https://testmaster:8140/packages/3.0/install.bash && bash install.bash main:dns_alt_names=puppet"
|
165
|
-
end
|
166
|
-
|
167
|
-
it 'generates a osx PE install command for a osx host' do
|
168
|
-
the_host = machost.dup
|
169
|
-
the_host['pe_installer'] = 'puppet-enterprise-installer'
|
170
|
-
expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp && hdiutil attach .dmg && installer -pkg /Volumes/puppet-enterprise-3.0/puppet-enterprise-installer-3.0.pkg -target /"
|
171
|
-
end
|
172
|
-
|
173
|
-
it 'calls the EOS PE install command for an EOS host' do
|
174
|
-
the_host = eoshost.dup
|
175
|
-
expect( the_host ).to receive( :install_from_file ).with( /swix$/ )
|
176
|
-
subject.installer_cmd( the_host, {} )
|
177
|
-
end
|
178
|
-
|
179
|
-
it 'generates a unix PE install command in verbose for a unix host when pe_debug is enabled' do
|
180
|
-
the_host = unixhost.dup
|
181
|
-
the_host['pe_installer'] = 'puppet-enterprise-installer'
|
182
|
-
the_host[:pe_debug] = true
|
183
|
-
expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp/puppet-enterprise-3.1.0-rc0-230-g36c9e5c-debian-7-i386 && ./puppet-enterprise-installer -D -a /tmp/answers"
|
184
|
-
end
|
185
|
-
|
186
|
-
it 'generates a osx PE install command in verbose for a osx host when pe_debug is enabled' do
|
187
|
-
the_host = machost.dup
|
188
|
-
the_host['pe_installer'] = 'puppet-enterprise-installer'
|
189
|
-
the_host[:pe_debug] = true
|
190
|
-
expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp && hdiutil attach .dmg && installer -verboseR -pkg /Volumes/puppet-enterprise-3.0/puppet-enterprise-installer-3.0.pkg -target /"
|
191
|
-
end
|
192
|
-
|
193
|
-
it 'generates a unix PE frictionless install command in verbose for a unix host with role "frictionless" and pe_debug is enabled' do
|
194
|
-
allow( subject ).to receive( :version_is_less ).and_return( false )
|
195
|
-
allow( subject ).to receive( :master ).and_return( 'testmaster' )
|
196
|
-
the_host = unixhost.dup
|
197
|
-
the_host['pe_installer'] = 'puppet-enterprise-installer'
|
198
|
-
the_host['roles'] = ['frictionless']
|
199
|
-
the_host[:pe_debug] = true
|
200
|
-
expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp && curl --tlsv1 -kO https://testmaster:8140/packages/3.0/install.bash && bash -x install.bash"
|
201
|
-
end
|
202
|
-
|
203
|
-
end
|
204
|
-
|
205
|
-
|
206
|
-
describe 'fetch_pe' do
|
207
|
-
|
208
|
-
it 'can push a local PE .tar.gz to a host and unpack it' do
|
209
|
-
allow( File ).to receive( :directory? ).and_return( true ) #is local
|
210
|
-
allow( File ).to receive( :exists? ).and_return( true ) #is a .tar.gz
|
211
|
-
unixhost['pe_dir'] = '/local/file/path'
|
212
|
-
allow( subject ).to receive( :scp_to ).and_return( true )
|
213
|
-
|
214
|
-
path = unixhost['pe_dir']
|
215
|
-
filename = "#{ unixhost['dist'] }"
|
216
|
-
extension = '.tar.gz'
|
217
|
-
expect( subject ).to receive( :scp_to ).with( unixhost, "#{ path }/#{ filename }#{ extension }", "#{ unixhost['working_dir'] }/#{ filename }#{ extension }" ).once
|
218
|
-
expect( subject ).to receive( :on ).with( unixhost, /gunzip/ ).once
|
219
|
-
expect( subject ).to receive( :on ).with( unixhost, /tar -xvf/ ).once
|
220
|
-
subject.fetch_pe( [unixhost], {} )
|
221
|
-
end
|
222
|
-
|
223
|
-
it 'can download a PE .tar from a URL to a host and unpack it' do
|
224
|
-
allow( File ).to receive( :directory? ).and_return( false ) #is not local
|
225
|
-
allow( subject ).to receive( :link_exists? ) do |arg|
|
226
|
-
if arg =~ /.tar.gz/ #there is no .tar.gz link, only a .tar
|
227
|
-
false
|
228
|
-
else
|
229
|
-
true
|
230
|
-
end
|
231
|
-
end
|
232
|
-
allow( subject ).to receive( :on ).and_return( true )
|
233
|
-
|
234
|
-
path = unixhost['pe_dir']
|
235
|
-
filename = "#{ unixhost['dist'] }"
|
236
|
-
extension = '.tar'
|
237
|
-
expect( subject ).to receive( :on ).with( unixhost, "cd #{ unixhost['working_dir'] }; curl #{ path }/#{ filename }#{ extension } | tar -xvf -" ).once
|
238
|
-
subject.fetch_pe( [unixhost], {} )
|
239
|
-
end
|
240
|
-
|
241
|
-
it 'can download a PE .tar from a URL to #fetch_and_push_pe' do
|
242
|
-
allow( File ).to receive( :directory? ).and_return( false ) #is not local
|
243
|
-
allow( subject ).to receive( :link_exists? ) do |arg|
|
244
|
-
if arg =~ /.tar.gz/ #there is no .tar.gz link, only a .tar
|
245
|
-
false
|
246
|
-
else
|
247
|
-
true
|
248
|
-
end
|
249
|
-
end
|
250
|
-
allow( subject ).to receive( :on ).and_return( true )
|
251
|
-
|
252
|
-
path = unixhost['pe_dir']
|
253
|
-
filename = "#{ unixhost['dist'] }"
|
254
|
-
extension = '.tar'
|
255
|
-
expect( subject ).to receive( :fetch_and_push_pe ).with( unixhost, anything, filename, extension ).once
|
256
|
-
expect( subject ).to receive( :on ).with( unixhost, "cd #{ unixhost['working_dir'] }; cat #{ filename }#{ extension } | tar -xvf -" ).once
|
257
|
-
subject.fetch_pe( [unixhost], {:fetch_local_then_push_to_host => true} )
|
258
|
-
end
|
259
|
-
|
260
|
-
it 'can download a PE .tar.gz from a URL to a host and unpack it' do
|
261
|
-
allow( File ).to receive( :directory? ).and_return( false ) #is not local
|
262
|
-
allow( subject ).to receive( :link_exists? ).and_return( true ) #is a tar.gz
|
263
|
-
allow( subject ).to receive( :on ).and_return( true )
|
264
|
-
|
265
|
-
path = unixhost['pe_dir']
|
266
|
-
filename = "#{ unixhost['dist'] }"
|
267
|
-
extension = '.tar.gz'
|
268
|
-
expect( subject ).to receive( :on ).with( unixhost, "cd #{ unixhost['working_dir'] }; curl #{ path }/#{ filename }#{ extension } | gunzip | tar -xvf -" ).once
|
269
|
-
subject.fetch_pe( [unixhost], {} )
|
270
|
-
end
|
271
|
-
|
272
|
-
it 'can download a PE .tar.gz from a URL to #fetch_and_push_pe' do
|
273
|
-
allow( File ).to receive( :directory? ).and_return( false ) #is not local
|
274
|
-
allow( subject ).to receive( :link_exists? ).and_return( true ) #is a tar.gz
|
275
|
-
allow( subject ).to receive( :on ).and_return( true )
|
276
|
-
|
277
|
-
path = unixhost['pe_dir']
|
278
|
-
filename = "#{ unixhost['dist'] }"
|
279
|
-
extension = '.tar.gz'
|
280
|
-
expect( subject ).to receive( :fetch_and_push_pe ).with( unixhost, anything, filename, extension ).once
|
281
|
-
expect( subject ).to receive( :on ).with( unixhost, "cd #{ unixhost['working_dir'] }; cat #{ filename }#{ extension } | gunzip | tar -xvf -" ).once
|
282
|
-
subject.fetch_pe( [unixhost], {:fetch_local_then_push_to_host => true} )
|
283
|
-
end
|
284
|
-
|
285
|
-
it 'calls the host method to get an EOS .swix file from a URL' do
|
286
|
-
allow( File ).to receive( :directory? ).and_return( false ) #is not local
|
287
|
-
allow( subject ).to receive( :link_exists? ).and_return( true ) #skip file check
|
288
|
-
|
289
|
-
expect( eoshost ).to receive( :get_remote_file ).with( /swix$/ ).once
|
290
|
-
subject.fetch_pe( [eoshost], {} )
|
291
|
-
end
|
292
|
-
|
293
|
-
it 'can push a local PE package to a windows host' do
|
294
|
-
allow( File ).to receive( :directory? ).and_return( true ) #is local
|
295
|
-
allow( File ).to receive( :exists? ).and_return( true ) #is present
|
296
|
-
winhost['dist'] = 'puppet-enterprise-3.0'
|
297
|
-
allow( subject ).to receive( :scp_to ).and_return( true )
|
298
|
-
|
299
|
-
path = winhost['pe_dir']
|
300
|
-
filename = "puppet-enterprise-#{ winhost['pe_ver'] }"
|
301
|
-
extension = '.msi'
|
302
|
-
expect( subject ).to receive( :scp_to ).with( winhost, "#{ path }/#{ filename }#{ extension }", "#{ winhost['working_dir'] }/#{ filename }#{ extension }" ).once
|
303
|
-
subject.fetch_pe( [winhost], {} )
|
304
|
-
|
305
|
-
end
|
306
|
-
|
307
|
-
it 'can download a PE dmg from a URL to a mac host' do
|
308
|
-
allow( File ).to receive( :directory? ).and_return( false ) #is not local
|
309
|
-
allow( subject ).to receive( :link_exists? ).and_return( true ) #is not local
|
310
|
-
allow( subject ).to receive( :on ).and_return( true )
|
311
|
-
|
312
|
-
path = machost['pe_dir']
|
313
|
-
filename = "#{ machost['dist'] }"
|
314
|
-
extension = '.dmg'
|
315
|
-
expect( subject ).to receive( :on ).with( machost, "cd #{ machost['working_dir'] }; curl -O #{ path }/#{ filename }#{ extension }" ).once
|
316
|
-
subject.fetch_pe( [machost], {} )
|
317
|
-
end
|
318
|
-
|
319
|
-
it 'can push a PE dmg to a mac host' do
|
320
|
-
allow( File ).to receive( :directory? ).and_return( true ) #is local
|
321
|
-
allow( File ).to receive( :exists? ).and_return( true ) #is present
|
322
|
-
allow( subject ).to receive( :scp_to ).and_return( true )
|
323
|
-
|
324
|
-
path = machost['pe_dir']
|
325
|
-
filename = "#{ machost['dist'] }"
|
326
|
-
extension = '.dmg'
|
327
|
-
expect( subject ).to receive( :scp_to ).with( machost, "#{ path }/#{ filename }#{ extension }", "#{ machost['working_dir'] }/#{ filename }#{ extension }" ).once
|
328
|
-
subject.fetch_pe( [machost], {} )
|
329
|
-
end
|
330
|
-
|
331
|
-
it "does nothing for a frictionless agent for PE >= 3.2.0" do
|
332
|
-
unixhost['roles'] << 'frictionless'
|
333
|
-
unixhost['pe_ver'] = '3.2.0'
|
334
|
-
|
335
|
-
expect( subject).to_not receive(:scp_to)
|
336
|
-
expect( subject).to_not receive(:on)
|
337
|
-
allow( subject ).to receive(:version_is_less).with('3.2.0', '3.2.0').and_return(false)
|
338
|
-
subject.fetch_pe( [unixhost], {} )
|
339
|
-
end
|
340
|
-
end
|
341
|
-
|
342
|
-
describe 'do_install' do
|
343
|
-
it 'can perform a simple installation' do
|
344
|
-
allow( subject ).to receive( :on ).and_return( Beaker::Result.new( {}, '' ) )
|
345
|
-
allow( subject ).to receive( :fetch_pe ).and_return( true )
|
346
|
-
allow( subject ).to receive( :create_remote_file ).and_return( true )
|
347
|
-
allow( subject ).to receive( :sign_certificate_for ).and_return( true )
|
348
|
-
allow( subject ).to receive( :stop_agent_on ).and_return( true )
|
349
|
-
allow( subject ).to receive( :sleep_until_puppetdb_started ).and_return( true )
|
350
|
-
allow( subject ).to receive( :max_version ).with(anything, '3.8').and_return('3.0')
|
351
|
-
allow( subject ).to receive( :version_is_less ).with('3.0', '4.0').and_return( true )
|
352
|
-
allow( subject ).to receive( :version_is_less ).with('3.0', '3.4').and_return( true )
|
353
|
-
allow( subject ).to receive( :version_is_less ).with('3.0', '3.0').and_return( false )
|
354
|
-
allow( subject ).to receive( :version_is_less ).with('3.0', '3.99').and_return( true )
|
355
|
-
allow( subject ).to receive( :version_is_less ).with('3.99', '3.0').and_return( false )
|
356
|
-
allow( subject ).to receive( :wait_for_host_in_dashboard ).and_return( true )
|
357
|
-
allow( subject ).to receive( :puppet_agent ) do |arg|
|
358
|
-
"puppet agent #{arg}"
|
359
|
-
end
|
360
|
-
allow( subject ).to receive( :puppet ) do |arg|
|
361
|
-
"puppet #{arg}"
|
362
|
-
end
|
363
|
-
|
364
|
-
allow( subject ).to receive( :hosts ).and_return( hosts )
|
365
|
-
#create answers file per-host, except windows
|
366
|
-
expect( subject ).to receive( :create_remote_file ).with( hosts[0], /answers/, /q/ ).once
|
367
|
-
#run installer on all hosts
|
368
|
-
expect( subject ).to receive( :on ).with( hosts[0], /puppet-enterprise-installer/ ).once
|
369
|
-
expect( subject ).to receive( :install_msi_on ).with ( any_args ) do | host, msi_path, msi_opts, opts |
|
370
|
-
expect( host ).to eq( hosts[1] )
|
371
|
-
end.once
|
372
|
-
expect( subject ).to receive( :on ).with( hosts[2], / hdiutil attach puppet-enterprise-3.0-osx-10.9-x86_64.dmg && installer -pkg \/Volumes\/puppet-enterprise-3.0\/puppet-enterprise-installer-3.0.pkg -target \// ).once
|
373
|
-
expect( hosts[3] ).to receive( :install_from_file ).with( /swix$/ ).once
|
374
|
-
#does extra mac/EOS specific commands
|
375
|
-
expect( subject ).to receive( :on ).with( hosts[2], /puppet config set server/ ).once
|
376
|
-
expect( subject ).to receive( :on ).with( hosts[3], /puppet config set server/ ).once
|
377
|
-
expect( subject ).to receive( :on ).with( hosts[2], /puppet config set certname/ ).once
|
378
|
-
expect( subject ).to receive( :on ).with( hosts[3], /puppet config set certname/ ).once
|
379
|
-
expect( subject ).to receive( :on ).with( hosts[2], /puppet agent -t/, :acceptable_exit_codes => [1] ).once
|
380
|
-
expect( subject ).to receive( :on ).with( hosts[3], /puppet agent -t/, :acceptable_exit_codes => [0, 1] ).once
|
381
|
-
#sign certificate per-host
|
382
|
-
expect( subject ).to receive( :sign_certificate_for ).with( hosts[0] ).once
|
383
|
-
expect( subject ).to receive( :sign_certificate_for ).with( hosts[1] ).once
|
384
|
-
expect( subject ).to receive( :sign_certificate_for ).with( hosts[2] ).once
|
385
|
-
expect( subject ).to receive( :sign_certificate_for ).with( hosts[3] ).once
|
386
|
-
#stop puppet agent on all hosts
|
387
|
-
expect( subject ).to receive( :stop_agent_on ).with( hosts[0] ).once
|
388
|
-
expect( subject ).to receive( :stop_agent_on ).with( hosts[1] ).once
|
389
|
-
expect( subject ).to receive( :stop_agent_on ).with( hosts[2] ).once
|
390
|
-
expect( subject ).to receive( :stop_agent_on ).with( hosts[3] ).once
|
391
|
-
#wait for puppetdb to start
|
392
|
-
expect( subject ).to receive( :sleep_until_puppetdb_started ).with( hosts[0] ).once
|
393
|
-
#run each puppet agent once
|
394
|
-
expect( subject ).to receive( :on ).with( hosts[0], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).once
|
395
|
-
expect( subject ).to receive( :on ).with( hosts[1], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).once
|
396
|
-
expect( subject ).to receive( :on ).with( hosts[2], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).once
|
397
|
-
expect( subject ).to receive( :on ).with( hosts[3], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).once
|
398
|
-
#run rake task on dashboard
|
399
|
-
|
400
|
-
expect( subject ).to receive( :on ).with( hosts[0], /\/opt\/puppet\/bin\/rake -sf \/opt\/puppet\/share\/puppet-dashboard\/Rakefile .* RAILS_ENV=production/ ).once
|
401
|
-
#wait for all hosts to appear in the dashboard
|
402
|
-
#run puppet agent now that installation is complete
|
403
|
-
expect( subject ).to receive( :on ).with( hosts, /puppet agent/, :acceptable_exit_codes => [0,2] ).once
|
404
|
-
subject.do_install( hosts, opts )
|
405
|
-
end
|
406
|
-
|
407
|
-
it 'can perform a masterless installation' do
|
408
|
-
hosts = make_hosts({
|
409
|
-
:pe_ver => '3.0',
|
410
|
-
:roles => ['agent']
|
411
|
-
}, 1)
|
412
|
-
opts[:masterless] = true
|
413
|
-
|
414
|
-
allow( subject ).to receive( :hosts ).and_return( hosts )
|
415
|
-
allow( subject ).to receive( :on ).and_return( Beaker::Result.new( {}, '' ) )
|
416
|
-
allow( subject ).to receive( :fetch_pe ).and_return( true )
|
417
|
-
allow( subject ).to receive( :create_remote_file ).and_return( true )
|
418
|
-
allow( subject ).to receive( :stop_agent_on ).and_return( true )
|
419
|
-
allow( subject ).to receive( :max_version ).with(['3.0'], '3.8').and_return('3.0')
|
420
|
-
allow( subject ).to receive( :version_is_less ).with('3.99', '3.0').and_return( false )
|
421
|
-
allow( subject ).to receive( :version_is_less ).with(anything, '3.2.0').exactly(hosts.length + 1).times.and_return( false )
|
422
|
-
allow( subject ).to receive( :version_is_less ).with(anything, '4.0').exactly(hosts.length + 1).times.and_return( true )
|
423
|
-
|
424
|
-
expect( subject ).to receive( :on ).with( hosts[0], /puppet-enterprise-installer/ ).once
|
425
|
-
expect( subject ).to receive( :create_remote_file ).with( hosts[0], /answers/, /q/ ).once
|
426
|
-
expect( subject ).to_not receive( :sign_certificate_for )
|
427
|
-
expect( subject ).to receive( :stop_agent_on ).with( hosts[0] ).once
|
428
|
-
expect( subject ).to_not receive( :sleep_until_puppetdb_started )
|
429
|
-
expect( subject ).to_not receive( :wait_for_host_in_dashboard )
|
430
|
-
expect( subject ).to_not receive( :on ).with( hosts[0], /puppet agent -t/, :acceptable_exit_codes => [0,2] )
|
431
|
-
subject.do_install( hosts, opts)
|
432
|
-
end
|
433
|
-
|
434
|
-
it 'can perform a 4+ installation using AIO agents' do
|
435
|
-
hosts = make_hosts({
|
436
|
-
:pe_ver => '4.0',
|
437
|
-
:roles => ['agent'],
|
438
|
-
}, 3)
|
439
|
-
hosts[0][:roles] = ['master', 'database', 'dashboard']
|
440
|
-
hosts[1][:platform] = 'windows'
|
441
|
-
hosts[2][:platform] = Beaker::Platform.new('el-6-x86_64')
|
442
|
-
|
443
|
-
allow( subject ).to receive( :hosts ).and_return( hosts )
|
444
|
-
allow( subject ).to receive( :options ).and_return(Beaker::Options::Presets.new.presets)
|
445
|
-
allow( subject ).to receive( :on ).and_return( Beaker::Result.new( {}, '' ) )
|
446
|
-
allow( subject ).to receive( :fetch_pe ).and_return( true )
|
447
|
-
allow( subject ).to receive( :create_remote_file ).and_return( true )
|
448
|
-
allow( subject ).to receive( :sign_certificate_for ).and_return( true )
|
449
|
-
allow( subject ).to receive( :stop_agent_on ).and_return( true )
|
450
|
-
allow( subject ).to receive( :sleep_until_puppetdb_started ).and_return( true )
|
451
|
-
allow( subject ).to receive( :max_version ).with(anything, '3.8').and_return('4.0')
|
452
|
-
allow( subject ).to receive( :version_is_less ).with('4.0', '4.0').and_return( false )
|
453
|
-
allow( subject ).to receive( :version_is_less ).with('4.0', '3.4').and_return( false )
|
454
|
-
allow( subject ).to receive( :version_is_less ).with('4.0', '3.0').and_return( false )
|
455
|
-
allow( subject ).to receive( :version_is_less ).with('3.99', '4.0').and_return( true )
|
456
|
-
# pe_ver is only set on the hosts for this test, not the opt
|
457
|
-
allow( subject ).to receive( :version_is_less ).with('4.0', '3.99').and_return( true )
|
458
|
-
allow( subject ).to receive( :wait_for_host_in_dashboard ).and_return( true )
|
459
|
-
allow( subject ).to receive( :puppet_agent ) do |arg|
|
460
|
-
"puppet agent #{arg}"
|
461
|
-
end
|
462
|
-
allow( subject ).to receive( :puppet ) do |arg|
|
463
|
-
"puppet #{arg}"
|
464
|
-
end
|
465
|
-
|
466
|
-
allow( subject ).to receive( :hosts ).and_return( hosts )
|
467
|
-
#create answers file per-host, except windows
|
468
|
-
expect( subject ).to receive( :create_remote_file ).with( hosts[0], /answers/, /q/ ).once
|
469
|
-
#run installer on all hosts
|
470
|
-
expect( subject ).to receive( :on ).with( hosts[0], /puppet-enterprise-installer/ ).once
|
471
|
-
expect( subject ).to receive( :install_puppet_agent_pe_promoted_repo_on ).with( hosts[1],
|
472
|
-
{:puppet_agent_version=>nil, :puppet_agent_sha=>nil, :pe_ver=>hosts[1][:pe_ver], :puppet_collection=>nil} ).once
|
473
|
-
expect( subject ).to receive( :install_puppet_agent_pe_promoted_repo_on ).with( hosts[2],
|
474
|
-
{:puppet_agent_version=>nil, :puppet_agent_sha=>nil, :pe_ver=>hosts[2][:pe_ver], :puppet_collection=>nil} ).once
|
475
|
-
hosts.each do |host|
|
476
|
-
expect( subject ).to receive( :configure_type_defaults_on ).with( host ).once
|
477
|
-
expect( subject ).to receive( :sign_certificate_for ).with( host ).once
|
478
|
-
expect( subject ).to receive( :stop_agent_on ).with( host ).once
|
479
|
-
expect( subject ).to receive( :on ).with( host, /puppet agent -t/, :acceptable_exit_codes => [0,2] ).once
|
480
|
-
end
|
481
|
-
#wait for puppetdb to start
|
482
|
-
expect( subject ).to receive( :sleep_until_puppetdb_started ).with( hosts[0] ).once#wait for all hosts to appear in the dashboard
|
483
|
-
#run puppet agent now that installation is complete
|
484
|
-
expect( subject ).to receive( :on ).with( hosts, /puppet agent/, :acceptable_exit_codes => [0,2] ).once
|
485
|
-
subject.do_install( hosts, opts )
|
486
|
-
end
|
487
|
-
|
488
|
-
it 'can perform a 4/3 mixed installation with AIO and -non agents' do
|
489
|
-
hosts = make_hosts({
|
490
|
-
:pe_ver => '4.0',
|
491
|
-
:roles => ['agent'],
|
492
|
-
}, 3)
|
493
|
-
hosts[0][:roles] = ['master', 'database', 'dashboard']
|
494
|
-
hosts[1][:platform] = 'windows'
|
495
|
-
hosts[2][:platform] = Beaker::Platform.new('el-6-x86_64')
|
496
|
-
hosts[2][:pe_ver] = '3.8'
|
497
|
-
|
498
|
-
allow( subject ).to receive( :hosts ).and_return( hosts )
|
499
|
-
allow( subject ).to receive( :options ).and_return(Beaker::Options::Presets.new.presets)
|
500
|
-
allow( subject ).to receive( :on ).and_return( Beaker::Result.new( {}, '' ) )
|
501
|
-
allow( subject ).to receive( :fetch_pe ).and_return( true )
|
502
|
-
allow( subject ).to receive( :create_remote_file ).and_return( true )
|
503
|
-
allow( subject ).to receive( :sign_certificate_for ).and_return( true )
|
504
|
-
allow( subject ).to receive( :stop_agent_on ).and_return( true )
|
505
|
-
allow( subject ).to receive( :sleep_until_puppetdb_started ).and_return( true )
|
506
|
-
allow( subject ).to receive( :max_version ).with(anything, '3.8').and_return('4.0')
|
507
|
-
allow( subject ).to receive( :version_is_less ).with('4.0', '4.0').and_return( false )
|
508
|
-
allow( subject ).to receive( :version_is_less ).with('4.0', '3.4').and_return( false )
|
509
|
-
allow( subject ).to receive( :version_is_less ).with('4.0', '3.0').and_return( false )
|
510
|
-
allow( subject ).to receive( :version_is_less ).with('3.99', '4.0').and_return( true )
|
511
|
-
allow( subject ).to receive( :version_is_less ).with('3.8', '4.0').and_return( true )
|
512
|
-
# pe_ver is only set on the hosts for this test, not the opt
|
513
|
-
allow( subject ).to receive( :version_is_less ).with('4.0', '3.99').and_return( true )
|
514
|
-
allow( subject ).to receive( :wait_for_host_in_dashboard ).and_return( true )
|
515
|
-
allow( subject ).to receive( :puppet_agent ) do |arg|
|
516
|
-
"puppet agent #{arg}"
|
517
|
-
end
|
518
|
-
allow( subject ).to receive( :puppet ) do |arg|
|
519
|
-
"puppet #{arg}"
|
520
|
-
end
|
521
|
-
|
522
|
-
allow( subject ).to receive( :hosts ).and_return( hosts )
|
523
|
-
#create answers file per-host, except windows
|
524
|
-
expect( subject ).to receive( :create_remote_file ).with( hosts[0], /answers/, /q/ ).once
|
525
|
-
#run installer on all hosts
|
526
|
-
expect( subject ).to receive( :on ).with( hosts[0], /puppet-enterprise-installer/ ).once
|
527
|
-
expect( subject ).to receive( :install_puppet_agent_pe_promoted_repo_on ).with( hosts[1],
|
528
|
-
{:puppet_agent_version=>nil, :puppet_agent_sha=>nil, :pe_ver=>hosts[1][:pe_ver], :puppet_collection=>nil} ).once
|
529
|
-
expect( subject ).to receive( :on ).with( hosts[2], /puppet-enterprise-installer/ ).once
|
530
|
-
hosts.each do |host|
|
531
|
-
expect( subject ).to receive( :configure_type_defaults_on ).with( host ).once
|
532
|
-
expect( subject ).to receive( :sign_certificate_for ).with( host ).once
|
533
|
-
expect( subject ).to receive( :stop_agent_on ).with( host ).once
|
534
|
-
expect( subject ).to receive( :on ).with( host, /puppet agent -t/, :acceptable_exit_codes => [0,2] ).once
|
535
|
-
end
|
536
|
-
#wait for puppetdb to start
|
537
|
-
expect( subject ).to receive( :sleep_until_puppetdb_started ).with( hosts[0] ).once#wait for all hosts to appear in the dashboard
|
538
|
-
#run puppet agent now that installation is complete
|
539
|
-
expect( subject ).to receive( :on ).with( hosts, /puppet agent/, :acceptable_exit_codes => [0,2] ).once
|
540
|
-
subject.do_install( hosts, opts )
|
541
|
-
end
|
542
|
-
|
543
|
-
it 'sets puppet-agent acceptable_exit_codes correctly for config helper on upgrade' do
|
544
|
-
hosts = make_hosts({
|
545
|
-
:pe_ver => '4.0',
|
546
|
-
:roles => ['agent'],
|
547
|
-
}, 2)
|
548
|
-
hosts[0][:roles] = ['master', 'database', 'dashboard']
|
549
|
-
hosts[1][:platform] = Beaker::Platform.new('el-6-x86_64')
|
550
|
-
|
551
|
-
allow( subject ).to receive( :hosts ).and_return( hosts )
|
552
|
-
allow( subject ).to receive( :options ).and_return(Beaker::Options::Presets.new.presets)
|
553
|
-
allow( subject ).to receive( :on ).and_return( Beaker::Result.new( {}, '' ) )
|
554
|
-
allow( subject ).to receive( :fetch_pe ).and_return( true )
|
555
|
-
allow( subject ).to receive( :create_remote_file ).and_return( true )
|
556
|
-
allow( subject ).to receive( :sign_certificate_for ).and_return( true )
|
557
|
-
allow( subject ).to receive( :stop_agent_on ).and_return( true )
|
558
|
-
allow( subject ).to receive( :sleep_until_puppetdb_started ).and_return( true )
|
559
|
-
allow( subject ).to receive( :max_version ).with(anything, '3.8').and_return('4.0')
|
560
|
-
allow( subject ).to receive( :version_is_less ).with('4.0', '4.0').and_return( false )
|
561
|
-
allow( subject ).to receive( :version_is_less ).with('4.0', '3.4').and_return( false )
|
562
|
-
allow( subject ).to receive( :version_is_less ).with('4.0', '3.0').and_return( false )
|
563
|
-
allow( subject ).to receive( :version_is_less ).with('3.99', '4.0').and_return( true )
|
564
|
-
allow( subject ).to receive( :version_is_less ).with('3.8', '4.0').and_return( true )
|
565
|
-
# pe_ver is only set on the hosts for this test, not the opt
|
566
|
-
allow( subject ).to receive( :version_is_less ).with('4.0', '3.99').and_return( true )
|
567
|
-
allow( subject ).to receive( :wait_for_host_in_dashboard ).and_return( true )
|
568
|
-
allow( subject ).to receive( :puppet_agent ) do |arg|
|
569
|
-
"puppet agent #{arg}"
|
570
|
-
end
|
571
|
-
allow( subject ).to receive( :puppet ) do |arg|
|
572
|
-
"puppet #{arg}"
|
573
|
-
end
|
574
|
-
|
575
|
-
allow( subject ).to receive( :hosts ).and_return( hosts )
|
576
|
-
#create answers file per-host, except windows
|
577
|
-
allow( subject ).to receive( :create_remote_file ).with( hosts[0], /answers/, /q/ )
|
578
|
-
#run installer on all hosts
|
579
|
-
allow( subject ).to receive( :on ).with( hosts[0], /puppet-enterprise-installer/ )
|
580
|
-
allow( subject ).to receive( :install_puppet_agent_pe_promoted_repo_on ).with( hosts[1],
|
581
|
-
{:puppet_agent_version=>nil, :puppet_agent_sha=>nil, :pe_ver=>hosts[1][:pe_ver], :puppet_collection=>nil} )
|
582
|
-
# expect( subject ).to receive( :on ).with( hosts[2], /puppet-enterprise-installer/ ).once
|
583
|
-
hosts.each do |host|
|
584
|
-
allow( subject ).to receive( :add_pe_defaults_on ).with( host ) unless subject.aio_version?(host)
|
585
|
-
allow( subject ).to receive( :sign_certificate_for ).with( host )
|
586
|
-
allow( subject ).to receive( :stop_agent_on ).with( host )
|
587
|
-
allow( subject ).to receive( :on ).with( host, /puppet agent -t/, :acceptable_exit_codes => [0,2] )
|
588
|
-
end
|
589
|
-
#wait for puppetdb to start
|
590
|
-
allow( subject ).to receive( :sleep_until_puppetdb_started ).with( hosts[0] ) #wait for all hosts to appear in the dashboard
|
591
|
-
#run puppet agent now that installation is complete
|
592
|
-
allow( subject ).to receive( :on ).with( hosts, /puppet agent/, :acceptable_exit_codes => [0,2] )
|
593
|
-
|
594
|
-
opts[:type] = :upgrade
|
595
|
-
expect( subject ).to receive( :setup_defaults_and_config_helper_on ).with( hosts[1], hosts[0], [0, 1, 2] )
|
596
|
-
subject.do_install( hosts, opts )
|
597
|
-
end
|
598
|
-
|
599
|
-
end
|
600
|
-
|
601
|
-
describe 'do_higgs_install' do
|
602
|
-
|
603
|
-
before :each do
|
604
|
-
my_time = double( "time double" )
|
605
|
-
allow( my_time ).to receive( :strftime ).and_return( "2014-07-01_15.27.53" )
|
606
|
-
allow( Time ).to receive( :new ).and_return( my_time )
|
607
|
-
|
608
|
-
hosts[0]['working_dir'] = "tmp/2014-07-01_15.27.53"
|
609
|
-
hosts[0]['dist'] = 'dist'
|
610
|
-
hosts[0]['pe_installer'] = 'pe-installer'
|
611
|
-
allow( hosts[0] ).to receive( :tmpdir ).and_return( "/tmp/2014-07-01_15.27.53" )
|
612
|
-
|
613
|
-
@fail_result = Beaker::Result.new( {}, '' )
|
614
|
-
@fail_result.stdout = "No match here"
|
615
|
-
@success_result = Beaker::Result.new( {}, '' )
|
616
|
-
@success_result.stdout = "Please go to https://website in your browser to continue installation"
|
617
|
-
end
|
618
|
-
|
619
|
-
it 'can perform a simple installation' do
|
620
|
-
allow( subject ).to receive( :fetch_pe ).and_return( true )
|
621
|
-
allow( subject ).to receive( :sleep ).and_return( true )
|
622
|
-
|
623
|
-
allow( subject ).to receive( :hosts ).and_return( hosts )
|
624
|
-
|
625
|
-
#run higgs installer command
|
626
|
-
expect( subject ).to receive( :on ).with( hosts[0],
|
627
|
-
"cd /tmp/2014-07-01_15.27.53/puppet-enterprise-3.0-linux ; nohup ./pe-installer <<<Y > higgs_2014-07-01_15.27.53.log 2>&1 &",
|
628
|
-
opts ).once
|
629
|
-
#check to see if the higgs installation has proceeded correctly, works on second check
|
630
|
-
expect( subject ).to receive( :on ).with( hosts[0], /cat #{hosts[0]['higgs_file']}/, { :accept_all_exit_codes => true }).and_return( @fail_result, @success_result )
|
631
|
-
subject.do_higgs_install( hosts[0], opts )
|
632
|
-
end
|
633
|
-
|
634
|
-
it 'fails out after checking installation log 10 times' do
|
635
|
-
allow( subject ).to receive( :fetch_pe ).and_return( true )
|
636
|
-
allow( subject ).to receive( :sleep ).and_return( true )
|
637
|
-
|
638
|
-
allow( subject ).to receive( :hosts ).and_return( hosts )
|
639
|
-
|
640
|
-
#run higgs installer command
|
641
|
-
expect( subject ).to receive( :on ).with( hosts[0],
|
642
|
-
"cd /tmp/2014-07-01_15.27.53/puppet-enterprise-3.0-linux ; nohup ./pe-installer <<<Y > higgs_2014-07-01_15.27.53.log 2>&1 &",
|
643
|
-
opts ).once
|
644
|
-
#check to see if the higgs installation has proceeded correctly, works on second check
|
645
|
-
expect( subject ).to receive( :on ).with( hosts[0], /cat #{hosts[0]['higgs_file']}/, { :accept_all_exit_codes => true }).exactly(10).times.and_return( @fail_result )
|
646
|
-
expect{ subject.do_higgs_install( hosts[0], opts ) }.to raise_error RuntimeError, "Failed to kick off PE (Higgs) web installation"
|
647
|
-
end
|
648
|
-
|
649
|
-
end
|
650
|
-
|
651
|
-
describe 'install_pe' do
|
652
|
-
|
653
|
-
it 'calls do_install with sorted hosts' do
|
654
|
-
allow( subject ).to receive( :options ).and_return( {} )
|
655
|
-
allow( subject ).to receive( :hosts ).and_return( hosts_sorted )
|
656
|
-
allow( subject ).to receive( :do_install ).and_return( true )
|
657
|
-
expect( subject ).to receive( :do_install ).with( hosts, {} )
|
658
|
-
subject.install_pe
|
659
|
-
end
|
660
|
-
|
661
|
-
it 'fills in missing pe_ver' do
|
662
|
-
hosts.each do |h|
|
663
|
-
h['pe_ver'] = nil
|
664
|
-
end
|
665
|
-
allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version ).and_return( '2.8' )
|
666
|
-
allow( subject ).to receive( :hosts ).and_return( hosts_sorted )
|
667
|
-
allow( subject ).to receive( :options ).and_return( {} )
|
668
|
-
allow( subject ).to receive( :do_install ).and_return( true )
|
669
|
-
expect( subject ).to receive( :do_install ).with( hosts, {} )
|
670
|
-
subject.install_pe
|
671
|
-
hosts.each do |h|
|
672
|
-
expect( h['pe_ver'] ).to be === '2.8'
|
673
|
-
end
|
674
|
-
end
|
675
|
-
|
676
|
-
it 'can act upon a single host' do
|
677
|
-
allow( subject ).to receive( :hosts ).and_return( hosts )
|
678
|
-
allow( subject ).to receive( :sorted_hosts ).and_return( [hosts[0]] )
|
679
|
-
expect( subject ).to receive( :do_install ).with( [hosts[0]], {} )
|
680
|
-
subject.install_pe_on(hosts[0], {})
|
681
|
-
end
|
682
|
-
end
|
683
|
-
|
684
|
-
describe 'install_higgs' do
|
685
|
-
it 'fills in missing pe_ver' do
|
686
|
-
hosts[0]['pe_ver'] = nil
|
687
|
-
allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version ).and_return( '2.8' )
|
688
|
-
allow( subject ).to receive( :hosts ).and_return( [ hosts[1], hosts[0], hosts[2] ] )
|
689
|
-
allow( subject ).to receive( :options ).and_return( {} )
|
690
|
-
allow( subject ).to receive( :do_higgs_install ).and_return( true )
|
691
|
-
expect( subject ).to receive( :do_higgs_install ).with( hosts[0], {} )
|
692
|
-
subject.install_higgs
|
693
|
-
expect( hosts[0]['pe_ver'] ).to be === '2.8'
|
694
|
-
end
|
695
|
-
|
696
|
-
end
|
697
|
-
|
698
|
-
describe 'upgrade_pe' do
|
699
|
-
|
700
|
-
it 'calls puppet-enterprise-upgrader for pre 3.0 upgrades' do
|
701
|
-
allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version ).and_return( '2.8' )
|
702
|
-
allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version_win ).and_return( '2.8' )
|
703
|
-
the_hosts = [ hosts[0].dup, hosts[1].dup, hosts[2].dup ]
|
704
|
-
allow( subject ).to receive( :hosts ).and_return( the_hosts )
|
705
|
-
allow( subject ).to receive( :options ).and_return( {} )
|
706
|
-
allow( subject ).to receive( :version_is_less ).with('3.0', '3.4.0').and_return( true )
|
707
|
-
allow( subject ).to receive( :version_is_less ).with('2.8', '3.0').and_return( true )
|
708
|
-
version = version_win = '2.8'
|
709
|
-
path = "/path/to/upgradepkg"
|
710
|
-
expect( subject ).to receive( :do_install ).with( the_hosts, {:type=>:upgrade, :set_console_password=>true} )
|
711
|
-
subject.upgrade_pe( path )
|
712
|
-
the_hosts.each do |h|
|
713
|
-
expect( h['pe_installer'] ).to be === 'puppet-enterprise-upgrader'
|
714
|
-
end
|
715
|
-
end
|
716
|
-
|
717
|
-
it 'uses standard upgrader for post 3.0 upgrades' do
|
718
|
-
allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version ).and_return( '3.1' )
|
719
|
-
allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version_win ).and_return( '3.1' )
|
720
|
-
the_hosts = [ hosts[0].dup, hosts[1].dup, hosts[2].dup ]
|
721
|
-
allow( subject ).to receive( :hosts ).and_return( the_hosts )
|
722
|
-
allow( subject ).to receive( :options ).and_return( {} )
|
723
|
-
allow( subject ).to receive( :version_is_less ).with('3.0', '3.4.0').and_return( true )
|
724
|
-
allow( subject ).to receive( :version_is_less ).with('3.1', '3.0').and_return( false )
|
725
|
-
version = version_win = '3.1'
|
726
|
-
path = "/path/to/upgradepkg"
|
727
|
-
expect( subject ).to receive( :do_install ).with( the_hosts, {:type=>:upgrade, :set_console_password=>true} )
|
728
|
-
subject.upgrade_pe( path )
|
729
|
-
the_hosts.each do |h|
|
730
|
-
expect( h['pe_installer'] ).to be nil
|
731
|
-
end
|
732
|
-
end
|
733
|
-
|
734
|
-
it 'updates pe_ver post upgrade' do
|
735
|
-
allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version ).and_return( '2.8' )
|
736
|
-
allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version_win ).and_return( '2.8' )
|
737
|
-
the_hosts = [ hosts[0].dup, hosts[1].dup, hosts[2].dup ]
|
738
|
-
allow( subject ).to receive( :hosts ).and_return( the_hosts )
|
739
|
-
allow( subject ).to receive( :options ).and_return( {} )
|
740
|
-
allow( subject ).to receive( :version_is_less ).with('3.0', '3.4.0').and_return( true )
|
741
|
-
allow( subject ).to receive( :version_is_less ).with('2.8', '3.0').and_return( true )
|
742
|
-
version = version_win = '2.8'
|
743
|
-
path = "/path/to/upgradepkg"
|
744
|
-
expect( subject ).to receive( :do_install ).with( the_hosts, {:type=>:upgrade, :set_console_password=>true} )
|
745
|
-
subject.upgrade_pe( path )
|
746
|
-
the_hosts.each do |h|
|
747
|
-
expect( h['pe_ver'] ).to be === '2.8'
|
748
|
-
end
|
749
|
-
end
|
750
|
-
|
751
|
-
it 'can act upon a single host' do
|
752
|
-
allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version ).and_return( '3.1' )
|
753
|
-
allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version_win ).and_return( '3.1' )
|
754
|
-
allow( subject ).to receive( :hosts ).and_return( hosts )
|
755
|
-
allow( subject ).to receive( :version_is_less ).with('3.0', '3.4.0').and_return( true )
|
756
|
-
allow( subject ).to receive( :version_is_less ).with('3.1', '3.0').and_return( false )
|
757
|
-
allow( subject ).to receive( :sorted_hosts ).and_return( [hosts[0]] )
|
758
|
-
version = version_win = '3.1'
|
759
|
-
path = "/path/to/upgradepkg"
|
760
|
-
expect( subject ).to receive( :do_install ).with( [hosts[0]], {:type=>:upgrade, :set_console_password=>true} )
|
761
|
-
subject.upgrade_pe_on(hosts[0], {}, path)
|
762
|
-
end
|
763
|
-
|
764
|
-
end
|
765
|
-
|
766
|
-
describe 'fetch_and_push_pe' do
|
767
|
-
|
768
|
-
it 'fetches the file' do
|
769
|
-
allow( subject ).to receive( :scp_to )
|
770
|
-
|
771
|
-
path = 'abcde/fg/hij'
|
772
|
-
filename = 'pants'
|
773
|
-
extension = '.txt'
|
774
|
-
expect( subject ).to receive( :fetch_http_file ).with( path, "#{filename}#{extension}", 'tmp/pe' )
|
775
|
-
subject.fetch_and_push_pe(unixhost, path, filename, extension)
|
776
|
-
end
|
777
|
-
|
778
|
-
it 'allows you to set the local copy dir' do
|
779
|
-
allow( subject ).to receive( :scp_to )
|
780
|
-
|
781
|
-
path = 'defg/hi/j'
|
782
|
-
filename = 'pants'
|
783
|
-
extension = '.txt'
|
784
|
-
local_dir = '/root/domes'
|
785
|
-
expect( subject ).to receive( :fetch_http_file ).with( path, "#{filename}#{extension}", local_dir )
|
786
|
-
subject.fetch_and_push_pe(unixhost, path, filename, extension, local_dir)
|
787
|
-
end
|
788
|
-
|
789
|
-
it 'scp\'s to the host' do
|
790
|
-
allow( subject ).to receive( :fetch_http_file )
|
791
|
-
|
792
|
-
path = 'abcde/fg/hij'
|
793
|
-
filename = 'pants'
|
794
|
-
extension = '.txt'
|
795
|
-
expect( subject ).to receive( :scp_to ).with( unixhost, "tmp/pe/#{filename}#{extension}", unixhost['working_dir'] )
|
796
|
-
subject.fetch_and_push_pe(unixhost, path, filename, extension)
|
797
|
-
end
|
798
|
-
|
799
|
-
end
|
800
|
-
|
801
|
-
describe 'create_agent_specified_arrays' do
|
802
|
-
let(:master) { make_host( 'master', { :platform => 'linux',
|
803
|
-
:pe_ver => '4.0',
|
804
|
-
:roles => ['master', 'agent']})}
|
805
|
-
let(:db) { make_host( 'db', { :platform => 'linux',
|
806
|
-
:pe_ver => '4.0',
|
807
|
-
:roles => ['database', 'agent']})}
|
808
|
-
let(:console) { make_host( 'console', { :platform => 'linux',
|
809
|
-
:pe_ver => '4.0',
|
810
|
-
:roles => ['dashboard', 'agent']})}
|
811
|
-
let(:monolith) { make_host( 'monolith', { :platform => 'linux',
|
812
|
-
:pe_ver => '4.0',
|
813
|
-
:roles => %w(master dashboard database)})}
|
814
|
-
let(:frictionless) { make_host( 'frictionless', { :platform => 'linux',
|
815
|
-
:pe_ver => '4.0',
|
816
|
-
:roles => ['agent', 'frictionless']})}
|
817
|
-
let(:agent1) { make_host( 'agent1', { :platform => 'linux',
|
818
|
-
:pe_ver => '4.0',
|
819
|
-
:roles => ['agent']})}
|
820
|
-
let(:agent2) { make_host( 'agent2', { :platform => 'linux',
|
821
|
-
:pe_ver => '4.0',
|
822
|
-
:roles => ['agent']})}
|
823
|
-
let(:default_agent) { make_host( 'default', { :platform => 'linux',
|
824
|
-
:pe_ver => '4.0',
|
825
|
-
:roles => ['default', 'agent']})}
|
826
|
-
let(:masterless) { make_host( 'masterless', { :platform => 'linux',
|
827
|
-
:pe_ver => '4.0',
|
828
|
-
:roles => ['agent', 'masterless']})}
|
829
|
-
let(:compiler) { make_host( 'compiler', { :platform => 'linux',
|
830
|
-
:pe_ver => '4.0',
|
831
|
-
:roles => ['agent', 'compile_master']})}
|
832
|
-
|
833
|
-
it 'sorts hosts with common PE roles' do
|
834
|
-
these_hosts = [master, db, console, agent1, frictionless]
|
835
|
-
agent_only, non_agent = subject.create_agent_specified_arrays(these_hosts)
|
836
|
-
expect(agent_only.length).to be 1
|
837
|
-
expect(agent_only).to include(agent1)
|
838
|
-
expect(non_agent.length).to be 4
|
839
|
-
expect(non_agent).to include(master)
|
840
|
-
expect(non_agent).to include(db)
|
841
|
-
expect(non_agent).to include(console)
|
842
|
-
expect(non_agent).to include(frictionless)
|
843
|
-
end
|
844
|
-
|
845
|
-
# Possibly needed for NetDev and Scale testing
|
846
|
-
it 'defaults to classifying custom roles as "agent only"' do
|
847
|
-
these_hosts = [monolith, compiler, agent1, agent2]
|
848
|
-
agent_only, non_agent = subject.create_agent_specified_arrays(these_hosts)
|
849
|
-
expect(agent_only.length).to be 3
|
850
|
-
expect(agent_only).to include(agent1)
|
851
|
-
expect(agent_only).to include(agent2)
|
852
|
-
expect(agent_only).to include(compiler)
|
853
|
-
expect(non_agent.length).to be 1
|
854
|
-
expect(non_agent).to include(monolith)
|
855
|
-
end
|
856
|
-
|
857
|
-
# Most common form of module testing
|
858
|
-
it 'allows a puppet-agent host to be the default test target' do
|
859
|
-
these_hosts = [monolith, default_agent]
|
860
|
-
agent_only, non_agent = subject.create_agent_specified_arrays(these_hosts)
|
861
|
-
expect(agent_only.length).to be 1
|
862
|
-
expect(agent_only).to include(default_agent)
|
863
|
-
expect(non_agent.length).to be 1
|
864
|
-
expect(non_agent).to include(monolith)
|
865
|
-
end
|
866
|
-
|
867
|
-
# Preferred module on commit scenario
|
868
|
-
it 'handles masterless scenarios' do
|
869
|
-
these_hosts = [masterless]
|
870
|
-
agent_only, non_agent = subject.create_agent_specified_arrays(these_hosts)
|
871
|
-
expect(agent_only.length).to be 1
|
872
|
-
expect(non_agent).to be_empty
|
873
|
-
end
|
874
|
-
|
875
|
-
# IIRC, this is the basic PE integration smoke test
|
876
|
-
it 'handles agent-only-less scenarios' do
|
877
|
-
these_hosts = [monolith, frictionless]
|
878
|
-
agent_only, non_agent = subject.create_agent_specified_arrays(these_hosts)
|
879
|
-
expect(agent_only).to be_empty
|
880
|
-
expect(non_agent.length).to be 2
|
881
|
-
end
|
882
|
-
end
|
883
|
-
|
884
|
-
end
|