Skip to content
This repository was archived by the owner on Mar 22, 2018. It is now read-only.

Commit d3399b4

Browse files
committed
Allow volume test to run outside an actual OpenStack VM
1 parent cadccc6 commit d3399b4

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

pkg/cloudprovider/providers/openstack/openstack_test.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -526,30 +526,30 @@ func TestVolumes(t *testing.T) {
526526

527527
id, err := os.InstanceID()
528528
if err != nil {
529-
t.Fatalf("Cannot find instance id: %v", err)
530-
}
529+
t.Logf("Cannot find instance id: %v - perhaps you are running this test outside a VM launched by OpenStack", err)
530+
} else {
531+
diskId, err := os.AttachDisk(id, vol)
532+
if err != nil {
533+
t.Fatalf("Cannot AttachDisk Cinder volume %s: %v", vol, err)
534+
}
535+
t.Logf("Volume (%s) attached, disk ID: %s\n", vol, diskId)
531536

532-
diskId, err := os.AttachDisk(id, vol)
533-
if err != nil {
534-
t.Fatalf("Cannot AttachDisk Cinder volume %s: %v", vol, err)
535-
}
536-
t.Logf("Volume (%s) attached, disk ID: %s\n", vol, diskId)
537+
WaitForVolumeStatus(t, os, vol, volumeInUseStatus)
537538

538-
WaitForVolumeStatus(t, os, vol, volumeInUseStatus)
539+
devicePath := os.GetDevicePath(diskId)
540+
if diskPathRegexp.FindString(devicePath) == "" {
541+
t.Fatalf("GetDevicePath returned and unexpected path for Cinder volume %s, returned %s", vol, devicePath)
542+
}
543+
t.Logf("Volume (%s) found at path: %s\n", vol, devicePath)
539544

540-
devicePath := os.GetDevicePath(diskId)
541-
if diskPathRegexp.FindString(devicePath) == "" {
542-
t.Fatalf("GetDevicePath returned and unexpected path for Cinder volume %s, returned %s", vol, devicePath)
543-
}
544-
t.Logf("Volume (%s) found at path: %s\n", vol, devicePath)
545+
err = os.DetachDisk(id, vol)
546+
if err != nil {
547+
t.Fatalf("Cannot DetachDisk Cinder volume %s: %v", vol, err)
548+
}
549+
t.Logf("Volume (%s) detached\n", vol)
545550

546-
err = os.DetachDisk(id, vol)
547-
if err != nil {
548-
t.Fatalf("Cannot DetachDisk Cinder volume %s: %v", vol, err)
551+
WaitForVolumeStatus(t, os, vol, volumeAvailableStatus)
549552
}
550-
t.Logf("Volume (%s) detached\n", vol)
551-
552-
WaitForVolumeStatus(t, os, vol, volumeAvailableStatus)
553553

554554
err = os.DeleteVolume(vol)
555555
if err != nil {

0 commit comments

Comments
 (0)