]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Move volume.api test to correct location
authorVipin Balachandran <vbala@vmware.com>
Fri, 26 Jun 2015 12:23:26 +0000 (17:53 +0530)
committerVipin Balachandran <vbala@vmware.com>
Tue, 21 Jul 2015 07:22:08 +0000 (07:22 +0000)
Test test_create_volume_with_consistencygroup_invalid_type in
tests.unit.api.v2.test_volumes is verifying consistency group
logic in cinder.volumes.api. This patch moves this test to
tests.unit.test_volume.py.

Change-Id: I0027f03fd084fd490c43e6a957f84a57de7523a6

cinder/tests/unit/api/v2/test_volumes.py
cinder/tests/unit/test_volume.py

index a250327674046e39a4d8d2819f055172c031a699..94a6b34e4dc493ff03a79323f2b3deebfe8de5c3 100644 (file)
@@ -113,36 +113,6 @@ class VolumeApiTest(test.TestCase):
                          'encrypted': False}}
         self.assertEqual(res_dict, ex)
 
-    def test_volume_create_with_consistencygroup_invalid_type(self):
-        ctxt = context.RequestContext('fake', 'fake', auth_token=True)
-        vol_type = db.volume_type_create(
-            context.get_admin_context(),
-            dict(name=CONF.default_volume_type, extra_specs={})
-        )
-        db_vol_type = db.volume_type_get(context.get_admin_context(),
-                                         vol_type.id)
-        cg = {
-            'id': '1',
-            'name': 'cg1',
-            'volume_type_id': db_vol_type['id'],
-        }
-        fake_type = {
-            'id': '9999',
-            'name': 'fake',
-        }
-        vol_api = volume_api.API()
-
-        self.assertRaises(exception.InvalidInput,
-                          vol_api.create,
-                          ctxt, 1, 'vol1', 'volume 1',
-                          consistencygroup=cg)
-
-        self.assertRaises(exception.InvalidInput,
-                          vol_api.create,
-                          ctxt, 1, 'vol1', 'volume 1',
-                          volume_type=fake_type,
-                          consistencygroup=cg)
-
     def test_volume_create_with_type(self):
         vol_type = db.volume_type_create(
             context.get_admin_context(),
index 4765edb636c69d064005d6cbaf883e3347e2b769..d42bd2040222a7fe43470ceb11cf08209fbe6d90 100644 (file)
@@ -5243,6 +5243,39 @@ class VolumeTestCase(BaseVolumeTestCase):
         volume = db.volume_get(context.get_admin_context(), test_vol_id)
         self.assertEqual('error', volume['status'])
 
+    def test_create_volume_with_consistencygroup_invalid_type(self):
+        """Test volume creation with ConsistencyGroup & invalid volume type."""
+        vol_type = db.volume_type_create(
+            context.get_admin_context(),
+            dict(name=conf_fixture.def_vol_type, extra_specs={})
+        )
+        db_vol_type = db.volume_type_get(context.get_admin_context(),
+                                         vol_type.id)
+        cg = {
+            'id': '1',
+            'name': 'cg1',
+            'volume_type_id': db_vol_type['id'],
+        }
+        fake_type = {
+            'id': '9999',
+            'name': 'fake',
+        }
+        vol_api = cinder.volume.api.API()
+
+        # Volume type must be provided when creating a volume in a
+        # consistency group.
+        self.assertRaises(exception.InvalidInput,
+                          vol_api.create,
+                          self.context, 1, 'vol1', 'volume 1',
+                          consistencygroup=cg)
+
+        # Volume type must be valid.
+        self.assertRaises(exception.InvalidInput,
+                          vol_api.create,
+                          self.context, 1, 'vol1', 'volume 1',
+                          volume_type=fake_type,
+                          consistencygroup=cg)
+
 
 class CopyVolumeToImageTestCase(BaseVolumeTestCase):
     def fake_local_path(self, volume):