beaker 3.37.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -1
- data/acceptance/lib/helpers/test_helper.rb +0 -28
- data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +106 -103
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/install_package_test.rb +1 -50
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +71 -27
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -3
- data/acceptance/tests/base/host/file_test.rb +81 -0
- data/beaker.gemspec +6 -14
- data/docs/how_to/install_puppet.md +2 -0
- data/docs/how_to/the_beaker_dsl.md +150 -150
- data/docs/how_to/upgrade_from_3_to_4.md +52 -0
- data/lib/beaker.rb +0 -10
- data/lib/beaker/dsl.rb +7 -0
- data/lib/beaker/dsl/helpers.rb +4 -6
- data/lib/beaker/dsl/helpers/host_helpers.rb +10 -34
- data/lib/beaker/dsl/install_utils.rb +0 -5
- data/lib/beaker/dsl/roles.rb +1 -1
- data/lib/beaker/host.rb +12 -11
- data/lib/beaker/host/aix/file.rb +2 -2
- data/lib/beaker/host/aix/group.rb +1 -0
- data/lib/beaker/host/aix/user.rb +1 -0
- data/lib/beaker/host/freebsd/pkg.rb +9 -0
- data/lib/beaker/host/mac/group.rb +1 -0
- data/lib/beaker/host/mac/user.rb +8 -13
- data/lib/beaker/host/pswindows/file.rb +2 -2
- data/lib/beaker/host/pswindows/group.rb +1 -0
- data/lib/beaker/host/pswindows/user.rb +1 -0
- data/lib/beaker/host/unix/exec.rb +5 -5
- data/lib/beaker/host/unix/file.rb +43 -2
- data/lib/beaker/host/unix/group.rb +1 -0
- data/lib/beaker/host/unix/user.rb +1 -0
- data/lib/beaker/host/windows/file.rb +32 -2
- data/lib/beaker/host/windows/group.rb +1 -0
- data/lib/beaker/host/windows/user.rb +1 -0
- data/lib/beaker/host_prebuilt_steps.rb +0 -4
- data/lib/beaker/hypervisor.rb +1 -5
- data/lib/beaker/result.rb +4 -0
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +14 -51
- data/spec/beaker/dsl/wrappers_spec.rb +0 -46
- data/spec/beaker/host/mac/user_spec.rb +5 -8
- data/spec/beaker/host/unix/exec_spec.rb +1 -1
- data/spec/beaker/host/unix/file_spec.rb +39 -0
- data/spec/beaker/host/windows/file_spec.rb +55 -0
- data/spec/beaker/host_prebuilt_steps_spec.rb +16 -67
- data/spec/beaker/host_spec.rb +10 -14
- data/spec/beaker/hypervisor/hypervisor_spec.rb +1 -1
- metadata +47 -165
- data/acceptance/lib/beaker/acceptance/install_utils.rb +0 -58
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_tmpdir_on_test.rb +0 -68
- data/acceptance/tests/base/dsl/install_utils/clone_git_repo_on_test.rb +0 -49
- data/lib/beaker/dsl/helpers/facter_helpers.rb +0 -57
- data/lib/beaker/dsl/install_utils/pe_defaults.rb +0 -143
- data/lib/beaker/dsl/install_utils/windows_utils.rb +0 -223
- data/spec/beaker/dsl/ezbake_utils_spec.rb +0 -279
- data/spec/beaker/dsl/install_utils/pe_defaults_spec.rb +0 -61
- data/spec/beaker/dsl/install_utils/windows_utils_spec.rb +0 -263
@@ -1,279 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
EZBAKE_CONFIG_EXAMPLE= {
|
4
|
-
:project => 'puppetserver',
|
5
|
-
:real_name => 'puppetserver',
|
6
|
-
:user => 'puppet',
|
7
|
-
:group => 'puppet',
|
8
|
-
:uberjar_name => 'puppetserver-release.jar',
|
9
|
-
:config_files => [],
|
10
|
-
:terminus_info => {},
|
11
|
-
:debian => { :additional_dependencies => ["puppet (= 3.6.1-puppetlabs1)"], },
|
12
|
-
:redhat => { :additional_dependencies => ["puppet = 3.6.1"], },
|
13
|
-
:java_args => '-Xmx192m',
|
14
|
-
}
|
15
|
-
|
16
|
-
class ClassMixedWithEZBakeUtils
|
17
|
-
include Beaker::DSL::EZBakeUtils
|
18
|
-
|
19
|
-
def initialize_ezbake_config
|
20
|
-
Beaker::DSL::EZBakeUtils.config = EZBAKE_CONFIG_EXAMPLE
|
21
|
-
end
|
22
|
-
|
23
|
-
def wipe_out_ezbake_config
|
24
|
-
Beaker::DSL::EZBakeUtils.config = nil
|
25
|
-
end
|
26
|
-
|
27
|
-
def logger
|
28
|
-
@logger ||= RSpec::Mocks::Double.new('logger').as_null_object
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
module Beaker::DSL::EZBakeUtils::EZBake
|
33
|
-
Config = EZBAKE_CONFIG_EXAMPLE
|
34
|
-
end
|
35
|
-
|
36
|
-
describe ClassMixedWithEZBakeUtils do
|
37
|
-
let( :opts ) { Beaker::Options::Presets.env_vars }
|
38
|
-
let( :host ) { double.as_null_object }
|
39
|
-
let( :local_commands ) { Beaker::DSL::EZBakeUtils::LOCAL_COMMANDS_REQUIRED }
|
40
|
-
|
41
|
-
describe '#install_from_ezbake' do
|
42
|
-
let(:platform) { Beaker::Platform.new('el-7-i386') }
|
43
|
-
let(:host) do
|
44
|
-
FakeHost.create('fakevm', platform.to_s)
|
45
|
-
end
|
46
|
-
|
47
|
-
before do
|
48
|
-
allow(subject).to receive(:ezbake_tools_available?) { true }
|
49
|
-
end
|
50
|
-
|
51
|
-
it "when ran with an el-7 machine runs correct installsh command" do
|
52
|
-
expect(subject).to receive(:install_ezbake_tarball_on_host).
|
53
|
-
ordered
|
54
|
-
expect(subject).
|
55
|
-
to receive(:ezbake_installsh).with(host, "service")
|
56
|
-
subject.install_from_ezbake host
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe '#install_termini_from_ezbake' do
|
61
|
-
let(:platform) { Beaker::Platform.new('el-7-i386') }
|
62
|
-
let(:host) do
|
63
|
-
FakeHost.create('fakevm', platform.to_s)
|
64
|
-
end
|
65
|
-
|
66
|
-
before do
|
67
|
-
allow(subject).to receive(:ezbake_tools_available?) { true }
|
68
|
-
end
|
69
|
-
|
70
|
-
it "when ran with an el-7 machine runs correct installsh command" do
|
71
|
-
expect(subject).to receive(:ezbake_validate_support).with(host).ordered
|
72
|
-
expect(subject).to receive(:install_ezbake_tarball_on_host).
|
73
|
-
with(host).ordered
|
74
|
-
expect(subject).
|
75
|
-
to receive(:ezbake_installsh).with(host, "termini")
|
76
|
-
subject.install_termini_from_ezbake host
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe '#ezbake_validate_support' do
|
81
|
-
context 'when OS supported' do
|
82
|
-
let(:platform) { Beaker::Platform.new('el-7-i386') }
|
83
|
-
let(:host) do
|
84
|
-
FakeHost.create('fakevm', platform.to_s)
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'should do nothing' do
|
88
|
-
subject.ezbake_validate_support host
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
context 'when OS not supported' do
|
93
|
-
let(:platform) { Beaker::Platform.new('aix-12-ppc') }
|
94
|
-
let(:host) do
|
95
|
-
FakeHost.create('fakevm', platform.to_s)
|
96
|
-
end
|
97
|
-
|
98
|
-
it 'should throw exception' do
|
99
|
-
expect {
|
100
|
-
subject.ezbake_validate_support host
|
101
|
-
}.to raise_error(RuntimeError,
|
102
|
-
"No support for aix within ezbake_utils ...")
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def install_ezbake_tarball_on_host_common_expects
|
108
|
-
result = object_double(Beaker::Result.new(host, "foo"), :exit_code => 1)
|
109
|
-
expect(subject).to receive(:on).
|
110
|
-
with(kind_of(Beaker::Host), /test -d/,
|
111
|
-
anything()).ordered { result }
|
112
|
-
expect(Dir).to receive(:chdir).and_yield()
|
113
|
-
expect(subject).to receive(:ezbake_local_cmd).with(/rake package:tar/).ordered
|
114
|
-
expect(subject).to receive(:scp_to).
|
115
|
-
with(kind_of(Beaker::Host), anything(), anything()).ordered
|
116
|
-
expect(subject).to receive(:on).
|
117
|
-
with(kind_of(Beaker::Host), /tar -xzf/).ordered
|
118
|
-
expect(subject).to receive(:on).
|
119
|
-
with(kind_of(Beaker::Host), /test -d/).ordered
|
120
|
-
end
|
121
|
-
|
122
|
-
describe '#install_ezbake_tarball_on_host' do
|
123
|
-
let(:platform) { Beaker::Platform.new('el-7-i386') }
|
124
|
-
let(:host) do
|
125
|
-
FakeHost.create('fakevm', platform.to_s)
|
126
|
-
end
|
127
|
-
|
128
|
-
it 'when invoked with configuration should run expected tasks' do
|
129
|
-
subject.initialize_ezbake_config
|
130
|
-
install_ezbake_tarball_on_host_common_expects
|
131
|
-
subject.install_ezbake_tarball_on_host host
|
132
|
-
end
|
133
|
-
|
134
|
-
it 'when invoked with nil configuration runs ezbake_stage' do
|
135
|
-
subject.wipe_out_ezbake_config
|
136
|
-
expect(subject).to receive(:ezbake_stage) {
|
137
|
-
Beaker::DSL::EZBakeUtils.config = EZBAKE_CONFIG_EXAMPLE
|
138
|
-
}.ordered
|
139
|
-
install_ezbake_tarball_on_host_common_expects
|
140
|
-
subject.install_ezbake_tarball_on_host host
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
describe '#ezbake_tools_available?' do
|
145
|
-
before do
|
146
|
-
allow(subject).to receive(:check_for_package) { true }
|
147
|
-
allow(subject).to receive(:system) { true }
|
148
|
-
end
|
149
|
-
|
150
|
-
describe "checks for local successful commands" do
|
151
|
-
|
152
|
-
it "and succeeds if all commands return successfully" do
|
153
|
-
local_commands.each do |software_name, command, additional_error_messages|
|
154
|
-
expect(subject).to receive(:system).with(/#{command}/)
|
155
|
-
end
|
156
|
-
subject.ezbake_tools_available?
|
157
|
-
end
|
158
|
-
|
159
|
-
it "and raises an exception if a command returns failure" do
|
160
|
-
allow(subject).to receive(:system) { false }
|
161
|
-
local_commands.each do |software_name, command, additional_error_messages|
|
162
|
-
expect(subject).to receive(:system).with(/#{command}/)
|
163
|
-
break # just need first element
|
164
|
-
end
|
165
|
-
expect{
|
166
|
-
subject.ezbake_tools_available?
|
167
|
-
}.to raise_error(RuntimeError, /Must have .* installed on development system./)
|
168
|
-
end
|
169
|
-
|
170
|
-
end
|
171
|
-
|
172
|
-
end
|
173
|
-
|
174
|
-
describe '#ezbake_config' do
|
175
|
-
it "returns a map with ezbake configuration parameters" do
|
176
|
-
subject.initialize_ezbake_config
|
177
|
-
config = subject.ezbake_config
|
178
|
-
expect(config).to include(EZBAKE_CONFIG_EXAMPLE)
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
describe '#ezbake_stage' do
|
183
|
-
before do
|
184
|
-
allow(subject).to receive(:ezbake_tools_available?) { true }
|
185
|
-
subject.wipe_out_ezbake_config
|
186
|
-
end
|
187
|
-
|
188
|
-
it "initializes EZBakeUtils.config" do
|
189
|
-
allow(Dir).to receive(:chdir).and_yield()
|
190
|
-
|
191
|
-
expect(subject).to receive(:ezbake_local_cmd).
|
192
|
-
with(/^lein.*install/, :throw_on_failure =>
|
193
|
-
true).ordered
|
194
|
-
expect(subject).to receive(:ezbake_local_cmd).
|
195
|
-
with(/^lein.*with-profile ezbake ezbake stage/, :throw_on_failure =>
|
196
|
-
true).ordered
|
197
|
-
expect(subject).to receive(:ezbake_local_cmd).with("rake package:bootstrap").ordered
|
198
|
-
expect(subject).to receive(:load) { }.ordered
|
199
|
-
expect(subject).to receive(:`).ordered
|
200
|
-
|
201
|
-
config = subject.ezbake_config
|
202
|
-
expect(config).to eq(nil)
|
203
|
-
|
204
|
-
subject.ezbake_stage
|
205
|
-
|
206
|
-
config = subject.ezbake_config
|
207
|
-
expect(config).to include(EZBAKE_CONFIG_EXAMPLE)
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
describe '#ezbake_local_cmd' do
|
212
|
-
it 'should execute system on the command specified' do
|
213
|
-
expect(subject).to receive(:system).with("my command") { true }
|
214
|
-
subject.ezbake_local_cmd("my command")
|
215
|
-
end
|
216
|
-
|
217
|
-
it 'with :throw_on_failure should throw exeception when failed' do
|
218
|
-
expect(subject).to receive(:system).with("my failure") { false }
|
219
|
-
expect {
|
220
|
-
subject.ezbake_local_cmd("my failure", :throw_on_failure => true)
|
221
|
-
}.to raise_error(RuntimeError, "Command failure my failure")
|
222
|
-
end
|
223
|
-
|
224
|
-
it 'without :throw_on_failure should just fail and return false' do
|
225
|
-
expect(subject).to receive(:system).with("my failure") { false }
|
226
|
-
expect(subject.ezbake_local_cmd("my failure")).to eq(false)
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
describe '#ezbake_install_name' do
|
231
|
-
it 'should return the installation name from example configuration' do
|
232
|
-
expect(subject).to receive(:ezbake_config) {{
|
233
|
-
:package_version => '1.1.1',
|
234
|
-
:project => 'myproject',
|
235
|
-
}}
|
236
|
-
expect(subject.ezbake_install_name).to eq "myproject-1.1.1"
|
237
|
-
end
|
238
|
-
end
|
239
|
-
|
240
|
-
describe '#ezbake_install_dir' do
|
241
|
-
it 'should return the full path from ezbake_install_name' do
|
242
|
-
expect(subject).to receive(:ezbake_install_name) {
|
243
|
-
"mynewproject-2.3.4"
|
244
|
-
}
|
245
|
-
expect(subject.ezbake_install_dir).to eq "/root/mynewproject-2.3.4"
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
describe '#ezbake_installsh' do
|
250
|
-
it 'run on command correctly when invoked' do
|
251
|
-
expect(subject).to receive(:on).with(host,
|
252
|
-
/install.sh my_task/)
|
253
|
-
subject.ezbake_installsh host, "my_task"
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
describe '#conditionally_clone' do
|
258
|
-
it 'when repo exists, just do fetch and checkout' do
|
259
|
-
expect(subject).to receive(:ezbake_local_cmd).
|
260
|
-
with(/git status/) { true }
|
261
|
-
expect(subject).to receive(:ezbake_local_cmd).
|
262
|
-
with(/git fetch origin/)
|
263
|
-
expect(subject).to receive(:ezbake_local_cmd).
|
264
|
-
with(/git checkout/)
|
265
|
-
subject.conditionally_clone("my_url", "my_local_path")
|
266
|
-
end
|
267
|
-
|
268
|
-
it 'when repo does not exist, do clone and checkout' do
|
269
|
-
expect(subject).to receive(:ezbake_local_cmd).
|
270
|
-
with(/git status/) { false }
|
271
|
-
expect(subject).to receive(:ezbake_local_cmd).
|
272
|
-
with(/git clone/)
|
273
|
-
expect(subject).to receive(:ezbake_local_cmd).
|
274
|
-
with(/git checkout/)
|
275
|
-
subject.conditionally_clone("my_url", "my_local_path")
|
276
|
-
end
|
277
|
-
end
|
278
|
-
|
279
|
-
end
|
@@ -1,61 +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 => @pe_ver || '3.0',
|
22
|
-
:platform => 'linux',
|
23
|
-
:roles => [ 'agent' ] }, 4 ) }
|
24
|
-
let(:hosts) { basic_hosts[0][:roles] = ['master', 'database', 'dashboard']
|
25
|
-
basic_hosts[1][:platform] = 'windows'
|
26
|
-
basic_hosts[2][:platform] = 'osx-10.9-x86_64'
|
27
|
-
basic_hosts[3][:platform] = 'eos'
|
28
|
-
basic_hosts }
|
29
|
-
let(:hosts_sorted) { [ hosts[1], hosts[0], hosts[2], hosts[3] ] }
|
30
|
-
let(:winhost) { make_host( 'winhost', { :platform => 'windows',
|
31
|
-
:pe_ver => '3.0',
|
32
|
-
:working_dir => '/tmp' } ) }
|
33
|
-
let(:machost) { make_host( 'machost', { :platform => 'osx-10.9-x86_64',
|
34
|
-
:pe_ver => '3.0',
|
35
|
-
:working_dir => '/tmp' } ) }
|
36
|
-
let(:unixhost) { make_host( 'unixhost', { :platform => 'linux',
|
37
|
-
:pe_ver => '3.0',
|
38
|
-
:working_dir => '/tmp',
|
39
|
-
:dist => 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-debian-7-i386' } ) }
|
40
|
-
let(:eoshost) { make_host( 'eoshost', { :platform => 'eos',
|
41
|
-
:pe_ver => '3.0',
|
42
|
-
:working_dir => '/tmp',
|
43
|
-
:dist => 'puppet-enterprise-3.7.1-rc0-78-gffc958f-eos-4-i386' } ) }
|
44
|
-
|
45
|
-
describe '#add_platform_pe_defaults' do
|
46
|
-
it 'sets puppetservice on master to be pe-httpd on pre-3.4 pe' do
|
47
|
-
@pe_ver = '3.3'
|
48
|
-
subject.add_platform_pe_defaults(hosts[0], 'unix')
|
49
|
-
expect(hosts[0]['puppetservice']).to be == 'pe-httpd'
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'sets puppetservice on master to be pe-puppetserver on post-3.4 pe' do
|
54
|
-
@pe_ver = '3.7'
|
55
|
-
subject.add_platform_pe_defaults(hosts[0], 'unix')
|
56
|
-
expect(hosts[0]['puppetservice']).to be == 'pe-puppetserver'
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
@@ -1,263 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class ClassMixedWithDSLInstallUtils
|
4
|
-
include Beaker::DSL::Helpers
|
5
|
-
include Beaker::DSL::Patterns
|
6
|
-
include Beaker::DSL::InstallUtils
|
7
|
-
|
8
|
-
def logger
|
9
|
-
@logger ||= RSpec::Mocks::Double.new('logger').as_null_object
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe ClassMixedWithDSLInstallUtils do
|
14
|
-
let(:windows_temp) { 'C:\\Windows\\Temp' }
|
15
|
-
let( :batch_path ) { '/fake/batch/path' }
|
16
|
-
let(:msi_path) { 'c:\\foo\\puppet.msi' }
|
17
|
-
let(:winhost) { make_host( 'winhost',
|
18
|
-
{ :platform => Beaker::Platform.new('windows-2008r2-64'),
|
19
|
-
:pe_ver => '3.0',
|
20
|
-
:working_dir => '/tmp',
|
21
|
-
:is_cygwin => true} ) }
|
22
|
-
let(:winhost_non_cygwin) { make_host( 'winhost_non_cygwin',
|
23
|
-
{ :platform => 'windows',
|
24
|
-
:pe_ver => '3.0',
|
25
|
-
:working_dir => '/tmp',
|
26
|
-
:is_cygwin => 'false' } ) }
|
27
|
-
let(:hosts) { [ winhost, winhost_non_cygwin ] }
|
28
|
-
|
29
|
-
def expect_install_called(times = hosts.length)
|
30
|
-
result = expect( Beaker::Command ).to receive( :new )
|
31
|
-
.with( /^"#{batch_path}"$/, [], {:cmdexe => true})
|
32
|
-
.exactly( times ).times
|
33
|
-
|
34
|
-
yield result if block_given?
|
35
|
-
end
|
36
|
-
|
37
|
-
def expect_status_called(times = hosts.length)
|
38
|
-
expect( Beaker::Command ).to receive( :new )
|
39
|
-
.with( "sc qc puppet || sc qc pe-puppet", [], {:cmdexe => true} )
|
40
|
-
.exactly( times ).times
|
41
|
-
end
|
42
|
-
|
43
|
-
def expect_version_log_called(times = hosts.length)
|
44
|
-
[
|
45
|
-
"\\\"%ProgramFiles%\\Puppet Labs\\puppet\\misc\\versions.txt\\\"",
|
46
|
-
"\\\"%ProgramFiles(x86)%\\Puppet Labs\\puppet\\misc\\versions.txt\\\"",
|
47
|
-
].each do |path|
|
48
|
-
expect( Beaker::Command ).to receive( :new )
|
49
|
-
.with( "\"if exist #{path} type #{path}\"", [], {:cmdexe => true} )
|
50
|
-
.exactly( times ).times
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def expect_script_matches(hosts, contents)
|
55
|
-
hosts.each do |host|
|
56
|
-
expect( host )
|
57
|
-
.to receive( :do_scp_to ) do |local_path, remote_path|
|
58
|
-
expect(File.read(local_path)).to match(contents)
|
59
|
-
end
|
60
|
-
.and_return( true )
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def expect_reg_query_called(times = hosts.length)
|
65
|
-
hosts.each do |host|
|
66
|
-
expect(host).to receive(:is_x86_64?).and_return(:true)
|
67
|
-
end
|
68
|
-
|
69
|
-
expect( Beaker::Command ).to receive( :new )
|
70
|
-
.with(%r{reg query "HKLM\\SOFTWARE\\Wow6432Node\\Puppet Labs\\PuppetInstaller}, [], {:cmdexe => true})
|
71
|
-
.exactly(times).times
|
72
|
-
end
|
73
|
-
|
74
|
-
describe "#install_msi_on" do
|
75
|
-
let( :log_file ) { '/fake/log/file.log' }
|
76
|
-
before :each do
|
77
|
-
allow( subject ).to receive( :on ).and_return( true )
|
78
|
-
allow( subject ).to receive( :create_install_msi_batch_on ).and_return( [batch_path, log_file] )
|
79
|
-
end
|
80
|
-
|
81
|
-
it "will specify a PUPPET_AGENT_STARTUP_MODE of Manual (disabling the service) by default" do
|
82
|
-
expect_install_called
|
83
|
-
expect_status_called
|
84
|
-
expect_reg_query_called
|
85
|
-
expect_version_log_called
|
86
|
-
expect( subject ).to receive( :create_install_msi_batch_on ).with(
|
87
|
-
anything, anything,
|
88
|
-
'PUPPET_AGENT_STARTUP_MODE' => 'Manual')
|
89
|
-
subject.install_msi_on(hosts, msi_path, {})
|
90
|
-
end
|
91
|
-
|
92
|
-
it "allows configuration of PUPPET_AGENT_STARTUP_MODE" do
|
93
|
-
expect_install_called
|
94
|
-
expect_status_called
|
95
|
-
expect_reg_query_called
|
96
|
-
expect_version_log_called
|
97
|
-
value = 'Automatic'
|
98
|
-
expect( subject ).to receive( :create_install_msi_batch_on ).with(
|
99
|
-
anything, anything,
|
100
|
-
'PUPPET_AGENT_STARTUP_MODE' => value)
|
101
|
-
subject.install_msi_on(hosts, msi_path, {'PUPPET_AGENT_STARTUP_MODE' => value})
|
102
|
-
end
|
103
|
-
|
104
|
-
it "will not generate a command to emit a log file without the :debug option set" do
|
105
|
-
expect_install_called
|
106
|
-
expect_status_called
|
107
|
-
expect( Beaker::Command ).not_to receive( :new ).with( /^type .*\.log$/, [], {:cmdexe => true} )
|
108
|
-
subject.install_msi_on(hosts, msi_path)
|
109
|
-
end
|
110
|
-
|
111
|
-
it "will generate a command to emit a log file when the install script fails" do
|
112
|
-
# note a single failure aborts executing against remaining hosts
|
113
|
-
hosts_affected = 1
|
114
|
-
|
115
|
-
expect_install_called(hosts_affected) { |e| e.and_raise }
|
116
|
-
expect_status_called(0)
|
117
|
-
|
118
|
-
expect( Beaker::Command ).to receive( :new ).with( /^type \".*\.log\"$/, [], {:cmdexe => true} ).exactly( hosts_affected ).times
|
119
|
-
expect { subject.install_msi_on(hosts, msi_path) }.to raise_error(RuntimeError)
|
120
|
-
end
|
121
|
-
|
122
|
-
it "will generate a command to emit a log file with the :debug option set" do
|
123
|
-
expect_install_called
|
124
|
-
expect_reg_query_called
|
125
|
-
expect_status_called
|
126
|
-
expect_version_log_called
|
127
|
-
|
128
|
-
expect( Beaker::Command ).to receive( :new ).with( /^type \".*\.log\"$/, [], {:cmdexe => true} ).exactly( hosts.length ).times
|
129
|
-
subject.install_msi_on(hosts, msi_path, {}, { :debug => true })
|
130
|
-
end
|
131
|
-
|
132
|
-
it 'will pass msi_path to #create_install_msi_batch_on as-is' do
|
133
|
-
expect_install_called
|
134
|
-
expect_reg_query_called
|
135
|
-
expect_status_called
|
136
|
-
expect_version_log_called
|
137
|
-
test_path = 'test/path'
|
138
|
-
expect( subject ).to receive( :create_install_msi_batch_on ).with(
|
139
|
-
anything, test_path, anything)
|
140
|
-
subject.install_msi_on(hosts, test_path)
|
141
|
-
end
|
142
|
-
|
143
|
-
it 'will search in Wow6432Node for the remembered startup setting on 64-bit hosts' do
|
144
|
-
expect_install_called
|
145
|
-
expect_status_called
|
146
|
-
expect_version_log_called
|
147
|
-
|
148
|
-
hosts.each do |host|
|
149
|
-
expect(host).to receive(:is_x86_64?).and_return(true)
|
150
|
-
end
|
151
|
-
|
152
|
-
expect( Beaker::Command ).to receive( :new )
|
153
|
-
.with('reg query "HKLM\\SOFTWARE\\Wow6432Node\\Puppet Labs\\PuppetInstaller" /v "RememberedPuppetAgentStartupMode" | findstr Foo', [], {:cmdexe => true})
|
154
|
-
.exactly(hosts.length).times
|
155
|
-
|
156
|
-
subject.install_msi_on(hosts, msi_path, {'PUPPET_AGENT_STARTUP_MODE' => "Foo"})
|
157
|
-
end
|
158
|
-
|
159
|
-
it 'will omit Wow6432Node in the registry search for remembered startup setting on 32-bit hosts' do
|
160
|
-
expect_install_called
|
161
|
-
expect_status_called
|
162
|
-
expect_version_log_called
|
163
|
-
|
164
|
-
hosts.each do |host|
|
165
|
-
expect(host).to receive(:is_x86_64?).and_return(false)
|
166
|
-
end
|
167
|
-
|
168
|
-
expect( Beaker::Command ).to receive( :new )
|
169
|
-
.with('reg query "HKLM\\SOFTWARE\\Puppet Labs\\PuppetInstaller" /v "RememberedPuppetAgentStartupMode" | findstr Foo', [], {:cmdexe => true})
|
170
|
-
.exactly(hosts.length).times
|
171
|
-
|
172
|
-
subject.install_msi_on(hosts, msi_path, {'PUPPET_AGENT_STARTUP_MODE' => "Foo"})
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
describe '#create_install_msi_batch_on' do
|
177
|
-
let( :tmp ) { '/tmp/create_install_msi_batch_on' }
|
178
|
-
let( :tmp_slashes ) { tmp.gsub('/', '\\') }
|
179
|
-
|
180
|
-
before :each do
|
181
|
-
FakeFS::FileSystem.add(File.expand_path tmp)
|
182
|
-
hosts.each do |host|
|
183
|
-
allow( host ).to receive( :system_temp_path ).and_return( tmp )
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
it 'passes msi_path & msi_opts down to #msi_install_script' do
|
188
|
-
allow( winhost ).to receive( :do_scp_to )
|
189
|
-
test_path = '/path/to/test/with/13540'
|
190
|
-
test_opts = { 'key1' => 'val1', 'key2' => 'val2' }
|
191
|
-
expect( subject ).to receive( :msi_install_script ).with(
|
192
|
-
test_path, test_opts, anything )
|
193
|
-
subject.create_install_msi_batch_on(winhost, test_path, test_opts)
|
194
|
-
end
|
195
|
-
|
196
|
-
it 'SCPs to & returns the same batch file path, corrected for slashes' do
|
197
|
-
test_time = Time.now
|
198
|
-
allow( Time ).to receive( :new ).and_return( test_time )
|
199
|
-
timestamp = test_time.strftime('%Y-%m-%d_%H.%M.%S')
|
200
|
-
|
201
|
-
correct_path = "#{tmp_slashes}\\install-puppet-msi-#{timestamp}.bat"
|
202
|
-
expect( winhost ).to receive( :do_scp_to ).with( anything, correct_path, {} )
|
203
|
-
test_path, _ = subject.create_install_msi_batch_on( winhost, msi_path, {} )
|
204
|
-
expect( test_path ).to be === correct_path
|
205
|
-
end
|
206
|
-
|
207
|
-
it 'returns & sends log_path to #msi_install_scripts, corrected for slashes' do
|
208
|
-
allow( winhost ).to receive( :do_scp_to )
|
209
|
-
test_time = Time.now
|
210
|
-
allow( Time ).to receive( :new ).and_return( test_time )
|
211
|
-
timestamp = test_time.strftime('%Y-%m-%d_%H.%M.%S')
|
212
|
-
|
213
|
-
correct_path = "#{tmp_slashes}\\install-puppet-#{timestamp}.log"
|
214
|
-
expect( subject ).to receive( :msi_install_script ).with(
|
215
|
-
anything, anything, correct_path )
|
216
|
-
_, log_path = subject.create_install_msi_batch_on( winhost, msi_path, {} )
|
217
|
-
expect( log_path ).to be === correct_path
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
describe '#msi_install_script' do
|
222
|
-
let( :log_path ) { '/log/msi_install_script' }
|
223
|
-
|
224
|
-
context 'msi_params parameter' do
|
225
|
-
it 'can take an empty hash' do
|
226
|
-
expected_cmd = /^start \/w msiexec\.exe \/i ".*" \/qn \/L\*V #{log_path}\ .exit/m
|
227
|
-
expect( subject.msi_install_script(msi_path, {}, log_path) ).to match(expected_cmd)
|
228
|
-
end
|
229
|
-
|
230
|
-
it 'uses a key-value pair correctly' do
|
231
|
-
params = { 'tk1' => 'tv1' }
|
232
|
-
expected_cmd = /^start \/w msiexec\.exe \/i ".*" \/qn \/L\*V #{log_path}\ tk1\=tv1/
|
233
|
-
expect( subject.msi_install_script(msi_path, params, log_path) ).to match(expected_cmd)
|
234
|
-
end
|
235
|
-
|
236
|
-
it 'uses multiple key-value pairs correctly' do
|
237
|
-
params = { 'tk1' => 'tv1', 'tk2' => 'tv2' }
|
238
|
-
expected_cmd = /^start \/w msiexec\.exe \/i ".*" \/qn \/L\*V #{log_path}\ tk1\=tv1\ tk2\=tv2/
|
239
|
-
expect( subject.msi_install_script(msi_path, params, log_path) ).to match(expected_cmd)
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
context 'msi_path parameter' do
|
244
|
-
it "will generate an appropriate command with a MSI file path using non-Windows slashes" do
|
245
|
-
msi_path = 'c:/foo/puppet.msi'
|
246
|
-
expected_cmd = /^start \/w msiexec\.exe \/i "c:\\foo\\puppet.msi" \/qn \/L\*V #{log_path}/
|
247
|
-
expect( subject.msi_install_script(msi_path, {}, log_path) ).to match(expected_cmd)
|
248
|
-
end
|
249
|
-
|
250
|
-
it "will generate an appropriate command with a MSI http(s) url" do
|
251
|
-
msi_url = "https://downloads.puppetlabs.com/puppet.msi"
|
252
|
-
expected_cmd = /^start \/w msiexec\.exe \/i "https\:\/\/downloads\.puppetlabs\.com\/puppet\.msi" \/qn \/L\*V #{log_path}/
|
253
|
-
expect( subject.msi_install_script(msi_url, {}, log_path) ).to match(expected_cmd)
|
254
|
-
end
|
255
|
-
|
256
|
-
it "will generate an appropriate command with a MSI file url" do
|
257
|
-
msi_url = "file://c:\\foo\\puppet.msi"
|
258
|
-
expected_cmd = /^start \/w msiexec\.exe \/i "file\:\/\/c:\\foo\\puppet\.msi" \/qn \/L\*V #{log_path}/
|
259
|
-
expect( subject.msi_install_script(msi_url, {}, log_path) ).to match(expected_cmd)
|
260
|
-
end
|
261
|
-
end
|
262
|
-
end
|
263
|
-
end
|