lib/torpedo/compute/servers.rb in torpedo-1.0.3 vs lib/torpedo/compute/servers.rb in torpedo-1.0.4
- old
+ new
@@ -7,10 +7,11 @@
@@servers = []
@@images = []
@@image_ref = Helper::get_image_ref(Helper::get_connection)
@@flavor_ref = Helper::get_flavor_ref(Helper::get_connection)
+ @@flavor_ref_resize = Helper::get_flavor_ref_resize(@conn)
@@server = nil #ref to last created server
def setup
@conn=Helper::get_connection
end
@@ -80,11 +81,11 @@
begin
timeout(SERVER_BUILD_TIMEOUT) do
until server.status == check_status do
if server.status == "ERROR" then
- fail('Server ERROR state detected when booting instance!')
+ fail('Server ERROR state detected when booting server!')
end
server = @conn.server(server.id)
sleep 1
end
end
@@ -114,11 +115,11 @@
options[:key_name] = KEYNAME
end
server = create_server(options)
assert_not_nil(@@server.adminPass)
- #boot an instance and check it
+ #boot a server and check it
check_server(server, @@image_ref, @@flavor_ref)
assert_equal "value1", @@server.metadata['key1']
assert_equal "value2", @@server.metadata['key2']
assert_equal 2, @@server.metadata.size
@@ -224,12 +225,57 @@
# Overwrite image_ref to make all subsequent tests use this snapshot
@@image_ref = image.id.to_s
end if TEST_CREATE_IMAGE
- def test_021_delete_image_metadata_items
+
+ def test_030_rebuild
+ # make sure our snapshot boots
+ personalities={SSH_PUBLIC_KEY => "/root/.ssh/authorized_keys"}
+ @@server.rebuild!(:imageRef => @@image_ref, :personality => personalities)
+ server = @conn.server(@@server.id)
+ sleep 15 # sleep a couple seconds until rebuild starts
+ check_server(server, @@image_ref, @@flavor_ref)
+ end if TEST_REBUILD_SERVER
+
+ def test_040_resize
+
+ @@server.resize!(@@flavor_ref_resize)
+ server = @conn.server(@@server.id)
+ assert_equal('RESIZE', server.status)
+
+ begin
+ timeout(SERVER_BUILD_TIMEOUT) do
+ until server.status == 'VERIFY_RESIZE' do
+ if server.status == "ERROR" then
+ fail('Server ERROR state detected when resizing server!')
+ end
+ server = @conn.server(server.id)
+ sleep 1
+ end
+ end
+ rescue Timeout::Error => te
+ fail('Timeout resizing server.')
+ end
+
+ check_server(server, @@image_ref, @@flavor_ref_resize, 'VERIFY_RESIZE')
+
+ end if TEST_RESIZE_SERVER
+
+ def test_041_resize_confirm
+
+ @@server.confirm_resize!
+ server = @conn.server(@@server.id)
+ assert_equal('ACTIVE', server.status)
+
+ check_server(server, @@image_ref, @@flavor_ref_resize)
+
+ end if TEST_RESIZE_SERVER
+
+ def test_051_delete_image_metadata_items
+
metadata = @conn.image(@@image_ref).metadata
metadata.each_pair do |key, value|
assert metadata.delete!(key)
end
@@ -237,11 +283,11 @@
assert_equal 0, metadata.size
end if TEST_CREATE_IMAGE
- def test_022_update_one_image_metadata_item
+ def test_052_update_one_image_metadata_item
metadata = @conn.image(@@image_ref).metadata
metadata['foo1'] = 'bar1'
assert metadata.update('foo1')
@@ -251,11 +297,11 @@
assert_equal 1, metadata.size
end if TEST_CREATE_IMAGE
- def test_023_update_some_image_metadata_items
+ def test_053_update_some_image_metadata_items
metadata = @conn.image(@@image_ref).metadata
metadata['foo1'] = 'bar1'
metadata['foo2'] = 'bar2'
assert metadata.update(['foo1','foo2'])
@@ -267,11 +313,11 @@
assert_equal 2, metadata.size
end if TEST_CREATE_IMAGE
- def test_024_set_image_metadata_items
+ def test_054_set_image_metadata_items
metadata = @conn.image(@@image_ref).metadata
metadata['foo1'] = 'that'
metadata['foo2'] = 'silly'
metadata['foo3'] = 'rabbit'
@@ -285,61 +331,19 @@
assert_equal 3, metadata.size
end if TEST_CREATE_IMAGE
- def test_025_clear_image_metadata
+ def test_055_clear_image_metadata
metadata = @conn.image(@@image_ref).metadata
assert metadata.clear!
metadata.refresh
assert_equal 0, metadata.size
end if TEST_CREATE_IMAGE
-
- def test_030_rebuild_instance
- # make sure our snapshot boots
- personalities={SSH_PUBLIC_KEY => "/root/.ssh/authorized_keys"}
- @@server.rebuild!(:imageRef => @@image_ref, :personality => personalities)
- server = @conn.server(@@server.id)
- sleep 15 # sleep a couple seconds until rebuild starts
- check_server(server, @@image_ref, @@flavor_ref)
-
- end if TEST_REBUILD_SERVER
-
- def test_040_resize_instance
-
- flavor_ref_resize = Helper::get_flavor_ref_resize(@conn)
-
- @@server.resize!(flavor_ref_resize)
- server = @conn.server(@@server.id)
- assert_equal('RESIZE', @@server.status)
-
- begin
- timeout(SERVER_BUILD_TIMEOUT) do
- until server.status == 'VERIFY_RESIZE' do
- if server.status == "ERROR" then
- fail('Server ERROR state detected when resizing instance!')
- end
- server = @conn.server(@@server.id)
- sleep 1
- end
- end
- rescue Timeout::Error => te
- fail('Timeout resizing server.')
- end
-
- check_server(server, @@image_ref, flavor_ref_resize, 'VERIFY_RESIZE')
-
- server.confirm_resize!
- server = @conn.server(@@server.id)
- assert_equal('ACTIVE', @@server.status)
-
- check_server(server, @@image_ref, flavor_ref_resize)
-
- end if TEST_RESIZE_SERVER
def test_999_teardown
@@servers.each do |server|
assert_equal(true, server.delete!)
end