diff --git a/pkg/cloudprovider/providers/openstack/openstack_test.go b/pkg/cloudprovider/providers/openstack/openstack_test.go index 40dc7a087d1..95cbfc0cb3b 100644 --- a/pkg/cloudprovider/providers/openstack/openstack_test.go +++ b/pkg/cloudprovider/providers/openstack/openstack_test.go @@ -526,31 +526,31 @@ func TestVolumes(t *testing.T) { id, err := os.InstanceID() if err != nil { - t.Fatalf("Cannot find instance id: %v", err) + t.Logf("Cannot find instance id: %v - perhaps you are running this test outside a VM launched by OpenStack", err) + } else { + diskId, err := os.AttachDisk(id, vol) + if err != nil { + t.Fatalf("Cannot AttachDisk Cinder volume %s: %v", vol, err) + } + t.Logf("Volume (%s) attached, disk ID: %s\n", vol, diskId) + + WaitForVolumeStatus(t, os, vol, volumeInUseStatus) + + devicePath := os.GetDevicePath(diskId) + if diskPathRegexp.FindString(devicePath) == "" { + t.Fatalf("GetDevicePath returned and unexpected path for Cinder volume %s, returned %s", vol, devicePath) + } + t.Logf("Volume (%s) found at path: %s\n", vol, devicePath) + + err = os.DetachDisk(id, vol) + if err != nil { + t.Fatalf("Cannot DetachDisk Cinder volume %s: %v", vol, err) + } + t.Logf("Volume (%s) detached\n", vol) + + WaitForVolumeStatus(t, os, vol, volumeAvailableStatus) } - diskId, err := os.AttachDisk(id, vol) - if err != nil { - t.Fatalf("Cannot AttachDisk Cinder volume %s: %v", vol, err) - } - t.Logf("Volume (%s) attached, disk ID: %s\n", vol, diskId) - - WaitForVolumeStatus(t, os, vol, volumeInUseStatus) - - devicePath := os.GetDevicePath(diskId) - if diskPathRegexp.FindString(devicePath) == "" { - t.Fatalf("GetDevicePath returned and unexpected path for Cinder volume %s, returned %s", vol, devicePath) - } - t.Logf("Volume (%s) found at path: %s\n", vol, devicePath) - - err = os.DetachDisk(id, vol) - if err != nil { - t.Fatalf("Cannot DetachDisk Cinder volume %s: %v", vol, err) - } - t.Logf("Volume (%s) detached\n", vol) - - WaitForVolumeStatus(t, os, vol, volumeAvailableStatus) - err = os.DeleteVolume(vol) if err != nil { t.Fatalf("Cannot delete Cinder volume %s: %v", vol, err)