From 568865ffaee26b5da26211d9d33e13d3314a52c0 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Mon, 18 May 2015 14:36:55 -0700 Subject: [PATCH] Check only for added/deleted metadata entries Utilize the same methodology as test_volume_metadata and only check for presence or absence of metadata entries explicitily touched on the snapshot. Update_snapshot_metadata requires testing for exact match (it replaces, not appends). Change-Id: I2be45ff13997269b39de85d16ccaea3504e972cc Closes-Bug: 1379460 --- tempest/api/volume/test_snapshot_metadata.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tempest/api/volume/test_snapshot_metadata.py b/tempest/api/volume/test_snapshot_metadata.py index b8e87f0378..641317a59b 100644 --- a/tempest/api/volume/test_snapshot_metadata.py +++ b/tempest/api/volume/test_snapshot_metadata.py @@ -13,6 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. +from testtools import matchers + from tempest.api.volume import base from tempest import test @@ -50,12 +52,14 @@ class SnapshotV2MetadataTestJSON(base.BaseVolumeTest): metadata) # Get the metadata of the snapshot body = self.client.show_snapshot_metadata(self.snapshot_id) - self.assertEqual(metadata, body) + self.assertThat(body.items(), matchers.ContainsAll(metadata.items())) + # Delete one item metadata of the snapshot self.client.delete_snapshot_metadata_item( self.snapshot_id, "key1") body = self.client.show_snapshot_metadata(self.snapshot_id) - self.assertEqual(expected, body) + self.assertThat(body.items(), matchers.ContainsAll(expected.items())) + self.assertNotIn("key1", body) @test.idempotent_id('bd2363bc-de92-48a4-bc98-28943c6e4be1') def test_update_snapshot_metadata(self): @@ -70,7 +74,8 @@ class SnapshotV2MetadataTestJSON(base.BaseVolumeTest): metadata) # Get the metadata of the snapshot body = self.client.show_snapshot_metadata(self.snapshot_id) - self.assertEqual(metadata, body) + self.assertThat(body.items(), matchers.ContainsAll(metadata.items())) + # Update metadata item body = self.client.update_snapshot_metadata( self.snapshot_id, update) @@ -93,13 +98,13 @@ class SnapshotV2MetadataTestJSON(base.BaseVolumeTest): metadata) # Get the metadata of the snapshot body = self.client.show_snapshot_metadata(self.snapshot_id) - self.assertEqual(metadata, body) + self.assertThat(body.items(), matchers.ContainsAll(metadata.items())) # Update metadata item body = self.client.update_snapshot_metadata_item( self.snapshot_id, "key3", update_item) # Get the metadata of the snapshot body = self.client.show_snapshot_metadata(self.snapshot_id) - self.assertEqual(expect, body) + self.assertThat(body.items(), matchers.ContainsAll(expect.items())) class SnapshotV1MetadataTestJSON(SnapshotV2MetadataTestJSON):