summaryrefslogtreecommitdiffstats
path: root/tests/functional/heketi/test_heketi_zones.py
diff options
context:
space:
mode:
authorArun Kumar <aanand01762@gmail.com>2020-06-02 16:34:18 +0530
committerVaibhav Mahajan <vamahaja@redhat.com>2020-06-10 06:32:19 +0000
commit13348013f1d3a9ddd4c015f6ef3d8434b3749e34 (patch)
treed05e3fa6f28e79eb361826cd428dc5ea9ba43e26 /tests/functional/heketi/test_heketi_zones.py
parent07edc353eea7523edaad5227db2102e3f50022ad (diff)
[Test] Add TC's create PVC with zone check set to strict in dc
Change-Id: I56807661c6a6b728a4b902ad14c1b8b0b0e268bf Signed-off-by: Arun Kumar <aanand01762@gmail.com>
Diffstat (limited to 'tests/functional/heketi/test_heketi_zones.py')
-rw-r--r--tests/functional/heketi/test_heketi_zones.py46
1 files changed, 40 insertions, 6 deletions
diff --git a/tests/functional/heketi/test_heketi_zones.py b/tests/functional/heketi/test_heketi_zones.py
index 065c40d4..15736e6d 100644
--- a/tests/functional/heketi/test_heketi_zones.py
+++ b/tests/functional/heketi/test_heketi_zones.py
@@ -200,11 +200,20 @@ class TestHeketiZones(baseclass.BaseClass):
self.node, new_heketi_pod, wait_step=20)
def _set_zone_check_env_in_heketi_dc(self, heketi_zone_checking):
- # Set env option zone checking in heketi dc
set_env = (
'HEKETI_POST_REQUEST_VOLUME_OPTIONS="user.heketi.zone-checking'
' {}"').format(heketi_zone_checking)
unset_env, e_list = "HEKETI_POST_REQUEST_VOLUME_OPTIONS-", "--list"
+ env = set_env.replace('"', '')
+
+ # Check if zone checking env is already set, then do nothing
+ cmd_list_env = (
+ "oc set env dc/{} {}".format(self.heketi_dc_name, e_list))
+ env_list = command.cmd_run(cmd_list_env, hostname=self.node)
+ if env in env_list:
+ return
+
+ # Set zone checking env option inside heketi dc
cmd_set_env = (
"oc set env dc/{} {}".format(self.heketi_dc_name, set_env))
cmd_unset_env = (
@@ -215,11 +224,8 @@ class TestHeketiZones(baseclass.BaseClass):
self.addCleanup(command.cmd_run, cmd_unset_env, hostname=self.node)
# List all envs and validate if env is set successfully
- env = set_env.replace('"', '')
- cmd_list_env = (
- "oc set env dc/{} {}".format(self.heketi_dc_name, e_list))
- env_list = command.cmd_run(cmd_list_env, hostname=self.node)
- self.assertIn(env, env_list, "Failed to set env {}".format(env))
+ new_env_list = command.cmd_run(cmd_list_env, hostname=self.node)
+ self.assertIn(env, new_env_list, "Failed to set env {}".format(env))
@pytest.mark.tier1
@ddt.data(
@@ -413,6 +419,34 @@ class TestHeketiZones(baseclass.BaseClass):
# Create app DC with the above PVC
self.create_dc_with_pvc(pvc_name, timeout=120, wait_step=3)
+ @pytest.mark.tier1
+ @ddt.data(3, 4)
+ def test_pvc_placement_with_zone_check_set_in_dc(self, zone_count):
+ heketi_zone_checking = "strict"
+
+ # Check amount of available online heketi zones
+ self._check_for_available_zones(zone_count)
+
+ # Set "user.heketi.zone-checking" to strict inside heketi dc
+ self._set_zone_check_env_in_heketi_dc(heketi_zone_checking)
+
+ # Create a PVC
+ pvc_name = self.create_and_wait_for_pvc(pvc_name_prefix=self.prefix)
+
+ # Validate brick placement
+ self._validate_brick_placement_in_correct_zone_or_with_expand_pvc(
+ heketi_zone_checking, pvc_name, zone_count)
+
+ # Make sure that gluster vol has appropriate option set
+ vol_info = openshift_ops.get_gluster_vol_info_by_pvc_name(
+ self.node, pvc_name)
+ self.assertIn('user.heketi.zone-checking', vol_info['options'])
+ self.assertEqual(vol_info['options']['user.heketi.zone-checking'],
+ heketi_zone_checking)
+
+ # Create app DC with the above PVC
+ self.create_dc_with_pvc(pvc_name, timeout=120, wait_step=3)
+
def _get_online_devices_and_nodes_with_zone(self):
"""
This function returns the list of nodes and devices associated to zone