def test_cluster(cluster, oc_map, ns_under_test): oc = oc_map.get(cluster) logging.info("[{}] Creating namespace '{}'".format(cluster, ns_under_test)) try: oc.new_project(ns_under_test) time.sleep(5) # allow time for resources to be created dat.test_project_admin_rolebindings(oc, ns_under_test) npt.test_project_network_policies(oc, ns_under_test) except Exception: logging.error(f"[{cluster}] failed test {QONTRACT_E2E_TEST}") finally: logging.info(f"[{cluster}] Deleting namespace '{ns_under_test}'") oc.delete_project(ns_under_test)
def test_cluster(cluster, oc_map, pattern): oc = oc_map.get(cluster) logging.info("[{}] validating default NetworkPolicies".format(cluster)) projects = [ p['metadata']['name'] for p in oc.get_all('Project')['items'] if p['status']['phase'] != 'Terminating' and not re.search(pattern, p['metadata']['name']) and 'api.openshift.com/id' not in p['metadata'].get('labels', {}) ] for project in projects: logging.info("[{}/{}] validating NetworkPolicies".format( cluster, project)) try: npt.test_project_network_policies(oc, project) except Exception: logging.error(f"[{cluster}] failed test {QONTRACT_E2E_TEST}")
def run(defer=None): oc_map = tb.get_oc_map(QONTRACT_E2E_TEST) defer(lambda: oc_map.cleanup()) pattern = tb.get_namespaces_pattern() for cluster in oc_map.clusters(): oc = oc_map.get(cluster) logging.info("[{}] validating default NetworkPolicies".format(cluster)) projects = [ p['metadata']['name'] for p in oc.get_all('Project')['items'] if p['status']['phase'] != 'Terminating' and not re.search(pattern, p['metadata']['name']) and 'api.openshift.com/id' not in p['metadata'].get('labels', {}) ] for project in projects: logging.info("[{}/{}] validating NetworkPolicies".format( cluster, project)) npt.test_project_network_policies(oc, project)
def run(defer=None): oc_map = tb.get_oc_map(QONTRACT_E2E_TEST) defer(lambda: oc_map.cleanup()) ns_under_test = tb.get_test_namespace_name() for cluster in oc_map.clusters(): oc = oc_map.get(cluster) logging.info("[{}] Creating namespace '{}'".format( cluster, ns_under_test)) try: oc.new_project(ns_under_test) time.sleep(5) # allow time for resources to be created dat.test_project_admin_rolebindings(oc, ns_under_test) npt.test_project_network_policies(oc, ns_under_test) finally: logging.info("[{}] Deleting namespace '{}'".format( cluster, ns_under_test)) oc.delete_project(ns_under_test)
def test_cluster(cluster, oc_map, pattern): oc = oc_map.get(cluster) if not oc: logging.log(level=oc.log_level, msg=oc.message) return None logging.info("[{}] validating default NetworkPolicies".format(cluster)) projects = [ p["metadata"]["name"] for p in oc.get_all("Project")["items"] if p["status"]["phase"] != "Terminating" and not re.search(pattern, p["metadata"]["name"]) and "api.openshift.com/id" not in p["metadata"].get("labels", {}) ] for project in projects: logging.info("[{}/{}] validating NetworkPolicies".format( cluster, project)) try: npt.test_project_network_policies(oc, project) except Exception: logging.error(f"[{cluster}] failed test {QONTRACT_E2E_TEST}")