]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Clean up attach/detach tests.
authorAvishay Traeger <avishay@il.ibm.com>
Mon, 8 Apr 2013 09:19:32 +0000 (12:19 +0300)
committerAvishay Traeger <avishay@il.ibm.com>
Mon, 8 Apr 2013 09:25:27 +0000 (12:25 +0300)
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

cinder/tests/test_volume.py

index e6a8a101eeda0a6c990a746ce93e07fd71dfeff6..a22224aceb7936c0791fc98d5520767edae25d40 100644 (file)
@@ -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 = []