beaker 1.21.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/CONTRIBUTING.md +1 -0
- data/HISTORY.md +17288 -2
- data/Rakefile +6 -2
- data/beaker.gemspec +15 -19
- data/lib/beaker.rb +2 -5
- data/lib/beaker/answers.rb +2 -0
- data/lib/beaker/answers/version34.rb +37 -1
- data/lib/beaker/cli.rb +4 -0
- data/lib/beaker/command.rb +16 -84
- data/lib/beaker/command_factory.rb +13 -2
- data/lib/beaker/dsl/assertions.rb +25 -2
- data/lib/beaker/dsl/ezbake_utils.rb +2 -2
- data/lib/beaker/dsl/helpers.rb +66 -12
- data/lib/beaker/dsl/install_utils.rb +128 -66
- data/lib/beaker/dsl/wrappers.rb +41 -3
- data/lib/beaker/host.rb +42 -6
- data/lib/beaker/host/mac.rb +62 -0
- data/lib/beaker/host/mac/group.rb +96 -0
- data/lib/beaker/host/mac/user.rb +93 -0
- data/lib/beaker/host/unix/exec.rb +1 -1
- data/lib/beaker/host/unix/pkg.rb +11 -11
- data/lib/beaker/host/windows.rb +4 -4
- data/lib/beaker/host_prebuilt_steps.rb +194 -58
- data/lib/beaker/hypervisor.rb +16 -9
- data/lib/beaker/hypervisor/aws_sdk.rb +61 -17
- data/lib/beaker/hypervisor/docker.rb +14 -2
- data/lib/beaker/hypervisor/ec2_helper.rb +15 -3
- data/lib/beaker/hypervisor/vagrant.rb +22 -10
- data/lib/beaker/hypervisor/vagrant_libvirt.rb +11 -0
- data/lib/beaker/hypervisor/vagrant_virtualbox.rb +1 -1
- data/lib/beaker/hypervisor/vcloud_pooled.rb +8 -39
- data/lib/beaker/logger.rb +15 -9
- data/lib/beaker/network_manager.rb +2 -2
- data/lib/beaker/options/command_line_parser.rb +1 -1
- data/lib/beaker/options/parser.rb +1 -8
- data/lib/beaker/options/presets.rb +70 -45
- data/lib/beaker/perf.rb +3 -4
- data/lib/beaker/platform.rb +2 -1
- data/lib/beaker/result.rb +3 -9
- data/lib/beaker/ssh_connection.rb +2 -0
- data/lib/beaker/test_case.rb +2 -21
- data/lib/beaker/test_suite.rb +21 -25
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/answers_spec.rb +36 -0
- data/spec/beaker/cli_spec.rb +45 -45
- data/spec/beaker/command_spec.rb +25 -36
- data/spec/beaker/dsl/assertions_spec.rb +20 -27
- data/spec/beaker/dsl/ezbake_utils_spec.rb +5 -5
- data/spec/beaker/dsl/helpers_spec.rb +293 -208
- data/spec/beaker/dsl/install_utils_spec.rb +310 -189
- data/spec/beaker/dsl/outcomes_spec.rb +6 -6
- data/spec/beaker/dsl/roles_spec.rb +27 -18
- data/spec/beaker/dsl/structure_spec.rb +11 -11
- data/spec/beaker/dsl/wrappers_spec.rb +35 -11
- data/spec/beaker/host/mac/group_spec.rb +124 -0
- data/spec/beaker/host/mac/user_spec.rb +134 -0
- data/spec/beaker/host/unix/pkg_spec.rb +40 -24
- data/spec/beaker/host/windows/group_spec.rb +1 -1
- data/spec/beaker/host_prebuilt_steps_spec.rb +194 -68
- data/spec/beaker/host_spec.rb +145 -67
- data/spec/beaker/hypervisor/aixer_spec.rb +6 -6
- data/spec/beaker/hypervisor/aws_sdk_spec.rb +22 -7
- data/spec/beaker/hypervisor/docker_spec.rb +71 -50
- data/spec/beaker/hypervisor/ec2_helper_spec.rb +25 -4
- data/spec/beaker/hypervisor/fusion_spec.rb +2 -2
- data/spec/beaker/hypervisor/hypervisor_spec.rb +20 -27
- data/spec/beaker/hypervisor/hypervisor_spec.rb.orig +80 -0
- data/spec/beaker/hypervisor/solaris_spec.rb +8 -8
- data/spec/beaker/hypervisor/vagrant_fusion_spec.rb +6 -8
- data/spec/beaker/hypervisor/vagrant_libvirt_spec.rb +34 -0
- data/spec/beaker/hypervisor/vagrant_spec.rb +34 -33
- data/spec/beaker/hypervisor/vagrant_virtualbox_spec.rb +18 -8
- data/spec/beaker/hypervisor/vagrant_workstation_spec.rb +6 -8
- data/spec/beaker/hypervisor/vcloud_pooled_spec.rb +8 -8
- data/spec/beaker/hypervisor/vcloud_spec.rb +10 -10
- data/spec/beaker/hypervisor/vsphere_helper_spec.rb +8 -8
- data/spec/beaker/hypervisor/vsphere_spec.rb +1 -1
- data/spec/beaker/logger_spec.rb +45 -31
- data/spec/beaker/options/command_line_parser_spec.rb +10 -2
- data/spec/beaker/options/hosts_file_parser_spec.rb +9 -2
- data/spec/beaker/options/options_hash_spec.rb +2 -2
- data/spec/beaker/options/parser_spec.rb +2 -2
- data/spec/beaker/options/pe_version_scaper_spec.rb +6 -1
- data/spec/beaker/options/presets_spec.rb +11 -1
- data/spec/beaker/shared/error_handler_spec.rb +5 -5
- data/spec/beaker/shared/host_manager_spec.rb +3 -2
- data/spec/beaker/shared/repetition_spec.rb +18 -18
- data/spec/beaker/ssh_connection_spec.rb +33 -4
- data/spec/beaker/test_case_spec.rb +9 -9
- data/spec/beaker/test_suite_spec.rb +14 -14
- data/spec/helpers.rb +4 -4
- data/spec/matchers.rb +4 -4
- data/spec/mocks.rb +5 -1
- data/spec/spec_helper.rb +2 -8
- metadata +114 -80
- data/lib/beaker/hypervisor/blimper.rb +0 -108
- data/spec/beaker/hypervisor/blimper_spec.rb +0 -42
- data/spec/beaker/options/data/LATEST +0 -1
- data/spec/beaker/puppet_command_spec.rb +0 -161
- data/spec/mock_blimpy.rb +0 -48
@@ -9,7 +9,7 @@ class ClassMixedWithDSLInstallUtils
|
|
9
9
|
include Beaker::DSL::Patterns
|
10
10
|
|
11
11
|
def logger
|
12
|
-
@logger ||= RSpec::Mocks::
|
12
|
+
@logger ||= RSpec::Mocks::Double.new('logger').as_null_object
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -18,11 +18,13 @@ describe ClassMixedWithDSLInstallUtils do
|
|
18
18
|
let(:opts) { presets.presets.merge(presets.env_vars) }
|
19
19
|
let(:basic_hosts) { make_hosts( { :pe_ver => '3.0',
|
20
20
|
:platform => 'linux',
|
21
|
-
:roles => [ 'agent' ] } ) }
|
21
|
+
:roles => [ 'agent' ] }, 4 ) }
|
22
22
|
let(:hosts) { basic_hosts[0][:roles] = ['master', 'database', 'dashboard']
|
23
23
|
basic_hosts[1][:platform] = 'windows'
|
24
24
|
basic_hosts[2][:platform] = 'osx-10.9-x86_64'
|
25
|
+
basic_hosts[3][:platform] = 'eos'
|
25
26
|
basic_hosts }
|
27
|
+
let(:hosts_sorted) { [ hosts[1], hosts[0], hosts[2], hosts[3] ] }
|
26
28
|
let(:winhost) { make_host( 'winhost', { :platform => 'windows',
|
27
29
|
:pe_ver => '3.0',
|
28
30
|
:working_dir => '/tmp' } ) }
|
@@ -33,6 +35,10 @@ describe ClassMixedWithDSLInstallUtils do
|
|
33
35
|
:pe_ver => '3.0',
|
34
36
|
:working_dir => '/tmp',
|
35
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' } ) }
|
36
42
|
|
37
43
|
|
38
44
|
context 'extract_repo_info_from' do
|
@@ -71,9 +77,9 @@ describe ClassMixedWithDSLInstallUtils do
|
|
71
77
|
cmd = 'cd /path/to/repo/name && git describe || true'
|
72
78
|
logger = double.as_null_object
|
73
79
|
|
74
|
-
subject.
|
75
|
-
subject.
|
76
|
-
subject.
|
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' )
|
77
83
|
|
78
84
|
version = subject.find_git_repo_versions( host, path, repository )
|
79
85
|
|
@@ -90,8 +96,8 @@ describe ClassMixedWithDSLInstallUtils do
|
|
90
96
|
host = { 'platform' => 'debian' }
|
91
97
|
logger = double.as_null_object
|
92
98
|
|
93
|
-
subject.
|
94
|
-
subject.
|
99
|
+
expect( subject ).to receive( :logger ).exactly( 3 ).times.and_return( logger )
|
100
|
+
expect( subject ).to receive( :on ).exactly( 4 ).times
|
95
101
|
|
96
102
|
subject.install_from_git( host, path, repo )
|
97
103
|
end
|
@@ -106,12 +112,12 @@ describe ClassMixedWithDSLInstallUtils do
|
|
106
112
|
cmd = "test -d #{path}/#{repo[:name]} || git clone --branch #{repo[:rev]} --depth #{repo[:depth]} #{repo[:path]} #{path}/#{repo[:name]}"
|
107
113
|
host = { 'platform' => 'debian' }
|
108
114
|
logger = double.as_null_object
|
109
|
-
subject.
|
110
|
-
subject.
|
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
|
111
117
|
# this is the the command we want to test
|
112
|
-
subject.
|
113
|
-
subject.
|
114
|
-
subject.
|
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
|
115
121
|
|
116
122
|
subject.install_from_git( host, path, repo )
|
117
123
|
end
|
@@ -127,12 +133,12 @@ describe ClassMixedWithDSLInstallUtils do
|
|
127
133
|
cmd = "test -d #{path}/#{repo[:name]} || git clone --branch #{repo[:depth_branch]} --depth #{repo[:depth]} #{repo[:path]} #{path}/#{repo[:name]}"
|
128
134
|
host = { 'platform' => 'debian' }
|
129
135
|
logger = double.as_null_object
|
130
|
-
subject.
|
131
|
-
subject.
|
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
|
132
138
|
# this is the the command we want to test
|
133
|
-
subject.
|
134
|
-
subject.
|
135
|
-
subject.
|
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
|
136
142
|
|
137
143
|
subject.install_from_git( host, path, repo )
|
138
144
|
end
|
@@ -140,12 +146,12 @@ describe ClassMixedWithDSLInstallUtils do
|
|
140
146
|
|
141
147
|
describe 'sorted_hosts' do
|
142
148
|
it 'can reorder so that the master comes first' do
|
143
|
-
subject.
|
149
|
+
allow( subject ).to receive( :hosts ).and_return( hosts_sorted )
|
144
150
|
expect( subject.sorted_hosts ).to be === hosts
|
145
151
|
end
|
146
152
|
|
147
153
|
it 'leaves correctly ordered hosts alone' do
|
148
|
-
subject.
|
154
|
+
allow( subject ).to receive( :hosts ).and_return( hosts )
|
149
155
|
expect( subject.sorted_hosts ).to be === hosts
|
150
156
|
end
|
151
157
|
end
|
@@ -154,7 +160,7 @@ describe ClassMixedWithDSLInstallUtils do
|
|
154
160
|
|
155
161
|
it 'generates a windows PE install command for a windows host' do
|
156
162
|
winhost['dist'] = 'puppet-enterprise-3.0'
|
157
|
-
subject.
|
163
|
+
allow( subject ).to receive( :hosts ).and_return( [ hosts[1], hosts[0], hosts[2], winhost ] )
|
158
164
|
expect( subject.installer_cmd( winhost, {} ) ).to be === "cd /tmp && cmd /C 'start /w msiexec.exe /qn /L*V tmp.log /i puppet-enterprise-3.0.msi PUPPET_MASTER_SERVER=vm1 PUPPET_AGENT_CERTNAME=winhost'"
|
159
165
|
end
|
160
166
|
|
@@ -165,12 +171,22 @@ describe ClassMixedWithDSLInstallUtils do
|
|
165
171
|
end
|
166
172
|
|
167
173
|
it 'generates a unix PE frictionless install command for a unix host with role "frictionless"' do
|
168
|
-
subject.
|
169
|
-
subject.
|
174
|
+
allow( subject ).to receive( :version_is_less ).and_return( false )
|
175
|
+
allow( subject ).to receive( :master ).and_return( 'testmaster' )
|
176
|
+
the_host = unixhost.dup
|
177
|
+
the_host['pe_installer'] = 'puppet-enterprise-installer'
|
178
|
+
the_host['roles'] = ['frictionless']
|
179
|
+
expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp && curl --tlsv1 -kO https://testmaster:8140/packages/3.0/install.bash && bash install.bash"
|
180
|
+
end
|
181
|
+
|
182
|
+
it 'generates a unix PE frictionless install command for a unix host with role "frictionless" and "frictionless_options"' do
|
183
|
+
allow( subject ).to receive( :version_is_less ).and_return( false )
|
184
|
+
allow( subject ).to receive( :master ).and_return( 'testmaster' )
|
170
185
|
the_host = unixhost.dup
|
171
186
|
the_host['pe_installer'] = 'puppet-enterprise-installer'
|
172
187
|
the_host['roles'] = ['frictionless']
|
173
|
-
|
188
|
+
the_host['frictionless_options'] = { 'main' => { 'dns_alt_names' => 'puppet' } }
|
189
|
+
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"
|
174
190
|
end
|
175
191
|
|
176
192
|
it 'generates a osx PE install command for a osx host' do
|
@@ -179,6 +195,13 @@ describe ClassMixedWithDSLInstallUtils do
|
|
179
195
|
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 /"
|
180
196
|
end
|
181
197
|
|
198
|
+
it 'generates an EOS PE install command for an EOS host' do
|
199
|
+
the_host = eoshost.dup
|
200
|
+
commands = ['enable', "extension puppet-enterprise-#{the_host['pe_ver']}-#{the_host['platform']}.swix"]
|
201
|
+
command = commands.join("\n")
|
202
|
+
expect( subject.installer_cmd( the_host, {} ) ).to be === "Cli -c '#{command}'"
|
203
|
+
end
|
204
|
+
|
182
205
|
it 'generates a unix PE install command in verbose for a unix host when pe_debug is enabled' do
|
183
206
|
the_host = unixhost.dup
|
184
207
|
the_host['pe_installer'] = 'puppet-enterprise-installer'
|
@@ -194,13 +217,13 @@ describe ClassMixedWithDSLInstallUtils do
|
|
194
217
|
end
|
195
218
|
|
196
219
|
it 'generates a unix PE frictionless install command in verbose for a unix host with role "frictionless" and pe_debug is enabled' do
|
197
|
-
subject.
|
198
|
-
subject.
|
220
|
+
allow( subject ).to receive( :version_is_less ).and_return( false )
|
221
|
+
allow( subject ).to receive( :master ).and_return( 'testmaster' )
|
199
222
|
the_host = unixhost.dup
|
200
223
|
the_host['pe_installer'] = 'puppet-enterprise-installer'
|
201
224
|
the_host['roles'] = ['frictionless']
|
202
225
|
the_host[:pe_debug] = true
|
203
|
-
expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp && curl -kO https://testmaster:8140/packages/3.0/install.bash && bash -x install.bash"
|
226
|
+
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"
|
204
227
|
end
|
205
228
|
|
206
229
|
end
|
@@ -209,90 +232,99 @@ describe ClassMixedWithDSLInstallUtils do
|
|
209
232
|
describe 'fetch_puppet' do
|
210
233
|
|
211
234
|
it 'can push a local PE .tar.gz to a host and unpack it' do
|
212
|
-
File.
|
213
|
-
File.
|
235
|
+
allow( File ).to receive( :directory? ).and_return( true ) #is local
|
236
|
+
allow( File ).to receive( :exists? ).and_return( true ) #is a .tar.gz
|
214
237
|
unixhost['pe_dir'] = '/local/file/path'
|
215
|
-
subject.
|
238
|
+
allow( subject ).to receive( :scp_to ).and_return( true )
|
216
239
|
|
217
240
|
path = unixhost['pe_dir']
|
218
241
|
filename = "#{ unixhost['dist'] }"
|
219
242
|
extension = '.tar.gz'
|
220
|
-
subject.
|
221
|
-
subject.
|
222
|
-
subject.
|
243
|
+
expect( subject ).to receive( :scp_to ).with( unixhost, "#{ path }/#{ filename }#{ extension }", "#{ unixhost['working_dir'] }/#{ filename }#{ extension }" ).once
|
244
|
+
expect( subject ).to receive( :on ).with( unixhost, /gunzip/ ).once
|
245
|
+
expect( subject ).to receive( :on ).with( unixhost, /tar -xvf/ ).once
|
223
246
|
subject.fetch_puppet( [unixhost], {} )
|
224
247
|
end
|
225
248
|
|
226
249
|
it 'can download a PE .tar from a URL to a host and unpack it' do
|
227
|
-
File.
|
228
|
-
|
229
|
-
subject.stub( :link_exists? ) do |arg|
|
250
|
+
allow( File ).to receive( :directory? ).and_return( false ) #is not local
|
251
|
+
allow( subject ).to receive( :link_exists? ) do |arg|
|
230
252
|
if arg =~ /.tar.gz/ #there is no .tar.gz link, only a .tar
|
231
253
|
false
|
232
254
|
else
|
233
255
|
true
|
234
256
|
end
|
235
257
|
end
|
236
|
-
subject.
|
258
|
+
allow( subject ).to receive( :on ).and_return( true )
|
237
259
|
|
238
260
|
path = unixhost['pe_dir']
|
239
261
|
filename = "#{ unixhost['dist'] }"
|
240
262
|
extension = '.tar'
|
241
|
-
subject.
|
263
|
+
expect( subject ).to receive( :on ).with( unixhost, "cd #{ unixhost['working_dir'] }; curl #{ path }/#{ filename }#{ extension } | tar -xvf -" ).once
|
242
264
|
subject.fetch_puppet( [unixhost], {} )
|
243
265
|
end
|
244
266
|
|
245
267
|
it 'can download a PE .tar.gz from a URL to a host and unpack it' do
|
246
|
-
File.
|
247
|
-
|
248
|
-
subject.
|
249
|
-
subject.stub( :on ).and_return( true )
|
268
|
+
allow( File ).to receive( :directory? ).and_return( false ) #is not local
|
269
|
+
allow( subject ).to receive( :link_exists? ).and_return( true ) #is a tar.gz
|
270
|
+
allow( subject ).to receive( :on ).and_return( true )
|
250
271
|
|
251
272
|
path = unixhost['pe_dir']
|
252
273
|
filename = "#{ unixhost['dist'] }"
|
253
274
|
extension = '.tar.gz'
|
254
|
-
subject.
|
275
|
+
expect( subject ).to receive( :on ).with( unixhost, "cd #{ unixhost['working_dir'] }; curl #{ path }/#{ filename }#{ extension } | gunzip | tar -xvf -" ).once
|
255
276
|
subject.fetch_puppet( [unixhost], {} )
|
256
277
|
end
|
257
278
|
|
279
|
+
it 'can download a PE .swix from a URL to an EOS host and unpack it' do
|
280
|
+
allow( File ).to receive( :directory? ).and_return( false ) #is not local
|
281
|
+
allow( subject ).to receive( :link_exists? ).and_return( true ) #is a tar.gz
|
282
|
+
allow( subject ).to receive( :on ).and_return( true )
|
283
|
+
|
284
|
+
path = eoshost['pe_dir']
|
285
|
+
filename = "#{ eoshost['dist'] }"
|
286
|
+
extension = '.swix'
|
287
|
+
commands = ['enable', "copy #{path}/#{filename}#{extension} extension:"]
|
288
|
+
command = commands.join("\n")
|
289
|
+
expect( subject ).to receive( :on ).with( eoshost, "Cli -c '#{command}'" ).once
|
290
|
+
subject.fetch_puppet( [eoshost], {} )
|
291
|
+
end
|
292
|
+
|
258
293
|
it 'can push a local PE package to a windows host' do
|
259
|
-
File.
|
260
|
-
File.
|
261
|
-
winhost['pe_dir'] = '/local/file/path'
|
294
|
+
allow( File ).to receive( :directory? ).and_return( true ) #is local
|
295
|
+
allow( File ).to receive( :exists? ).and_return( true ) #is present
|
262
296
|
winhost['dist'] = 'puppet-enterprise-3.0'
|
263
|
-
subject.
|
297
|
+
allow( subject ).to receive( :scp_to ).and_return( true )
|
264
298
|
|
265
299
|
path = winhost['pe_dir']
|
266
300
|
filename = "puppet-enterprise-#{ winhost['pe_ver'] }"
|
267
301
|
extension = '.msi'
|
268
|
-
subject.
|
302
|
+
expect( subject ).to receive( :scp_to ).with( winhost, "#{ path }/#{ filename }#{ extension }", "#{ winhost['working_dir'] }/#{ filename }#{ extension }" ).once
|
269
303
|
subject.fetch_puppet( [winhost], {} )
|
270
304
|
|
271
305
|
end
|
272
306
|
|
273
307
|
it 'can download a PE dmg from a URL to a mac host' do
|
274
|
-
File.
|
275
|
-
|
276
|
-
subject.
|
277
|
-
subject.stub( :on ).and_return( true )
|
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 )
|
278
311
|
|
279
312
|
path = machost['pe_dir']
|
280
313
|
filename = "#{ machost['dist'] }"
|
281
314
|
extension = '.dmg'
|
282
|
-
subject.
|
315
|
+
expect( subject ).to receive( :on ).with( machost, "cd #{ machost['working_dir'] }; curl -O #{ path }/#{ filename }#{ extension }" ).once
|
283
316
|
subject.fetch_puppet( [machost], {} )
|
284
317
|
end
|
285
318
|
|
286
319
|
it 'can push a PE dmg to a mac host' do
|
287
|
-
File.
|
288
|
-
|
289
|
-
|
290
|
-
subject.stub( :scp_to ).and_return( true )
|
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 )
|
291
323
|
|
292
324
|
path = machost['pe_dir']
|
293
325
|
filename = "#{ machost['dist'] }"
|
294
326
|
extension = '.dmg'
|
295
|
-
subject.
|
327
|
+
expect( subject ).to receive( :scp_to ).with( machost, "#{ path }/#{ filename }#{ extension }", "#{ machost['working_dir'] }/#{ filename }#{ extension }" ).once
|
296
328
|
subject.fetch_puppet( [machost], {} )
|
297
329
|
end
|
298
330
|
|
@@ -300,64 +332,69 @@ describe ClassMixedWithDSLInstallUtils do
|
|
300
332
|
unixhost['roles'] << 'frictionless'
|
301
333
|
unixhost['pe_ver'] = '3.2.0'
|
302
334
|
|
303
|
-
subject.
|
304
|
-
subject.
|
305
|
-
subject.
|
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)
|
306
338
|
subject.fetch_puppet( [unixhost], {} )
|
307
339
|
end
|
308
340
|
end
|
309
341
|
|
310
342
|
describe 'do_install' do
|
311
343
|
it 'can perform a simple installation' do
|
312
|
-
subject.
|
313
|
-
subject.
|
314
|
-
subject.
|
315
|
-
subject.
|
316
|
-
subject.
|
317
|
-
subject.
|
318
|
-
subject.
|
319
|
-
subject.
|
320
|
-
subject.
|
321
|
-
subject.
|
344
|
+
allow( subject ).to receive( :on ).and_return( Beaker::Result.new( {}, '' ) )
|
345
|
+
allow( subject ).to receive( :fetch_puppet ).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( :version_is_less ).with('3.0', '3.4').and_return( true )
|
351
|
+
allow( subject ).to receive( :version_is_less ).with('3.0', '3.0').and_return( false )
|
352
|
+
allow( subject ).to receive( :version_is_less ).with('3.0', '3.4').and_return( true )
|
353
|
+
allow( subject ).to receive( :wait_for_host_in_dashboard ).and_return( true )
|
354
|
+
allow( subject ).to receive( :puppet_agent ) do |arg|
|
322
355
|
"puppet agent #{arg}"
|
323
356
|
end
|
324
|
-
subject.
|
357
|
+
allow( subject ).to receive( :puppet ) do |arg|
|
325
358
|
"puppet #{arg}"
|
326
359
|
end
|
327
360
|
|
328
|
-
subject.
|
361
|
+
allow( subject ).to receive( :hosts ).and_return( hosts )
|
329
362
|
#create answers file per-host, except windows
|
330
|
-
subject.
|
363
|
+
expect( subject ).to receive( :create_remote_file ).with( hosts[0], /answers/, /q/ ).once
|
331
364
|
#run installer on all hosts
|
332
|
-
subject.
|
333
|
-
subject.
|
334
|
-
subject.
|
335
|
-
|
336
|
-
|
337
|
-
subject.
|
338
|
-
subject.
|
365
|
+
expect( subject ).to receive( :on ).with( hosts[0], /puppet-enterprise-installer/ ).once
|
366
|
+
expect( subject ).to receive( :on ).with( hosts[1], /msiexec.exe/ ).once
|
367
|
+
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
|
368
|
+
expect( subject ).to receive( :on ).with( hosts[3], /^Cli/ ).once
|
369
|
+
#does extra mac/EOS specific commands
|
370
|
+
expect( subject ).to receive( :on ).with( hosts[2], /puppet config set server/ ).once
|
371
|
+
expect( subject ).to receive( :on ).with( hosts[3], /puppet config set server/ ).once
|
372
|
+
expect( subject ).to receive( :on ).with( hosts[2], /puppet config set certname/ ).once
|
373
|
+
expect( subject ).to receive( :on ).with( hosts[3], /puppet config set certname/ ).once
|
374
|
+
expect( subject ).to receive( :on ).with( hosts[2], /puppet agent -t/, :acceptable_exit_codes => [1] ).once
|
375
|
+
expect( subject ).to receive( :on ).with( hosts[3], /puppet agent -t/, :acceptable_exit_codes => [1] ).once
|
339
376
|
#sign certificate per-host
|
340
|
-
subject.
|
341
|
-
subject.
|
342
|
-
subject.
|
377
|
+
expect( subject ).to receive( :sign_certificate_for ).with( hosts[0] ).once
|
378
|
+
expect( subject ).to receive( :sign_certificate_for ).with( hosts[1] ).once
|
379
|
+
expect( subject ).to receive( :sign_certificate_for ).with( hosts[2] ).once
|
380
|
+
expect( subject ).to receive( :sign_certificate_for ).with( hosts[3] ).once
|
343
381
|
#stop puppet agent on all hosts
|
344
|
-
subject.
|
345
|
-
subject.
|
346
|
-
subject.
|
382
|
+
expect( subject ).to receive( :stop_agent_on ).with( hosts[0] ).once
|
383
|
+
expect( subject ).to receive( :stop_agent_on ).with( hosts[1] ).once
|
384
|
+
expect( subject ).to receive( :stop_agent_on ).with( hosts[2] ).once
|
385
|
+
expect( subject ).to receive( :stop_agent_on ).with( hosts[3] ).once
|
347
386
|
#wait for puppetdb to start
|
348
|
-
subject.
|
387
|
+
expect( subject ).to receive( :sleep_until_puppetdb_started ).with( hosts[0] ).once
|
349
388
|
#run each puppet agent once
|
350
|
-
subject.
|
351
|
-
subject.
|
352
|
-
subject.
|
389
|
+
expect( subject ).to receive( :on ).with( hosts[0], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).once
|
390
|
+
expect( subject ).to receive( :on ).with( hosts[1], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).once
|
391
|
+
expect( subject ).to receive( :on ).with( hosts[2], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).once
|
392
|
+
expect( subject ).to receive( :on ).with( hosts[3], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).once
|
353
393
|
#run rake task on dashboard
|
354
|
-
subject.
|
394
|
+
expect( subject ).to receive( :on ).with( hosts[0], /\/opt\/puppet\/bin\/rake -sf \/opt\/puppet\/share\/puppet-dashboard\/Rakefile .* RAILS_ENV=production/ ).once
|
355
395
|
#wait for all hosts to appear in the dashboard
|
356
|
-
subject.should_receive( :wait_for_host_in_dashboard ).with( hosts[0] ).once
|
357
|
-
subject.should_receive( :wait_for_host_in_dashboard ).with( hosts[1] ).once
|
358
|
-
subject.should_receive( :wait_for_host_in_dashboard ).with( hosts[2] ).once
|
359
396
|
#run puppet agent now that installation is complete
|
360
|
-
subject.
|
397
|
+
expect( subject ).to receive( :on ).with( hosts, /puppet agent/, :acceptable_exit_codes => [0,2] ).once
|
361
398
|
subject.do_install( hosts, opts )
|
362
399
|
end
|
363
400
|
end
|
@@ -366,13 +403,13 @@ describe ClassMixedWithDSLInstallUtils do
|
|
366
403
|
|
367
404
|
before :each do
|
368
405
|
my_time = double( "time double" )
|
369
|
-
my_time.
|
370
|
-
Time.
|
406
|
+
allow( my_time ).to receive( :strftime ).and_return( "2014-07-01_15.27.53" )
|
407
|
+
allow( Time ).to receive( :new ).and_return( my_time )
|
371
408
|
|
372
409
|
hosts[0]['working_dir'] = "tmp/2014-07-01_15.27.53"
|
373
410
|
hosts[0]['dist'] = 'dist'
|
374
411
|
hosts[0]['pe_installer'] = 'pe-installer'
|
375
|
-
hosts[0].
|
412
|
+
allow( hosts[0] ).to receive( :tmpdir ).and_return( "/tmp/2014-07-01_15.27.53" )
|
376
413
|
|
377
414
|
@fail_result = Beaker::Result.new( {}, '' )
|
378
415
|
@fail_result.stdout = "No match here"
|
@@ -381,32 +418,32 @@ describe ClassMixedWithDSLInstallUtils do
|
|
381
418
|
end
|
382
419
|
|
383
420
|
it 'can perform a simple installation' do
|
384
|
-
subject.
|
385
|
-
subject.
|
421
|
+
allow( subject ).to receive( :fetch_puppet ).and_return( true )
|
422
|
+
allow( subject ).to receive( :sleep ).and_return( true )
|
386
423
|
|
387
|
-
subject.
|
424
|
+
allow( subject ).to receive( :hosts ).and_return( hosts )
|
388
425
|
|
389
426
|
#run higgs installer command
|
390
|
-
subject.
|
427
|
+
expect( subject ).to receive( :on ).with( hosts[0],
|
391
428
|
"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 &",
|
392
429
|
opts ).once
|
393
430
|
#check to see if the higgs installation has proceeded correctly, works on second check
|
394
|
-
subject.
|
431
|
+
expect( subject ).to receive( :on ).with( hosts[0], /cat #{hosts[0]['higgs_file']}/, { :acceptable_exit_codes => 0..255 }).and_return( @fail_result, @success_result )
|
395
432
|
subject.do_higgs_install( hosts[0], opts )
|
396
433
|
end
|
397
434
|
|
398
435
|
it 'fails out after checking installation log 10 times' do
|
399
|
-
subject.
|
400
|
-
subject.
|
436
|
+
allow( subject ).to receive( :fetch_puppet ).and_return( true )
|
437
|
+
allow( subject ).to receive( :sleep ).and_return( true )
|
401
438
|
|
402
|
-
subject.
|
439
|
+
allow( subject ).to receive( :hosts ).and_return( hosts )
|
403
440
|
|
404
441
|
#run higgs installer command
|
405
|
-
subject.
|
442
|
+
expect( subject ).to receive( :on ).with( hosts[0],
|
406
443
|
"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 &",
|
407
444
|
opts ).once
|
408
445
|
#check to see if the higgs installation has proceeded correctly, works on second check
|
409
|
-
subject.
|
446
|
+
expect( subject ).to receive( :on ).with( hosts[0], /cat #{hosts[0]['higgs_file']}/, { :acceptable_exit_codes => 0..255 }).exactly(10).times.and_return( @fail_result )
|
410
447
|
expect{ subject.do_higgs_install( hosts[0], opts ) }.to raise_error
|
411
448
|
end
|
412
449
|
|
@@ -418,8 +455,8 @@ describe ClassMixedWithDSLInstallUtils do
|
|
418
455
|
end
|
419
456
|
|
420
457
|
before do
|
421
|
-
subject.
|
422
|
-
subject.
|
458
|
+
allow( subject ).to receive(:hosts).and_return(hosts)
|
459
|
+
allow( subject ).to receive(:on).and_return(Beaker::Result.new({},''))
|
423
460
|
end
|
424
461
|
context 'on el-6' do
|
425
462
|
let(:platform) { "el-6-i386" }
|
@@ -475,6 +512,21 @@ describe ClassMixedWithDSLInstallUtils do
|
|
475
512
|
subject.install_puppet( :version => '3000', :facter_version => '1999', :hiera_version => '2001' )
|
476
513
|
end
|
477
514
|
end
|
515
|
+
context 'on windows' do
|
516
|
+
let(:platform) { "windows-2008r2-i386" }
|
517
|
+
it 'installs specific version of puppet when passed :version' do
|
518
|
+
allow(subject).to receive(:link_exists?).and_return( true )
|
519
|
+
expect(subject).to receive(:on).with(hosts[0], 'curl -O http://downloads.puppetlabs.com/windows/puppet-3000.msi')
|
520
|
+
expect(subject).to receive(:on).with(hosts[0], 'msiexec /qn /i puppet-3000.msi')
|
521
|
+
subject.install_puppet(:version => '3000')
|
522
|
+
end
|
523
|
+
it 'installs from custom url when passed :win_download_url' do
|
524
|
+
allow(subject).to receive(:link_exists?).and_return( true )
|
525
|
+
expect(subject).to receive(:on).with(hosts[0], 'curl -O http://nightlies.puppetlabs.com/puppet-latest/repos/windows/puppet-3000.msi')
|
526
|
+
expect(subject).to receive(:on).with(hosts[0], 'msiexec /qn /i puppet-3000.msi')
|
527
|
+
subject.install_puppet( :version => '3000', :win_download_url => 'http://nightlies.puppetlabs.com/puppet-latest/repos/windows' )
|
528
|
+
end
|
529
|
+
end
|
478
530
|
describe 'on unsupported platforms' do
|
479
531
|
let(:platform) { 'solaris-11-x86_64' }
|
480
532
|
let(:host) { make_host('henry', :platform => 'solaris-11-x86_64') }
|
@@ -494,13 +546,44 @@ describe ClassMixedWithDSLInstallUtils do
|
|
494
546
|
end
|
495
547
|
end
|
496
548
|
|
549
|
+
describe '#add_system32_hosts_entry' do
|
550
|
+
before do
|
551
|
+
allow( subject ).to receive(:on).and_return(Beaker::Result.new({},''))
|
552
|
+
end
|
553
|
+
context 'on debian' do
|
554
|
+
let(:platform) { 'debian-7-amd64' }
|
555
|
+
let(:host) { make_host('testbox.test.local', :platform => 'debian-7-amd64') }
|
556
|
+
it 'logs message - nothing to do on this host' do
|
557
|
+
expect( Beaker::Command ).to receive( :new ).never
|
558
|
+
|
559
|
+
expect {
|
560
|
+
subject.add_system32_hosts_entry(host, {})
|
561
|
+
}.to raise_error
|
562
|
+
end
|
563
|
+
end
|
564
|
+
context 'on windows' do
|
565
|
+
let(:platform) { 'windows-2008R2-amd64' }
|
566
|
+
let(:host) { make_host('testbox.test.local', :platform => 'windows-2008R2-amd64') }
|
567
|
+
it 'it add an entry into the /etc/hosts file' do
|
568
|
+
entry = { 'ip' => '23.251.154.122', 'name' => 'forge.puppetlabs.com' }
|
569
|
+
expect(subject).to receive(:on) do |host, command|
|
570
|
+
expect(command.command).to eq('powershell.exe')
|
571
|
+
expect(command.args).to eq(" -ExecutionPolicy Bypass -InputFormat None -NoLogo -NoProfile -NonInteractive -Command \"$text = \\\"23.251.154.122`t`tforge.puppetlabs.com\\\"; Add-Content -path 'C:\\Windows\\System32\\Drivers\\etc\\hosts' -value $text\"")
|
572
|
+
end
|
573
|
+
|
574
|
+
|
575
|
+
subject.add_system32_hosts_entry(host, entry)
|
576
|
+
end
|
577
|
+
end
|
578
|
+
end
|
579
|
+
|
497
580
|
describe 'install_pe' do
|
498
581
|
|
499
582
|
it 'calls do_install with sorted hosts' do
|
500
|
-
subject.
|
501
|
-
subject.
|
502
|
-
subject.
|
503
|
-
subject.
|
583
|
+
allow( subject ).to receive( :options ).and_return( {} )
|
584
|
+
allow( subject ).to receive( :hosts ).and_return( hosts_sorted )
|
585
|
+
allow( subject ).to receive( :do_install ).and_return( true )
|
586
|
+
expect( subject ).to receive( :do_install ).with( hosts, {} )
|
504
587
|
subject.install_pe
|
505
588
|
end
|
506
589
|
|
@@ -508,11 +591,11 @@ describe ClassMixedWithDSLInstallUtils do
|
|
508
591
|
hosts.each do |h|
|
509
592
|
h['pe_ver'] = nil
|
510
593
|
end
|
511
|
-
Beaker::Options::PEVersionScraper.
|
512
|
-
subject.
|
513
|
-
subject.
|
514
|
-
subject.
|
515
|
-
subject.
|
594
|
+
allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version ).and_return( '2.8' )
|
595
|
+
allow( subject ).to receive( :hosts ).and_return( hosts_sorted )
|
596
|
+
allow( subject ).to receive( :options ).and_return( {} )
|
597
|
+
allow( subject ).to receive( :do_install ).and_return( true )
|
598
|
+
expect( subject ).to receive( :do_install ).with( hosts, {} )
|
516
599
|
subject.install_pe
|
517
600
|
hosts.each do |h|
|
518
601
|
expect( h['pe_ver'] ).to be === '2.8'
|
@@ -523,11 +606,11 @@ describe ClassMixedWithDSLInstallUtils do
|
|
523
606
|
describe 'install_higgs' do
|
524
607
|
it 'fills in missing pe_ver' do
|
525
608
|
hosts[0]['pe_ver'] = nil
|
526
|
-
Beaker::Options::PEVersionScraper.
|
527
|
-
subject.
|
528
|
-
subject.
|
529
|
-
subject.
|
530
|
-
subject.
|
609
|
+
allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version ).and_return( '2.8' )
|
610
|
+
allow( subject ).to receive( :hosts ).and_return( [ hosts[1], hosts[0], hosts[2] ] )
|
611
|
+
allow( subject ).to receive( :options ).and_return( {} )
|
612
|
+
allow( subject ).to receive( :do_higgs_install ).and_return( true )
|
613
|
+
expect( subject ).to receive( :do_higgs_install ).with( hosts[0], {} )
|
531
614
|
subject.install_higgs
|
532
615
|
expect( hosts[0]['pe_ver'] ).to be === '2.8'
|
533
616
|
end
|
@@ -537,15 +620,15 @@ describe ClassMixedWithDSLInstallUtils do
|
|
537
620
|
describe 'upgrade_pe' do
|
538
621
|
|
539
622
|
it 'calls puppet-enterprise-upgrader for pre 3.0 upgrades' do
|
540
|
-
Beaker::Options::PEVersionScraper.
|
541
|
-
Beaker::Options::PEVersionScraper.
|
623
|
+
allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version ).and_return( '2.8' )
|
624
|
+
allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version_win ).and_return( '2.8' )
|
542
625
|
the_hosts = [ hosts[0].dup, hosts[1].dup, hosts[2].dup ]
|
543
|
-
subject.
|
544
|
-
subject.
|
545
|
-
subject.
|
626
|
+
allow( subject ).to receive( :hosts ).and_return( the_hosts )
|
627
|
+
allow( subject ).to receive( :options ).and_return( {} )
|
628
|
+
allow( subject ).to receive( :version_is_less ).with('2.8', '3.0').and_return( true )
|
546
629
|
version = version_win = '2.8'
|
547
630
|
path = "/path/to/upgradepkg"
|
548
|
-
subject.
|
631
|
+
expect( subject ).to receive( :do_install ).with( the_hosts, { :type => :upgrade } )
|
549
632
|
subject.upgrade_pe( path )
|
550
633
|
the_hosts.each do |h|
|
551
634
|
expect( h['pe_installer'] ).to be === 'puppet-enterprise-upgrader'
|
@@ -553,15 +636,15 @@ describe ClassMixedWithDSLInstallUtils do
|
|
553
636
|
end
|
554
637
|
|
555
638
|
it 'uses standard upgrader for post 3.0 upgrades' do
|
556
|
-
Beaker::Options::PEVersionScraper.
|
557
|
-
Beaker::Options::PEVersionScraper.
|
639
|
+
allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version ).and_return( '3.1' )
|
640
|
+
allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version_win ).and_return( '3.1' )
|
558
641
|
the_hosts = [ hosts[0].dup, hosts[1].dup, hosts[2].dup ]
|
559
|
-
subject.
|
560
|
-
subject.
|
561
|
-
subject.
|
642
|
+
allow( subject ).to receive( :hosts ).and_return( the_hosts )
|
643
|
+
allow( subject ).to receive( :options ).and_return( {} )
|
644
|
+
allow( subject ).to receive( :version_is_less ).with('3.1', '3.0').and_return( false )
|
562
645
|
version = version_win = '3.1'
|
563
646
|
path = "/path/to/upgradepkg"
|
564
|
-
subject.
|
647
|
+
expect( subject ).to receive( :do_install ).with( the_hosts, { :type => :upgrade } )
|
565
648
|
subject.upgrade_pe( path )
|
566
649
|
the_hosts.each do |h|
|
567
650
|
expect( h['pe_installer'] ).to be nil
|
@@ -569,15 +652,15 @@ describe ClassMixedWithDSLInstallUtils do
|
|
569
652
|
end
|
570
653
|
|
571
654
|
it 'updates pe_ver post upgrade' do
|
572
|
-
Beaker::Options::PEVersionScraper.
|
573
|
-
Beaker::Options::PEVersionScraper.
|
655
|
+
allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version ).and_return( '2.8' )
|
656
|
+
allow( Beaker::Options::PEVersionScraper ).to receive( :load_pe_version_win ).and_return( '2.8' )
|
574
657
|
the_hosts = [ hosts[0].dup, hosts[1].dup, hosts[2].dup ]
|
575
|
-
subject.
|
576
|
-
subject.
|
577
|
-
subject.
|
658
|
+
allow( subject ).to receive( :hosts ).and_return( the_hosts )
|
659
|
+
allow( subject ).to receive( :options ).and_return( {} )
|
660
|
+
allow( subject ).to receive( :version_is_less ).with('2.8', '3.0').and_return( true )
|
578
661
|
version = version_win = '2.8'
|
579
662
|
path = "/path/to/upgradepkg"
|
580
|
-
subject.
|
663
|
+
expect( subject ).to receive( :do_install ).with( the_hosts, { :type => :upgrade } )
|
581
664
|
subject.upgrade_pe( path )
|
582
665
|
the_hosts.each do |h|
|
583
666
|
expect( h['pe_ver'] ).to be === '2.8'
|
@@ -588,8 +671,6 @@ describe ClassMixedWithDSLInstallUtils do
|
|
588
671
|
|
589
672
|
|
590
673
|
def fetch_allows
|
591
|
-
allow(File).to receive( :exists? ) { true }
|
592
|
-
allow(File).to receive( :open ).and_yield()
|
593
674
|
allow(subject).to receive( :logger ) { logger }
|
594
675
|
end
|
595
676
|
|
@@ -603,6 +684,7 @@ describe ClassMixedWithDSLInstallUtils do
|
|
603
684
|
describe "given valid arguments" do
|
604
685
|
|
605
686
|
it "returns its second and third arguments concatenated." do
|
687
|
+
create_files(['destdir/name'])
|
606
688
|
result = subject.fetch_http_file "http://beaker.tool/", "name", "destdir"
|
607
689
|
expect(result).to eq("destdir/name")
|
608
690
|
end
|
@@ -623,6 +705,7 @@ describe ClassMixedWithDSLInstallUtils do
|
|
623
705
|
|
624
706
|
it "returns basename of first argument concatenated to second." do
|
625
707
|
expect(subject).to receive(:`).with(/^wget.*/).ordered { result }
|
708
|
+
expect($?).to receive(:to_i).and_return(0)
|
626
709
|
result = subject.fetch_http_dir "http://beaker.tool/beep", "destdir"
|
627
710
|
expect(result).to eq("destdir/beep")
|
628
711
|
end
|
@@ -730,32 +813,32 @@ describe ClassMixedWithDSLInstallUtils do
|
|
730
813
|
end
|
731
814
|
|
732
815
|
describe '#install_dev_puppet_module_on' do
|
733
|
-
context 'having set a
|
816
|
+
context 'having set allow( a ).to receive forge' do
|
734
817
|
it 'stubs the forge on the host' do
|
735
818
|
master = hosts.first
|
736
|
-
subject.
|
819
|
+
allow( subject ).to receive( :options ).and_return( {:forge_host => 'ahost.com'} )
|
737
820
|
|
738
|
-
subject.
|
821
|
+
expect( subject ).to receive( :with_forge_stubbed_on )
|
739
822
|
|
740
823
|
subject.install_dev_puppet_module_on( master, {:source => '/module', :module_name => 'test'} )
|
741
824
|
end
|
742
825
|
|
743
826
|
it 'installs via #install_puppet_module_via_pmt' do
|
744
827
|
master = hosts.first
|
745
|
-
subject.
|
746
|
-
subject.
|
828
|
+
allow( subject ).to receive( :options ).and_return( {:forge_host => 'ahost.com'} )
|
829
|
+
allow( subject ).to receive( :with_forge_stubbed_on ).and_yield
|
747
830
|
|
748
|
-
subject.
|
831
|
+
expect( subject ).to receive( :install_puppet_module_via_pmt_on )
|
749
832
|
|
750
833
|
subject.install_dev_puppet_module_on( master, {:source => '/module', :module_name => 'test'} )
|
751
834
|
end
|
752
835
|
end
|
753
|
-
context 'without a
|
836
|
+
context 'without allow( a ).to receive forge (default)' do
|
754
837
|
it 'calls copy_module_to to get the module on the SUT' do
|
755
838
|
master = hosts.first
|
756
|
-
subject.
|
839
|
+
allow( subject ).to receive( :options ).and_return( {} )
|
757
840
|
|
758
|
-
subject.
|
841
|
+
expect( subject ).to receive( :copy_module_to )
|
759
842
|
|
760
843
|
subject.install_dev_puppet_module_on( master, {:source => '/module', :module_name => 'test'} )
|
761
844
|
end
|
@@ -764,11 +847,11 @@ describe ClassMixedWithDSLInstallUtils do
|
|
764
847
|
|
765
848
|
describe '#install_dev_puppet_module' do
|
766
849
|
it 'delegates to #install_dev_puppet_module_on with the hosts list' do
|
767
|
-
subject.
|
768
|
-
subject.
|
850
|
+
allow( subject ).to receive( :hosts ).and_return( hosts )
|
851
|
+
allow( subject ).to receive( :options ).and_return( {} )
|
769
852
|
|
770
853
|
hosts.each do |host|
|
771
|
-
subject.
|
854
|
+
expect( subject ).to receive( :install_dev_puppet_module_on ).
|
772
855
|
with( host, {:source => '/module', :module_name => 'test'})
|
773
856
|
end
|
774
857
|
|
@@ -778,10 +861,22 @@ describe ClassMixedWithDSLInstallUtils do
|
|
778
861
|
|
779
862
|
describe '#install_puppet_module_via_pmt_on' do
|
780
863
|
it 'installs module via puppet module tool' do
|
781
|
-
subject.
|
864
|
+
allow( subject ).to receive( :hosts ).and_return( hosts )
|
865
|
+
master = hosts.first
|
866
|
+
|
867
|
+
|
868
|
+
expect( subject ).to receive( :puppet ).with('module install test ', {}).once
|
869
|
+
|
870
|
+
subject.install_puppet_module_via_pmt_on( master, {:module_name => 'test'} )
|
871
|
+
end
|
872
|
+
|
873
|
+
it 'takes the trace option and passes it down correctly' do
|
874
|
+
allow( subject ).to receive( :hosts ).and_return( hosts )
|
782
875
|
master = hosts.first
|
876
|
+
trace_opts = { :trace => nil }
|
877
|
+
master['default_module_install_opts'] = trace_opts
|
783
878
|
|
784
|
-
subject.
|
879
|
+
expect( subject ).to receive( :puppet ).with('module install test ', trace_opts).once
|
785
880
|
|
786
881
|
subject.install_puppet_module_via_pmt_on( master, {:module_name => 'test'} )
|
787
882
|
end
|
@@ -789,9 +884,9 @@ describe ClassMixedWithDSLInstallUtils do
|
|
789
884
|
|
790
885
|
describe '#install_puppet_module_via_pmt' do
|
791
886
|
it 'delegates to #install_puppet_module_via_pmt with the hosts list' do
|
792
|
-
subject.
|
887
|
+
allow( subject ).to receive( :hosts ).and_return( hosts )
|
793
888
|
|
794
|
-
subject.
|
889
|
+
expect( subject ).to receive( :install_puppet_module_via_pmt_on ).with( hosts, {:source => '/module', :module_name => 'test'}).once
|
795
890
|
|
796
891
|
subject.install_puppet_module_via_pmt( {:source => '/module', :module_name => 'test'} )
|
797
892
|
end
|
@@ -806,24 +901,24 @@ describe ClassMixedWithDSLInstallUtils do
|
|
806
901
|
shared_examples 'copy_module_to' do |opts|
|
807
902
|
it{
|
808
903
|
host = double("host")
|
809
|
-
host.
|
904
|
+
allow( host ).to receive(:[]).with('distmoduledir').and_return('/etc/puppetlabs/puppet/modules')
|
810
905
|
result = double
|
811
906
|
stdout = target.split('/')[0..-2].join('/') + "\n"
|
812
|
-
result.
|
813
|
-
host.
|
814
|
-
Dir.
|
907
|
+
allow( result ).to receive(:stdout).and_return( stdout )
|
908
|
+
allow( host ).to receive(:exec).with( any_args ).and_return( result )
|
909
|
+
allow( Dir ).to receive(:getpwd).and_return(source)
|
815
910
|
|
816
|
-
subject.
|
911
|
+
allow( subject ).to receive(:parse_for_moduleroot).and_return(source)
|
817
912
|
if module_parse_name
|
818
|
-
subject.
|
913
|
+
allow( subject ).to receive(:parse_for_modulename).with(any_args()).and_return(module_parse_name)
|
819
914
|
else
|
820
|
-
subject.
|
915
|
+
expect( subject).to_not receive(:parse_for_modulename)
|
821
916
|
end
|
822
917
|
|
823
|
-
File.
|
824
|
-
File.
|
918
|
+
allow( File ).to receive(:exists?).with(any_args()).and_return(false)
|
919
|
+
allow( File ).to receive(:directory?).with(any_args()).and_return(false)
|
825
920
|
|
826
|
-
subject.
|
921
|
+
expect( subject ).to receive(:scp_to).with(host,source, target, {:ignore => ignore_list})
|
827
922
|
if opts.nil?
|
828
923
|
subject.copy_module_to(host)
|
829
924
|
else
|
@@ -831,21 +926,36 @@ describe ClassMixedWithDSLInstallUtils do
|
|
831
926
|
end
|
832
927
|
}
|
833
928
|
end
|
929
|
+
|
834
930
|
describe 'should call scp with the correct info, with only providing host' do
|
835
931
|
let(:target){'/etc/puppetlabs/puppet/modules/testmodule'}
|
836
932
|
|
837
933
|
it_should_behave_like 'copy_module_to', :module_name => 'testmodule'
|
838
934
|
end
|
935
|
+
|
839
936
|
describe 'should call scp with the correct info, when specifying the modulename' do
|
840
937
|
let(:target){'/etc/puppetlabs/puppet/modules/bogusmodule'}
|
841
938
|
let(:module_parse_name){false}
|
842
939
|
it_should_behave_like 'copy_module_to', {:module_name =>'bogusmodule'}
|
843
940
|
end
|
941
|
+
|
844
942
|
describe 'should call scp with the correct info, when specifying the target to a different path' do
|
845
943
|
target = '/opt/shared/puppet/modules'
|
846
944
|
let(:target){"#{target}/testmodule"}
|
847
945
|
it_should_behave_like 'copy_module_to', {:target_module_path => target, :module_name => 'testmodule'}
|
848
946
|
end
|
947
|
+
|
948
|
+
describe 'should accept multiple hosts when' do
|
949
|
+
it 'used in a default manner' do
|
950
|
+
allow( subject ).to receive( :build_ignore_list ).and_return( [] )
|
951
|
+
allow( subject ).to receive( :parse_for_modulename ).and_return( [nil, 'modulename'] )
|
952
|
+
allow( subject ).to receive( :on ).and_return( double.as_null_object )
|
953
|
+
hosts = [{}, {}]
|
954
|
+
|
955
|
+
expect( subject ).to receive( :scp_to ).twice
|
956
|
+
subject.copy_module_to( hosts )
|
957
|
+
end
|
958
|
+
end
|
849
959
|
end
|
850
960
|
|
851
961
|
describe 'split_author_modulename' do
|
@@ -868,35 +978,46 @@ describe ClassMixedWithDSLInstallUtils do
|
|
868
978
|
describe 'parse_for_modulename' do
|
869
979
|
directory = '/testfilepath/myname-testmodule'
|
870
980
|
it 'should return name from metadata.json' do
|
871
|
-
File.
|
872
|
-
File.
|
873
|
-
subject.logger.
|
874
|
-
subject.logger.
|
875
|
-
subject.parse_for_modulename(directory).
|
981
|
+
allow( File ).to receive(:exists?).with("#{directory}/metadata.json").and_return(true)
|
982
|
+
allow( File ).to receive(:read).with("#{directory}/metadata.json").and_return(" {\"name\":\"myname-testmodule\"} ")
|
983
|
+
expect( subject.logger ).to receive(:debug).with("Attempting to parse Modulename from metadata.json")
|
984
|
+
expect(subject.logger).to_not receive(:debug).with('Unable to determine name, returning null')
|
985
|
+
expect(subject.parse_for_modulename(directory)).to eq(['myname', 'testmodule'])
|
876
986
|
end
|
877
987
|
it 'should return name from Modulefile' do
|
878
|
-
File.
|
879
|
-
File.
|
880
|
-
File.
|
881
|
-
subject.logger.
|
882
|
-
subject.logger.
|
988
|
+
allow( File ).to receive(:exists?).with("#{directory}/metadata.json").and_return(false)
|
989
|
+
allow( File ).to receive(:exists?).with("#{directory}/Modulefile").and_return(true)
|
990
|
+
allow( File ).to receive(:read).with("#{directory}/Modulefile").and_return("name 'myname-testmodule' \nauthor 'myname'")
|
991
|
+
expect( subject.logger ).to receive(:debug).with("Attempting to parse Modulename from Modulefile")
|
992
|
+
expect(subject.logger).to_not receive(:debug).with("Unable to determine name, returning null")
|
883
993
|
expect(subject.parse_for_modulename(directory)).to eq(['myname', 'testmodule'])
|
884
994
|
end
|
885
995
|
end
|
886
996
|
|
887
997
|
describe 'parse_for_module_root' do
|
888
998
|
directory = '/testfilepath/myname-testmodule'
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
999
|
+
describe 'stops searching when either' do
|
1000
|
+
it 'finds a Modulefile' do
|
1001
|
+
allow( File ).to receive(:exists?).and_return(false)
|
1002
|
+
allow( File ).to receive(:exists?).with("#{directory}/Modulefile").and_return(true)
|
1003
|
+
|
1004
|
+
expect( subject.logger ).to_not receive(:debug).with("At root, can't parse for another directory")
|
1005
|
+
expect( subject.logger ).to receive(:debug).with("No Modulefile or metadata.json found at #{directory}/acceptance, moving up")
|
1006
|
+
expect(subject.parse_for_moduleroot("#{directory}/acceptance")).to eq(directory)
|
1007
|
+
end
|
1008
|
+
it 'finds a metadata.json file' do
|
1009
|
+
allow( File ).to receive(:exists?).and_return(false)
|
1010
|
+
allow( File ).to receive(:exists?).with("#{directory}/metadata.json").and_return(true)
|
1011
|
+
|
1012
|
+
expect( subject.logger ).to_not receive(:debug).with("At root, can't parse for another directory")
|
1013
|
+
expect( subject.logger ).to receive(:debug).with("No Modulefile or metadata.json found at #{directory}/acceptance, moving up")
|
1014
|
+
expect(subject.parse_for_moduleroot("#{directory}/acceptance")).to eq(directory)
|
1015
|
+
end
|
895
1016
|
end
|
896
1017
|
it 'should recersively go up the directory to find the module files' do
|
897
|
-
File.
|
898
|
-
subject.logger.
|
899
|
-
subject.logger.
|
1018
|
+
allow( File ).to receive(:exists?).and_return(false)
|
1019
|
+
expect( subject.logger ).to receive(:debug).with("No Modulefile or metadata.json found at #{directory}, moving up")
|
1020
|
+
expect( subject.logger ).to receive(:error).with("At root, can't parse for another directory")
|
900
1021
|
expect(subject.parse_for_moduleroot(directory)).to eq(nil)
|
901
1022
|
end
|
902
1023
|
end
|