lib/torpedo/compute/servers.rb in torpedo-1.0.16 vs lib/torpedo/compute/servers.rb in torpedo-1.0.17

- old
+ new

@@ -79,21 +79,19 @@ end def ping_test(ip_addr) begin + ping = TEST_IP_TYPE == 6 ? 'ping6' : 'ping' + ping_command = "#{ping} -c 1 #{ip_addr} > /dev/null 2>&1" Timeout::timeout(PING_TIMEOUT) do - while(1) do - if system("ping -c 1 #{ip_addr} > /dev/null 2>&1") then - return true - end + return true if system(ping_command) end - end rescue Timeout::Error => te - fail("Timeout pinging server: #{ip_addr}") + fail("Timeout pinging server: #{ping_command}") end return false end @@ -118,18 +116,19 @@ end rescue Timeout::Error => te fail('Timeout creating server.') end - # lookup the first IPv4 address and use that for verification - v4_addresses = server.addresses[:public].reject {|addr| addr.version != 4} - ping_test(v4_addresses[0].address) if TEST_PING + # lookup the first public IP address and use that for verification + addresses = server.addresses[:public].select {|a| a.version == TEST_IP_TYPE} + address = addresses[0].address + ping_test(address) if TEST_PING if TEST_SSH if TEST_ADMIN_PASSWORD - ssh_test(v4_addresses[0].address, "cat /tmp/foo/bar", "yo") + ssh_test(address, "cat /tmp/foo/bar", "yo") else - ssh_test(v4_addresses[0].address) + ssh_test(address) end end server @@ -248,13 +247,13 @@ end def test_020_create_image #snapshot the image - image = create_image(@@server, :name => "My Backup", :metadata => {"key1" => "value1"}) + image = create_image(@@server, :name => "torpedo", :metadata => {"key1" => "value1"}) assert_equal('SAVING', image.status) - assert_equal('My Backup', image.name) + assert_equal('torpedo', image.name) assert_equal(25, image.progress) #FIXME: server id should be a uuid string assert_equal(@@server.id.to_s, image.server['id']) assert_not_nil(image.created) assert_not_nil(image.id) @@ -268,9 +267,11 @@ end end rescue Timeout::Error => te fail('Timeout creating image snapshot.') end + + sleep SLEEP_AFTER_IMAGE_CREATE # Overwrite image_ref to make all subsequent tests use this snapshot @@image_ref = image.id.to_s end if TEST_CREATE_IMAGE