]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Port test_emc_vnx to Python 3
authorVictor Stinner <vstinner@redhat.com>
Mon, 15 Feb 2016 13:43:32 +0000 (14:43 +0100)
committerVictor Stinner <vstinner@redhat.com>
Mon, 15 Feb 2016 13:51:19 +0000 (14:51 +0100)
* Configuration.__getattr__(): replace self.local_conf with
  object.__getattribute__(self, 'local_conf') to avoid reentrant call
  to __getattr__() in copy.copy(conf) on Python 3.
* test_emc_vnx: Don't compare directly provider_location strings but
  set of provider_location items to support hash randomization. On
  Python 3, hash randomization is enabled by default and so
  dictionary items are rendered in an random order.
* test_emc_vnx: use assertIn() to check if the provider_location
  contains 'type^smp' substring. Before, the test failed if the
  substring was a the beginning of the string (position 0).
* tests-py3.txt: add cinder.tests.unit.test_emc_vnx

Partial-Implements: blueprint cinder-python3
Related-Bug: 1348818
Change-Id: If3be17ca6a1d14d6f1a16ee9934221f77e161686

cinder/tests/unit/test_emc_vnx.py
cinder/volume/configuration.py
tests-py3.txt

index d3a18c6a0085f7e9e7233750d5761e459f267576..a3a00fc133659870938910ba0b0928d5b4095c77 100644 (file)
@@ -2814,8 +2814,7 @@ Time Remaining:  0 second(s)
         new_volume['name_id'] = new_volume['id']
         vol = self.driver.create_volume_from_snapshot(
             new_volume, test_snap)
-        self.assertTrue(
-            vol['provider_location'].find('type^smp') > 0)
+        self.assertIn('type^smp', vol['provider_location'])
         expect_cmd = [
             mock.call(
                 *self.testData.SNAP_COPY_CMD(
@@ -6144,11 +6143,14 @@ class EMCVNXCLIDriverReplicationV2TestCase(DriverTestCaseBase):
         self.assertEqual(
             self.configuration.replication_device[0]['managed_backend_name'],
             model_update['host'])
-        self.assertEqual(
-            build_provider_location(
-                '1', 'lun', rep_volume.name,
-                self.target_device_id),
-            model_update['provider_location'])
+        expected = build_provider_location('1', 'lun', rep_volume.name,
+                                           self.target_device_id)
+        provider_location = model_update['provider_location']
+        # Don't compare the exact string but the set of items: dictionary
+        # items are rendered in a random order because of the hash
+        # randomization
+        self.assertSetEqual(set(expected.split('|')),
+                            set(provider_location.split('|')))
 
     def test_failover_replication_from_secondary(self):
         rep_volume = EMCVNXCLIDriverTestData.convert_volume(
index 887896d682d3d0949ac5eb304f63908e35ddb2ed..8b6fb36a14bbd36806fcc65874c62963a4598102 100644 (file)
@@ -77,4 +77,6 @@ class Configuration(object):
             return None
 
     def __getattr__(self, value):
-        return getattr(self.local_conf, value)
+        # Don't use self.local_conf to avoid reentrant call to __getattr__()
+        local_conf = object.__getattribute__(self, 'local_conf')
+        return getattr(local_conf, value)
index cc2d520cff9668166b4bb2e6b7d798a10a564166..e47dd0f828f03a9c6f1b9a8e30e6b26a734ce0b7 100644 (file)
@@ -90,6 +90,7 @@ cinder.tests.unit.test_dellscapi
 cinder.tests.unit.test_dothill
 cinder.tests.unit.test_drbdmanagedrv
 cinder.tests.unit.test_emc_vmax
+cinder.tests.unit.test_emc_vnx
 cinder.tests.unit.test_emc_vnxdirect
 cinder.tests.unit.test_emc_xtremio
 cinder.tests.unit.test_eqlx