1111
1212oc = os .environ ["HOME" ] + "/oc_client/oc"
1313
14- """
15- Validate following manuela components pods and endpoints
16- on hub site (central server):
17-
18-
19- 1) argocd
20- 2) openshift-operators
21- 3) pods
22- 4) applications health (Applications deployed through argocd)
23- """
24-
2514
2615@pytest .mark .test_validate_hub_site_components
2716def test_validate_hub_site_components (openshift_dyn_client ):
@@ -40,19 +29,8 @@ def test_validate_hub_site_components(openshift_dyn_client):
4029@pytest .mark .validate_hub_site_reachable
4130def test_validate_hub_site_reachable (kube_config , openshift_dyn_client ):
4231 logger .info ("Check if hub site API end point is reachable" )
43- namespace = "openshift-gitops"
44- sub_string = "argocd-dex-server-token"
45- try :
46- hub_api_url = application .get_site_api_url (kube_config )
47- hub_api_response = application .get_site_api_response (
48- openshift_dyn_client , hub_api_url , namespace , sub_string
49- )
50- except AssertionError as e :
51- logger .error (f"FAIL: { e } " )
52- assert False , e
53-
54- if hub_api_response .status_code != 200 :
55- err_msg = "Hub site is not reachable. Please check the deployment."
32+ err_msg = components .validate_site_reachable (kube_config , openshift_dyn_client )
33+ if err_msg :
5634 logger .error (f"FAIL: { err_msg } " )
5735 assert False , err_msg
5836 else :
@@ -62,11 +40,6 @@ def test_validate_hub_site_reachable(kube_config, openshift_dyn_client):
6240@pytest .mark .check_pod_status_hub
6341def test_check_pod_status (openshift_dyn_client ):
6442 logger .info ("Checking pod status" )
65-
66- err_msg = []
67- failed_pods = []
68- missing_pods = []
69- missing_projects = []
7043 projects = [
7144 "openshift-operators" ,
7245 "ansible-automation-platform" ,
@@ -75,27 +48,7 @@ def test_check_pod_status(openshift_dyn_client):
7548 "edge-gitops-vms" ,
7649 "vault" ,
7750 ]
78-
79- missing_projects = components .check_project_absense (openshift_dyn_client , projects )
80- missing_pods = []
81- failed_pods = []
82-
83- for project in projects :
84- logger .info (f"Checking pods in namespace '{ project } '" )
85- missing_pods += components .check_pod_absence (openshift_dyn_client , project )
86- failed_pods += components .check_pod_status (openshift_dyn_client , projects )
87-
88- if missing_projects :
89- err_msg .append (f"The following namespaces are missing: { missing_projects } " )
90-
91- if missing_pods :
92- err_msg .append (
93- f"The following namespaces have no pods deployed: { missing_pods } "
94- )
95-
96- if failed_pods :
97- err_msg .append (f"The following pods are failed: { failed_pods } " )
98-
51+ err_msg = components .check_pod_status (openshift_dyn_client , projects )
9952 if err_msg :
10053 logger .error (f"FAIL: { err_msg } " )
10154 assert False , err_msg
@@ -105,30 +58,9 @@ def test_check_pod_status(openshift_dyn_client):
10558
10659@pytest .mark .validate_argocd_reachable_hub_site
10760def test_validate_argocd_reachable_hub_site (openshift_dyn_client ):
108- namespace = "openshift-gitops"
109- name = "openshift-gitops-server"
110- sub_string = "argocd-dex-server-token"
11161 logger .info ("Check if argocd route/url on hub site is reachable" )
112- try :
113- argocd_route_url = application .get_argocd_route_url (
114- openshift_dyn_client , namespace , name
115- )
116- argocd_route_response = application .get_site_api_response (
117- openshift_dyn_client , argocd_route_url , namespace , sub_string
118- )
119- except StopIteration :
120- err_msg = "Argocd url/route is missing in open-cluster-management namespace"
121- logger .error (f"FAIL: { err_msg } " )
122- assert False , err_msg
123- except AssertionError :
124- err_msg = "Bearer token is missing for argocd-dex-server"
125- logger .error (f"FAIL: { err_msg } " )
126- assert False , err_msg
127-
128- logger .info (f"Argocd route response : { argocd_route_response } " )
129-
130- if argocd_route_response .status_code != 200 :
131- err_msg = "Argocd is not reachable. Please check the deployment"
62+ err_msg = components .validate_argocd_reachable (openshift_dyn_client )
63+ if err_msg :
13264 logger .error (f"FAIL: { err_msg } " )
13365 assert False , err_msg
13466 else :
@@ -137,13 +69,11 @@ def test_validate_argocd_reachable_hub_site(openshift_dyn_client):
13769
13870@pytest .mark .validate_argocd_applications_health_hub_site
13971def test_validate_argocd_applications_health_hub_site (openshift_dyn_client ):
140- unhealthy_apps = []
14172 logger .info ("Get all applications deployed by argocd on hub site" )
14273 projects = ["openshift-gitops" , "ansible-edge-gitops-hub" ]
143- for project in projects :
144- unhealthy_apps += application .get_argocd_application_status (
145- openshift_dyn_client , project
146- )
74+ unhealthy_apps = application .get_argocd_application_status (
75+ openshift_dyn_client , projects
76+ )
14777 if unhealthy_apps :
14878 err_msg = "Some or all applications deployed on hub site are unhealthy"
14979 logger .error (f"FAIL: { err_msg } :\n { unhealthy_apps } " )
0 commit comments