lib/torpedo/compute/servers.rb in torpedo-1.0.10 vs lib/torpedo/compute/servers.rb in torpedo-1.0.11

- old
+ new

@@ -6,13 +6,13 @@ module Compute class Servers < Test::Unit::TestCase @@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) + @@image_ref = nil + @@flavor_ref = nil + @@flavor_ref_resize = nil @@server = nil #ref to last created server @@hostname = "torpedo" def setup @conn=Helper::get_connection @@ -46,11 +46,11 @@ end end def ssh_test(ip_addr, test_cmd="hostname", test_output=@@hostname, admin_pass=@@admin_pass) - ssh_opts = {} + ssh_opts = {:paranoid => false} if TEST_ADMIN_PASSWORD then ssh_opts.store(:password, admin_pass) else ssh_identity=SSH_PRIVATE_KEY if KEYPAIR and not KEYPAIR.empty? then @@ -133,10 +133,28 @@ server end + def test_000_setup + begin + @@image_ref = Helper::get_image_ref(Helper::get_connection) + rescue Exception => e + fail("Failed get image ref: #{e.message}") + end + begin + @@flavor_ref = Helper::get_flavor_ref(Helper::get_connection) + rescue Exception => e + fail("Failed get flavor ref: #{e.message}") + end + begin + @@flavor_ref_resize = Helper::get_flavor_ref_resize(@conn) + rescue Exception => e + fail("Failed get flavor ref resize: #{e.message}") + end + end + def test_001_create_server metadata={ "key1" => "value1", "key2" => "value2" } options = {:name => @@hostname, :imageRef => @@image_ref, :flavorRef => @@flavor_ref, :personality => get_personalities, :metadata => metadata} if KEYNAME and not KEYNAME.empty? then @@ -446,14 +464,18 @@ assert_equal 0, metadata.size end if TEST_CREATE_IMAGE def test_999_teardown - @@servers.each do |server| - assert_equal(true, server.delete!) + if CLEAN_UP_SERVERS + @@servers.each do |server| + assert_equal(true, server.delete!) + end end - @@images.each do |image| - assert_equal(true, image.delete!) + if CLEAN_UP_IMAGES + @@images.each do |image| + assert_equal(true, image.delete!) + end end end end end