beaker 1.9.1 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +8 -8
  2. data/.simplecov +1 -0
  3. data/beaker.gemspec +2 -0
  4. data/lib/beaker/dsl/helpers.rb +15 -6
  5. data/lib/beaker/dsl/install_utils.rb +1 -1
  6. data/lib/beaker/host.rb +21 -2
  7. data/lib/beaker/host/aix/exec.rb +7 -0
  8. data/lib/beaker/host/unix.rb +4 -0
  9. data/lib/beaker/host/unix/exec.rb +8 -0
  10. data/lib/beaker/host/windows.rb +2 -0
  11. data/lib/beaker/host/windows/exec.rb +11 -0
  12. data/lib/beaker/host_prebuilt_steps.rb +7 -6
  13. data/lib/beaker/hypervisor.rb +6 -2
  14. data/lib/beaker/hypervisor/aws_sdk.rb +389 -0
  15. data/lib/beaker/hypervisor/blimper.rb +8 -23
  16. data/lib/beaker/hypervisor/ec2_helper.rb +28 -0
  17. data/lib/beaker/hypervisor/google_compute.rb +10 -8
  18. data/lib/beaker/hypervisor/google_compute_helper.rb +1 -1
  19. data/lib/beaker/hypervisor/vagrant.rb +8 -0
  20. data/lib/beaker/options/command_line_parser.rb +6 -0
  21. data/lib/beaker/options/parser.rb +1 -1
  22. data/lib/beaker/options/presets.rb +3 -0
  23. data/lib/beaker/ssh_connection.rb +2 -3
  24. data/lib/beaker/test_case.rb +2 -2
  25. data/lib/beaker/version.rb +1 -1
  26. data/spec/beaker/dsl/helpers_spec.rb +27 -5
  27. data/spec/beaker/dsl/install_utils_spec.rb +2 -2
  28. data/spec/beaker/host_prebuilt_steps_spec.rb +2 -2
  29. data/spec/beaker/hypervisor/aws_sdk_spec.rb +81 -0
  30. data/spec/beaker/hypervisor/blimper_spec.rb +0 -35
  31. data/spec/beaker/hypervisor/ec2_helper_spec.rb +23 -0
  32. data/spec/beaker/hypervisor/vagrant_spec.rb +22 -1
  33. data/spec/beaker/options/parser_spec.rb +4 -1
  34. data/spec/beaker/test_case_spec.rb +85 -1
  35. data/spec/mocks.rb +4 -0
  36. metadata +37 -2
@@ -38,40 +38,5 @@ module Beaker
38
38
  blimper.cleanup
39
39
  end
40
40
 
41
- context "amiports" do
42
-
43
- it "can set ports for database host" do
44
- host = @hosts[0]
45
- host[ :roles ] = [ "database" ]
46
-
47
- expect( blimper.amiports(host) ).to be === [ 22, 8080, 8081 ]
48
-
49
- end
50
-
51
- it "can set ports for master host" do
52
- host = @hosts[0]
53
- host[ :roles ] = [ "master" ]
54
-
55
- expect( blimper.amiports(host) ).to be === [ 22, 8140 ]
56
-
57
- end
58
-
59
- it "can set ports for dashboard host" do
60
- host = @hosts[0]
61
- host[ :roles ] = [ "dashboard" ]
62
-
63
- expect( blimper.amiports(host) ).to be === [ 22, 443 ]
64
- end
65
-
66
- it "can set ports for combined master/database/dashboard host" do
67
- host = @hosts[0]
68
- host[ :roles ] = [ "dashboard", "master", "database" ]
69
-
70
- expect( blimper.amiports(host) ).to be === [ 22, 8080, 8081, 8140, 443 ]
71
- end
72
- end
73
-
74
-
75
41
  end
76
-
77
42
  end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+ require 'beaker/hypervisor/ec2_helper'
3
+
4
+ describe Beaker::EC2Helper do
5
+ context ".amiports" do
6
+ let(:ec2) { Beaker::EC2Helper }
7
+ it "can set ports for database host" do
8
+ expect(ec2.amiports(["database"])).to be === [22, 8080, 8081]
9
+ end
10
+
11
+ it "can set ports for master host" do
12
+ expect(ec2.amiports(["master"])).to be === [22, 8140]
13
+ end
14
+
15
+ it "can set ports for dashboard host" do
16
+ expect(ec2.amiports(["dashboard"])).to be === [22, 443]
17
+ end
18
+
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]
21
+ end
22
+ end
23
+ end
@@ -18,7 +18,6 @@ module Beaker
18
18
 
19
19
  end
20
20
 
21
-
22
21
  it "can make a Vagranfile for a set of hosts" do
23
22
  FakeFS.activate!
