beaker 0.0.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +8 -0
- data/README.md +6 -6
- data/beaker.gemspec +6 -2
- data/lib/beaker.rb +1 -1
- data/lib/beaker/answers.rb +34 -7
- data/lib/beaker/answers/version20.rb +124 -0
- data/lib/beaker/answers/version28.rb +21 -0
- data/lib/beaker/answers/version30.rb +24 -5
- data/lib/beaker/cli.rb +55 -41
- data/lib/beaker/command.rb +2 -2
- data/lib/beaker/dsl/helpers.rb +320 -106
- data/lib/beaker/dsl/install_utils.rb +202 -81
- data/lib/beaker/dsl/roles.rb +40 -0
- data/lib/beaker/host.rb +28 -20
- data/lib/beaker/host/unix.rb +7 -4
- data/lib/beaker/host/unix/pkg.rb +42 -12
- data/lib/beaker/host/windows.rb +9 -5
- data/lib/beaker/host/windows/group.rb +1 -1
- data/lib/beaker/host/windows/pkg.rb +41 -8
- data/lib/beaker/hypervisor.rb +23 -10
- data/lib/beaker/hypervisor/aixer.rb +15 -19
- data/lib/beaker/hypervisor/blimper.rb +71 -72
- data/lib/beaker/hypervisor/fusion.rb +11 -10
- data/lib/beaker/hypervisor/solaris.rb +17 -23
- data/lib/beaker/hypervisor/vagrant.rb +27 -12
- data/lib/beaker/hypervisor/vcloud.rb +154 -138
- data/lib/beaker/hypervisor/vcloud_pooled.rb +97 -0
- data/lib/beaker/hypervisor/vsphere.rb +8 -5
- data/lib/beaker/hypervisor/vsphere_helper.rb +43 -33
- data/lib/beaker/network_manager.rb +16 -12
- data/lib/beaker/options/command_line_parser.rb +199 -0
- data/lib/beaker/options/hosts_file_parser.rb +39 -0
- data/lib/beaker/options/options_file_parser.rb +45 -0
- data/lib/beaker/options/options_hash.rb +294 -0
- data/lib/beaker/options/parser.rb +288 -0
- data/lib/beaker/options/pe_version_scraper.rb +35 -0
- data/lib/beaker/options/presets.rb +70 -0
- data/lib/beaker/shared.rb +2 -1
- data/lib/beaker/shared/host_handler.rb +7 -2
- data/lib/beaker/shared/repetition.rb +1 -0
- data/lib/beaker/shared/timed.rb +14 -0
- data/lib/beaker/test_case.rb +2 -38
- data/lib/beaker/test_suite.rb +11 -25
- data/lib/beaker/utils/repo_control.rb +6 -8
- data/lib/beaker/utils/setup_helper.rb +9 -20
- data/spec/beaker/answers_spec.rb +109 -0
- data/spec/beaker/command_spec.rb +2 -2
- data/spec/beaker/dsl/assertions_spec.rb +1 -3
- data/spec/beaker/dsl/helpers_spec.rb +519 -84
- data/spec/beaker/dsl/install_utils_spec.rb +265 -16
- data/spec/beaker/dsl/roles_spec.rb +31 -10
- data/spec/beaker/host/windows/group_spec.rb +55 -0
- data/spec/beaker/host_spec.rb +130 -40
- data/spec/beaker/hypervisor/aixer_spec.rb +34 -0
- data/spec/beaker/hypervisor/blimper_spec.rb +77 -0
- data/spec/beaker/hypervisor/fusion_spec.rb +26 -0
- data/spec/beaker/hypervisor/hypervisor_spec.rb +66 -0
- data/spec/beaker/hypervisor/solaris_spec.rb +39 -0
- data/spec/beaker/hypervisor/vagrant_spec.rb +105 -0
- data/spec/beaker/hypervisor/vcloud_pooled_spec.rb +60 -0
- data/spec/beaker/hypervisor/vcloud_spec.rb +70 -0
- data/spec/beaker/hypervisor/vsphere_helper_spec.rb +162 -0
- data/spec/beaker/hypervisor/vsphere_spec.rb +76 -0
- data/spec/beaker/options/command_line_parser_spec.rb +25 -0
- data/spec/beaker/options/data/LATEST +1 -0
- data/spec/beaker/options/data/badyaml.cfg +21 -0
- data/spec/beaker/options/data/hosts.cfg +21 -0
- data/spec/beaker/options/data/opts.txt +6 -0
- data/spec/beaker/options/hosts_file_parser_spec.rb +30 -0
- data/spec/beaker/options/options_file_parser_spec.rb +23 -0
- data/spec/beaker/options/options_hash_spec.rb +111 -0
- data/spec/beaker/options/parser_spec.rb +172 -0
- data/spec/beaker/options/pe_version_scaper_spec.rb +15 -0
- data/spec/beaker/options/presets_spec.rb +24 -0
- data/spec/beaker/puppet_command_spec.rb +54 -21
- data/spec/beaker/shared/error_handler_spec.rb +40 -0
- data/spec/beaker/shared/host_handler_spec.rb +104 -0
- data/spec/beaker/shared/repetition_spec.rb +72 -0
- data/spec/beaker/test_suite_spec.rb +3 -16
- data/spec/beaker/utils/ntp_control_spec.rb +42 -0
- data/spec/beaker/utils/repo_control_spec.rb +168 -0
- data/spec/beaker/utils/setup_helper_spec.rb +82 -0
- data/spec/beaker/utils/validator_spec.rb +58 -0
- data/spec/helpers.rb +97 -0
- data/spec/matchers.rb +39 -0
- data/spec/mock_blimpy.rb +48 -0
- data/spec/mock_fission.rb +60 -0
- data/spec/mock_vsphere.rb +310 -0
- data/spec/mock_vsphere_helper.rb +183 -0
- data/spec/mocks.rb +83 -0
- data/spec/spec_helper.rb +8 -1
- metadata +106 -13
- data/beaker.rb +0 -10
- data/lib/beaker/options_parsing.rb +0 -323
- data/lib/beaker/test_config.rb +0 -148
- data/spec/beaker/options_parsing_spec.rb +0 -37
- data/spec/mocks_and_helpers.rb +0 -34
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Beaker
|
4
|
+
describe Aixer do
|
5
|
+
let( :aixer) { Beaker::Aixer.new( @hosts, make_opts ) }
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
@hosts = make_hosts()
|
9
|
+
File.stub( :exists? ).and_return( true )
|
10
|
+
YAML.stub( :load_file ).and_return( fog_file_contents )
|
11
|
+
Host.any_instance.stub( :exec ).and_return( true )
|
12
|
+
end
|
13
|
+
|
14
|
+
it "can provision a set of hosts" do
|
15
|
+
@hosts.each do |host|
|
16
|
+
Command.should_receive( :new ).with( "cd pe-aix && rake restore:#{host.name}" ).once
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
aixer.provision
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
it "does nothing for cleanup" do
|
25
|
+
Command.should_receive( :new ).never
|
26
|
+
Host.should_receive( :exec ).never
|
27
|
+
|
28
|
+
aixer.cleanup
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'blimpy'
|
3
|
+
|
4
|
+
module Beaker
|
5
|
+
describe Blimper do
|
6
|
+
let( :blimper ) { Beaker::Blimper.new( @hosts, make_opts ) }
|
7
|
+
let( :amispec ) { { "centos-5-x86-64-west" => { :image => { :pe => "ami-sekrit1" }, :region => "us-west-2" },
|
8
|
+
"centos-6-x86-64-west" => { :image => { :pe => "ami-sekrit2" }, :region => "us-west-2" },
|
9
|
+
"centos-7-x86-64-west" => { :image => { :pe => "ami-sekrit3" }, :region => "us-west-2" } }}
|
10
|
+
|
11
|
+
before :each do
|
12
|
+
@hosts = make_hosts( { :snapshot => :pe })
|
13
|
+
@hosts[0][:platform] = "centos-5-x86-64-west"
|
14
|
+
@hosts[1][:platform] = "centos-6-x86-64-west"
|
15
|
+
@hosts[2][:platform] = "centos-7-x86-64-west"
|
16
|
+
blimper.instance_variable_set( :@blimpy, MockBlimpy )
|
17
|
+
end
|
18
|
+
|
19
|
+
it "can provision a set of hosts" do
|
20
|
+
YAML.stub( :load_file ).and_return( {"AMI" => amispec} )
|
21
|
+
blimper.stub( :get_ip ) do |host|
|
22
|
+
host['ip']
|
23
|
+
end
|
24
|
+
blimper.stub( :get_domain_name ).and_return( 'domain' )
|
25
|
+
blimper.stub( :sleep ).and_return( true )
|
26
|
+
|
27
|
+
@hosts.each do |host|
|
28
|
+
blimper.should_receive( :set_etc_hosts ).with( host, "127.0.0.1\tlocalhost localhost.localdomain\nvm1.my.ip\tvm1\tvm1.domain\nvm2.my.ip\tvm2\tvm2.domain\nvm3.my.ip\tvm3\tvm3.domain\n" )
|
29
|
+
end
|
30
|
+
|
31
|
+
blimper.provision
|
32
|
+
end
|
33
|
+
|
34
|
+
it "calls fleet.destroy on cleanup" do
|
35
|
+
MockFleet.any_instance.should_receive( :add ).with( :aws ).exactly( @hosts.length ).times
|
36
|
+
MockFleet.any_instance.should_receive( :destroy ).once
|
37
|
+
|
38
|
+
blimper.cleanup
|
39
|
+
end
|
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
|
+
end
|
76
|
+
|
77
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Beaker
|
4
|
+
describe Fusion do
|
5
|
+
let( :fusion ) { Beaker::Fusion.new( @hosts, make_opts ) }
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
stub_const( "Fission::VM", true )
|
9
|
+
@hosts = make_hosts()
|
10
|
+
MockFission.presets( @hosts )
|
11
|
+
Fusion.any_instance.stub( :require ).with( 'fission' ).and_return( true )
|
12
|
+
fusion.instance_variable_set( :@fission, MockFission )
|
13
|
+
end
|
14
|
+
|
15
|
+
it "can interoperate with the fission library to provision hosts" do
|
16
|
+
fusion.provision
|
17
|
+
end
|
18
|
+
|
19
|
+
it "raises an error if unknown snapshot name is used" do
|
20
|
+
@hosts[0][:snapshot] = 'unknown'
|
21
|
+
expect{ fusion.provision }.to raise_error
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Beaker
|
4
|
+
describe Hypervisor do
|
5
|
+
let( :hypervisor ) { Beaker::Hypervisor }
|
6
|
+
|
7
|
+
it "creates an aix hypervisor for aix hosts" do
|
8
|
+
aix = double( 'aix' )
|
9
|
+
aix.stub( :provision ).and_return( true )
|
10
|
+
|
11
|
+
Aixer.should_receive( :new ).once.and_return( aix )
|
12
|
+
expect( hypervisor.create( 'aix', [], make_opts() ) ).to be === aix
|
13
|
+
end
|
14
|
+
|
15
|
+
it "creates a solaris hypervisor for solaris hosts" do
|
16
|
+
solaris = double( 'solaris' )
|
17
|
+
solaris.stub( :provision ).and_return( true )
|
18
|
+
Solaris.should_receive( :new ).once.and_return( solaris )
|
19
|
+
expect( hypervisor.create( 'solaris', [], make_opts() ) ).to be === solaris
|
20
|
+
end
|
21
|
+
|
22
|
+
it "creates a vsphere hypervisor for vsphere hosts" do
|
23
|
+
vsphere = double( 'vsphere' )
|
24
|
+
vsphere.stub( :provision ).and_return( true )
|
25
|
+
Vsphere.should_receive( :new ).once.and_return( vsphere )
|
26
|
+
expect( hypervisor.create( 'vsphere', [], make_opts() ) ).to be === vsphere
|
27
|
+
end
|
28
|
+
|
29
|
+
it "creates a fusion hypervisor for fusion hosts" do
|
30
|
+
fusion = double( 'fusion' )
|
31
|
+
fusion.stub( :provision ).and_return( true )
|
32
|
+
Fusion.should_receive( :new ).once.and_return( fusion )
|
33
|
+
expect( hypervisor.create( 'fusion', [], make_opts() ) ).to be === fusion
|
34
|
+
end
|
35
|
+
|
36
|
+
it "creates a vcloudpooled hypervisor for vcloud hosts that are pooled" do
|
37
|
+
vcloud = double( 'vcloud' )
|
38
|
+
vcloud.stub( :provision ).and_return( true )
|
39
|
+
VcloudPooled.should_receive( :new ).once.and_return( vcloud )
|
40
|
+
expect( hypervisor.create( 'vcloud', [], make_opts().merge( { 'pooling_api' => true } ) ) ).to be === vcloud
|
41
|
+
end
|
42
|
+
|
43
|
+
it "creates a vcloud hypervisor for vcloud hosts that are not pooled" do
|
44
|
+
vcloud = double( 'vcloud' )
|
45
|
+
vcloud.stub( :provision ).and_return( true )
|
46
|
+
Vcloud.should_receive( :new ).once.and_return( vcloud )
|
47
|
+
expect( hypervisor.create( 'vcloud', [], make_opts().merge( { 'pooling_api' => false } ) ) ).to be === vcloud
|
48
|
+
end
|
49
|
+
|
50
|
+
it "creates a vagrant hypervisor for vagrant hosts" do
|
51
|
+
vagrant = double( 'vagrant' )
|
52
|
+
vagrant.stub( :provision ).and_return( true )
|
53
|
+
Vagrant.should_receive( :new ).once.and_return( vagrant )
|
54
|
+
expect( hypervisor.create( 'vagrant', [], make_opts() ) ).to be === vagrant
|
55
|
+
end
|
56
|
+
|
57
|
+
it "creates a blimpy hypervisor for blimpy hosts" do
|
58
|
+
blimpy = double( 'blimpy' )
|
59
|
+
blimpy.stub( :provision ).and_return( true )
|
60
|
+
Blimper.should_receive( :new ).once.and_return( blimpy )
|
61
|
+
expect( hypervisor.create( 'blimpy', [], make_opts() ) ).to be === blimpy
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Beaker
|
4
|
+
describe Solaris do
|
5
|
+
let( :solaris) { Beaker::Solaris.new( @hosts, make_opts ) }
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
@hosts = make_hosts()
|
9
|
+
File.stub( :exists? ).and_return( true )
|
10
|
+
YAML.stub( :load_file ).and_return( fog_file_contents )
|
11
|
+
Host.any_instance.stub( :exec ).and_return( true )
|
12
|
+
end
|
13
|
+
|
14
|
+
it "can provision a set of hosts" do
|
15
|
+
vmpath = "rpoooool/zs"
|
16
|
+
spath = "rpoooool/USER/z0"
|
17
|
+
|
18
|
+
@hosts.each do |host|
|
19
|
+
vm_name = host['vmname'] || host.name
|
20
|
+
snapshot = host['snapshot']
|
21
|
+
Command.should_receive( :new ).with("sudo /sbin/zfs rollback -Rf #{vmpath}/#{vm_name}@#{snapshot}").once
|
22
|
+
Command.should_receive( :new ).with("sudo /sbin/zfs rollback -Rf #{vmpath}/#{vm_name}/#{spath}@#{snapshot}").once
|
23
|
+
Command.should_receive( :new ).with("sudo /sbin/zoneadm -z #{vm_name} boot").once
|
24
|
+
end
|
25
|
+
|
26
|
+
solaris.provision
|
27
|
+
end
|
28
|
+
|
29
|
+
it "does nothing for cleanup" do
|
30
|
+
Command.should_receive( :new ).never
|
31
|
+
Host.should_receive( :exec ).never
|
32
|
+
|
33
|
+
solaris.cleanup
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Beaker
|
4
|
+
describe Vagrant do
|
5
|
+
let( :vagrant ) { Beaker::Vagrant.new( @hosts, make_opts ) }
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
@hosts = make_hosts()
|
9
|
+
end
|
10
|
+
|
11
|
+
it "can make a Vagranfile for a set of hosts" do
|
12
|
+
FakeFS.activate!
|
13
|
+
path = vagrant.instance_variable_get( :@vagrant_path )
|
14
|
+
vagrant.stub( :randmac ).and_return( "0123456789" )
|
15
|
+
|
16
|
+
vagrant.make_vfile( @hosts )
|
17
|
+
|
18
|
+
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"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "can generate a new /etc/hosts file referencing each host" do
|
22
|
+
|
23
|
+
@hosts.each do |host|
|
24
|
+
vagrant.should_receive( :set_etc_hosts ).with( host, "127.0.0.1\tlocalhost localhost.localdomain\nip.address.for.vm1\tvm1\nip.address.for.vm2\tvm2\nip.address.for.vm3\tvm3\n" ).once
|
25
|
+
end
|
26
|
+
|
27
|
+
vagrant.hack_etc_hosts( @hosts )
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
context "can copy vagrant's key to root .ssh on each host" do
|
32
|
+
|
33
|
+
it "can copy to root on unix" do
|
34
|
+
host = @hosts[0]
|
35
|
+
host[:platform] = 'unix'
|
36
|
+
|
37
|
+
Command.should_receive( :new ).with("sudo su -c \"cp -r .ssh /root/.\"").once
|
38
|
+
|
39
|
+
vagrant.copy_ssh_to_root( host )
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
it "can copy to Administrator on windows" do
|
44
|
+
host = @hosts[0]
|
45
|
+
host[:platform] = 'windows'
|
46
|
+
|
47
|
+
Command.should_receive( :new ).with("sudo su -c \"cp -r .ssh /home/Administrator/.\"").once
|
48
|
+
|
49
|
+
vagrant.copy_ssh_to_root( host )
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it "can generate a ssh-config file" do
|
55
|
+
host = @hosts[0]
|
56
|
+
name = host.name
|
57
|
+
Dir.stub( :chdir ).and_yield()
|
58
|
+
|
59
|
+
out = double( 'stdout' )
|
60
|
+
out.stub( :read ).and_return("Host #{host.name}
|
61
|
+
HostName 127.0.0.1
|
62
|
+
User vagrant
|
63
|
+
Port 2222
|
64
|
+
UserKnownHostsFile /dev/null
|
65
|
+
StrictHostKeyChecking no
|
66
|
+
PasswordAuthentication no
|
67
|
+
IdentityFile /home/root/.vagrant.d/insecure_private_key
|
68
|
+
IdentitiesOnly yes")
|
69
|
+
|
70
|
+
Open3.stub( :popen3 ).with( 'vagrant', 'ssh-config', host.name ).and_return( [ "", out ])
|
71
|
+
|
72
|
+
file = double( 'file' )
|
73
|
+
file.stub( :path ).and_return( '/path/sshconfig' )
|
74
|
+
file.stub( :rewind ).and_return( true )
|
75
|
+
|
76
|
+
Tempfile.should_receive( :new ).with( "#{host.name}").and_return( file )
|
77
|
+
file.should_receive( :write ).with("Host ip.address.for.#{name}\n HostName 127.0.0.1\n User root\n Port 2222\n UserKnownHostsFile /dev/null\n StrictHostKeyChecking no\n PasswordAuthentication no\n IdentityFile /home/root/.vagrant.d/insecure_private_key\n IdentitiesOnly yes")
|
78
|
+
|
79
|
+
vagrant.set_ssh_config( host, 'root' )
|
80
|
+
expect( host['ssh'] ).to be === { :config => file.path }
|
81
|
+
expect( host['user']).to be === 'root'
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
it "can provision a set of hosts" do
|
86
|
+
|
87
|
+
vagrant.should_receive( :make_vfile ).with( @hosts ).once
|
88
|
+
|
89
|
+
vagrant.should_receive( :vagrant_cmd ).with( "halt" ).once
|
90
|
+
vagrant.should_receive( :vagrant_cmd ).with( "up" ).once
|
91
|
+
@hosts.each do |host|
|
92
|
+
host_prev_name = host['user']
|
93
|
+
vagrant.should_receive( :set_ssh_config ).with( host, 'vagrant' ).once
|
94
|
+
vagrant.should_receive( :copy_ssh_to_root ).with( host ).once
|
95
|
+
vagrant.should_receive( :set_ssh_config ).with( host, host_prev_name ).once
|
96
|
+
end
|
97
|
+
vagrant.should_receive( :hack_etc_hosts ).with( @hosts ).once
|
98
|
+
|
99
|
+
|
100
|
+
vagrant.provision
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Beaker
|
4
|
+
describe VcloudPooled do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
vms = make_hosts()
|
8
|
+
MockVsphereHelper.set_config( fog_file_contents )
|
9
|
+
MockVsphereHelper.set_vms( vms )
|
10
|
+
stub_const( "VsphereHelper", MockVsphereHelper )
|
11
|
+
stub_const( "Net", MockNet )
|
12
|
+
JSON.stub( :parse ) do |arg|
|
13
|
+
arg
|
14
|
+
end
|
15
|
+
Socket.stub( :getaddrinfo ).and_return( true )
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#provision" do
|
19
|
+
|
20
|
+
it 'provisions hosts from the pool' do
|
21
|
+
|
22
|
+
vcloud = Beaker::VcloudPooled.new( make_hosts, make_opts )
|
23
|
+
vcloud.stub( :require ).and_return( true )
|
24
|
+
vcloud.stub( :sleep ).and_return( true )
|
25
|
+
vcloud.provision
|
26
|
+
|
27
|
+
hosts = vcloud.instance_variable_get( :@vcloud_hosts )
|
28
|
+
hosts.each do | host |
|
29
|
+
expect( host['vmhostname'] ).to be === 'pool'
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#cleanup" do
|
37
|
+
|
38
|
+
it "cleans up hosts in the pool" do
|
39
|
+
MockVsphereHelper.powerOn
|
40
|
+
|
41
|
+
vcloud = Beaker::VcloudPooled.new( make_hosts, make_opts )
|
42
|
+
vcloud.stub( :require ).and_return( true )
|
43
|
+
vcloud.stub( :sleep ).and_return( true )
|
44
|
+
vcloud.provision
|
45
|
+
vcloud.cleanup
|
46
|
+
|
47
|
+
hosts = vcloud.instance_variable_get( :@vcloud_hosts )
|
48
|
+
hosts.each do | host |
|
49
|
+
name = host.name
|
50
|
+
vm = MockVsphereHelper.find_vm( name )
|
51
|
+
expect( vm.runtime.powerState ).to be === "poweredOn" #handed back to the pool, stays on
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Beaker
|
4
|
+
describe Vcloud do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
MockVsphereHelper.set_config( fog_file_contents )
|
8
|
+
MockVsphereHelper.set_vms( make_hosts() )
|
9
|
+
stub_const( "VsphereHelper", MockVsphereHelper )
|
10
|
+
stub_const( "Net", MockNet )
|
11
|
+
json = mock( 'json' )
|
12
|
+
json.stub( :parse ) do |arg|
|
13
|
+
arg
|
14
|
+
end
|
15
|
+
stub_const( "JSON", json )
|
16
|
+
Socket.stub( :getaddrinfo ).and_return( true )
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#provision" do
|
20
|
+
|
21
|
+
it 'provisions hosts and add them to the pool' do
|
22
|
+
MockVsphereHelper.powerOff
|
23
|
+
|
24
|
+
opts = make_opts
|
25
|
+
opts[:pooling_api] = nil
|
26
|
+
|
27
|
+
vcloud = Beaker::Vcloud.new( make_hosts, opts )
|
28
|
+
vcloud.stub( :require ).and_return( true )
|
29
|
+
vcloud.stub( :sleep ).and_return( true )
|
30
|
+
vcloud.provision
|
31
|
+
|
32
|
+
hosts = vcloud.instance_variable_get( :@vcloud_hosts )
|
33
|
+
hosts.each do | host |
|
34
|
+
name = host['vmhostname']
|
35
|
+
vm = MockVsphereHelper.find_vm( name )
|
36
|
+
expect( vm.toolsRunningStatus ).to be === "guestToolsRunning"
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#cleanup" do
|
44
|
+
|
45
|
+
it "cleans up hosts not in the pool" do
|
46
|
+
MockVsphereHelper.powerOn
|
47
|
+
|
48
|
+
opts = make_opts
|
49
|
+
opts[:pooling_api] = nil
|
50
|
+
|
51
|
+
vcloud = Beaker::Vcloud.new( make_hosts, opts )
|
52
|
+
vcloud.stub( :require ).and_return( true )
|
53
|
+
vcloud.stub( :sleep ).and_return( true )
|
54
|
+
vcloud.provision
|
55
|
+
vcloud.cleanup
|
56
|
+
|
57
|
+
hosts = vcloud.instance_variable_get( :@vcloud_hosts )
|
58
|
+
vm_names = hosts.map {|h| h['vmhostname'] }.compact
|
59
|
+
vm_names.each do | name |
|
60
|
+
vm = MockVsphereHelper.find_vm( name )
|
61
|
+
expect( vm.runtime.powerState ).to be === "poweredOff"
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|