From: Avishay Traeger Date: Mon, 8 Apr 2013 09:19:32 +0000 (+0300) Subject: Clean up attach/detach tests. X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=6d7a681fa38bc39e6c0d0db684caec627b4daffa;p=openstack-build%2Fcinder-build.git Clean up attach/detach tests. The code tested by test_preattach_status_volume was moved, and the test no longer tested anything relevant (i.e., instead of checking that the volume is 'attached', the test was changed to test for 'available' since the attach code was moved). This patch, therefore, deletes that test. Further, test_run_attach_detach_volume called database functions for attaching and detaching. This patch changes those calls to call higher-level functions which in turn call the database functions. This gives better code coverage and gives the tests more meaning. Change-Id: If688fe6a14940148b5792256c8507803e8cde901 --- diff --git a/cinder/tests/test_volume.py b/cinder/tests/test_volume.py index e6a8a101e..a22224ace 100644 --- a/cinder/tests/test_volume.py +++ b/cinder/tests/test_volume.py @@ -363,7 +363,8 @@ class VolumeTestCase(test.TestCase): volume = self._create_volume() volume_id = volume['id'] self.volume.create_volume(self.context, volume_id) - db.volume_attached(self.context, volume_id, instance_uuid, mountpoint) + self.volume.attach_volume(self.context, volume_id, instance_uuid, + mountpoint) vol = db.volume_get(context.get_admin_context(), volume_id) self.assertEqual(vol['status'], "in-use") self.assertEqual(vol['attach_status'], "attached") @@ -374,7 +375,7 @@ class VolumeTestCase(test.TestCase): self.volume.delete_volume, self.context, volume_id) - db.volume_detached(self.context, volume_id) + self.volume.detach_volume(self.context, volume_id) vol = db.volume_get(self.context, volume_id) self.assertEqual(vol['status'], "available") @@ -384,22 +385,6 @@ class VolumeTestCase(test.TestCase): self.context, volume_id) - def test_preattach_status_volume(self): - """Ensure volume goes into pre-attaching state""" - instance_uuid = '12345678-1234-5678-1234-567812345678' - mountpoint = "/dev/sdf" - volume = db.volume_create(self.context, {'size': 1, - 'status': 'available'}) - volume_id = volume['id'] - - volume_api = cinder.volume.api.API() - volume_api.attach(self.context, volume, instance_uuid, mountpoint) - - vol = db.volume_get(self.context, volume_id) - self.assertEqual(vol['status'], "available") - self.assertEqual(vol['attach_status'], None) - self.assertEqual(vol['instance_uuid'], None) - def test_concurrent_volumes_get_different_targets(self): """Ensure multiple concurrent volumes get different targets.""" volume_ids = []