beaker 3.20.0 → 3.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/beaker.gemspec +4 -5
- data/docs/how_to/hypervisors/README.md +7 -3
- data/docs/tutorials/quick_start_rake_tasks.md +1 -1
- data/lib/beaker/command.rb +1 -1
- data/lib/beaker/host.rb +6 -4
- data/lib/beaker/host/windows/exec.rb +10 -0
- data/lib/beaker/host/windows/pkg.rb +1 -29
- data/lib/beaker/host_prebuilt_steps.rb +1 -0
- data/lib/beaker/hypervisor.rb +26 -37
- data/lib/beaker/ssh_connection.rb +8 -15
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/dsl/install_utils/windows_utils_spec.rb +1 -1
- data/spec/beaker/host/windows/exec_spec.rb +18 -0
- data/spec/beaker/host/windows/pkg_spec.rb +0 -7
- data/spec/beaker/host_prebuilt_steps_spec.rb +1 -0
- data/spec/beaker/host_spec.rb +31 -40
- data/spec/beaker/hypervisor/hypervisor_spec.rb +20 -34
- data/spec/beaker/ssh_connection_spec.rb +18 -19
- data/spec/spec_helper.rb +0 -1
- metadata +23 -57
- data/docs/how_to/hypervisors/aws.md +0 -149
- data/docs/how_to/hypervisors/ec2.md +0 -81
- data/docs/how_to/hypervisors/google_compute_engine.md +0 -41
- data/docs/how_to/hypervisors/vagrant.md +0 -165
- data/docs/how_to/hypervisors/vagrant_hosts_file_examples.md +0 -60
- data/docs/how_to/hypervisors/vagrant_libvirt.md +0 -58
- data/docs/how_to/hypervisors/vmware_fusion.md +0 -36
- data/docs/how_to/hypervisors/vsphere.md +0 -54
- data/lib/beaker/hypervisor/aws_sdk.rb +0 -989
- data/lib/beaker/hypervisor/ec2_helper.rb +0 -41
- data/lib/beaker/hypervisor/fusion.rb +0 -65
- data/lib/beaker/hypervisor/google_compute.rb +0 -164
- data/lib/beaker/hypervisor/google_compute_helper.rb +0 -577
- data/lib/beaker/hypervisor/vagrant.rb +0 -286
- data/lib/beaker/hypervisor/vagrant_custom.rb +0 -11
- data/lib/beaker/hypervisor/vagrant_fusion.rb +0 -17
- data/lib/beaker/hypervisor/vagrant_libvirt.rb +0 -41
- data/lib/beaker/hypervisor/vagrant_parallels.rb +0 -18
- data/lib/beaker/hypervisor/vagrant_virtualbox.rb +0 -76
- data/lib/beaker/hypervisor/vagrant_workstation.rb +0 -13
- data/lib/beaker/hypervisor/vsphere.rb +0 -85
- data/lib/beaker/hypervisor/vsphere_helper.rb +0 -204
- data/spec/beaker/hypervisor/aws_sdk_spec.rb +0 -980
- data/spec/beaker/hypervisor/ec2_helper_spec.rb +0 -44
- data/spec/beaker/hypervisor/fusion_spec.rb +0 -41
- data/spec/beaker/hypervisor/vagrant_custom_spec.rb +0 -46
- data/spec/beaker/hypervisor/vagrant_fusion_spec.rb +0 -32
- data/spec/beaker/hypervisor/vagrant_libvirt_spec.rb +0 -61
- data/spec/beaker/hypervisor/vagrant_parallels_spec.rb +0 -44
- data/spec/beaker/hypervisor/vagrant_spec.rb +0 -479
- data/spec/beaker/hypervisor/vagrant_virtualbox_spec.rb +0 -44
- data/spec/beaker/hypervisor/vagrant_workstation_spec.rb +0 -32
- data/spec/beaker/hypervisor/vsphere_helper_spec.rb +0 -163
- data/spec/beaker/hypervisor/vsphere_spec.rb +0 -90
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Beaker::VagrantVirtualbox do
|
4
|
-
let( :options ) { make_opts.merge({ :hosts_file => 'sample.cfg', 'logger' => double().as_null_object }) }
|
5
|
-
let( :vagrant ) { Beaker::VagrantVirtualbox.new( @hosts, options ) }
|
6
|
-
|
7
|
-
before :each do
|
8
|
-
@hosts = make_hosts()
|
9
|
-
end
|
10
|
-
|
11
|
-
it "uses the virtualbox provider for provisioning" do
|
12
|
-
@hosts.each do |host|
|
13
|
-
host_prev_name = host['user']
|
14
|
-
expect( vagrant ).to receive( :set_ssh_config ).with( host, 'vagrant' ).once
|
15
|
-
expect( vagrant ).to receive( :copy_ssh_to_root ).with( host, options ).once
|
16
|
-
expect( vagrant ).to receive( :set_ssh_config ).with( host, host_prev_name ).once
|
17
|
-
end
|
18
|
-
expect( vagrant ).to receive( :hack_etc_hosts ).with( @hosts, options ).once
|
19
|
-
expect( vagrant ).to receive( :vagrant_cmd ).with( "up --provider virtualbox" ).once
|
20
|
-
vagrant.provision
|
21
|
-
end
|
22
|
-
|
23
|
-
it "can make a Vagranfile for a set of hosts" do
|
24
|
-
path = vagrant.instance_variable_get( :@vagrant_path )
|
25
|
-
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
|
26
|
-
|
27
|
-
vagrant.make_vfile( @hosts )
|
28
|
-
|
29
|
-
vagrantfile = File.read( File.expand_path( File.join( path, 'Vagrantfile' )))
|
30
|
-
expect( vagrantfile ).to include( %Q{ v.vm.provider :virtualbox do |vb|\n vb.customize ['modifyvm', :id, '--memory', '1024', '--cpus', '1']\n end})
|
31
|
-
end
|
32
|
-
|
33
|
-
it "can disable the vb guest plugin" do
|
34
|
-
options.merge!({ :vbguest_plugin => 'disable' })
|
35
|
-
|
36
|
-
vfile_section = vagrant.class.provider_vfile_section( @hosts.first, options )
|
37
|
-
|
38
|
-
match = vfile_section.match(/vb.vbguest.auto_update = false/)
|
39
|
-
|
40
|
-
expect( match ).to_not be nil
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Beaker::VagrantWorkstation do
|
4
|
-
let( :options ) { make_opts.merge({ :hosts_file => 'sample.cfg', 'logger' => double().as_null_object }) }
|
5
|
-
let( :vagrant ) { Beaker::VagrantWorkstation.new( @hosts, options ) }
|
6
|
-
|
7
|
-
before :each do
|
8
|
-
@hosts = make_hosts()
|
9
|
-
end
|
10
|
-
|
11
|
-
it "uses the vmware_workstation provider for provisioning" do
|
12
|
-
@hosts.each do |host|
|
13
|
-
host_prev_name = host['user']
|
14
|
-
expect( vagrant ).to receive( :set_ssh_config ).with( host, 'vagrant' ).once
|
15
|
-
expect( vagrant ).to receive( :copy_ssh_to_root ).with( host, options ).once
|
16
|
-
expect( vagrant ).to receive( :set_ssh_config ).with( host, host_prev_name ).once
|
17
|
-
end
|
18
|
-
expect( vagrant ).to receive( :hack_etc_hosts ).with( @hosts, options ).once
|
19
|
-
expect( vagrant ).to receive( :vagrant_cmd ).with( "up --provider vmware_workstation" ).once
|
20
|
-
vagrant.provision
|
21
|
-
end
|
22
|
-
|
23
|
-
it "can make a Vagranfile for a set of hosts" do
|
24
|
-
path = vagrant.instance_variable_get( :@vagrant_path )
|
25
|
-
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
|
26
|
-
|
27
|
-
vagrant.make_vfile( @hosts )
|
28
|
-
|
29
|
-
vagrantfile = File.read( File.expand_path( File.join( path, "Vagrantfile")))
|
30
|
-
expect( vagrantfile ).to include( %Q{ v.vm.provider :vmware_workstation do |v|\n v.vmx['memsize'] = '1024'\n end})
|
31
|
-
end
|
32
|
-
end
|
@@ -1,163 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Beaker
|
4
|
-
describe VsphereHelper do
|
5
|
-
let( :logger ) { double('logger').as_null_object }
|
6
|
-
let( :vInfo ) { { :server => "vsphere.labs.net", :user => "vsphere@labs.com", :pass => "supersekritpassword" } }
|
7
|
-
let( :vsphere_helper ) { VsphereHelper.new ( vInfo.merge( { :logger => logger } ) ) }
|
8
|
-
let( :snaplist ) { { 'snap1' => { 'snap1sub1' => nil ,
|
9
|
-
'snap1sub2' => nil },
|
10
|
-
'snap2' => nil,
|
11
|
-
'snap3' => { 'snap3sub1' => nil ,
|
12
|
-
'snap3sub2' => nil ,
|
13
|
-
'snap3sub3' => nil } } }
|
14
|
-
let( :vms ) { [ MockRbVmomiVM.new( 'mockvm1', snaplist ),
|
15
|
-
MockRbVmomiVM.new( 'mockvm2', snaplist ),
|
16
|
-
MockRbVmomiVM.new( 'mockvm3', snaplist ) ] }
|
17
|
-
|
18
|
-
before :each do
|
19
|
-
stub_const( "RbVmomi", MockRbVmomi )
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "#load_config" do
|
23
|
-
|
24
|
-
it 'can load a .fog file' do
|
25
|
-
allow( File ).to receive( :exists? ).and_return( true )
|
26
|
-
allow( YAML ).to receive( :load_file ).and_return( fog_file_contents )
|
27
|
-
|
28
|
-
expect( VsphereHelper.load_config ).to be === vInfo
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'raises an error when the .fog file is missing' do
|
33
|
-
allow( File ).to receive( :exists? ).and_return( false )
|
34
|
-
|
35
|
-
expect{ VsphereHelper.load_config }.to raise_error( ArgumentError )
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "#find_snapshot" do
|
42
|
-
it 'can find a given snapshot name' do
|
43
|
-
mockvm = MockRbVmomiVM.new( 'mockvm', snaplist )
|
44
|
-
|
45
|
-
expect( vsphere_helper.find_snapshot( mockvm, 'snap2' ) ).to be === mockvm.get_snapshot( 'snap2' )
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "#find_customization" do
|
52
|
-
it 'returns the customization spec' do
|
53
|
-
|
54
|
-
expect( vsphere_helper.find_customization( 'name' ) ).to be === true
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "#find_vms" do
|
61
|
-
it 'finds the list of vms' do
|
62
|
-
connection = vsphere_helper.instance_variable_get( :@connection )
|
63
|
-
connection.set_info( vms )
|
64
|
-
|
65
|
-
expect( vsphere_helper.find_vms( 'mockvm1' ) ).to be === {vms[0].name => vms[0]}
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'returns {} when no vm is found' do
|
69
|
-
connection = vsphere_helper.instance_variable_get( :@connection )
|
70
|
-
connection.set_info( vms )
|
71
|
-
|
72
|
-
expect( vsphere_helper.find_vms( 'novm' ) ).to be === {}
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
describe "#find_datastore" do
|
78
|
-
it 'finds the datastore from the connection object' do
|
79
|
-
connection = vsphere_helper.instance_variable_get( :@connection )
|
80
|
-
dc = connection.serviceInstance.find_datacenter('testdc')
|
81
|
-
expect(vsphere_helper.find_datastore( dc,'datastorename' ) ).to be === true
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
describe "#find_folder" do
|
87
|
-
it 'can find a folder in the datacenter' do
|
88
|
-
connection = vsphere_helper.instance_variable_get( :@connection )
|
89
|
-
expect(vsphere_helper.find_folder( 'testdc','root' ) ).to be === connection.serviceInstance.find_datacenter('testdc').vmFolder
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
describe "#find_pool" do
|
95
|
-
it 'can find a pool in a folder in the datacenter' do
|
96
|
-
connection = vsphere_helper.instance_variable_get( :@connection )
|
97
|
-
dc = connection.serviceInstance.find_datacenter('testdc')
|
98
|
-
dc.hostFolder = MockRbVmomi::VIM::Folder.new
|
99
|
-
dc.hostFolder.name = "/root"
|
100
|
-
|
101
|
-
expect(vsphere_helper.find_pool( 'testdc','root' ) ).to be === connection.serviceInstance.find_datacenter('testdc').hostFolder
|
102
|
-
|
103
|
-
end
|
104
|
-
it 'can find a pool in a clustercomputeresource in the datacenter' do
|
105
|
-
connection = vsphere_helper.instance_variable_get( :@connection )
|
106
|
-
dc = connection.serviceInstance.find_datacenter('testdc')
|
107
|
-
dc.hostFolder = MockRbVmomi::VIM::ClusterComputeResource.new
|
108
|
-
dc.hostFolder.name = "/root"
|
109
|
-
|
110
|
-
expect(vsphere_helper.find_pool( 'testdc','root' ) ).to be === connection.serviceInstance.find_datacenter('testdc').hostFolder
|
111
|
-
end
|
112
|
-
it 'can find a pool in a resourcepool in the datacenter' do
|
113
|
-
connection = vsphere_helper.instance_variable_get( :@connection )
|
114
|
-
dc = connection.serviceInstance.find_datacenter('testdc')
|
115
|
-
dc.hostFolder = MockRbVmomi::VIM::ResourcePool.new
|
116
|
-
dc.hostFolder.name = "/root"
|
117
|
-
|
118
|
-
expect(vsphere_helper.find_pool( 'testdc','root' ) ).to be === connection.serviceInstance.find_datacenter('testdc').hostFolder
|
119
|
-
end
|
120
|
-
|
121
|
-
end
|
122
|
-
|
123
|
-
describe "#wait_for_tasks" do
|
124
|
-
it "can wait for tasks to error" do
|
125
|
-
allow( vsphere_helper ).to receive( :sleep ).and_return( true )
|
126
|
-
vms.each do |vm|
|
127
|
-
vm.info.state = 'error'
|
128
|
-
end
|
129
|
-
|
130
|
-
expect(vsphere_helper.wait_for_tasks( vms, 0, 5 ) ).to be === vms
|
131
|
-
end
|
132
|
-
|
133
|
-
it "can wait for tasks to succeed" do
|
134
|
-
allow( vsphere_helper ).to receive( :sleep ).and_return( true )
|
135
|
-
vms.each do |vm|
|
136
|
-
vm.info.state = 'success'
|
137
|
-
end
|
138
|
-
|
139
|
-
expect(vsphere_helper.wait_for_tasks( vms, 0, 5 ) ).to be === vms
|
140
|
-
end
|
141
|
-
|
142
|
-
it "errors when tasks fail to error/success before timing out" do
|
143
|
-
allow( vsphere_helper ).to receive( :sleep ).and_return( true )
|
144
|
-
vms.each do |vm|
|
145
|
-
vm.info.state = 'nope'
|
146
|
-
end
|
147
|
-
|
148
|
-
expect{ vsphere_helper.wait_for_tasks( vms, 0, 5 ) }.to raise_error
|
149
|
-
end
|
150
|
-
|
151
|
-
end
|
152
|
-
|
153
|
-
describe "#close" do
|
154
|
-
it 'closes the connection' do
|
155
|
-
connection = vsphere_helper.instance_variable_get( :@connection )
|
156
|
-
expect( connection ).to receive( :close ).once
|
157
|
-
|
158
|
-
vsphere_helper.close
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
end
|
163
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Beaker
|
4
|
-
describe Vsphere 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
|
-
end
|
11
|
-
|
12
|
-
describe "#provision" do
|
13
|
-
|
14
|
-
it 'provisions hosts' do
|
15
|
-
MockVsphereHelper.powerOff
|
16
|
-
vsphere = Beaker::Vsphere.new( make_hosts(), make_opts )
|
17
|
-
|
18
|
-
vsphere.provision
|
19
|
-
|
20
|
-
hosts = vsphere.instance_variable_get( :@hosts )
|
21
|
-
hosts.each do |host|
|
22
|
-
expect( MockVsphereHelper.find_vm( host.name ).powerState ) == "poweredOn"
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'raises an error if a vm is missing in Vsphere' do
|
28
|
-
MockVsphereHelper.powerOff
|
29
|
-
hosts = make_hosts()
|
30
|
-
hosts[0][:vmname] = 'unknown'
|
31
|
-
vsphere = Beaker::Vsphere.new( hosts, make_opts )
|
32
|
-
|
33
|
-
expect{ vsphere.provision }.to raise_error
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'raises an error if a vm does not have a given snapshot name' do
|
38
|
-
MockVsphereHelper.powerOff
|
39
|
-
hosts = make_hosts()
|
40
|
-
hosts[0]["snapshot"] = 'unknown'
|
41
|
-
vsphere = Beaker::Vsphere.new( hosts, make_opts )
|
42
|
-
|
43
|
-
expect{ vsphere.provision }.to raise_error
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'provisions hosts if no snapshot is provided' do
|
48
|
-
MockVsphereHelper.powerOff
|
49
|
-
hosts = make_hosts()
|
50
|
-
hosts[0]["snapshot"] = nil
|
51
|
-
vsphere = Beaker::Vsphere.new( hosts, make_opts )
|
52
|
-
|
53
|
-
vsphere.provision
|
54
|
-
|
55
|
-
hosts.each do |host|
|
56
|
-
expect( MockVsphereHelper.find_vm( host.name ).powerState ) == "poweredOn"
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
describe "#cleanup" do
|
64
|
-
|
65
|
-
it "cleans up" do
|
66
|
-
MockVsphereHelper.powerOn
|
67
|
-
vsphere = Beaker::Vsphere.new( make_hosts(), make_opts )
|
68
|
-
vsphere.cleanup
|
69
|
-
|
70
|
-
hosts = vsphere.instance_variable_get( :@hosts )
|
71
|
-
hosts.each do |host|
|
72
|
-
expect( MockVsphereHelper.find_vm( host.name ).powerState ) == "poweredOff"
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'raises an error if a vm is missing in Vsphere' do
|
77
|
-
MockVsphereHelper.powerOn
|
78
|
-
hosts = make_hosts()
|
79
|
-
hosts[0][:vmname] = 'unknown'
|
80
|
-
vsphere = Beaker::Vsphere.new( hosts, make_opts )
|
81
|
-
|
82
|
-
expect{ vsphere.cleanup }.to raise_error
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|