From ab667960ef337538cf777bb0f325cb5d0e865d76 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanino Date: Wed, 10 Dec 2014 15:52:08 -0500 Subject: [PATCH] Actually attach a volume to an instance before taking snapshot In the test test_snapshot_create_with_volume_in_use, the test calls Cinder "os-attach" for attaching a volume. The "os-attach" to tell Cinder the volume is attached, but the API doesn't actually attach the volume to an instance.(Only update volume status in DB) This is not right test case for taking a snapshot with in-use volume. In this test, Nova "os-volume_attachment" should be called for volume attachment. Also, some Cinder drivers fails assisted snapshot due to this problem. In order to perform the snapshot properly, this fix is needed. Closes-Bug #1401110 Change-Id: Ib31e351fe7c3d27824241cf142c213eae287483f --- tempest/api/volume/test_volumes_snapshots.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py index 21d0a863df..b7e9422954 100644 --- a/tempest/api/volume/test_volumes_snapshots.py +++ b/tempest/api/volume/test_volumes_snapshots.py @@ -70,11 +70,14 @@ class VolumesV2SnapshotTestJSON(base.BaseVolumeTest): self.addCleanup(self.servers_client.delete_server, server['id']) self.servers_client.wait_for_server_status(server['id'], 'ACTIVE') mountpoint = '/dev/%s' % CONF.compute.volume_device_name - _, body = self.volumes_client.attach_volume( - self.volume_origin['id'], server['id'], mountpoint) + _, body = self.servers_client.attach_volume( + server['id'], self.volume_origin['id'], mountpoint) self.volumes_client.wait_for_volume_status(self.volume_origin['id'], 'in-use') - self.addCleanup(self._detach, self.volume_origin['id']) + self.addCleanup(self.volumes_client.wait_for_volume_status, + self.volume_origin['id'], 'available') + self.addCleanup(self.servers_client.detach_volume, server['id'], + self.volume_origin['id']) # Snapshot a volume even if it's attached to an instance snapshot = self.create_snapshot(self.volume_origin['id'], force=True)