24
23
  path = vagrant.instance_variable_get( :@vagrant_path )
@@ -29,6 +28,28 @@ module Beaker
29
28
  expect( File.read( File.expand_path( File.join( path, "Vagrantfile") ) ) ).to be === "Vagrant.configure(\"2\") do |c|\n c.vm.define 'vm1' do |v|\n v.vm.hostname = 'vm1'\n v.vm.box = 'vm1_of_my_box'\n v.vm.box_url = 'http://address.for.my.box.vm1'\n v.vm.base_mac = '0123456789'\n v.vm.network :private_network, ip: \"ip.address.for.vm1\", :netmask => \"255.255.0.0\"\n end\n c.vm.define 'vm2' do |v|\n v.vm.hostname = 'vm2'\n v.vm.box = 'vm2_of_my_box'\n v.vm.box_url = 'http://address.for.my.box.vm2'\n v.vm.base_mac = '0123456789'\n v.vm.network :private_network, ip: \"ip.address.for.vm2\", :netmask => \"255.255.0.0\"\n end\n c.vm.define 'vm3' do |v|\n v.vm.hostname = 'vm3'\n v.vm.box = 'vm3_of_my_box'\n v.vm.box_url = 'http://address.for.my.box.vm3'\n v.vm.base_mac = '0123456789'\n v.vm.network :private_network, ip: \"ip.address.for.vm3\", :netmask => \"255.255.0.0\"\n end\n c.vm.provider :virtualbox do |vb|\n vb.customize [\"modifyvm\", :id, \"--memory\", \"1024\"]\n end\nend\n"
30
29
  end
31
30
 
31
+ it "generates a valid windows config" do
32
+ FakeFS.activate!
33
+ path = vagrant.instance_variable_get( :@vagrant_path )
34
+ vagrant.stub( :randmac ).and_return( "0123456789" )
35
+ @hosts[0][:platform] = 'windows'
36
+
37
+ vagrant.make_vfile( @hosts )
38
+
39
+ generated_file = File.read( File.expand_path( File.join( path, "Vagrantfile") ) )
40
+
41
+ match = generated_file.match(/v.vm.network :forwarded_port, guest: 3389, host: 3389/)
42
+ expect( match ).to_not be_nil,'Should have proper port for RDP'
43
+
44
+ match = generated_file.match(/v.vm.network :forwarded_port, guest: 5985, host: 5985, id: 'winrm', auto_correct: true/)
45
+ expect( match ).to_not be_nil, "Should have proper port for WinRM"
46
+
47
+ match = generated_file.match(/v.vm.guest = :windows/)
48
+ expect( match ).to_not be_nil, 'Should correctly identify guest OS so Vagrant can act accordingly'
49
+
50
+
51
+ end
52
+
32
53
  it "uses the memsize defined per vagrant host" do
33
54
  FakeFS.activate!
34
55
  path = vagrant.instance_variable_get( :@vagrant_path )
@@ -132,8 +132,11 @@ module Beaker
132
132
 
133
133
  it "can correctly combine arguments from different sources" do
134
134
  FakeFS.deactivate!
135
+ build_url = ENV["BUILD_URL"]
136
+ ENV["BUILD_URL"] = "http://my.build.url/"
135
137
  args = ["-h", hosts_path, "--log-level", "debug", "--type", "git", "--install", "PUPPET/1.0,HIERA/hello"]
