Skip to content

Commit

Permalink
Merge "Ignore a Cinder volume's "updated_at" field."
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Jan 2, 2018
2 parents 47b13f8 + 18bcc9e commit cbb9d21
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tempest/api/volume/test_volumes_list.py
Expand Up @@ -34,6 +34,19 @@ class VolumesListTestJSON(base.BaseVolumeTest):

VOLUME_FIELDS = ('id', 'name')

@classmethod
def _remove_volatile_fields(cls, fetched_list):
"""Remove fields that should not be compared.
This method makes sure that Tempest does not compare e.g.
the volume's "updated_at" field that may change for any reason
internal to the operation of Cinder.
"""
for volume in fetched_list:
for field in ('updated_at',):
if field in volume:
del volume[field]

def _assert_volumes_in(self, fetched_list, expected_list, fields=None):
"""Check out the list.
Expand All @@ -45,6 +58,8 @@ def _assert_volumes_in(self, fetched_list, expected_list, fields=None):
expected_list = map(fieldsgetter, expected_list)
fetched_list = [fieldsgetter(item) for item in fetched_list]

# Hopefully the expected_list has already been cleaned.
self._remove_volatile_fields(fetched_list)
missing_vols = [v for v in expected_list if v not in fetched_list]
if not missing_vols:
return
Expand Down Expand Up @@ -72,6 +87,7 @@ def resource_setup(cls):
volume = cls.volumes_client.show_volume(volume['id'])['volume']
cls.volume_list.append(volume)
cls.volume_id_list.append(volume['id'])
cls._remove_volatile_fields(cls.volume_list)

def _list_by_param_value_and_assert(self, params, with_detail=False):
"""list or list_details with given params and validates result"""
Expand Down

0 comments on commit cbb9d21

Please sign in to comment.