beaker 2.14.1 → 2.15.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/HISTORY.md +286 -27
- data/beaker.gemspec +1 -0
- data/lib/beaker/answers.rb +1 -1
- data/lib/beaker/answers/version40.rb +7 -5
- data/lib/beaker/cli.rb +2 -2
- data/lib/beaker/dsl/helpers/puppet_helpers.rb +24 -2
- data/lib/beaker/dsl/helpers/web_helpers.rb +3 -1
- data/lib/beaker/dsl/install_utils/foss_defaults.rb +11 -1
- data/lib/beaker/dsl/install_utils/foss_utils.rb +358 -248
- data/lib/beaker/dsl/install_utils/module_utils.rb +1 -7
- data/lib/beaker/dsl/install_utils/pe_defaults.rb +1 -1
- data/lib/beaker/dsl/install_utils/pe_utils.rb +63 -9
- data/lib/beaker/dsl/install_utils/puppet_utils.rb +40 -0
- data/lib/beaker/dsl/structure.rb +35 -0
- data/lib/beaker/host/pswindows/exec.rb +9 -0
- data/lib/beaker/host/unix/exec.rb +10 -1
- data/lib/beaker/host/unix/pkg.rb +0 -2
- data/lib/beaker/host_prebuilt_steps.rb +2 -2
- data/lib/beaker/hypervisor/aws_sdk.rb +1 -1
- data/lib/beaker/options/command_line_parser.rb +7 -0
- data/lib/beaker/options/parser.rb +28 -8
- data/lib/beaker/options/presets.rb +4 -3
- data/lib/beaker/shared/semvar.rb +23 -2
- data/lib/beaker/test_suite.rb +2 -2
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/cli_spec.rb +35 -34
- data/spec/beaker/dsl/helpers/puppet_helpers_spec.rb +78 -7
- data/spec/beaker/dsl/install_utils/foss_utils_spec.rb +126 -17
- data/spec/beaker/dsl/install_utils/module_utils_spec.rb +2 -2
- data/spec/beaker/dsl/install_utils/pe_utils_spec.rb +106 -0
- data/spec/beaker/dsl/install_utils/puppet_utils_spec.rb +73 -0
- data/spec/beaker/dsl/structure_spec.rb +67 -0
- data/spec/beaker/host/unix/exec_spec.rb +53 -0
- data/spec/beaker/host/windows/exec_spec.rb +53 -0
- data/spec/beaker/host_prebuilt_steps_spec.rb +13 -0
- data/spec/beaker/hypervisor/aws_sdk_spec.rb +65 -0
- data/spec/beaker/options/command_line_parser_spec.rb +2 -2
- data/spec/beaker/options/parser_spec.rb +126 -1
- data/spec/beaker/shared/semvar_spec.rb +43 -0
- data/spec/beaker/test_suite_spec.rb +21 -0
- data/spec/helpers.rb +4 -0
- metadata +19 -2
@@ -136,7 +136,7 @@ describe ClassMixedWithDSLInstallUtils do
|
|
136
136
|
allow( File ).to receive(:directory?).with(any_args()).and_return(false)
|
137
137
|
|
138
138
|
expect( subject ).to receive(:scp_to).with(host,source, File.dirname(target), {:ignore => ignore_list})
|
139
|
-
expect(
|
139
|
+
expect( host ).to receive(:mv).with(File.join(File.dirname(target), File.basename(source)), target)
|
140
140
|
if opts.nil?
|
141
141
|
subject.copy_module_to(host)
|
142
142
|
else
|
@@ -187,7 +187,7 @@ describe ClassMixedWithDSLInstallUtils do
|
|
187
187
|
expect( subject ).to receive(:on).with(host, "echo C:\\ProgramData\\PuppetLabs\\puppet\\etc\\modules" ).and_return( result )
|
188
188
|
|
189
189
|
expect( subject ).to receive(:scp_to).with(host, "/opt/testmodule2", "C:\\ProgramData\\PuppetLabs\\puppet\\etc\\modules", {:ignore => ignore_list})
|
190
|
-
expect(
|
190
|
+
expect( host ).to receive(:mv).with('C:\\ProgramData\\PuppetLabs\\puppet\\etc\\modules/testmodule2', 'C:\\ProgramData\\PuppetLabs\\puppet\\etc\\modules/testmodule')
|
191
191
|
|
192
192
|
subject.copy_module_to(host, {:module_name => 'testmodule', :source => '/opt/testmodule2'})
|
193
193
|
end
|
@@ -41,6 +41,55 @@ describe ClassMixedWithDSLInstallUtils do
|
|
41
41
|
:pe_ver => '3.0',
|
42
42
|
:working_dir => '/tmp',
|
43
43
|
:dist => 'puppet-enterprise-3.7.1-rc0-78-gffc958f-eos-4-i386' } ) }
|
44
|
+
context '#configure_pe_defaults_on' do
|
45
|
+
it 'uses aio paths for hosts of type aio' do
|
46
|
+
hosts.each do |host|
|
47
|
+
host[:type] = 'aio'
|
48
|
+
end
|
49
|
+
expect(subject).to receive(:add_aio_defaults_on).exactly(hosts.length).times
|
50
|
+
expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
|
51
|
+
|
52
|
+
subject.configure_pe_defaults_on( hosts )
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'uses foss paths for hosts of type pe' do
|
56
|
+
hosts.each do |host|
|
57
|
+
host[:type] = 'pe'
|
58
|
+
end
|
59
|
+
expect(subject).to receive(:add_pe_defaults_on).exactly(hosts.length).times
|
60
|
+
expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
|
61
|
+
|
62
|
+
subject.configure_pe_defaults_on( hosts )
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'uses foss paths for hosts with no type and version < 4.0' do
|
66
|
+
expect(subject).to receive(:add_pe_defaults_on).exactly(hosts.length).times
|
67
|
+
expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
|
68
|
+
|
69
|
+
subject.configure_pe_defaults_on( hosts )
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'uses aio paths for hosts of version >= 4.0' do
|
73
|
+
hosts.each do |host|
|
74
|
+
host[:pe_ver] = '4.0'
|
75
|
+
end
|
76
|
+
expect(subject).to receive(:add_aio_defaults_on).exactly(hosts.length).times
|
77
|
+
expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
|
78
|
+
|
79
|
+
subject.configure_pe_defaults_on( hosts )
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'uses foss paths for hosts of version < 4.0' do
|
83
|
+
hosts.each do |host|
|
84
|
+
host[:pe_ver] = '3.8'
|
85
|
+
end
|
86
|
+
expect(subject).to receive(:add_pe_defaults_on).exactly(hosts.length).times
|
87
|
+
expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
|
88
|
+
|
89
|
+
subject.configure_pe_defaults_on( hosts )
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
44
93
|
|
45
94
|
describe 'sorted_hosts' do
|
46
95
|
it 'can reorder so that the master comes first' do
|
@@ -285,10 +334,12 @@ describe ClassMixedWithDSLInstallUtils do
|
|
285
334
|
allow( subject ).to receive( :sign_certificate_for ).and_return( true )
|
286
335
|
allow( subject ).to receive( :stop_agent_on ).and_return( true )
|
287
336
|
allow( subject ).to receive( :sleep_until_puppetdb_started ).and_return( true )
|
337
|
+
allow( subject ).to receive( :max_version ).with(anything, '3.8').and_return('3.0')
|
288
338
|
allow( subject ).to receive( :version_is_less ).with('3.0', '4.0').and_return( true )
|
289
339
|
allow( subject ).to receive( :version_is_less ).with('3.0', '3.4').and_return( true )
|
290
340
|
allow( subject ).to receive( :version_is_less ).with('3.0', '3.0').and_return( false )
|
291
341
|
allow( subject ).to receive( :version_is_less ).with('3.0', '3.99').and_return( true )
|
342
|
+
allow( subject ).to receive( :version_is_less ).with('3.99', '3.0').and_return( false )
|
292
343
|
allow( subject ).to receive( :wait_for_host_in_dashboard ).and_return( true )
|
293
344
|
allow( subject ).to receive( :puppet_agent ) do |arg|
|
294
345
|
"puppet agent #{arg}"
|
@@ -350,7 +401,10 @@ describe ClassMixedWithDSLInstallUtils do
|
|
350
401
|
allow( subject ).to receive( :fetch_pe ).and_return( true )
|
351
402
|
allow( subject ).to receive( :create_remote_file ).and_return( true )
|
352
403
|
allow( subject ).to receive( :stop_agent_on ).and_return( true )
|
404
|
+
allow( subject ).to receive( :max_version ).with(['3.0'], '3.8').and_return('3.0')
|
405
|
+
allow( subject ).to receive( :version_is_less ).with('3.99', '3.0').and_return( false )
|
353
406
|
allow( subject ).to receive( :version_is_less ).with(anything, '3.2.0').exactly(hosts.length + 1).times.and_return( false )
|
407
|
+
allow( subject ).to receive( :version_is_less ).with(anything, '4.0').exactly(hosts.length + 1).times.and_return( true )
|
354
408
|
|
355
409
|
expect( subject ).to receive( :on ).with( hosts[0], /puppet-enterprise-installer/ ).once
|
356
410
|
expect( subject ).to receive( :create_remote_file ).with( hosts[0], /answers/, /q/ ).once
|
@@ -361,6 +415,58 @@ describe ClassMixedWithDSLInstallUtils do
|
|
361
415
|
expect( subject ).to_not receive( :on ).with( hosts[0], /puppet agent -t/, :acceptable_exit_codes => [0,2] )
|
362
416
|
subject.do_install( hosts, opts)
|
363
417
|
end
|
418
|
+
|
419
|
+
it 'can perform a 4+ installation using AIO agents' do
|
420
|
+
hosts = make_hosts({
|
421
|
+
:pe_ver => '4.0',
|
422
|
+
:roles => ['agent'],
|
423
|
+
}, 3)
|
424
|
+
hosts[0][:roles] = ['master', 'database', 'dashboard']
|
425
|
+
hosts[1][:platform] = 'windows'
|
426
|
+
hosts[2][:platform] = Beaker::Platform.new('el-6-x86_64')
|
427
|
+
|
428
|
+
allow( subject ).to receive( :hosts ).and_return( hosts )
|
429
|
+
allow( subject ).to receive( :options ).and_return(Beaker::Options::Presets.new.presets)
|
430
|
+
allow( subject ).to receive( :on ).and_return( Beaker::Result.new( {}, '' ) )
|
431
|
+
allow( subject ).to receive( :fetch_pe ).and_return( true )
|
432
|
+
allow( subject ).to receive( :create_remote_file ).and_return( true )
|
433
|
+
allow( subject ).to receive( :sign_certificate_for ).and_return( true )
|
434
|
+
allow( subject ).to receive( :stop_agent_on ).and_return( true )
|
435
|
+
allow( subject ).to receive( :sleep_until_puppetdb_started ).and_return( true )
|
436
|
+
allow( subject ).to receive( :max_version ).with(anything, '3.8').and_return('4.0')
|
437
|
+
allow( subject ).to receive( :version_is_less ).with('4.0', '4.0').and_return( false )
|
438
|
+
allow( subject ).to receive( :version_is_less ).with('4.0', '3.4').and_return( false )
|
439
|
+
allow( subject ).to receive( :version_is_less ).with('4.0', '3.0').and_return( false )
|
440
|
+
allow( subject ).to receive( :version_is_less ).with('3.99', '4.0').and_return( true )
|
441
|
+
# pe_ver is only set on the hosts for this test, not the opt
|
442
|
+
allow( subject ).to receive( :version_is_less ).with('4.0', '3.99').and_return( true )
|
443
|
+
allow( subject ).to receive( :wait_for_host_in_dashboard ).and_return( true )
|
444
|
+
allow( subject ).to receive( :puppet_agent ) do |arg|
|
445
|
+
"puppet agent #{arg}"
|
446
|
+
end
|
447
|
+
allow( subject ).to receive( :puppet ) do |arg|
|
448
|
+
"puppet #{arg}"
|
449
|
+
end
|
450
|
+
|
451
|
+
allow( subject ).to receive( :hosts ).and_return( hosts )
|
452
|
+
#create answers file per-host, except windows
|
453
|
+
expect( subject ).to receive( :create_remote_file ).with( hosts[0], /answers/, /q/ ).once
|
454
|
+
#run installer on all hosts
|
455
|
+
expect( subject ).to receive( :on ).with( hosts[0], /puppet-enterprise-installer/ ).once
|
456
|
+
expect( subject ).to receive( :install_puppet_agent_pe_promoted_repo_on ).with( hosts[1], opts ).once
|
457
|
+
expect( subject ).to receive( :install_puppet_agent_pe_promoted_repo_on ).with( hosts[2], opts ).once
|
458
|
+
hosts.each do |host|
|
459
|
+
expect( subject ).to receive( :add_aio_defaults_on ).with( host ).once
|
460
|
+
expect( subject ).to receive( :sign_certificate_for ).with( host ).once
|
461
|
+
expect( subject ).to receive( :stop_agent_on ).with( host ).once
|
462
|
+
expect( subject ).to receive( :on ).with( host, /puppet agent -t/, :acceptable_exit_codes => [0,2] ).once
|
463
|
+
end
|
464
|
+
#wait for puppetdb to start
|
465
|
+
expect( subject ).to receive( :sleep_until_puppetdb_started ).with( hosts[0] ).once#wait for all hosts to appear in the dashboard
|
466
|
+
#run puppet agent now that installation is complete
|
467
|
+
expect( subject ).to receive( :on ).with( hosts, /puppet agent/, :acceptable_exit_codes => [0,2] ).once
|
468
|
+
subject.do_install( hosts, opts )
|
469
|
+
end
|
364
470
|
end
|
365
471
|
|
366
472
|
describe 'do_higgs_install' do
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class ClassMixedWithDSLInstallUtils
|
4
|
+
include Beaker::DSL::Wrappers
|
5
|
+
include Beaker::DSL::Helpers
|
6
|
+
include Beaker::DSL::Structure
|
7
|
+
include Beaker::DSL::Roles
|
8
|
+
include Beaker::DSL::Patterns
|
9
|
+
include Beaker::DSL::InstallUtils
|
10
|
+
|
11
|
+
def logger
|
12
|
+
@logger ||= RSpec::Mocks::Double.new('logger').as_null_object
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe ClassMixedWithDSLInstallUtils do
|
17
|
+
let(:metadata) { @metadata ||= {} }
|
18
|
+
let(:presets) { Beaker::Options::Presets.new }
|
19
|
+
let(:opts) { presets.presets.merge(presets.env_vars) }
|
20
|
+
let(:basic_hosts) { make_hosts( { :pe_ver => '3.0',
|
21
|
+
:platform => 'linux',
|
22
|
+
:roles => [ 'agent' ] }, 4 ) }
|
23
|
+
let(:hosts) { basic_hosts[0][:roles] = ['master', 'database', 'dashboard']
|
24
|
+
basic_hosts[1][:platform] = 'windows'
|
25
|
+
basic_hosts[2][:platform] = 'osx-10.9-x86_64'
|
26
|
+
basic_hosts[3][:platform] = 'eos'
|
27
|
+
basic_hosts }
|
28
|
+
let(:hosts_sorted) { [ hosts[1], hosts[0], hosts[2], hosts[3] ] }
|
29
|
+
let(:winhost) { make_host( 'winhost', { :platform => 'windows',
|
30
|
+
:pe_ver => '3.0',
|
31
|
+
:working_dir => '/tmp',
|
32
|
+
:is_cygwin => true} ) }
|
33
|
+
let(:winhost_non_cygwin) { make_host( 'winhost_non_cygwin', { :platform => 'windows',
|
34
|
+
:pe_ver => '3.0',
|
35
|
+
:working_dir => '/tmp',
|
36
|
+
:is_cygwin => 'false' } ) }
|
37
|
+
let(:machost) { make_host( 'machost', { :platform => 'osx-10.9-x86_64',
|
38
|
+
:pe_ver => '3.0',
|
39
|
+
:working_dir => '/tmp' } ) }
|
40
|
+
let(:unixhost) { make_host( 'unixhost', { :platform => 'linux',
|
41
|
+
:pe_ver => '3.0',
|
42
|
+
:working_dir => '/tmp',
|
43
|
+
:dist => 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-debian-7-i386' } ) }
|
44
|
+
let(:eoshost) { make_host( 'eoshost', { :platform => 'eos',
|
45
|
+
:pe_ver => '3.0',
|
46
|
+
:working_dir => '/tmp',
|
47
|
+
:dist => 'puppet-enterprise-3.7.1-rc0-78-gffc958f-eos-4-i386' } ) }
|
48
|
+
|
49
|
+
describe "#configure_defaults_on" do
|
50
|
+
|
51
|
+
it "can set foss defaults" do
|
52
|
+
expect(subject).to receive(:add_foss_defaults_on).exactly(hosts.length).times
|
53
|
+
subject.configure_defaults_on(hosts, 'foss')
|
54
|
+
end
|
55
|
+
|
56
|
+
it "can set aio defaults" do
|
57
|
+
expect(subject).to receive(:add_aio_defaults_on).exactly(hosts.length).times
|
58
|
+
subject.configure_defaults_on(hosts, 'aio')
|
59
|
+
end
|
60
|
+
|
61
|
+
it "can set pe defaults" do
|
62
|
+
expect(subject).to receive(:add_pe_defaults_on).exactly(hosts.length).times
|
63
|
+
subject.configure_defaults_on(hosts, 'pe')
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'can remove old defaults ands replace with new' do
|
67
|
+
expect(subject).to receive(:remove_pe_defaults_on).exactly(hosts.length).times
|
68
|
+
expect(subject).to receive(:add_foss_defaults_on).exactly(hosts.length).times
|
69
|
+
subject.configure_defaults_on(hosts, 'pe')
|
70
|
+
subject.configure_defaults_on(hosts, 'foss')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -227,4 +227,71 @@ describe ClassMixedWithDSLStructure do
|
|
227
227
|
expect( selected_hosts ).to be == [ host1 ]
|
228
228
|
end
|
229
229
|
end
|
230
|
+
|
231
|
+
describe '#tag' do
|
232
|
+
let ( :tag_includes ) { @tag_includes || [] }
|
233
|
+
let ( :tag_excludes ) { @tag_excludes || [] }
|
234
|
+
let ( :options ) {
|
235
|
+
opts = Beaker::Options::OptionsHash.new
|
236
|
+
opts[:tag_includes] = tag_includes
|
237
|
+
opts[:tag_excludes] = tag_excludes
|
238
|
+
opts
|
239
|
+
}
|
240
|
+
|
241
|
+
it 'sets tags on the TestCase\'s metadata object' do
|
242
|
+
subject.instance_variable_set(:@options, options)
|
243
|
+
tags = ['pants', 'jayjay', 'moguely']
|
244
|
+
subject.tag(*tags)
|
245
|
+
expect( metadata[:case][:tags] ).to be === tags
|
246
|
+
end
|
247
|
+
|
248
|
+
it 'lowercases the tags' do
|
249
|
+
subject.instance_variable_set(:@options, options)
|
250
|
+
tags_upper = ['pANTs', 'jAYJAy', 'moGUYly']
|
251
|
+
tags_lower = tags_upper.map(&:downcase)
|
252
|
+
subject.tag(*tags_upper)
|
253
|
+
expect( metadata[:case][:tags] ).to be === tags_lower
|
254
|
+
end
|
255
|
+
|
256
|
+
it 'skips the test if any of the requested tags isn\'t included in this test' do
|
257
|
+
test_tags = ['pants', 'jayjay', 'moguely']
|
258
|
+
@tag_includes = test_tags.compact.push('needed_tag_not_in_test')
|
259
|
+
subject.instance_variable_set(:@options, options)
|
260
|
+
|
261
|
+
allow( subject ).to receive( :path )
|
262
|
+
expect( subject ).to receive( :skip_test )
|
263
|
+
subject.tag(*test_tags)
|
264
|
+
end
|
265
|
+
|
266
|
+
it 'runs the test if all requested tags are included in this test' do
|
267
|
+
@tag_includes = ['pants_on_head', 'jayjay_jayjay', 'mo']
|
268
|
+
test_tags = @tag_includes.compact.push('extra_asdf')
|
269
|
+
subject.instance_variable_set(:@options, options)
|
270
|
+
|
271
|
+
allow( subject ).to receive( :path )
|
272
|
+
expect( subject ).to receive( :skip_test ).never
|
273
|
+
subject.tag(*test_tags)
|
274
|
+
end
|
275
|
+
|
276
|
+
it 'skips the test if any of the excluded tags are included in this test' do
|
277
|
+
test_tags = ['ports', 'jay_john_mary', 'mog_the_dog']
|
278
|
+
@tag_excludes = [test_tags[0]]
|
279
|
+
subject.instance_variable_set(:@options, options)
|
280
|
+
|
281
|
+
allow( subject ).to receive( :path )
|
282
|
+
expect( subject ).to receive( :skip_test )
|
283
|
+
subject.tag(*test_tags)
|
284
|
+
end
|
285
|
+
|
286
|
+
it 'runs the test if none of the excluded tags are included in this test' do
|
287
|
+
@tag_excludes = ['pants_on_head', 'jayjay_jayjay', 'mo']
|
288
|
+
test_tags = ['pants_at_head', 'jayj00_jayjay', 'motly_crew']
|
289
|
+
subject.instance_variable_set(:@options, options)
|
290
|
+
|
291
|
+
allow( subject ).to receive( :path )
|
292
|
+
expect( subject ).to receive( :skip_test ).never
|
293
|
+
subject.tag(*test_tags)
|
294
|
+
end
|
295
|
+
|
296
|
+
end
|
230
297
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Beaker
|
4
|
+
describe Unix::Exec do
|
5
|
+
class UnixExecTest
|
6
|
+
include Unix::Exec
|
7
|
+
|
8
|
+
def initialize(hash, logger)
|
9
|
+
@hash = hash
|
10
|
+
@logger = logger
|
11
|
+
end
|
12
|
+
|
13
|
+
def [](k)
|
14
|
+
@hash[k]
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
"me"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
let (:opts) { @opts || {} }
|
24
|
+
let (:logger) { double( 'logger' ).as_null_object }
|
25
|
+
let (:instance) { UnixExecTest.new(opts, logger) }
|
26
|
+
|
27
|
+
context "rm" do
|
28
|
+
|
29
|
+
it "deletes" do
|
30
|
+
path = '/path/to/delete'
|
31
|
+
expect( instance ).to receive(:execute).with("rm -rf #{path}").and_return(0)
|
32
|
+
expect( instance.rm_rf(path) ).to be === 0
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'mv' do
|
37
|
+
let(:origin) { '/origin/path/of/content' }
|
38
|
+
let(:destination) { '/destination/path/of/content' }
|
39
|
+
|
40
|
+
it 'rm first' do
|
41
|
+
expect( instance ).to receive(:execute).with("rm -rf #{destination}").and_return(0)
|
42
|
+
expect( instance ).to receive(:execute).with("mv #{origin} #{destination}").and_return(0)
|
43
|
+
expect( instance.mv(origin, destination) ).to be === 0
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'does not rm' do
|
48
|
+
expect( instance ).to receive(:execute).with("mv #{origin} #{destination}").and_return(0)
|
49
|
+
expect( instance.mv(origin, destination, false) ).to be === 0
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Beaker
|
4
|
+
describe PSWindows::Exec do
|
5
|
+
class PSWindowsExecTest
|
6
|
+
include PSWindows::Exec
|
7
|
+
|
8
|
+
def initialize(hash, logger)
|
9
|
+
@hash = hash
|
10
|
+
@logger = logger
|
11
|
+
end
|
12
|
+
|
13
|
+
def [](k)
|
14
|
+
@hash[k]
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
"me"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
let (:opts) { @opts || {} }
|
24
|
+
let (:logger) { double( 'logger' ).as_null_object }
|
25
|
+
let (:instance) { PSWindowsExecTest.new(opts, logger) }
|
26
|
+
|
27
|
+
context "rm" do
|
28
|
+
|
29
|
+
it "deletes" do
|
30
|
+
path = '/path/to/delete'
|
31
|
+
expect( instance ).to receive(:execute).with("del /s /q #{path}").and_return(0)
|
32
|
+
expect( instance.rm_rf(path) ).to be === 0
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'mv' do
|
37
|
+
let(:origin) { '/origin/path/of/content' }
|
38
|
+
let(:destination) { '/destination/path/of/content' }
|
39
|
+
|
40
|
+
it 'rm first' do
|
41
|
+
expect( instance ).to receive(:execute).with("del /s /q #{destination}").and_return(0)
|
42
|
+
expect( instance ).to receive(:execute).with("move /y #{origin} #{destination}").and_return(0)
|
43
|
+
expect( instance.mv(origin, destination) ).to be === 0
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'does not rm' do
|
48
|
+
expect( instance ).to receive(:execute).with("move /y #{origin} #{destination}").and_return(0)
|
49
|
+
expect( instance.mv(origin, destination, false) ).to be === 0
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -46,6 +46,11 @@ describe Beaker do
|
|
46
46
|
"sudo su -c \"sed -ri 's/^#?PermitRootLogin no|^#?PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config\""
|
47
47
|
], true
|
48
48
|
|
49
|
+
# FreeBSD
|
50
|
+
it_should_behave_like 'enables_root_login', 'freesbd', [
|
51
|
+
"sudo su -c \"sed -ri 's/^#?PermitRootLogin no|^#?PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config\""
|
52
|
+
], true
|
53
|
+
|
49
54
|
it_should_behave_like 'enables_root_login', 'osx', [
|
50
55
|
"sudo sed -i '' 's/#PermitRootLogin yes/PermitRootLogin Yes/g' /etc/sshd_config",
|
51
56
|
"sudo sed -i '' 's/#PermitRootLogin no/PermitRootLogin Yes/g' /etc/sshd_config"
|
@@ -540,6 +545,14 @@ describe Beaker do
|
|
540
545
|
set_env_helper('aix', commands)
|
541
546
|
end
|
542
547
|
|
548
|
+
it "can set the environment on a FreeBSD host" do
|
549
|
+
commands = [
|
550
|
+
"sudo perl -pi -e 's/^#?PermitUserEnvironment no/PermitUserEnvironment yes/' /etc/ssh/sshd_config",
|
551
|
+
"sudo /etc/rc.d/sshd restart",
|
552
|
+
]
|
553
|
+
set_env_helper('freebsd', commands)
|
554
|
+
end
|
555
|
+
|
543
556
|
def set_env_helper(platform_name, host_specific_commands_array)
|
544
557
|
host = make_host('name', {
|
545
558
|
:platform => platform_name,
|
@@ -92,5 +92,70 @@ module Beaker
|
|
92
92
|
expect { aws.group_id([]) }.to raise_error(ArgumentError, "Ports list cannot be nil or empty")
|
93
93
|
end
|
94
94
|
end
|
95
|
+
|
96
|
+
describe '#populate_dns' do
|
97
|
+
let( :vpc_instance ) { {ip_address: nil, private_ip_address: "vpc_private_ip", dns_name: "vpc_dns_name"} }
|
98
|
+
let( :ec2_instance ) { {ip_address: "ec2_public_ip", private_ip_address: "ec2_private_ip", dns_name: "ec2_dns_name"} }
|
99
|
+
|
100
|
+
context 'on a public EC2 instance' do
|
101
|
+
before :each do
|
102
|
+
@hosts.each {|host| host['instance'] = make_instance ec2_instance}
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'sets host ip to instance.ip_address' do
|
106
|
+
aws.populate_dns();
|
107
|
+
hosts = aws.instance_variable_get( :@hosts )
|
108
|
+
hosts.each do |host|
|
109
|
+
expect(host['ip']).to eql(ec2_instance[:ip_address])
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'sets host private_ip to instance.private_ip_address' do
|
114
|
+
aws.populate_dns();
|
115
|
+
hosts = aws.instance_variable_get( :@hosts )
|
116
|
+
hosts.each do |host|
|
117
|
+
expect(host['private_ip']).to eql(ec2_instance[:private_ip_address])
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'sets host dns_name to instance.dns_name' do
|
122
|
+
aws.populate_dns();
|
123
|
+
hosts = aws.instance_variable_get( :@hosts )
|
124
|
+
hosts.each do |host|
|
125
|
+
expect(host['dns_name']).to eql(ec2_instance[:dns_name])
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'on a VPC based instance' do
|
131
|
+
before :each do
|
132
|
+
@hosts.each {|host| host['instance'] = make_instance vpc_instance}
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'sets host ip to instance.private_ip_address' do
|
136
|
+
aws.populate_dns();
|
137
|
+
hosts = aws.instance_variable_get( :@hosts )
|
138
|
+
hosts.each do |host|
|
139
|
+
expect(host['ip']).to eql(vpc_instance[:private_ip_address])
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'sets host private_ip to instance.private_ip_address' do
|
144
|
+
aws.populate_dns();
|
145
|
+
hosts = aws.instance_variable_get( :@hosts )
|
146
|
+
hosts.each do |host|
|
147
|
+
expect(host['private_ip']).to eql(vpc_instance[:private_ip_address])
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'sets host dns_name to instance.dns_name' do
|
152
|
+
aws.populate_dns();
|
153
|
+
hosts = aws.instance_variable_get( :@hosts )
|
154
|
+
hosts.each do |host|
|
155
|
+
expect(host['dns_name']).to eql(vpc_instance[:dns_name])
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
95
160
|
end
|
96
161
|
end
|