136
- expect(parser.parse_args(args)).to be === {:project=>"Beaker", :department=>"#{ENV['USER']}", :log_level=>"debug", :trace_limit=>10, :hosts_file=>hosts_path, :options_file=>nil, :type=>"git", :provision=>true, :preserve_hosts=>'never', :root_keys=>false, :quiet=>false, :xml=>false, :color=>true, :dry_run=>false, :timeout=>300, :fail_mode=>'slow', :timesync=>false, :repo_proxy=>false, :add_el_extras=>false, :add_master_entry=>false, :consoleport=>443, :pe_dir=>"/opt/enterprise/dists", :pe_version_file=>"LATEST", :pe_version_file_win=>"LATEST-win", :dot_fog=>"#{home}/.fog", :help=>false, :ec2_yaml=>"config/image_templates/ec2.yaml", :ssh=>{:config=>false, :paranoid=>false, :timeout=>300, :auth_methods=>["publickey"], :port=>22, :forward_agent=>true, :keys=>["#{home}/.ssh/id_rsa"], :user_known_hosts_file=>"#{home}/.ssh/known_hosts"}, :install=>["git://github.com/puppetlabs/puppet.git#1.0", "git://github.com/puppetlabs/hiera.git#hello"], :HOSTS=>{:"pe-ubuntu-lucid"=>{:roles=>["agent", "dashboard", "database", "master"], :vmname=>"pe-ubuntu-lucid", :platform=>"ubuntu-10.04-i386", :snapshot=>"clean-w-keys", :hypervisor=>"fusion"}, :"pe-centos6"=>{:roles=>["agent"], :vmname=>"pe-centos6", :platform=>"el-6-i386", :hypervisor=>"fusion", :snapshot=>"clean-w-keys"}}, :nfs_server=>"none", :helper=>[], :load_path=>[], :tests=>[], :pre_suite=>[], :post_suite=>[], :modules=>[]}
138
+ expect(parser.parse_args(args)).to be === {:project=>"Beaker", :department=>"#{ENV['USER']}", :validate=>true, :jenkins_build_url=> "http://my.build.url/", :log_level=>"debug", :trace_limit=>10, :hosts_file=>hosts_path, :options_file=>nil, :type=>"git", :provision=>true, :preserve_hosts=>'never', :root_keys=>false, :quiet=>false, :xml=>false, :color=>true, :dry_run=>false, :timeout=>300, :fail_mode=>'slow', :timesync=>false, :repo_proxy=>false, :add_el_extras=>false, :add_master_entry=>false, :consoleport=>443, :pe_dir=>"/opt/enterprise/dists", :pe_version_file=>"LATEST", :pe_version_file_win=>"LATEST-win", :dot_fog=>"#{home}/.fog", :help=>false, :ec2_yaml=>"config/image_templates/ec2.yaml", :ssh=>{:config=>false, :paranoid=>false, :timeout=>300, :auth_methods=>["publickey"], :port=>22, :forward_agent=>true, :keys=>["#{home}/.ssh/id_rsa"], :user_known_hosts_file=>"#{home}/.ssh/known_hosts"}, :install=>["git://github.com/puppetlabs/puppet.git#1.0", "git://github.com/puppetlabs/hiera.git#hello"], :HOSTS=>{:"pe-ubuntu-lucid"=>{:roles=>["agent", "dashboard", "database", "master"], :vmname=>"pe-ubuntu-lucid", :platform=>"ubuntu-10.04-i386", :snapshot=>"clean-w-keys", :hypervisor=>"fusion"}, :"pe-centos6"=>{:roles=>["agent"], :vmname=>"pe-centos6", :platform=>"el-6-i386", :hypervisor=>"fusion", :snapshot=>"clean-w-keys"}}, :nfs_server=>"none", :helper=>[], :load_path=>[], :tests=>[], :pre_suite=>[], :post_suite=>[], :modules=>[]}
139
+ ENV["BUILD_URL"] = build_url
137
140
  end
138
141
 
139
142
  it "ensures that fail-mode is one of fast/slow" do
@@ -1,6 +1,90 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Beaker
4
- describe TestCase do
4
+ describe TestCase, :use_fakefs => true do
5
+ let(:logger) { double('logger').as_null_object }
6
+ let(:path) { @path || '/tmp/nope' }
7
+ let(:testcase) { TestCase.new({}, logger, {}, path) }
8
+
9
+ context 'run_test' do
10
+ it 'defaults to test_status :pass on success' do
11
+ path = 'test.rb'
12
+ File.open(path, 'w') do |f|
13
+ f.write ""
14
+ end
15
+ @path = path
16
+ testcase.should_not_receive( :log_and_fail_test )
17
+ testcase.run_test
18
+ status = testcase.instance_variable_get(:@test_status)
19
+ expect(status).to be === :pass
20
+ end
21
+
22
+ it 'updates test_status to :skip on SkipTest' do
23
+ path = 'test.rb'
24
+ File.open(path, 'w') do |f|
25
+ f.write "raise SkipTest"
26
+ end
27
+ @path = path
28
+ testcase.should_not_receive( :log_and_fail_test )
29
+ testcase.run_test
30
+ status = testcase.instance_variable_get(:@test_status)
31
+ expect(status).to be === :skip
32
+ end
33
+
34
+ it 'updates test_status to :pending on PendingTest' do
35
+ path = 'test.rb'
36
+ File.open(path, 'w') do |f|
37
+ f.write "raise PendingTest"
38
+ end
39
+ @path = path
40
+ testcase.should_not_receive( :log_and_fail_test )
41
+ testcase.run_test
42
+ status = testcase.instance_variable_get(:@test_status)
43
+ expect(status).to be === :pending
44
+ end
45
+
46
+ it 'updates test_status to :fail on FailTest' do
47
+ path = 'test.rb'
48
+ File.open(path, 'w') do |f|
49
+ f.write "raise FailTest"
50
+ end
51
+ @path = path
52
+ testcase.should_not_receive( :log_and_fail_test )
53
+ testcase.run_test
54
+ status = testcase.instance_variable_get(:@test_status)
55
+ expect(status).to be === :fail
56
+ end
57
+
58
+ it 'correctly handles RuntimeError' do
59
+ path = 'test.rb'
60
+ File.open(path, 'w') do |f|
61
+ f.write "raise RuntimeError"
62
+ end
63
+ @path = path
64
+ testcase.should_receive( :log_and_fail_test ).once.with(kind_of(RuntimeError))
65
+ testcase.run_test
66
+ end
67
+
68
+ it 'correctly handles ScriptError' do
69
+ path = 'test.rb'
70
+ File.open(path, 'w') do |f|
71
+ f.write "raise ScriptError"
72
+ end
73
+ @path = path
74
+ testcase.should_receive( :log_and_fail_test ).once.with(kind_of(ScriptError))
75
+ testcase.run_test
76
+ end
77
+
78
+ it 'correctly handles Timeout::Error' do
79
+ path = 'test.rb'
80
+ File.open(path, 'w') do |f|
81
+ f.write "raise Timeout::Error"
82
+ end
83
+ @path = path
84
+ testcase.should_receive( :log_and_fail_test ).once.with(kind_of(Timeout::Error))
85
+ testcase.run_test
86
+ end
87
+ end
88
+
5
89
  end
