From 38d6106c7d5bbda02a08bef57efb72dc5892a62f Mon Sep 17 00:00:00 2001 From: Arun Kumar Date: Mon, 11 May 2020 18:41:56 +0530 Subject: [Test] Add TC's validate PVC creation with 1 and 2 heketi zones Change-Id: I38546a5e91e56294c03981a182d37b19e2e151a2 Signed-off-by: Arun Kumar --- tests/functional/heketi/test_heketi_zones.py | 50 +++++++++++++++++----------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/tests/functional/heketi/test_heketi_zones.py b/tests/functional/heketi/test_heketi_zones.py index eaf24adc..159dfa1d 100644 --- a/tests/functional/heketi/test_heketi_zones.py +++ b/tests/functional/heketi/test_heketi_zones.py @@ -12,6 +12,7 @@ import pytest from openshiftstoragelibs import baseclass from openshiftstoragelibs import command +from openshiftstoragelibs import exceptions from openshiftstoragelibs import heketi_ops from openshiftstoragelibs import openshift_ops from openshiftstoragelibs import openshift_storage_libs @@ -231,6 +232,10 @@ class TestHeketiZones(baseclass.BaseClass): @pytest.mark.tier1 @ddt.data( + (1, "strict", False), + (1, "strict", True), + (2, "strict", False), + (2, "strict", True), (3, "strict", False), (3, "strict", True), (4, "strict", False), @@ -282,28 +287,35 @@ class TestHeketiZones(baseclass.BaseClass): if is_set_env: self._set_zone_check_env_in_heketi_dc(heketi_zone_checking) - # Create PVC using above storage class - pvc_name = self.create_and_wait_for_pvc( - pvc_name_prefix=prefix, sc_name=sc_name) + # PVC creation should fail when zones are below 3 and check is strict + if heketi_zone_checking == "strict" and zone_count < 3: + self.assertRaises( + exceptions.ExecutionError, self.create_and_wait_for_pvc, + pvc_name_prefix=prefix, sc_name=sc_name, timeout=30) - # Validate brick placement and expand if needed - self._validate_brick_placement_in_correct_zone_or_with_expand_pvc( - heketi_zone_checking, pvc_name, zone_count, expand=expand) - - # 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) - if is_arbiter_vol: - self.assertIn('user.heketi.arbiter', vol_info['options']) + else: + # Create PVC using above storage class + pvc_name = self.create_and_wait_for_pvc( + pvc_name_prefix=prefix, sc_name=sc_name) + + # Validate brick placement and expand if needed + self._validate_brick_placement_in_correct_zone_or_with_expand_pvc( + heketi_zone_checking, pvc_name, zone_count, expand=expand) + + # 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.arbiter'], 'true') + vol_info['options']['user.heketi.zone-checking'], + heketi_zone_checking) + if is_arbiter_vol: + self.assertIn('user.heketi.arbiter', vol_info['options']) + self.assertEqual( + vol_info['options']['user.heketi.arbiter'], 'true') - # Create app DC with the above PVC - self.create_dc_with_pvc(pvc_name, timeout=120, wait_step=3) + # 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): """ -- cgit