1010
1111oc = os .environ ["HOME" ] + "/oc_client/oc"
1212
13- """
14- Validate following multicluster-devsecops components pods and
15- endpoints on edge site (line server):
16-
17- 1) argocd
18- 2) ACM agents
19- 3) applications health (Applications deployed through argocd)
20- """
21-
2213
2314@pytest .mark .test_validate_devel_site_components
2415def test_validate_devel_site_components ():
@@ -30,19 +21,8 @@ def test_validate_devel_site_components():
3021@pytest .mark .validate_devel_site_reachable
3122def test_validate_devel_site_reachable (kube_config , openshift_dyn_client ):
3223 logger .info ("Check if devel site API end point is reachable" )
33- namespace = "openshift-gitops"
34- sub_string = "argocd-dex-server-token"
35- try :
36- devel_api_url = application .get_site_api_url (kube_config )
37- devel_api_response = application .get_site_api_response (
38- openshift_dyn_client , devel_api_url , namespace , sub_string
39- )
40- except AssertionError as e :
41- logger .error (f"FAIL: { e } " )
42- assert False , e
43-
44- if devel_api_response .status_code != 200 :
45- err_msg = "Devel site is not reachable. Please check the deployment."
24+ err_msg = components .validate_site_reachable (kube_config , openshift_dyn_client )
25+ if err_msg :
4626 logger .error (f"FAIL: { err_msg } " )
4727 assert False , err_msg
4828 else :
@@ -52,36 +32,14 @@ def test_validate_devel_site_reachable(kube_config, openshift_dyn_client):
5232@pytest .mark .check_pod_status_devel
5333def test_check_pod_status (openshift_dyn_client ):
5434 logger .info ("Checking pod status" )
55-
56- err_msg = []
5735 projects = [
5836 "openshift-operators" ,
5937 "openshift-gitops" ,
6038 "multicluster-devsecops-development" ,
6139 "open-cluster-management-agent" ,
6240 "open-cluster-management-agent-addon" ,
6341 ]
64-
65- missing_projects = components .check_project_absense (openshift_dyn_client , projects )
66- missing_pods = []
67- failed_pods = []
68-
69- for project in projects :
70- logger .info (f"Checking pods in namespace '{ project } '" )
71- missing_pods += components .check_pod_absence (openshift_dyn_client , project )
72- failed_pods += components .check_pod_status (openshift_dyn_client , projects )
73-
74- if missing_projects :
75- err_msg .append (f"The following namespaces are missing: { missing_projects } " )
76-
77- if missing_pods :
78- err_msg .append (
79- f"The following namespaces have no pods deployed: { missing_pods } "
80- )
81-
82- if failed_pods :
83- err_msg .append (f"The following pods are failed: { failed_pods } " )
84-
42+ err_msg = components .check_pod_status (openshift_dyn_client , projects )
8543 if err_msg :
8644 logger .error (f"FAIL: { err_msg } " )
8745 assert False , err_msg
@@ -91,30 +49,9 @@ def test_check_pod_status(openshift_dyn_client):
9149
9250@pytest .mark .validate_argocd_reachable_devel_site
9351def test_validate_argocd_reachable_devel_site (openshift_dyn_client ):
94- namespace = "openshift-gitops"
95- name = "openshift-gitops-server"
96- sub_string = "argocd-dex-server-token"
9752 logger .info ("Check if argocd route/url on devel site is reachable" )
98- try :
99- argocd_route_url = application .get_argocd_route_url (
100- openshift_dyn_client , namespace , name
101- )
102- argocd_route_response = application .get_site_api_response (
103- openshift_dyn_client , argocd_route_url , namespace , sub_string
104- )
105- except StopIteration :
106- err_msg = "Argocd url/route is missing in open-cluster-management namespace"
107- logger .error (f"FAIL: { err_msg } " )
108- assert False , err_msg
109- except AssertionError :
110- err_msg = "Bearer token is missing for argocd-dex-server"
111- logger .error (f"FAIL: { err_msg } " )
112- assert False , err_msg
113-
114- logger .info (f"Argocd route response : { argocd_route_response } " )
115-
116- if argocd_route_response .status_code != 200 :
117- err_msg = "Argocd is not reachable. Please check the deployment"
53+ err_msg = components .validate_argocd_reachable (openshift_dyn_client )
54+ if err_msg :
11855 logger .error (f"FAIL: { err_msg } " )
11956 assert False , err_msg
12057 else :
@@ -123,13 +60,11 @@ def test_validate_argocd_reachable_devel_site(openshift_dyn_client):
12360
12461@pytest .mark .validate_argocd_applications_health_devel_site
12562def test_validate_argocd_applications_health_devel_site (openshift_dyn_client ):
126- unhealthy_apps = []
12763 logger .info ("Get all applications deployed by argocd on devel site" )
12864 projects = ["openshift-gitops" ]
129- for project in projects :
130- unhealthy_apps += application .get_argocd_application_status (
131- openshift_dyn_client , project
132- )
65+ unhealthy_apps = application .get_argocd_application_status (
66+ openshift_dyn_client , projects
67+ )
13368 if unhealthy_apps :
13469 err_msg = "Some or all applications deployed on devel site are unhealthy"
13570 logger .error (f"FAIL: { err_msg } :\n { unhealthy_apps } " )
0 commit comments