]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Tests: Fix az test failure when PYTHONHASHSEED != 0
authorEric Harney <eharney@redhat.com>
Thu, 19 Mar 2015 16:27:59 +0000 (12:27 -0400)
committerEric Harney <eharney@redhat.com>
Thu, 19 Mar 2015 16:33:27 +0000 (12:33 -0400)
The test_list_availability_zones_enabled_service test calls
a method which returns a tuple that is generated from a dict.
This is compared to a tuple in the test, which can fail when
PYTHONHASHSEED is not 0, due to the tuples containing elements
in different orders.  (Because the dict used to build the tuple
was ordered differently.)

For this test, we can convert to lists and sort them to do the
comparison, since the ordering is not important.

Partial-Bug: #1348818

Change-Id: Ib7e5d59073e5e243450e28492d68942f6088bb5f

cinder/tests/test_volume.py
cinder/volume/api.py

index f10ea2302ebb6dac6728595829685e1cc96609b8..537373543a82c49093cce61daa2b02f71f2c2f52 100644 (file)
@@ -3507,12 +3507,13 @@ class VolumeTestCase(BaseVolumeTestCase):
 
         volume_api = cinder.volume.api.API()
         azs = volume_api.list_availability_zones()
+        azs = list(azs).sort()
 
-        expected = (
+        expected = [
             {'name': 'pung', 'available': False},
             {'name': 'pong', 'available': True},
             {'name': 'ping', 'available': True},
-        )
+        ].sort()
 
         self.assertEqual(expected, azs)
 
index da9753e7fb553b3fa5b7a9918a33af28cdd08d28..8a2874e2bb5dc9911170c0ccbfe26a07d46cb4cb 100644 (file)
@@ -122,7 +122,7 @@ class API(base.Base):
     def list_availability_zones(self, enable_cache=False):
         """Describe the known availability zones
 
-        :retval list of dicts, each with a 'name' and 'available' key
+        :retval tuple of dicts, each with a 'name' and 'available' key
         """
         refresh_cache = False
         if enable_cache: