Fix init of test_volume_type_extra_specs_list
* test_volume_type_extra_specs_list relied on another test running
first to create a volume type extra spec. When the tests are run
in parallel (or if the test is run by itself), the test can fail
if a suitable test to perform the initialisation is not run
before it does. This patch adds the required volume type extra spec
creation to the test
* test_volume_type_extra_specs_update relied on another test running
before it to create a volume type extra spec which it would update.
Now create it within the test itself
* Create unique extra_specs for each test. This should reduce the probability
of changes in the future resulting in tests accidentally relying on each other
* Combines *_create_delete and *_create_get tests into one _create_get_delete test
Change-Id: Ieffc20599d98ee33d1d2ac41ec0abe812a1afab5
diff --git a/tempest/tests/volume/admin/test_volume_types_extra_specs.py b/tempest/tests/volume/admin/test_volume_types_extra_specs.py
index c743567..f19cd7b 100644
--- a/tempest/tests/volume/admin/test_volume_types_extra_specs.py
+++ b/tempest/tests/volume/admin/test_volume_types_extra_specs.py
@@ -39,7 +39,6 @@
adm_tenant)
vol_type_name = rand_name('Volume-type-')
- cls.extra_spec = {"spec1": "val1"}
resp, cls.volume_type = cls.client.create_volume_type(vol_type_name)
@classmethod
@@ -50,6 +49,12 @@
def test_volume_type_extra_specs_list(self):
# List Volume types extra specs.
try:
+ extra_specs = {"spec1": "val1"}
+ resp, body = self.client.\
+ create_volume_type_extra_specs(self.volume_type['id'], extra_specs)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(extra_specs, body,
+ "Volume type extra spec incorrectly created")
resp, body = self.client.\
list_volume_types_extra_specs(self.volume_type['id'])
self.assertEqual(200, resp.status)
@@ -62,49 +67,46 @@
def test_volume_type_extra_specs_update(self):
# Update volume type extra specs
try:
- extra_spec = {"spec1": "val2"}
- resp, body = self.client.\
- update_volume_type_extra_specs(self.volume_type['id'],
- extra_spec.keys()[0],
- extra_spec)
- self.assertEqual(200, resp.status)
- self.assertTrue('spec1' in body,
- "Volume type extra spec incorrectly updated")
- self.assertEqual(extra_spec['spec1'], body['spec1'],
- "Volume type extra spec incorrectly updated")
- except Exception:
- self.fail("Couldnt update volume type extra spec")
-
- def test_volume_type_extra_spec_create_delete(self):
- # Create/Delete volume type extra spec.
- try:
extra_specs = {"spec2": "val1"}
resp, body = self.client.\
create_volume_type_extra_specs(self.volume_type['id'], extra_specs)
self.assertEqual(200, resp.status)
self.assertEqual(extra_specs, body,
"Volume type extra spec incorrectly created")
- resp, _ = self.client.\
- delete_volume_type_extra_specs(self.volume_type['id'],
- extra_specs.keys()[0])
- self.assertEqual(202, resp.status)
- except Exception:
- self.fail("Could not create a volume_type extra spec")
- def test_volume_type_extra_spec_create_get(self):
- # Create/get volume type extra spec
+ extra_spec = {"spec2": "val2"}
+ resp, body = self.client.\
+ update_volume_type_extra_specs(self.volume_type['id'],
+ extra_spec.keys()[0],
+ extra_spec)
+ self.assertEqual(200, resp.status)
+ self.assertTrue('spec2' in body,
+ "Volume type extra spec incorrectly updated")
+ self.assertEqual(extra_spec['spec2'], body['spec2'],
+ "Volume type extra spec incorrectly updated")
+ except Exception:
+ self.fail("Couldnt update volume type extra spec")
+
+ def test_volume_type_extra_spec_create_get_delete(self):
+ # Create/Get/Delete volume type extra spec.
try:
- extra_specs = {"spec1": "val1"}
+ extra_specs = {"spec3": "val1"}
resp, body = self.client.\
create_volume_type_extra_specs(self.volume_type['id'], extra_specs)
self.assertEqual(200, resp.status)
self.assertEqual(extra_specs, body,
"Volume type extra spec incorrectly created")
+
resp, fetched_vol_type_extra_spec = self.client.\
get_volume_type_extra_specs(self.volume_type['id'],
extra_specs.keys()[0])
self.assertEqual(200, resp.status)
self.assertEqual(extra_specs, body,
"Volume type extra spec incorrectly fetched")
+
+ resp, _ = self.client.\
+ delete_volume_type_extra_specs(self.volume_type['id'],
+ extra_specs.keys()[0])
+ self.assertEqual(202, resp.status)
except Exception:
self.fail("Could not create a volume_type extra spec")