beaker 3.21.1 → 3.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +1 -1
- data/beaker.gemspec +9 -3
- data/docs/how_to/hypervisors/README.md +9 -7
- data/lib/beaker/dsl/helpers/host_helpers.rb +2 -2
- data/lib/beaker/host/pswindows/exec.rb +1 -1
- data/lib/beaker/hypervisor.rb +1 -15
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/host/pswindows/exec_spec.rb +2 -2
- metadata +26 -18
- data/docs/how_to/hypervisors/docker.md +0 -148
- data/docs/how_to/hypervisors/openstack.md +0 -166
- data/lib/beaker/hypervisor/docker.rb +0 -336
- data/lib/beaker/hypervisor/openstack.rb +0 -363
- data/spec/beaker/hypervisor/docker_spec.rb +0 -491
- data/spec/beaker/hypervisor/openstack_spec.rb +0 -238
@@ -1,238 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'fog'
|
3
|
-
|
4
|
-
module Beaker
|
5
|
-
describe OpenStack do
|
6
|
-
|
7
|
-
let(:options) { make_opts.merge({'logger' => double().as_null_object}) }
|
8
|
-
|
9
|
-
let(:openstack) {
|
10
|
-
OpenStack.new(@hosts, options)
|
11
|
-
}
|
12
|
-
|
13
|
-
before :each do
|
14
|
-
@hosts = make_hosts()
|
15
|
-
|
16
|
-
@compute_client = double().as_null_object
|
17
|
-
@network_client = double().as_null_object
|
18
|
-
|
19
|
-
allow( Fog::Compute ).to receive( :new ).and_return( @compute_client )
|
20
|
-
allow( Fog::Network ).to receive( :new ).and_return( @network_client )
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'keystone version support' do
|
24
|
-
it 'supports keystone v2' do
|
25
|
-
credentials = openstack.instance_eval('@credentials')
|
26
|
-
expect(credentials[:openstack_user_domain]).to be_nil
|
27
|
-
expect(credentials[:openstack_project_domain]).to be_nil
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'supports keystone v3 with implicit arguments' do
|
31
|
-
v3_options = options
|
32
|
-
v3_options[:openstack_auth_url] = 'https://example.com/identity/v3/auth'
|
33
|
-
|
34
|
-
credentials = OpenStack.new(@hosts, v3_options).instance_eval('@credentials')
|
35
|
-
expect(credentials[:openstack_user_domain]).to eq('Default')
|
36
|
-
expect(credentials[:openstack_project_domain]).to eq('Default')
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'supports keystone v3 with explicit arguments' do
|
40
|
-
v3_options = options
|
41
|
-
v3_options[:openstack_auth_url] = 'https://example.com/identity/v3/auth'
|
42
|
-
v3_options[:openstack_user_domain] = 'acme.com'
|
43
|
-
v3_options[:openstack_project_domain] = 'R&D'
|
44
|
-
|
45
|
-
credentials = OpenStack.new(@hosts, v3_options).instance_eval('@credentials')
|
46
|
-
expect(credentials[:openstack_user_domain]).to eq('acme.com')
|
47
|
-
expect(credentials[:openstack_project_domain]).to eq('R&D')
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe '#provision' do
|
52
|
-
|
53
|
-
it 'check openstack options during initialization' do
|
54
|
-
options = openstack.instance_eval('@options')
|
55
|
-
expect(options['openstack_api_key']).to eq('P1as$w0rd')
|
56
|
-
expect(options['openstack_username']).to eq('user')
|
57
|
-
expect(options['openstack_auth_url']).to eq('http://openstack_hypervisor.labs.net:5000/v2.0/tokens')
|
58
|
-
expect(options['openstack_tenant']).to eq('testing')
|
59
|
-
expect(options['openstack_network']).to eq('testing')
|
60
|
-
expect(options['openstack_keyname']).to eq('nopass')
|
61
|
-
expect(options['security_group']).to eq(['my_sg', 'default'])
|
62
|
-
expect(options['floating_ip_pool']).to eq('my_pool')
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'check hosts options during initialization' do
|
66
|
-
@hosts.each do |host|
|
67
|
-
expect(host['image']).to eq('default_image')
|
68
|
-
expect(host['flavor']).to eq('m1.large')
|
69
|
-
expect(host['user_data']).to eq('#cloud-config\nmanage_etc_hosts: true\nfinal_message: "The host is finally up!"')
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'check host options during server creation' do
|
74
|
-
|
75
|
-
mock_flavor = Object.new
|
76
|
-
allow( mock_flavor ).to receive( :id ).and_return( 12345 )
|
77
|
-
allow( openstack ).to receive( :flavor ).and_return( mock_flavor )
|
78
|
-
expect( openstack ).to receive( :flavor ).with( 'm1.large' )
|
79
|
-
|
80
|
-
mock_image = Object.new
|
81
|
-
allow( mock_image ).to receive( :id ).and_return( 54321 )
|
82
|
-
allow( openstack ).to receive( :image ).and_return( mock_image )
|
83
|
-
expect( openstack ).to receive( :image ).with( 'default_image' )
|
84
|
-
|
85
|
-
mock_servers = double().as_null_object
|
86
|
-
allow( @compute_client ).to receive( :servers ).and_return( mock_servers )
|
87
|
-
|
88
|
-
expect(mock_servers).to receive(:create).with(hash_including(
|
89
|
-
:user_data => '#cloud-config\nmanage_etc_hosts: true\nfinal_message: "The host is finally up!"',
|
90
|
-
:flavor_ref => 12345,
|
91
|
-
:image_ref => 54321)
|
92
|
-
)
|
93
|
-
|
94
|
-
@hosts.each do |host|
|
95
|
-
allow(host).to receive(:wait_for_port).and_return(true)
|
96
|
-
end
|
97
|
-
|
98
|
-
openstack.provision
|
99
|
-
end
|
100
|
-
|
101
|
-
it 'generates valid keynames during server creation' do
|
102
|
-
# Simulate getting a dynamic IP from OpenStack to test key generation code
|
103
|
-
# after provisioning. See _validate_new_key_pair in openstack/nova for reference
|
104
|
-
mock_ip = double().as_null_object
|
105
|
-
allow( openstack ).to receive( :get_ip ).and_return( mock_ip )
|
106
|
-
allow( mock_ip ).to receive( :ip ).and_return( '172.16.0.1' )
|
107
|
-
openstack.instance_eval('@options')['openstack_keyname'] = nil
|
108
|
-
|
109
|
-
@hosts.each do |host|
|
110
|
-
allow(host).to receive(:wait_for_port).and_return(true)
|
111
|
-
end
|
112
|
-
|
113
|
-
openstack.provision
|
114
|
-
|
115
|
-
@hosts.each do |host|
|
116
|
-
expect(host[:keyname]).to match(/^[_\-0-9a-zA-Z]+$/)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
it 'get_ip always allocates a new floatingip' do
|
121
|
-
# Assume beaker is being executed in parallel N times by travis (or similar).
|
122
|
-
# IPs are allocated (but not associated) before an instance is created; it is
|
123
|
-
# hightly possible the first instance will allocate a new IP and create an ssh
|
124
|
-
# key. While the instance is being created the other N-1 instances come along,
|
125
|
-
# find the unused IP and try to use it as well which causes keyname clashes
|
126
|
-
# and other IP related shenannigans. Ensure we allocate a new IP each and every
|
127
|
-
# time
|
128
|
-
mock_addresses = double().as_null_object
|
129
|
-
mock_ip = double().as_null_object
|
130
|
-
allow(@compute_client).to receive(:addresses).and_return(mock_addresses)
|
131
|
-
allow(mock_addresses).to receive(:create).and_return(mock_ip)
|
132
|
-
expect(mock_addresses).to receive(:create).exactly(3).times
|
133
|
-
(1..3).each { openstack.get_ip }
|
134
|
-
end
|
135
|
-
|
136
|
-
context 'volume creation option' do
|
137
|
-
it 'provisions volume by default' do
|
138
|
-
mock_flavor = Object.new
|
139
|
-
allow( mock_flavor ).to receive( :id ).and_return( 12345 )
|
140
|
-
allow( openstack ).to receive( :flavor ).and_return( mock_flavor )
|
141
|
-
mock_image = Object.new
|
142
|
-
allow( mock_image ).to receive( :id ).and_return( 54321 )
|
143
|
-
allow( openstack ).to receive( :image ).and_return( mock_image )
|
144
|
-
mock_servers = double().as_null_object
|
145
|
-
allow( @compute_client ).to receive( :servers ).and_return( mock_servers )
|
146
|
-
|
147
|
-
@hosts.each do |host|
|
148
|
-
allow(host).to receive(:wait_for_port).and_return(true)
|
149
|
-
expect(openstack).to receive(:provision_storage)
|
150
|
-
end
|
151
|
-
|
152
|
-
openstack.provision
|
153
|
-
end
|
154
|
-
|
155
|
-
it 'skips provisioning when disabled' do
|
156
|
-
mock_flavor = Object.new
|
157
|
-
allow( mock_flavor ).to receive( :id ).and_return( 12345 )
|
158
|
-
allow( openstack ).to receive( :flavor ).and_return( mock_flavor )
|
159
|
-
mock_image = Object.new
|
160
|
-
allow( mock_image ).to receive( :id ).and_return( 54321 )
|
161
|
-
allow( openstack ).to receive( :image ).and_return( mock_image )
|
162
|
-
mock_servers = double().as_null_object
|
163
|
-
allow( @compute_client ).to receive( :servers ).and_return( mock_servers )
|
164
|
-
|
165
|
-
openstack.instance_eval('@options')['openstack_volume_support'] = false
|
166
|
-
|
167
|
-
@hosts.each do |host|
|
168
|
-
allow(host).to receive(:wait_for_port).and_return(true)
|
169
|
-
expect(openstack).not_to receive(:provision_storage)
|
170
|
-
end
|
171
|
-
|
172
|
-
openstack.provision
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
describe '#provision_storage' do
|
178
|
-
|
179
|
-
it 'creates volumes with cinder v1' do
|
180
|
-
# Mock a volume
|
181
|
-
allow(openstack).to receive(:get_volumes).and_return({'volume1' => {'size' => 1000000 }})
|
182
|
-
|
183
|
-
# Stub out the call to create the client and hard code the return value
|
184
|
-
allow(openstack).to receive(:volume_client_create).and_return(nil)
|
185
|
-
client = double().as_null_object
|
186
|
-
openstack.instance_variable_set(:@volume_client, client)
|
187
|
-
allow(openstack).to receive(:get_volume_api_version).and_return(1)
|
188
|
-
|
189
|
-
# Check the parameters are valid, correct 'name' parameter and correct size conversion
|
190
|
-
mock_volume = double().as_null_object
|
191
|
-
expect(client).to receive(:create).with(:display_name => 'volume1',
|
192
|
-
:description => 'Beaker volume: host=alan volume=volume1',
|
193
|
-
:size => 1000
|
194
|
-
).and_return(mock_volume)
|
195
|
-
allow(mock_volume).to receive(:wait_for).and_return(nil)
|
196
|
-
|
197
|
-
# Perform the test!
|
198
|
-
mock_vm = double().as_null_object
|
199
|
-
allow(mock_volume).to receive(:id).and_return('Fake ID')
|
200
|
-
expect(mock_vm).to receive(:attach_volume).with('Fake ID', '/dev/vdb')
|
201
|
-
|
202
|
-
mock_host = double().as_null_object
|
203
|
-
allow(mock_host).to receive(:name).and_return('alan')
|
204
|
-
|
205
|
-
openstack.provision_storage mock_host, mock_vm
|
206
|
-
end
|
207
|
-
|
208
|
-
it 'creates volumes with cinder v2' do
|
209
|
-
# Mock a volume
|
210
|
-
allow(openstack).to receive(:get_volumes).and_return({'volume1' => {'size' => 1000000 }})
|
211
|
-
|
212
|
-
# Stub out the call to create the client and hard code the return value
|
213
|
-
allow(openstack).to receive(:volume_client_create).and_return(nil)
|
214
|
-
client = double().as_null_object
|
215
|
-
openstack.instance_variable_set(:@volume_client, client)
|
216
|
-
allow(openstack).to receive(:get_volume_api_version).and_return(-1)
|
217
|
-
|
218
|
-
# Check the parameters are valid, correct 'name' parameter and correct size conversion
|
219
|
-
mock_volume = double().as_null_object
|
220
|
-
expect(client).to receive(:create).with(:name => 'volume1',
|
221
|
-
:description => 'Beaker volume: host=alan volume=volume1',
|
222
|
-
:size => 1000
|
223
|
-
).and_return(mock_volume)
|
224
|
-
allow(mock_volume).to receive(:wait_for).and_return(nil)
|
225
|
-
|
226
|
-
# Perform the test!
|
227
|
-
mock_vm = double().as_null_object
|
228
|
-
allow(mock_volume).to receive(:id).and_return('Fake ID')
|
229
|
-
expect(mock_vm).to receive(:attach_volume).with('Fake ID', '/dev/vdb')
|
230
|
-
|
231
|
-
mock_host = double().as_null_object
|
232
|
-
allow(mock_host).to receive(:name).and_return('alan')
|
233
|
-
|
234
|
-
openstack.provision_storage mock_host, mock_vm
|
235
|
-
end
|
236
|
-
end
|
237
|
-
end
|
238
|
-
end
|