From b74a207e646afe0fc19599ff508afce302d63a03 Mon Sep 17 00:00:00 2001 From: "jeremy.zhang" Date: Tue, 24 Oct 2017 15:24:45 +0800 Subject: [PATCH] Fix test case for updating volume type extra specs The create_volume_type_extra_specs API in volume types_client actually contains both 'create' and 'update' function for extra specs of a volume type. The 'update' function not only can update volume type's existing extra specs, but also can add new extra specs to the volume type. This patch adds test for this 'update' function. Change-Id: Iaa7c760920267c7db58650fc120e8c9033e875d7 --- .../admin/test_volume_types_extra_specs.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tempest/api/volume/admin/test_volume_types_extra_specs.py b/tempest/api/volume/admin/test_volume_types_extra_specs.py index b5a2fb72a7..730acdf379 100644 --- a/tempest/api/volume/admin/test_volume_types_extra_specs.py +++ b/tempest/api/volume/admin/test_volume_types_extra_specs.py @@ -46,14 +46,32 @@ class VolumeTypesExtraSpecsTest(base.BaseVolumeAdminTest): self.volume_type['id'], extra_specs)['extra_specs'] self.assertEqual(extra_specs, body, "Volume type extra spec incorrectly created") + + # Only update an extra spec spec_key = "spec2" extra_spec = {spec_key: "val2"} body = self.admin_volume_types_client.update_volume_type_extra_specs( self.volume_type['id'], spec_key, extra_spec) self.assertIn(spec_key, body) + self.assertEqual(extra_spec[spec_key], body[spec_key]) + body = self.admin_volume_types_client.show_volume_type_extra_specs( + self.volume_type['id'], spec_key) + self.assertIn(spec_key, body) self.assertEqual(extra_spec[spec_key], body[spec_key], "Volume type extra spec incorrectly updated") + # Update an existing extra spec and create a new extra spec + extra_specs = {spec_key: "val3", "spec4": "val4"} + body = self.admin_volume_types_client.create_volume_type_extra_specs( + self.volume_type['id'], extra_specs)['extra_specs'] + self.assertEqual(extra_specs, body) + body = self.admin_volume_types_client.list_volume_types_extra_specs( + self.volume_type['id'])['extra_specs'] + for key in extra_specs: + self.assertIn(key, body) + self.assertEqual(extra_specs[key], body[key], + "Volume type extra spec incorrectly created") + @decorators.idempotent_id('d4772798-601f-408a-b2a5-29e8a59d1220') def test_volume_type_extra_spec_create_get_delete(self): # Create/Get/Delete volume type extra spec.