mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
OpenStack server test updates for real mode.
Updates to the OpenStack server tests to get things running in *real* test mode. This patch also adds some useful helper functions which are now used to: -get the flavor ref for testing -get the image ref for testing -get the resize flavor ref for testing (defaults to flavor + 1) -disable password testing (not all hypervisors support this in OS)
This commit is contained in:
parent
11591b3ed9
commit
a1f13bb04f
3 changed files with 44 additions and 14 deletions
|
@ -1,10 +1,8 @@
|
||||||
Shindo.tests('Fog::Compute[:openstack] | address requests', ['openstack']) do
|
Shindo.tests('Fog::Compute[:openstack] | address requests', ['openstack']) do
|
||||||
|
|
||||||
compute = Fog::Compute[:openstack]
|
compute = Fog::Compute[:openstack]
|
||||||
flavor_ref = ENV['OPENSTACK_FLAVOR_REF'] || compute.list_flavors.body['flavors'].first['links'].first['href']
|
|
||||||
image_ref = ENV['OPENSTACK_IMAGE_REF'] || compute.list_images.body['images'].first['links'].first['href']
|
|
||||||
|
|
||||||
@server_id = compute.create_server("shindo_test_server", image_ref, flavor_ref).body['server']['id']
|
@server_id = compute.create_server("shindo_test_server", get_image_ref, get_flavor_ref).body['server']['id']
|
||||||
|
|
||||||
@address_format = {
|
@address_format = {
|
||||||
"instance_id" => NilClass,
|
"instance_id" => NilClass,
|
||||||
|
|
|
@ -15,3 +15,23 @@ class OpenStack
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_flavor_ref
|
||||||
|
compute = Fog::Compute[:openstack]
|
||||||
|
ENV['OPENSTACK_FLAVOR_REF'] || compute.list_flavors.body['flavors'].first['id']
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_image_ref
|
||||||
|
compute = Fog::Compute[:openstack]
|
||||||
|
ENV['OPENSTACK_IMAGE_REF'] || compute.list_images.body['images'].first['id']
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_flavor_ref_resize
|
||||||
|
# by default we simply add one to the default flavor ref
|
||||||
|
ENV['OPENSTACK_FLAVOR_REF_RESIZE'] || (get_flavor_ref.to_i + 1).to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_password_enabled
|
||||||
|
pw_enabled = ENV['OPENSTACK_SET_PASSWORD_ENABLED'] || "true"
|
||||||
|
return pw_enabled == "true"
|
||||||
|
end
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
Shindo.tests('Fog::Compute[:openstack] | server requests', ['openstack']) do
|
Shindo.tests('Fog::Compute[:openstack] | server requests', ['openstack']) do
|
||||||
|
|
||||||
@server_format = {
|
@server_format = {
|
||||||
|
'id' => String,
|
||||||
|
'links' => Array,
|
||||||
|
}
|
||||||
|
|
||||||
|
@detailed_server_format = {
|
||||||
'id' => String,
|
'id' => String,
|
||||||
'addresses' => Hash,
|
'addresses' => Hash,
|
||||||
'flavor' => Hash,
|
'flavor' => Hash,
|
||||||
|
@ -33,9 +38,9 @@ Shindo.tests('Fog::Compute[:openstack] | server requests', ['openstack']) do
|
||||||
|
|
||||||
tests('success') do
|
tests('success') do
|
||||||
|
|
||||||
@image_id = Fog::Compute[:openstack].images[0].id
|
@image_id = get_image_ref
|
||||||
@snapshot_id = nil
|
@snapshot_id = nil
|
||||||
@flavor_id = 2
|
@flavor_id = get_flavor_ref
|
||||||
|
|
||||||
tests('#create_server("test", #{@image_id} , 19)').formats(@server_format.merge('adminPass' => String), false) do
|
tests('#create_server("test", #{@image_id} , 19)').formats(@server_format.merge('adminPass' => String), false) do
|
||||||
data = Fog::Compute[:openstack].create_server("test", @image_id, @flavor_id).body['server']
|
data = Fog::Compute[:openstack].create_server("test", @image_id, @flavor_id).body['server']
|
||||||
|
@ -46,7 +51,7 @@ Shindo.tests('Fog::Compute[:openstack] | server requests', ['openstack']) do
|
||||||
Fog::Compute[:openstack].servers.get(@server_id).wait_for { ready? }
|
Fog::Compute[:openstack].servers.get(@server_id).wait_for { ready? }
|
||||||
|
|
||||||
#CREATE
|
#CREATE
|
||||||
tests("#get_server_details(#{@server_id})").formats(@server_format, false) do
|
tests("#get_server_details(#{@server_id})").formats(@detailed_server_format, false) do
|
||||||
Fog::Compute[:openstack].get_server_details(@server_id).body['server']
|
Fog::Compute[:openstack].get_server_details(@server_id).body['server']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -57,15 +62,17 @@ Shindo.tests('Fog::Compute[:openstack] | server requests', ['openstack']) do
|
||||||
end
|
end
|
||||||
|
|
||||||
#DETAILS
|
#DETAILS
|
||||||
tests('#list_servers_detail').formats({'servers' => [@server_format]}, false) do
|
tests('#list_servers_detail').formats({'servers' => [@detailed_server_format]}, false) do
|
||||||
Fog::Compute[:openstack].list_servers_detail.body
|
Fog::Compute[:openstack].list_servers_detail.body
|
||||||
end
|
end
|
||||||
|
|
||||||
#CHANGE PASSWORD
|
#CHANGE PASSWORD
|
||||||
tests("#change_server_password(#{@server_id}, 'fogupdatedserver')").succeeds do
|
if set_password_enabled
|
||||||
Fog::Compute[:openstack].change_server_password(@server_id, 'foggy')
|
tests("#change_server_password(#{@server_id}, 'fogupdatedserver')").succeeds do
|
||||||
|
Fog::Compute[:openstack].change_server_password(@server_id, 'foggy')
|
||||||
|
end
|
||||||
|
Fog::Compute[:openstack].servers.get(@server_id).wait_for { ready? }
|
||||||
end
|
end
|
||||||
Fog::Compute[:openstack].servers.get(@server_id).wait_for { ready? }
|
|
||||||
|
|
||||||
#UPDATE SERVER NAME
|
#UPDATE SERVER NAME
|
||||||
tests("#update_server(#{@server_id}, :name => 'fogupdatedserver')").succeeds do
|
tests("#update_server(#{@server_id}, :name => 'fogupdatedserver')").succeeds do
|
||||||
|
@ -82,19 +89,19 @@ Shindo.tests('Fog::Compute[:openstack] | server requests', ['openstack']) do
|
||||||
Fog::Compute[:openstack].images.get(@snapshot_id).wait_for { ready? }
|
Fog::Compute[:openstack].images.get(@snapshot_id).wait_for { ready? }
|
||||||
|
|
||||||
#REBUILD
|
#REBUILD
|
||||||
tests("#rebuild_server(#{@server_id}, #{@snapshot_id}, 'fog')").formats({'server' => @server_format}, false) do
|
tests("#rebuild_server(#{@server_id}, #{@snapshot_id}, 'fog')").formats({'server' => @detailed_server_format}, false) do
|
||||||
Fog::Compute[:openstack].rebuild_server(@server_id, @snapshot_id, 'fog', 'newpass', {"foo" => "bar"}).body
|
Fog::Compute[:openstack].rebuild_server(@server_id, @snapshot_id, 'fog', 'newpass', {"foo" => "bar"}).body
|
||||||
end
|
end
|
||||||
Fog::Compute[:openstack].servers.get(@server_id).wait_for { ready? } if not Fog.mocking?
|
Fog::Compute[:openstack].servers.get(@server_id).wait_for { ready? } if not Fog.mocking?
|
||||||
|
|
||||||
#RESIZE
|
#RESIZE
|
||||||
tests("#resize_server(#{@server_id}, '3')").succeeds do
|
tests("#resize_server(#{@server_id}, #{get_flavor_ref_resize})").succeeds do
|
||||||
Fog::Compute[:openstack].resize_server(@server_id, 3)
|
Fog::Compute[:openstack].resize_server(@server_id, get_flavor_ref_resize)
|
||||||
end
|
end
|
||||||
Fog::Compute[:openstack].servers.get(@server_id).wait_for { self.state == 'VERIFY_RESIZE' } if not Fog.mocking?
|
Fog::Compute[:openstack].servers.get(@server_id).wait_for { self.state == 'VERIFY_RESIZE' } if not Fog.mocking?
|
||||||
|
|
||||||
#RESIZE CONFIRM
|
#RESIZE CONFIRM
|
||||||
tests("#resize_confirm(#{@server_id}, '3')").succeeds do
|
tests("#resize_confirm(#{@server_id}, #{get_flavor_ref_resize})").succeeds do
|
||||||
Fog::Compute[:openstack].confirm_resize_server(@server_id)
|
Fog::Compute[:openstack].confirm_resize_server(@server_id)
|
||||||
end
|
end
|
||||||
Fog::Compute[:openstack].servers.get(@server_id).wait_for { ready? } if not Fog.mocking?
|
Fog::Compute[:openstack].servers.get(@server_id).wait_for { ready? } if not Fog.mocking?
|
||||||
|
@ -118,6 +125,11 @@ Shindo.tests('Fog::Compute[:openstack] | server requests', ['openstack']) do
|
||||||
Fog::Compute[:openstack].delete_server(@server_id)
|
Fog::Compute[:openstack].delete_server(@server_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#DELETE IMAGE
|
||||||
|
tests("#delete_image(#{@snapshot_id})").succeeds do
|
||||||
|
Fog::Compute[:openstack].delete_image(@snapshot_id)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
tests('failure') do
|
tests('failure') do
|
||||||
|
|
Loading…
Reference in a new issue