From 51eb333432e3d98dea7283a013ef6b4dfd93f5bb Mon Sep 17 00:00:00 2001 From: Arun Kumar Date: Fri, 12 Jul 2019 15:00:48 +0530 Subject: Add TC creating bunch of PVCs during network failure Create network side failure by opening and closing the ports related to gluster-blockd during creation of the PVC's, Verify PVC's are bound and validate multipath. Change-Id: Ibc53a13e2abb8674661da83d5881a13bbb2ad7fb --- .../openshiftstoragelibs/baseclass.py | 36 ++++++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'openshift-storage-libs') diff --git a/openshift-storage-libs/openshiftstoragelibs/baseclass.py b/openshift-storage-libs/openshiftstoragelibs/baseclass.py index cd9f24ca..ad9c45ae 100644 --- a/openshift-storage-libs/openshiftstoragelibs/baseclass.py +++ b/openshift-storage-libs/openshiftstoragelibs/baseclass.py @@ -274,10 +274,25 @@ class BaseClass(unittest.TestCase): def get_block_provisioner_for_sc(self): return get_block_provisioner(self.ocp_client[0]) - def create_and_wait_for_pvcs(self, pvc_size=1, - pvc_name_prefix="autotests-pvc", - pvc_amount=1, sc_name=None, - timeout=120, wait_step=3): + def create_and_wait_for_pvcs( + self, pvc_size=1, pvc_name_prefix="autotests-pvc", pvc_amount=1, + sc_name=None, timeout=120, wait_step=3, skip_waiting=False): + """Create multiple PVC's not waiting for it + + Args: + pvc_size (int): size of PVC, default value is 1 + pvc_name_prefix (str): volume prefix for each PVC, default value is + 'autotests-pvc' + pvc_amount (int): number of PVC's, default value is 1 + sc_name (str): storage class to create PVC, default value is None, + which will cause automatic creation of sc. + timeout (int): timeout time for waiting for PVC's to get bound + wait_step (int): waiting time between each try of PVC status check + skip_waiting (bool): boolean value which defines whether + we need to wait for PVC creation or not. + Returns: + List: list of PVC names + """ node = self.ocp_client[0] # Create storage class if not specified @@ -299,7 +314,8 @@ class BaseClass(unittest.TestCase): # Wait for PVCs to be in bound state try: - wait_for_pvcs_be_bound(node, pvc_names, timeout, wait_step) + if not skip_waiting: + wait_for_pvcs_be_bound(node, pvc_names, timeout, wait_step) finally: if get_openshift_version() < "3.9": reclaim_policy = "Delete" @@ -310,6 +326,8 @@ class BaseClass(unittest.TestCase): for pvc_name in pvc_names: if reclaim_policy == 'Retain': pv_name = get_pv_name_from_pvc(node, pvc_name) + if not pv_name and skip_waiting: + continue self.addCleanup(oc_delete, node, 'pv', pv_name, raise_on_absence=False) custom = (r':.metadata.annotations."gluster\.kubernetes' @@ -328,7 +346,6 @@ class BaseClass(unittest.TestCase): raise_on_error=False) self.addCleanup(oc_delete, node, 'pvc', pvc_name, raise_on_absence=False) - return pvc_names def create_and_wait_for_pvc(self, pvc_size=1, @@ -338,6 +355,13 @@ class BaseClass(unittest.TestCase): )[0] return self.pvc_name + def create_pvcs_not_waiting( + self, pvc_size=1, pvc_name_prefix="autotests-pvc", + pvc_amount=1, sc_name=None): + return self.create_and_wait_for_pvcs( + pvc_size=pvc_size, pvc_name_prefix=pvc_name_prefix, + pvc_amount=pvc_amount, sc_name=sc_name, skip_waiting=True) + def create_dcs_with_pvc(self, pvc_names, timeout=600, wait_step=5): """Create bunch of DCs with app PODs which use unique PVCs. -- cgit