beaker 1.16.0 → 1.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CONTRIBUTING.md +90 -0
- data/HISTORY.md +654 -2
- data/beaker.gemspec +1 -0
- data/lib/beaker/answers/version34.rb +4 -0
- data/lib/beaker/cli.rb +49 -2
- data/lib/beaker/dsl/helpers.rb +356 -196
- data/lib/beaker/dsl/install_utils.rb +135 -16
- data/lib/beaker/dsl/patterns.rb +37 -0
- data/lib/beaker/dsl/roles.rb +29 -0
- data/lib/beaker/dsl.rb +2 -1
- data/lib/beaker/host/unix.rb +14 -10
- data/lib/beaker/host/windows.rb +2 -0
- data/lib/beaker/host.rb +96 -1
- data/lib/beaker/host_prebuilt_steps.rb +41 -51
- data/lib/beaker/hypervisor/aws_sdk.rb +80 -16
- data/lib/beaker/hypervisor/ec2_helper.rb +1 -1
- data/lib/beaker/logger.rb +17 -0
- data/lib/beaker/options/command_line_parser.rb +3 -0
- data/lib/beaker/options/hosts_file_parser.rb +7 -4
- data/lib/beaker/options/options_hash.rb +2 -2
- data/lib/beaker/options/parser.rb +1 -1
- data/lib/beaker/options/presets.rb +128 -83
- data/lib/beaker/perf.rb +58 -0
- data/lib/beaker/shared/host_manager.rb +81 -0
- data/lib/beaker/shared.rb +2 -2
- data/lib/beaker/ssh_connection.rb +14 -7
- data/lib/beaker/test_case.rb +13 -0
- data/lib/beaker/test_suite.rb +23 -5
- data/lib/beaker/version.rb +1 -1
- data/lib/beaker.rb +1 -1
- data/spec/beaker/answers_spec.rb +13 -8
- data/spec/beaker/dsl/ezbake_utils_spec.rb +8 -9
- data/spec/beaker/dsl/helpers_spec.rb +299 -51
- data/spec/beaker/dsl/install_utils_spec.rb +75 -10
- data/spec/beaker/dsl/roles_spec.rb +36 -1
- data/spec/beaker/host_prebuilt_steps_spec.rb +21 -5
- data/spec/beaker/host_spec.rb +187 -23
- data/spec/beaker/hypervisor/ec2_helper_spec.rb +4 -4
- data/spec/beaker/hypervisor/vagrant_spec.rb +1 -1
- data/spec/beaker/options/hosts_file_parser_spec.rb +5 -0
- data/spec/beaker/options/options_hash_spec.rb +2 -2
- data/spec/beaker/options/parser_spec.rb +6 -0
- data/spec/beaker/options/presets_spec.rb +18 -2
- data/spec/beaker/perf_spec.rb +87 -0
- data/spec/beaker/shared/{host_role_parser_spec.rb → host_manager_spec.rb} +36 -5
- data/spec/beaker/test_suite_spec.rb +4 -3
- data/spec/matchers.rb +31 -3
- data/spec/mocks.rb +31 -25
- metadata +24 -5
- data/lib/beaker/shared/host_role_parser.rb +0 -36
@@ -4,10 +4,11 @@ class ClassMixedWithDSLInstallUtils
|
|
4
4
|
include Beaker::DSL::InstallUtils
|
5
5
|
include Beaker::DSL::Structure
|
6
6
|
include Beaker::DSL::Roles
|
7
|
+
include Beaker::DSL::Patterns
|
7
8
|
end
|
8
9
|
|
9
10
|
describe ClassMixedWithDSLInstallUtils do
|
10
|
-
let(:opts) { Beaker::Options::Presets.env_vars }
|
11
|
+
let(:opts) { Beaker::Options::Presets.presets.merge(Beaker::Options::Presets.env_vars) }
|
11
12
|
let(:basic_hosts) { make_hosts( { :pe_ver => '3.0',
|
12
13
|
:platform => 'linux',
|
13
14
|
:roles => [ 'agent' ] } ) }
|
@@ -276,10 +277,6 @@ describe ClassMixedWithDSLInstallUtils do
|
|
276
277
|
subject.stub( :hosts ).and_return( hosts )
|
277
278
|
#determine mastercert
|
278
279
|
subject.should_receive( :on ).with( hosts[0], /uname/ ).once
|
279
|
-
#create working dirs per-host
|
280
|
-
subject.should_receive( :on ).with( hosts[0], /mkdir/ ).once
|
281
|
-
subject.should_receive( :on ).with( hosts[1], /mkdir/ ).once
|
282
|
-
subject.should_receive( :on ).with( hosts[2], /mkdir/ ).once
|
283
280
|
#create answers file per-host, except windows
|
284
281
|
subject.should_receive( :create_remote_file ).with( hosts[0], /answers/, /q/ ).once
|
285
282
|
#run installer on all hosts
|
@@ -316,6 +313,56 @@ describe ClassMixedWithDSLInstallUtils do
|
|
316
313
|
end
|
317
314
|
end
|
318
315
|
|
316
|
+
describe 'do_higgs_install' do
|
317
|
+
|
318
|
+
before :each do
|
319
|
+
my_time = double( "time double" )
|
320
|
+
my_time.stub( :strftime ).and_return( "2014-07-01_15.27.53" )
|
321
|
+
Time.stub( :new ).and_return( my_time )
|
322
|
+
|
323
|
+
hosts[0]['working_dir'] = "tmp/2014-07-01_15.27.53"
|
324
|
+
hosts[0]['dist'] = 'dist'
|
325
|
+
hosts[0]['pe_installer'] = 'pe-installer'
|
326
|
+
hosts[0].stub( :tmpdir ).and_return( "/tmp/2014-07-01_15.27.53" )
|
327
|
+
|
328
|
+
@fail_result = Beaker::Result.new( {}, '' )
|
329
|
+
@fail_result.stdout = "No match here"
|
330
|
+
@success_result = Beaker::Result.new( {}, '' )
|
331
|
+
@success_result.stdout = "Please go to https://website in your browser to continue installation"
|
332
|
+
end
|
333
|
+
|
334
|
+
it 'can perform a simple installation' do
|
335
|
+
subject.stub( :fetch_puppet ).and_return( true )
|
336
|
+
subject.stub( :sleep ).and_return( true )
|
337
|
+
|
338
|
+
subject.stub( :hosts ).and_return( hosts )
|
339
|
+
|
340
|
+
#run higgs installer command
|
341
|
+
subject.should_receive( :on ).with( hosts[0],
|
342
|
+
"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 &",
|
343
|
+
opts ).once
|
344
|
+
#check to see if the higgs installation has proceeded correctly, works on second check
|
345
|
+
subject.should_receive( :on ).with( hosts[0], /cat #{hosts[0]['higgs_file']}/, { :acceptable_exit_codes => 0..255 }).and_return( @fail_result, @success_result )
|
346
|
+
subject.do_higgs_install( hosts[0], opts )
|
347
|
+
end
|
348
|
+
|
349
|
+
it 'fails out after checking installation log 10 times' do
|
350
|
+
subject.stub( :fetch_puppet ).and_return( true )
|
351
|
+
subject.stub( :sleep ).and_return( true )
|
352
|
+
|
353
|
+
subject.stub( :hosts ).and_return( hosts )
|
354
|
+
|
355
|
+
#run higgs installer command
|
356
|
+
subject.should_receive( :on ).with( hosts[0],
|
357
|
+
"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 &",
|
358
|
+
opts ).once
|
359
|
+
#check to see if the higgs installation has proceeded correctly, works on second check
|
360
|
+
subject.should_receive( :on ).with( hosts[0], /cat #{hosts[0]['higgs_file']}/, { :acceptable_exit_codes => 0..255 }).exactly(10).times.and_return( @fail_result )
|
361
|
+
expect{ subject.do_higgs_install( hosts[0], opts ) }.to raise_error
|
362
|
+
end
|
363
|
+
|
364
|
+
end
|
365
|
+
|
319
366
|
describe '#install_puppet' do
|
320
367
|
let(:hosts) do
|
321
368
|
make_hosts({:platform => platform })
|
@@ -381,12 +428,18 @@ describe ClassMixedWithDSLInstallUtils do
|
|
381
428
|
end
|
382
429
|
describe 'on unsupported platforms' do
|
383
430
|
let(:platform) { 'solaris-11-x86_64' }
|
431
|
+
let(:host) { make_host('henry', :platform => 'solaris-11-x86_64') }
|
432
|
+
let(:hosts) { [host] }
|
384
433
|
it 'by default raises an error' do
|
385
434
|
expect(subject).to_not receive(:on)
|
386
435
|
expect { subject.install_puppet }.to raise_error(/unsupported platform/)
|
387
436
|
end
|
388
437
|
it 'falls back to installing from gem when given :default_action => "gem_install"' do
|
389
|
-
|
438
|
+
result = double
|
439
|
+
gem_env_string = '{"RubyGems Environment": [ {"GEM PATHS": [] } ] }'
|
440
|
+
allow( result ).to receive(:stdout).and_return gem_env_string
|
441
|
+
allow(subject).to receive(:on).with(host, /gem environment/).and_return result
|
442
|
+
expect(subject).to receive(:on).with(host, /gem install/)
|
390
443
|
subject.install_puppet :default_action => 'gem_install'
|
391
444
|
end
|
392
445
|
end
|
@@ -418,6 +471,20 @@ describe ClassMixedWithDSLInstallUtils do
|
|
418
471
|
end
|
419
472
|
end
|
420
473
|
|
474
|
+
describe 'install_higgs' do
|
475
|
+
it 'fills in missing pe_ver' do
|
476
|
+
hosts[0]['pe_ver'] = nil
|
477
|
+
Beaker::Options::PEVersionScraper.stub( :load_pe_version ).and_return( '2.8' )
|
478
|
+
subject.stub( :hosts ).and_return( [ hosts[1], hosts[0], hosts[2] ] )
|
479
|
+
subject.stub( :options ).and_return( {} )
|
480
|
+
subject.stub( :do_higgs_install ).and_return( true )
|
481
|
+
subject.should_receive( :do_higgs_install ).with( hosts[0], {} )
|
482
|
+
subject.install_higgs
|
483
|
+
expect( hosts[0]['pe_ver'] ).to be === '2.8'
|
484
|
+
end
|
485
|
+
|
486
|
+
end
|
487
|
+
|
421
488
|
describe 'upgrade_pe' do
|
422
489
|
|
423
490
|
it 'calls puppet-enterprise-upgrader for pre 3.0 upgrades' do
|
@@ -518,7 +585,7 @@ describe ClassMixedWithDSLInstallUtils do
|
|
518
585
|
describe "#install_puppetlabs_release_repo" do
|
519
586
|
let( :platform ) { Beaker::Platform.new('solaris-7-i386') }
|
520
587
|
let( :host ) do
|
521
|
-
FakeHost.
|
588
|
+
FakeHost.create('fakevm', platform.to_s)
|
522
589
|
end
|
523
590
|
|
524
591
|
before do
|
@@ -585,9 +652,7 @@ describe ClassMixedWithDSLInstallUtils do
|
|
585
652
|
let( :package_name ) { "puppet" }
|
586
653
|
let( :package_version ) { "7.5.6" }
|
587
654
|
let( :host ) do
|
588
|
-
FakeHost.
|
589
|
-
'platform' => platform,
|
590
|
-
}))
|
655
|
+
FakeHost.create('fakvm', platform.to_s, opts)
|
591
656
|
end
|
592
657
|
|
593
658
|
describe "When host is unsupported platform" do
|
@@ -12,7 +12,7 @@ describe ClassMixedWithDSLRoles do
|
|
12
12
|
let( :agent1 ) { make_host( 'agent1', { :roles => [ 'agent' ] } ) }
|
13
13
|
let( :agent2 ) { make_host( 'agent2', { :roles => [ 'agent' ] } ) }
|
14
14
|
let( :a_and_dash ) { make_host( 'a_and_dash', { :roles => [ 'agent', 'dashboard' ] } ) }
|
15
|
-
let( :custom ) { make_host( 'custom', { :roles => [ '
|
15
|
+
let( :custom ) { make_host( 'custom', { :roles => [ 'custom_role' ] } ) }
|
16
16
|
let( :db ) { make_host( 'db', { :roles => [ 'database' ] } ) }
|
17
17
|
let( :master ) { make_host( 'master', { :roles => [ 'master', 'agent' ] } ) }
|
18
18
|
let( :default ) { make_host( 'default', { :roles => [ 'default'] } ) }
|
@@ -94,4 +94,39 @@ describe ClassMixedWithDSLRoles do
|
|
94
94
|
expect { subject.database }.to raise_error Beaker::DSL::FailTest
|
95
95
|
end
|
96
96
|
end
|
97
|
+
describe '#add_role_def' do
|
98
|
+
it 'raises an error on unsupported role format "1role"' do
|
99
|
+
expect { subject.add_role_def( "1role" ) }.to raise_error
|
100
|
+
end
|
101
|
+
it 'raises an error on unsupported role format "role_!a"' do
|
102
|
+
expect { subject.add_role_def( "role_!a" ) }.to raise_error
|
103
|
+
end
|
104
|
+
it 'raises an error on unsupported role format "role=="' do
|
105
|
+
expect { subject.add_role_def( "role==" ) }.to raise_error
|
106
|
+
end
|
107
|
+
it 'creates new method for role "role_correct!"' do
|
108
|
+
test_role = "role_correct!"
|
109
|
+
subject.add_role_def( test_role )
|
110
|
+
subject.should respond_to test_role
|
111
|
+
subject.class.send( :undef_method, test_role )
|
112
|
+
end
|
113
|
+
it 'returns a single node for a new method for a role defined in a single node' do
|
114
|
+
@hosts = [ agent1, agent2, monolith ]
|
115
|
+
subject.should_receive( :hosts ).and_return( hosts )
|
116
|
+
test_role = "custom_role"
|
117
|
+
subject.add_role_def( test_role )
|
118
|
+
subject.should respond_to test_role
|
119
|
+
expect( subject.send( test_role )).to be == @hosts[2]
|
120
|
+
subject.class.send( :undef_method, test_role )
|
121
|
+
end
|
122
|
+
it 'returns an array of nodes for a new method for a role defined in multiple nodes' do
|
123
|
+
@hosts = [ agent1, agent2, monolith, custom ]
|
124
|
+
subject.should_receive( :hosts ).and_return( hosts )
|
125
|
+
test_role = "custom_role"
|
126
|
+
subject.add_role_def( test_role )
|
127
|
+
subject.should respond_to test_role
|
128
|
+
expect( subject.send( test_role )).to be == [@hosts[2], @hosts[3]]
|
129
|
+
subject.class.send( :undef_method, test_role )
|
130
|
+
end
|
131
|
+
end
|
97
132
|
end
|
@@ -17,7 +17,8 @@ describe Beaker do
|
|
17
17
|
hosts[1][:roles] = ['master', 'dashboard', 'agent', 'database']
|
18
18
|
hosts[2][:roles] = ['agent']
|
19
19
|
hosts }
|
20
|
-
let( :dummy_class ) { Class.new { include Beaker::HostPrebuiltSteps
|
20
|
+
let( :dummy_class ) { Class.new { include Beaker::HostPrebuiltSteps
|
21
|
+
include Beaker::DSL::Patterns } }
|
21
22
|
|
22
23
|
context 'timesync' do
|
23
24
|
|
@@ -271,10 +272,25 @@ describe Beaker do
|
|
271
272
|
host.should_receive( :check_for_package ).with( pkg ).once.and_return( false )
|
272
273
|
host.should_receive( :install_package ).with( pkg ).once
|
273
274
|
end
|
274
|
-
|
275
275
|
end
|
276
276
|
|
277
|
-
subject.validate_host(hosts,
|
277
|
+
subject.validate_host(hosts, options)
|
278
|
+
|
279
|
+
end
|
280
|
+
|
281
|
+
it "can validate unix hosts that need sysstat installed" do
|
282
|
+
total_pkgs = Array.new(unix_only_pkgs);
|
283
|
+
total_pkgs << "sysstat"
|
284
|
+
|
285
|
+
hosts.each do |host|
|
286
|
+
total_pkgs.each do |pkg|
|
287
|
+
host.should_receive( :check_for_package ).with( pkg ).once.and_return( false )
|
288
|
+
host.should_receive( :install_package ).with( pkg ).once
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
opts = options.merge({:collect_perf_data => true})
|
293
|
+
subject.validate_host(hosts, opts)
|
278
294
|
|
279
295
|
end
|
280
296
|
|
@@ -288,7 +304,7 @@ describe Beaker do
|
|
288
304
|
end
|
289
305
|
end
|
290
306
|
|
291
|
-
subject.validate_host(hosts,
|
307
|
+
subject.validate_host(hosts, options)
|
292
308
|
|
293
309
|
end
|
294
310
|
|
@@ -303,7 +319,7 @@ describe Beaker do
|
|
303
319
|
|
304
320
|
end
|
305
321
|
|
306
|
-
subject.validate_host(hosts,
|
322
|
+
subject.validate_host(hosts, options)
|
307
323
|
|
308
324
|
end
|
309
325
|
end
|
data/spec/beaker/host_spec.rb
CHANGED
@@ -24,6 +24,86 @@ module Beaker
|
|
24
24
|
expect( host['value'] ).to be === 'blarg'
|
25
25
|
end
|
26
26
|
|
27
|
+
describe "host types" do
|
28
|
+
let(:options) { Beaker::Options::OptionsHash.new }
|
29
|
+
|
30
|
+
it "can be a pe host" do
|
31
|
+
options['type'] = 'pe'
|
32
|
+
expect(host.is_pe?).to be_true
|
33
|
+
expect(host.use_service_scripts?).to be_true
|
34
|
+
expect(host.is_using_passenger?).to be_true
|
35
|
+
expect(host.graceful_restarts?).to be_false
|
36
|
+
end
|
37
|
+
|
38
|
+
it "can be a foss-source host" do
|
39
|
+
expect(host.is_pe?).to be_false
|
40
|
+
expect(host.use_service_scripts?).to be_false
|
41
|
+
expect(host.is_using_passenger?).to be_false
|
42
|
+
end
|
43
|
+
|
44
|
+
it "can be a foss-package host" do
|
45
|
+
options['use-service'] = true
|
46
|
+
expect(host.is_pe?).to be_false
|
47
|
+
expect(host.use_service_scripts?).to be_true
|
48
|
+
expect(host.is_using_passenger?).to be_false
|
49
|
+
expect(host.graceful_restarts?).to be_false
|
50
|
+
end
|
51
|
+
|
52
|
+
it "can be a foss-packaged host using passenger" do
|
53
|
+
host.uses_passenger!
|
54
|
+
expect(host.is_pe?).to be_false
|
55
|
+
expect(host.use_service_scripts?).to be_true
|
56
|
+
expect(host.is_using_passenger?).to be_true
|
57
|
+
expect(host.graceful_restarts?).to be_true
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "uses_passenger!" do
|
62
|
+
it "sets passenger property" do
|
63
|
+
host.uses_passenger!
|
64
|
+
expect(host['passenger']).to be_true
|
65
|
+
expect(host.is_using_passenger?).to be_true
|
66
|
+
end
|
67
|
+
|
68
|
+
it "sets puppetservice" do
|
69
|
+
host.uses_passenger!('servicescript')
|
70
|
+
expect(host['puppetservice']).to eq('servicescript')
|
71
|
+
end
|
72
|
+
|
73
|
+
it "sets puppetservice to apache2 by default" do
|
74
|
+
host.uses_passenger!
|
75
|
+
expect(host['puppetservice']).to eq('apache2')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "graceful_restarts?" do
|
80
|
+
it "is true if graceful-restarts property is set true" do
|
81
|
+
options['graceful-restarts'] = true
|
82
|
+
expect(host.graceful_restarts?).to be_true
|
83
|
+
end
|
84
|
+
|
85
|
+
it "is false if graceful-restarts property is set false" do
|
86
|
+
options['graceful-restarts'] = false
|
87
|
+
expect(host.graceful_restarts?).to be_false
|
88
|
+
end
|
89
|
+
|
90
|
+
it "is false if is_pe and graceful-restarts is nil" do
|
91
|
+
options['type'] = 'pe'
|
92
|
+
expect(host.graceful_restarts?).to be_false
|
93
|
+
end
|
94
|
+
|
95
|
+
it "is true if is_pe and graceful-restarts is true" do
|
96
|
+
options['type'] = 'pe'
|
97
|
+
options['graceful-restarts'] = true
|
98
|
+
expect(host.graceful_restarts?).to be_true
|
99
|
+
end
|
100
|
+
|
101
|
+
it "falls back to passenger property if not pe and graceful-restarts is nil" do
|
102
|
+
host.uses_passenger!
|
103
|
+
expect(host.graceful_restarts?).to be_true
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
27
107
|
describe "windows hosts" do
|
28
108
|
describe "install_package" do
|
29
109
|
let(:cygwin) { 'setup-x86.exe' }
|
@@ -148,40 +228,124 @@ module Beaker
|
|
148
228
|
end
|
149
229
|
end
|
150
230
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
231
|
+
context 'do_scp_to' do
|
232
|
+
# it takes a location and a destination
|
233
|
+
# it basically proxies that to the connection object
|
234
|
+
it 'do_scp_to logs info and proxies to the connection' do
|
235
|
+
File.stub(:file?).and_return(true)
|
236
|
+
logger = host[:logger]
|
237
|
+
conn = double(:connection)
|
238
|
+
@options = { :logger => logger }
|
239
|
+
host.instance_variable_set :@connection, conn
|
240
|
+
args = [ 'source', 'target', {} ]
|
241
|
+
conn_args = args + [ nil ]
|
242
|
+
|
243
|
+
logger.should_receive(:debug)
|
244
|
+
conn.should_receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
|
245
|
+
|
246
|
+
host.do_scp_to *args
|
247
|
+
end
|
248
|
+
|
249
|
+
context "using an ignore array" do
|
250
|
+
|
251
|
+
before :each do
|
252
|
+
test_dir = 'tmp/tests'
|
253
|
+
other_test_dir = 'tmp/tests2'
|
254
|
+
|
255
|
+
files = [
|
256
|
+
'00_EnvSetup.rb', '035_StopFirewall.rb', '05_HieraSetup.rb',
|
257
|
+
'01_TestSetup.rb', '03_PuppetMasterSanity.rb',
|
258
|
+
'06_InstallModules.rb','02_PuppetUserAndGroup.rb',
|
259
|
+
'04_ValidateSignCert.rb', '07_InstallCACerts.rb' ]
|
160
260
|
|
161
|
-
|
162
|
-
|
261
|
+
@fileset1 = files.shuffle.map {|file| test_dir + '/' + file }
|
262
|
+
@fileset2 = files.shuffle.map {|file| other_test_dir + '/' + file }
|
163
263
|
|
164
|
-
|
264
|
+
create_files( @fileset1 )
|
265
|
+
create_files( @fileset2 )
|
266
|
+
end
|
267
|
+
|
268
|
+
it 'can take an ignore list that excludes all files and not call scp_to', :use_fakefs => true do
|
269
|
+
logger = host[:logger]
|
270
|
+
conn = double(:connection)
|
271
|
+
@options = { :logger => logger }
|
272
|
+
host.instance_variable_set :@connection, conn
|
273
|
+
args = [ 'tmp', 'target', {:ignore => ['tests', 'tests2']} ]
|
274
|
+
|
275
|
+
logger.should_receive(:debug)
|
276
|
+
host.should_receive( :mkdir_p ).exactly(0).times
|
277
|
+
conn.should_receive(:scp_to).exactly(0).times
|
278
|
+
|
279
|
+
host.do_scp_to *args
|
280
|
+
end
|
281
|
+
|
282
|
+
it 'can take an ignore list that excludes a single file and scp the rest', :use_fakefs => true do
|
283
|
+
exclude_file = '07_InstallCACerts.rb'
|
284
|
+
logger = host[:logger]
|
285
|
+
conn = double(:connection)
|
286
|
+
@options = { :logger => logger }
|
287
|
+
host.instance_variable_set :@connection, conn
|
288
|
+
args = [ 'tmp', 'target', {:ignore => [exclude_file]} ]
|
289
|
+
|
290
|
+
Dir.stub( :glob ).and_return( @fileset1 + @fileset2 )
|
291
|
+
|
292
|
+
logger.should_receive(:debug)
|
293
|
+
host.should_receive( :mkdir_p ).with('target/tmp/tests')
|
294
|
+
host.should_receive( :mkdir_p ).with('target/tmp/tests2')
|
295
|
+
(@fileset1 + @fileset2).each do |file|
|
296
|
+
if file !~ /#{exclude_file}/
|
297
|
+
file_args = [ file, File.join('target', file), {:ignore => [exclude_file]} ]
|
298
|
+
conn_args = file_args + [ nil ]
|
299
|
+
conn.should_receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
host.do_scp_to *args
|
304
|
+
end
|
305
|
+
|
306
|
+
it 'can take an ignore list that excludes a dir and scp the rest', :use_fakefs => true do
|
307
|
+
exclude_file = 'tests'
|
308
|
+
logger = host[:logger]
|
309
|
+
conn = double(:connection)
|
310
|
+
@options = { :logger => logger }
|
311
|
+
host.instance_variable_set :@connection, conn
|
312
|
+
args = [ 'tmp', 'target', {:ignore => [exclude_file]} ]
|
313
|
+
|
314
|
+
Dir.stub( :glob ).and_return( @fileset1 + @fileset2 )
|
315
|
+
|
316
|
+
logger.should_receive(:debug)
|
317
|
+
host.should_receive( :mkdir_p ).with('target/tmp/tests2')
|
318
|
+
(@fileset2).each do |file|
|
319
|
+
file_args = [ file, File.join('target', file), {:ignore => [exclude_file]} ]
|
320
|
+
conn_args = file_args + [ nil ]
|
321
|
+
conn.should_receive(:scp_to).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
|
322
|
+
end
|
323
|
+
|
324
|
+
host.do_scp_to *args
|
325
|
+
end
|
326
|
+
end
|
165
327
|
end
|
166
328
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
329
|
+
context 'do_scp_from' do
|
330
|
+
it 'do_scp_from logs info and proxies to the connection' do
|
331
|
+
logger = host[:logger]
|
332
|
+
conn = double(:connection)
|
333
|
+
@options = { :logger => logger }
|
334
|
+
host.instance_variable_set :@connection, conn
|
335
|
+
args = [ 'source', 'target', {} ]
|
336
|
+
conn_args = args + [ nil ]
|
174
337
|
|
175
|
-
|
176
|
-
|
338
|
+
logger.should_receive(:debug)
|
339
|
+
conn.should_receive(:scp_from).with( *conn_args ).and_return(Beaker::Result.new(host, 'output!'))
|
177
340
|
|
178
|
-
|
341
|
+
host.do_scp_from *args
|
342
|
+
end
|
179
343
|
end
|
344
|
+
|
180
345
|
it 'interpolates to its "name"' do
|
181
346
|
expect( "#{host}" ).to be === 'name'
|
182
347
|
end
|
183
348
|
|
184
|
-
|
185
349
|
context 'merging defaults' do
|
186
350
|
it 'knows the difference between foss and pe' do
|
187
351
|
@options = { :type => 'pe' }
|
@@ -5,19 +5,19 @@ describe Beaker::EC2Helper do
|
|
5
5
|
context ".amiports" do
|
6
6
|
let(:ec2) { Beaker::EC2Helper }
|
7
7
|
it "can set ports for database host" do
|
8
|
-
expect(ec2.amiports(["database"])).to be === [22, 8080, 8081]
|
8
|
+
expect(ec2.amiports(["database"])).to be === [22, 61613, 8139, 8080, 8081]
|
9
9
|
end
|
10
10
|
|
11
11
|
it "can set ports for master host" do
|
12
|
-
expect(ec2.amiports(["master"])).to be === [22, 8140]
|
12
|
+
expect(ec2.amiports(["master"])).to be === [22, 61613, 8139, 8140]
|
13
13
|
end
|
14
14
|
|
15
15
|
it "can set ports for dashboard host" do
|
16
|
-
expect(ec2.amiports(["dashboard"])).to be === [22, 443]
|
16
|
+
expect(ec2.amiports(["dashboard"])).to be === [22, 61613, 8139, 443]
|
17
17
|
end
|
18
18
|
|
19
19
|
it "can set ports for combined master/database/dashboard host" do
|
20
|
-
expect(ec2.amiports(["dashboard", "master", "database"])).to be === [22, 8080, 8081, 8140, 443]
|
20
|
+
expect(ec2.amiports(["dashboard", "master", "database"])).to be === [22, 61613, 8139, 8080, 8081, 8140, 443]
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Beaker
|
4
4
|
describe Vagrant do
|
5
|
-
let( :options ) { make_opts.merge({ 'logger' => double().as_null_object }) }
|
5
|
+
let( :options ) { make_opts.merge({ 'logger' => double().as_null_object, :hosts_file => 'sample.cfg' }) }
|
6
6
|
let( :vagrant ) { Beaker::Vagrant.new( @hosts, options ) }
|
7
7
|
|
8
8
|
before :each do
|
@@ -20,6 +20,11 @@ module Beaker
|
|
20
20
|
expect(config['consoleport']).to be === 443
|
21
21
|
end
|
22
22
|
|
23
|
+
it "returns empty configuration when no file provided" do
|
24
|
+
FakeFS.deactivate!
|
25
|
+
expect(parser.parse_hosts_file()).to be === { :HOSTS => {} }
|
26
|
+
end
|
27
|
+
|
23
28
|
it "raises an error on no file found" do
|
24
29
|
FakeFS.deactivate!
|
25
30
|
expect{parser.parse_hosts_file("not a valid path")}.to raise_error(ArgumentError)
|
@@ -17,12 +17,12 @@ module Beaker
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "supports is_pe?, defaults to pe" do
|
20
|
-
expect(options.is_pe?)
|
20
|
+
expect(options.is_pe?).to be_true
|
21
21
|
end
|
22
22
|
|
23
23
|
it "supports is_pe?, respects :type == foss" do
|
24
24
|
options[:type] = 'foss'
|
25
|
-
expect(options.is_pe?)
|
25
|
+
expect(options.is_pe?).to be_false
|
26
26
|
end
|
27
27
|
|
28
28
|
it "can delete by string of symbol key" do
|
@@ -200,6 +200,12 @@ module Beaker
|
|
200
200
|
expect( hosts[:node1][:roles].include?('default') ).to be === true
|
201
201
|
end
|
202
202
|
|
203
|
+
it "makes a single non-master node default" do
|
204
|
+
@roles = [ ["database", "dashboard", "agent"] ]
|
205
|
+
parser.set_default_host!(node1)
|
206
|
+
expect( hosts[:node1][:roles].include?('default') ).to be === true
|
207
|
+
end
|
208
|
+
|
203
209
|
it "raises an error if two nodes are defined as default" do
|
204
210
|
@roles = [ ["master", "default"], ["default"] ]
|
205
211
|
expect{ parser.set_default_host!(hosts) }.to raise_error(ArgumentError)
|
@@ -11,14 +11,30 @@ module Beaker
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "removes all empty/nil entries in env_vars" do
|
14
|
-
expect(presets.env_vars.has_value?(nil)).to be === false
|
14
|
+
expect(presets.env_vars.has_value?(nil)).to be === false
|
15
|
+
expect(presets.env_vars.has_value?({})).to be === false
|
15
16
|
end
|
16
17
|
|
17
18
|
it "returns a presets OptionsHash" do
|
18
19
|
expect(presets.presets).to be_instance_of(Beaker::Options::OptionsHash)
|
19
20
|
end
|
20
21
|
|
21
|
-
|
22
|
+
describe 'when setting the type as pe from the environment' do
|
23
|
+
describe 'sets type to pe if...' do
|
24
|
+
it 'env var is set to "true"' do
|
25
|
+
munged = presets.munge_found_env_vars :is_pe => 'true'
|
26
|
+
expect( munged[:type] ).to be == 'pe'
|
27
|
+
end
|
28
|
+
it 'env var is set to "yes"' do
|
29
|
+
munged = presets.munge_found_env_vars :is_pe => 'yes'
|
30
|
+
expect( munged[:type] ).to be == 'pe'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
it 'does not set type otherwise' do
|
34
|
+
munged = presets.munge_found_env_vars :is_pe => 'false'
|
35
|
+
expect( munged[:type] ).to be == nil
|
36
|
+
end
|
37
|
+
end
|
22
38
|
end
|
23
39
|
end
|
24
40
|
end
|