summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNitin Goyal <nigoyal@redhat.com>2019-12-02 11:54:40 +0530
committerNitin Goyal <nigoyal@redhat.com>2019-12-03 09:11:18 +0530
commitf75cf7f58dc17d45ab93aeedbbbbfe9cd9134d03 (patch)
treed8300d3e5b338a74c90c52fd6284cad310ec1d82
parentcb28f23637696288ae6a937b6ac1e97315f7e8c2 (diff)
Add TC create two heketi volumes with same name
Add TC where it creates two volumes with the same name via heketi and verifies that first one gets successfully created and the second one gets failed. Change-Id: I36e9bb1ed93b807458fcbdf8d417ada1cbc7b943
-rw-r--r--tests/functional/heketi/test_volume_creation.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/functional/heketi/test_volume_creation.py b/tests/functional/heketi/test_volume_creation.py
index 6fbd2a7..354f788 100644
--- a/tests/functional/heketi/test_volume_creation.py
+++ b/tests/functional/heketi/test_volume_creation.py
@@ -6,6 +6,7 @@ import six
from openshiftstoragelibs.baseclass import BaseClass
from openshiftstoragelibs import heketi_ops
from openshiftstoragelibs import podcmd
+from openshiftstoragelibs import utils
class TestVolumeCreationTestCases(BaseClass):
@@ -368,3 +369,35 @@ class TestVolumeCreationTestCases(BaseClass):
msg = ("Volume %s does not have bricks count multiple of 3. It has %s"
% (vol_name, gluster_v_info['brickCount']))
self.assertFalse(int(gluster_v_info['brickCount']) % 3)
+
+ def test_create_volume_with_same_name(self):
+ """Test create two volumes with the same name and verify that 2nd one
+ is failing with the appropriate error.
+ """
+ h_node, h_url = self.heketi_client_node, self.heketi_server_url
+ vol_name = "autovol-%s" % utils.get_random_str()
+
+ # Create volume for the first time
+ vol_info = heketi_ops.heketi_volume_create(
+ h_node, h_url, size=1, name=vol_name, json=True)
+ self.addCleanup(
+ heketi_ops.heketi_volume_delete, h_node, h_url, vol_info['id'])
+
+ vol_info_new = None
+ try:
+ # Try to create volume for 2nd time
+ vol_info_new = heketi_ops.heketi_volume_create(
+ h_node, h_url, size=1, name=vol_name, json=True)
+ self.addCleanup(
+ heketi_ops.heketi_volume_delete,
+ h_node, h_url, vol_info_new['id'])
+ except AssertionError as err:
+ # Verify msg in error
+ msg = "Volume name '%s' already in use" % vol_name
+ if msg not in six.text_type(err):
+ raise
+
+ # Raise exception if there is no error raised by heketi
+ msg = ('Volume %s and %s got created two times with the same name '
+ 'unexpectedly.' % (vol_info, vol_info_new))
+ self.assertFalse(vol_info_new, msg)