beaker 1.21.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
data/spec/beaker/host_spec.rb
CHANGED
|
@@ -29,40 +29,40 @@ module Beaker
|
|
|
29
29
|
|
|
30
30
|
it "can be a pe host" do
|
|
31
31
|
options['type'] = 'pe'
|
|
32
|
-
expect(host.is_pe?).to
|
|
33
|
-
expect(host.use_service_scripts?).to
|
|
34
|
-
expect(host.is_using_passenger?).to
|
|
35
|
-
expect(host.graceful_restarts?).to
|
|
32
|
+
expect(host.is_pe?).to be_truthy
|
|
33
|
+
expect(host.use_service_scripts?).to be_truthy
|
|
34
|
+
expect(host.is_using_passenger?).to be_truthy
|
|
35
|
+
expect(host.graceful_restarts?).to be_falsy
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
it "can be a foss-source host" do
|
|
39
|
-
expect(host.is_pe?).to
|
|
40
|
-
expect(host.use_service_scripts?).to
|
|
41
|
-
expect(host.is_using_passenger?).to
|
|
39
|
+
expect(host.is_pe?).to be_falsy
|
|
40
|
+
expect(host.use_service_scripts?).to be_falsy
|
|
41
|
+
expect(host.is_using_passenger?).to be_falsy
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
it "can be a foss-package host" do
|
|
45
45
|
options['use-service'] = true
|
|
46
|
-
expect(host.is_pe?).to
|
|
47
|
-
expect(host.use_service_scripts?).to
|
|
48
|
-
expect(host.is_using_passenger?).to
|
|
49
|
-
expect(host.graceful_restarts?).to
|
|
46
|
+
expect(host.is_pe?).to be_falsy
|
|
47
|
+
expect(host.use_service_scripts?).to be_truthy
|
|
48
|
+
expect(host.is_using_passenger?).to be_falsy
|
|
49
|
+
expect(host.graceful_restarts?).to be_falsy
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
it "can be a foss-packaged host using passenger" do
|
|
53
53
|
host.uses_passenger!
|
|
54
|
-
expect(host.is_pe?).to
|
|
55
|
-
expect(host.use_service_scripts?).to
|
|
56
|
-
expect(host.is_using_passenger?).to
|
|
57
|
-
expect(host.graceful_restarts?).to
|
|
54
|
+
expect(host.is_pe?).to be_falsy
|
|
55
|
+
expect(host.use_service_scripts?).to be_truthy
|
|
56
|
+
expect(host.is_using_passenger?).to be_truthy
|
|
57
|
+
expect(host.graceful_restarts?).to be_truthy
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
describe "uses_passenger!" do
|
|
62
62
|
it "sets passenger property" do
|
|
63
63
|
host.uses_passenger!
|
|
64
|
-
expect(host['passenger']).to
|
|
65
|
-
expect(host.is_using_passenger?).to
|
|
64
|
+
expect(host['passenger']).to be_truthy
|
|
65
|
+
expect(host.is_using_passenger?).to be_truthy
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
it "sets puppetservice" do
|
|
@@ -79,28 +79,28 @@ module Beaker
|
|
|
79
79
|
describe "graceful_restarts?" do
|
|
80
80
|
it "is true if graceful-restarts property is set true" do
|
|
81
81
|
options['graceful-restarts'] = true
|
|
82
|
-
expect(host.graceful_restarts?).to
|
|
82
|
+
expect(host.graceful_restarts?).to be_truthy
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
it "is false if graceful-restarts property is set false" do
|
|
86
86
|
options['graceful-restarts'] = false
|
|
87
|
-
expect(host.graceful_restarts?).to
|
|
87
|
+
expect(host.graceful_restarts?).to be_falsy
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
it "is false if is_pe and graceful-restarts is nil" do
|
|
91
91
|
options['type'] = 'pe'
|
|
92
|
-
expect(host.graceful_restarts?).to
|
|
92
|
+
expect(host.graceful_restarts?).to be_falsy
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
it "is true if is_pe and graceful-restarts is true" do
|
|
96
96
|
options['type'] = 'pe'
|
|
97
97
|
options['graceful-restarts'] = true
|
|
98
|
-
expect(host.graceful_restarts?).to
|
|
98
|
+
expect(host.graceful_restarts?).to be_truthy
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
it "falls back to passenger property if not pe and graceful-restarts is nil" do
|
|
102
102
|
host.uses_passenger!
|
|
103
|
-
expect(host.graceful_restarts?).to
|
|
103
|
+
expect(host.graceful_restarts?).to be_truthy
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
106
|
|
|
@@ -112,20 +112,20 @@ module Beaker
|
|
|
112
112
|
|
|
113
113
|
before(:each) do
|
|
114
114
|
@platform = 'windows'
|
|
115
|
-
host.
|
|
115
|
+
allow( host ).to receive(:check_for_package).and_return(true)
|
|
116
116
|
end
|
|
117
117
|
|
|
118
118
|
context "testing osarchitecture" do
|
|
119
119
|
|
|
120
120
|
before(:each) do
|
|
121
|
-
host.
|
|
121
|
+
expect( host ).to receive(:execute).with(/wmic os get osarchitecture/, anything).and_yield(success_osarch_check)
|
|
122
122
|
end
|
|
123
123
|
|
|
124
124
|
context "32 bit" do
|
|
125
125
|
let(:success_osarch_check) { double(:success, :exit_code => 0, :stdout => '32-bit') }
|
|
126
126
|
|
|
127
127
|
it "uses 32 bit cygwin" do
|
|
128
|
-
host.
|
|
128
|
+
expect( host ).to receive(:execute).with(/#{cygwin}.*#{package}/)
|
|
129
129
|
host.install_package(package)
|
|
130
130
|
end
|
|
131
131
|
end
|
|
@@ -134,7 +134,7 @@ module Beaker
|
|
|
134
134
|
let(:success_osarch_check) { double(:success, :exit_code => 0, :stdout => '64-bit') }
|
|
135
135
|
|
|
136
136
|
it "uses 64 bit cygwin" do
|
|
137
|
-
host.
|
|
137
|
+
expect( host ).to receive(:execute).with(/#{cygwin64}.*#{package}/)
|
|
138
138
|
host.install_package(package)
|
|
139
139
|
end
|
|
140
140
|
end
|
|
@@ -144,15 +144,15 @@ module Beaker
|
|
|
144
144
|
let(:failed_osarch_check) { double(:failed, :exit_code => 1) }
|
|
145
145
|
|
|
146
146
|
before(:each) do
|
|
147
|
-
host.
|
|
148
|
-
host.
|
|
147
|
+
expect( host ).to receive(:execute).with(/wmic os get osarchitecture/, anything).and_yield(failed_osarch_check)
|
|
148
|
+
expect( host ).to receive(:execute).with(/wmic os get name/, anything).and_yield(name_check)
|
|
149
149
|
end
|
|
150
150
|
|
|
151
151
|
context "32 bit" do
|
|
152
152
|
let(:name_check) { double(:failure, :exit_code => 1) }
|
|
153
153
|
|
|
154
154
|
it "uses 32 bit cygwin" do
|
|
155
|
-
host.
|
|
155
|
+
expect( host ).to receive(:execute).with(/#{cygwin}.*#{package}/)
|
|
156
156
|
host.install_package(package)
|
|
157
157
|
end
|
|
158
158
|
end
|
|
@@ -161,7 +161,7 @@ module Beaker
|
|
|
161
161
|
let(:name_check) { double(:success, :exit_code => 0) }
|
|
162
162
|
|
|
163
163
|
it "uses 64 bit cygwin" do
|
|
164
|
-
host.
|
|
164
|
+
expect( host ).to receive(:execute).with(/#{cygwin64}.*#{package}/)
|
|
165
165
|
host.install_package(package)
|
|
166
166
|
end
|
|
167
167
|
end
|
|
@@ -169,6 +169,52 @@ module Beaker
|
|
|
169
169
|
end
|
|
170
170
|
end
|
|
171
171
|
|
|
172
|
+
describe "#add_env_var" do
|
|
173
|
+
|
|
174
|
+
it "does nothing if the key/value pair already exists" do
|
|
175
|
+
result = Beaker::Result.new(host, '')
|
|
176
|
+
result.exit_code = 0
|
|
177
|
+
expect( Beaker::Command ).to receive(:new).with("grep -e KEY=.*\\/my\\/first\\/value ~/.ssh/environment")
|
|
178
|
+
expect( host ).to receive(:exec).once.and_return(result)
|
|
179
|
+
|
|
180
|
+
host.add_env_var('key', '/my/first/value')
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
it "adds new line to environment file if no env var of that name already exists" do
|
|
184
|
+
result = Beaker::Result.new(host, '')
|
|
185
|
+
result.exit_code = 1
|
|
186
|
+
expect( Beaker::Command ).to receive(:new).with("grep -e KEY=.*\\/my\\/first\\/value ~/.ssh/environment")
|
|
187
|
+
expect( host ).to receive(:exec).and_return(result)
|
|
188
|
+
expect( Beaker::Command ).to receive(:new).with(/grep KEY ~\/\.ssh\/environment/)
|
|
189
|
+
expect( host ).to receive(:exec).and_return(result)
|
|
190
|
+
expect( Beaker::Command ).to receive(:new).with("echo \"KEY=/my/first/value\" >> ~/.ssh/environment")
|
|
191
|
+
host.add_env_var('key', '/my/first/value')
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
it "updates existing line in environment file when adding additional value to existing variable" do
|
|
195
|
+
result = Beaker::Result.new(host, '')
|
|
196
|
+
result.exit_code = 1
|
|
197
|
+
expect( Beaker::Command ).to receive(:new).with("grep -e KEY=.*\\/my\\/first\\/value ~/.ssh/environment")
|
|
198
|
+
expect( host ).to receive(:exec).and_return(result)
|
|
199
|
+
result = Beaker::Result.new(host, '')
|
|
200
|
+
result.exit_code = 0
|
|
201
|
+
expect( Beaker::Command ).to receive(:new).with(/grep KEY ~\/\.ssh\/environment/)
|
|
202
|
+
expect( host ).to receive(:exec).and_return(result)
|
|
203
|
+
expect( Beaker::Command ).to receive(:new).with("sed -i -e \"s/KEY=/KEY=\\/my\\/first\\/value:/\" ~/.ssh/environment")
|
|
204
|
+
host.add_env_var('key', '/my/first/value')
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
describe "#delete_env_var" do
|
|
210
|
+
it "deletes env var" do
|
|
211
|
+
expect( Beaker::Command ).to receive(:new).with("sed -i -e \"/key=\\/my\\/first\\/value$/d\" ~/.ssh/environment")
|
|
212
|
+
expect( Beaker::Command ).to receive(:new).with("sed -i -e \"s/key=\\(.*[:;]*\\)\\/my\\/first\\/value[:;]*/key=\\1/\" ~/.ssh/environment")
|
|
213
|
+
host.delete_env_var('key', '/my/first/value')
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
end
|
|
217
|
+
|
|
172
218
|
describe "executing commands" do
|
|
173
219
|
let(:command) { Beaker::Command.new('ls') }
|
|
174
220
|
let(:host) { Beaker::Host.create('host', make_host_opts('host', options.merge(platform))) }
|
|
@@ -179,11 +225,11 @@ module Beaker
|
|
|
179
225
|
result.stderr = 'stderr'
|
|
180
226
|
|
|
181
227
|
logger = double(:logger)
|
|
182
|
-
logger.
|
|
183
|
-
logger.
|
|
228
|
+
allow( logger ).to receive(:host_output)
|
|
229
|
+
allow( logger ).to receive(:debug)
|
|
184
230
|
host.instance_variable_set :@logger, logger
|
|
185
231
|
conn = double(:connection)
|
|
186
|
-
conn.
|
|
232
|
+
allow( conn ).to receive(:execute).and_return(result)
|
|
187
233
|
host.instance_variable_set :@connection, conn
|
|
188
234
|
end
|
|
189
235
|
|
|
@@ -200,6 +246,33 @@ module Beaker
|
|
|
200
246
|
host.exec(command,{})
|
|
201
247
|
end
|
|
202
248
|
|
|
249
|
+
it 'raises a CommandFailure when an unacceptable exit code is returned' do
|
|
250
|
+
result.exit_code = 7
|
|
251
|
+
opts = { :acceptable_exit_codes => [0, 1] }
|
|
252
|
+
|
|
253
|
+
expect { host.exec(command, opts) }.to raise_error(Beaker::Host::CommandFailure)
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
it 'raises a CommandFailure when an unacceptable exit code is returned and the accept_all_exit_codes flag is set to false' do
|
|
257
|
+
result.exit_code = 7
|
|
258
|
+
opts = {
|
|
259
|
+
:acceptable_exit_codes => [0, 1],
|
|
260
|
+
:accept_all_exit_codes => false
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
expect { host.exec(command, opts) }.to raise_error(Beaker::Host::CommandFailure)
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
it 'does not throw an error when an unacceptable exit code is returned and the accept_all_exit_codes flag is set' do
|
|
267
|
+
result.exit_code = 7
|
|
268
|
+
opts = {
|
|
269
|
+
:acceptable_exit_codes => [0, 1],
|
|
270
|
+
:accept_all_exit_codes => true
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
expect { host.exec(command, opts) }.to_not raise_error
|
|
274
|
+
end
|
|
275
|
+
|
|
203
276
|
context "controls the result objects logging" do
|
|
204
277
|
it "and passes a test if the exit_code doesn't match the default :acceptable_exit_codes of 0" do
|
|
205
278
|
result.exit_code = 0
|
|
@@ -232,7 +305,7 @@ module Beaker
|
|
|
232
305
|
# it takes a location and a destination
|
|
233
306
|
# it basically proxies that to the connection object
|
|
234
307
|
it 'do_scp_to logs info and proxies to the connection' do
|
|
235
|
-
|
|
308
|
+
create_files(['source'])
|
|
236
309
|
logger = host[:logger]
|
|
237
310
|
conn = double(:connection)
|
|
238
311
|
@options = { :logger => logger }
|
|
@@ -240,15 +313,20 @@ module Beaker
|
|
|
240
313
|
args = [ 'source', 'target', {} ]
|
|
241
314
|
conn_args = args + [ nil ]
|
|
242
315
|
|
|
243
|
-
logger.
|
|
244
|
-
conn.
|
|
316
|
+
expect( logger ).to receive(:trace)
|
|
317
|
+
expect( conn ).to receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
|
|
245
318
|
|
|
246
319
|
host.do_scp_to *args
|
|
247
320
|
end
|
|
248
321
|
|
|
322
|
+
it 'throws an IOError when the file given doesn\'t exist' do
|
|
323
|
+
expect { host.do_scp_to "/does/not/exist", "does/not/exist/over/there", {} }.to raise_error(IOError)
|
|
324
|
+
end
|
|
325
|
+
|
|
249
326
|
context "using an ignore array with an absolute source path" do
|
|
250
|
-
source_path
|
|
251
|
-
target_path
|
|
327
|
+
let( :source_path ) { '/repos/puppetlabs-inifile' }
|
|
328
|
+
let( :target_path ) { '/etc/puppetlabs/modules/inifile' }
|
|
329
|
+
|
|
252
330
|
before :each do
|
|
253
331
|
test_dir = "#{source_path}/tests"
|
|
254
332
|
other_test_dir = "#{source_path}/tests2"
|
|
@@ -265,20 +343,20 @@ module Beaker
|
|
|
265
343
|
create_files( @fileset1 )
|
|
266
344
|
create_files( @fileset2 )
|
|
267
345
|
end
|
|
268
|
-
it 'can take an ignore list that excludes all files and not call scp_to'
|
|
346
|
+
it 'can take an ignore list that excludes all files and not call scp_to' do
|
|
269
347
|
logger = host[:logger]
|
|
270
348
|
conn = double(:connection)
|
|
271
349
|
@options = { :logger => logger }
|
|
272
350
|
host.instance_variable_set :@connection, conn
|
|
273
351
|
args = [ source_path, target_path, {:ignore => ['tests', 'tests2']} ]
|
|
274
352
|
|
|
275
|
-
logger.
|
|
276
|
-
host.
|
|
277
|
-
conn.
|
|
353
|
+
expect( logger ).to receive(:trace)
|
|
354
|
+
expect( host ).to receive( :mkdir_p ).exactly(0).times
|
|
355
|
+
expect( conn ).to receive(:scp_to).exactly(0).times
|
|
278
356
|
|
|
279
357
|
host.do_scp_to *args
|
|
280
358
|
end
|
|
281
|
-
it 'can take an ignore list that excludes a single file and scp the rest'
|
|
359
|
+
it 'can take an ignore list that excludes a single file and scp the rest' do
|
|
282
360
|
exclude_file = '07_InstallCACerts.rb'
|
|
283
361
|
logger = host[:logger]
|
|
284
362
|
conn = double(:connection)
|
|
@@ -286,20 +364,21 @@ module Beaker
|
|
|
286
364
|
host.instance_variable_set :@connection, conn
|
|
287
365
|
args = [ source_path, target_path, {:ignore => [exclude_file]} ]
|
|
288
366
|
|
|
289
|
-
Dir.
|
|
367
|
+
allow( Dir ).to receive( :glob ).and_return( @fileset1 + @fileset2 )
|
|
368
|
+
|
|
369
|
+
expect( logger ).to receive(:trace)
|
|
370
|
+
expect( host ).to receive( :mkdir_p ).with("#{target_path}/tests")
|
|
371
|
+
expect( host ).to receive( :mkdir_p ).with("#{target_path}/tests2")
|
|
290
372
|
|
|
291
|
-
logger.should_receive(:trace)
|
|
292
|
-
host.should_receive( :mkdir_p ).with("#{target_path}/tests")
|
|
293
|
-
host.should_receive( :mkdir_p ).with("#{target_path}/tests2")
|
|
294
373
|
(@fileset1 + @fileset2).each do |file|
|
|
295
374
|
if file !~ /#{exclude_file}/
|
|
296
375
|
file_args = [ file, File.join(target_path, file.gsub(source_path,'')), {:ignore => [exclude_file]} ]
|
|
297
376
|
conn_args = file_args + [ nil ]
|
|
298
|
-
conn.
|
|
377
|
+
expect( conn ).to receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
|
|
299
378
|
else
|
|
300
379
|
file_args = [ file, File.join(target_path, file.gsub(source_path,'')), {:ignore => [exclude_file]} ]
|
|
301
380
|
conn_args = file_args + [ nil ]
|
|
302
|
-
conn.
|
|
381
|
+
expect( conn ).to_not receive(:scp_to).with( *conn_args )
|
|
303
382
|
end
|
|
304
383
|
end
|
|
305
384
|
|
|
@@ -325,21 +404,21 @@ module Beaker
|
|
|
325
404
|
create_files( @fileset2 )
|
|
326
405
|
end
|
|
327
406
|
|
|
328
|
-
it 'can take an ignore list that excludes all files and not call scp_to'
|
|
407
|
+
it 'can take an ignore list that excludes all files and not call scp_to' do
|
|
329
408
|
logger = host[:logger]
|
|
330
409
|
conn = double(:connection)
|
|
331
410
|
@options = { :logger => logger }
|
|
332
411
|
host.instance_variable_set :@connection, conn
|
|
333
412
|
args = [ 'tmp', 'target', {:ignore => ['tests', 'tests2']} ]
|
|
334
413
|
|
|
335
|
-
logger.
|
|
336
|
-
host.
|
|
337
|
-
conn.
|
|
414
|
+
expect( logger ).to receive(:trace)
|
|
415
|
+
expect( host ).to receive( :mkdir_p ).exactly(0).times
|
|
416
|
+
expect( conn ).to receive(:scp_to).exactly(0).times
|
|
338
417
|
|
|
339
418
|
host.do_scp_to *args
|
|
340
419
|
end
|
|
341
420
|
|
|
342
|
-
it 'can take an ignore list that excludes a single file and scp the rest'
|
|
421
|
+
it 'can take an ignore list that excludes a single file and scp the rest' do
|
|
343
422
|
exclude_file = '07_InstallCACerts.rb'
|
|
344
423
|
logger = host[:logger]
|
|
345
424
|
conn = double(:connection)
|
|
@@ -347,23 +426,23 @@ module Beaker
|
|
|
347
426
|
host.instance_variable_set :@connection, conn
|
|
348
427
|
args = [ 'tmp', 'target', {:ignore => [exclude_file]} ]
|
|
349
428
|
|
|
350
|
-
Dir.
|
|
429
|
+
allow( Dir ).to receive( :glob ).and_return( @fileset1 + @fileset2 )
|
|
351
430
|
|
|
352
|
-
logger.
|
|
353
|
-
host.
|
|
354
|
-
host.
|
|
431
|
+
expect( logger ).to receive(:trace)
|
|
432
|
+
expect( host ).to receive( :mkdir_p ).with('target/tmp/tests')
|
|
433
|
+
expect( host ).to receive( :mkdir_p ).with('target/tmp/tests2')
|
|
355
434
|
(@fileset1 + @fileset2).each do |file|
|
|
356
435
|
if file !~ /#{exclude_file}/
|
|
357
436
|
file_args = [ file, File.join('target', file), {:ignore => [exclude_file]} ]
|
|
358
437
|
conn_args = file_args + [ nil ]
|
|
359
|
-
conn.
|
|
438
|
+
expect( conn ).to receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
|
|
360
439
|
end
|
|
361
440
|
end
|
|
362
441
|
|
|
363
442
|
host.do_scp_to *args
|
|
364
443
|
end
|
|
365
444
|
|
|
366
|
-
it 'can take an ignore list that excludes a dir and scp the rest'
|
|
445
|
+
it 'can take an ignore list that excludes a dir and scp the rest' do
|
|
367
446
|
exclude_file = 'tests'
|
|
368
447
|
logger = host[:logger]
|
|
369
448
|
conn = double(:connection)
|
|
@@ -371,14 +450,14 @@ module Beaker
|
|
|
371
450
|
host.instance_variable_set :@connection, conn
|
|
372
451
|
args = [ 'tmp', 'target', {:ignore => [exclude_file]} ]
|
|
373
452
|
|
|
374
|
-
Dir.
|
|
453
|
+
allow( Dir ).to receive( :glob ).and_return( @fileset1 + @fileset2 )
|
|
375
454
|
|
|
376
|
-
logger.
|
|
377
|
-
host.
|
|
455
|
+
expect( logger ).to receive(:trace)
|
|
456
|
+
expect( host ).to receive( :mkdir_p ).with('target/tmp/tests2')
|
|
378
457
|
(@fileset2).each do |file|
|
|
379
458
|
file_args = [ file, File.join('target', file), {:ignore => [exclude_file]} ]
|
|
380
459
|
conn_args = file_args + [ nil ]
|
|
381
|
-
conn.
|
|
460
|
+
expect( conn ).to receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
|
|
382
461
|
end
|
|
383
462
|
|
|
384
463
|
host.do_scp_to *args
|
|
@@ -395,8 +474,8 @@ module Beaker
|
|
|
395
474
|
args = [ 'source', 'target', {} ]
|
|
396
475
|
conn_args = args + [ nil ]
|
|
397
476
|
|
|
398
|
-
logger.
|
|
399
|
-
conn.
|
|
477
|
+
expect( logger ).to receive(:debug)
|
|
478
|
+
expect( conn ).to receive(:scp_from).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
|
|
400
479
|
|
|
401
480
|
host.do_scp_from *args
|
|
402
481
|
end
|
|
@@ -413,6 +492,5 @@ module Beaker
|
|
|
413
492
|
end
|
|
414
493
|
|
|
415
494
|
end
|
|
416
|
-
|
|
417
495
|
end
|
|
418
496
|
end
|
|
@@ -6,14 +6,14 @@ module Beaker
|
|
|
6
6
|
|
|
7
7
|
before :each do
|
|
8
8
|
@hosts = make_hosts()
|
|
9
|
-
File.
|
|
10
|
-
YAML.
|
|
11
|
-
Host.
|
|
9
|
+
allow( File ).to receive( :exists? ).and_return( true )
|
|
10
|
+
allow( YAML ).to receive( :load_file ).and_return( fog_file_contents )
|
|
11
|
+
allow_any_instance_of( Host ).to receive( :exec ).and_return( true )
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
it "can provision a set of hosts" do
|
|
15
15
|
@hosts.each do |host|
|
|
16
|
-
Command.
|
|
16
|
+
expect( Command ).to receive( :new ).with( "cd pe-aix && rake restore:#{host.name}" ).once
|
|
17
17
|
|
|
18
18
|
end
|
|
19
19
|
|
|
@@ -22,8 +22,8 @@ module Beaker
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
it "does nothing for cleanup" do
|
|
25
|
-
Command.
|
|
26
|
-
Host.
|
|
25
|
+
expect( Command ).to receive( :new ).never
|
|
26
|
+
expect( Host ).to receive( :exec ).never
|
|
27
27
|
|
|
28
28
|
aixer.cleanup
|
|
29
29
|
|