6
90
  end
data/spec/mocks.rb CHANGED
@@ -65,6 +65,10 @@ class FakeHost
65
65
  @commands = []
66
66
  end
67
67
 
68
+ def port_open?(port)
69
+ true
70
+ end
71
+
68
72
  def is_pe?
69
73
  @pe
70
74
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppetlabs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-27 00:00:00.000000000 Z
11
+ date: 2014-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rspec
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -220,6 +234,20 @@ dependencies:
220
234
  - - ~>
221
235
  - !ruby/object:Gem::Version
222
236
  version: 0.6.4
237
+ - !ruby/object:Gem::Dependency
238
+ name: aws-sdk
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - ~>
242
+ - !ruby/object:Gem::Version
243
+ version: '1.38'
244
+ type: :runtime
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - ~>
249
+ - !ruby/object:Gem::Version
250
+ version: '1.38'
223
251
  - !ruby/object:Gem::Dependency
224
252
  name: nokogiri
225
253
  requirement: !ruby/object:Gem::Requirement
@@ -300,6 +328,7 @@ files:
300
328
  - lib/beaker/dsl/wrappers.rb
301
329
  - lib/beaker/host.rb
302
330
  - lib/beaker/host/aix.rb
331
+ - lib/beaker/host/aix/exec.rb
303
332
  - lib/beaker/host/aix/file.rb
304
333
  - lib/beaker/host/aix/group.rb
305
334
  - lib/beaker/host/aix/user.rb
@@ -318,7 +347,9 @@ files:
318
347
  - lib/beaker/host_prebuilt_steps.rb
319
348
  - lib/beaker/hypervisor.rb
320
349
  - lib/beaker/hypervisor/aixer.rb
350
+ - lib/beaker/hypervisor/aws_sdk.rb
321
351
  - lib/beaker/hypervisor/blimper.rb
352
+ - lib/beaker/hypervisor/ec2_helper.rb
322
353
  - lib/beaker/hypervisor/fusion.rb
323
354
  - lib/beaker/hypervisor/google_compute.rb
324
355
  - lib/beaker/hypervisor/google_compute_helper.rb
@@ -363,7 +394,9 @@ files:
363
394
  - spec/beaker/host_prebuilt_steps_spec.rb
364
395
  - spec/beaker/host_spec.rb
365
396
  - spec/beaker/hypervisor/aixer_spec.rb
397
+ - spec/beaker/hypervisor/aws_sdk_spec.rb
366
398
  - spec/beaker/hypervisor/blimper_spec.rb
399
+ - spec/beaker/hypervisor/ec2_helper_spec.rb
367
400
  - spec/beaker/hypervisor/fusion_spec.rb
368
401
  - spec/beaker/hypervisor/google_compute.rb
369
402
  - spec/beaker/hypervisor/hypervisor_spec.rb
@@ -440,7 +473,9 @@ test_files:
440
473
  - spec/beaker/host_prebuilt_steps_spec.rb
441
474
  - spec/beaker/host_spec.rb
442
475
  - spec/beaker/hypervisor/aixer_spec.rb
476
+ - spec/beaker/hypervisor/aws_sdk_spec.rb
443
477
  - spec/beaker/hypervisor/blimper_spec.rb
478
+ - spec/beaker/hypervisor/ec2_helper_spec.rb
444
479
  - spec/beaker/hypervisor/fusion_spec.rb
445
480
  - spec/beaker/hypervisor/google_compute.rb
446
481
  - spec/beaker/hypervisor/hypervisor_spec.rb