11import { DataTestIDs , LegacyTestIDs } from '../../../src/components/data-test' ;
2+ import { waitForPodsReady , waitForResourceCondition } from './wait-utils' ;
23
34export { } ;
45
@@ -9,16 +10,8 @@ export const dashboardsUtils = {
910 setupMonitoringUIPlugin ( MCP : { namespace : string } ) : void {
1011 cy . log ( 'Create Monitoring UI Plugin instance.' ) ;
1112 cy . exec ( `oc apply -f ./cypress/fixtures/coo/monitoring-ui-plugin.yaml --kubeconfig ${ Cypress . env ( 'KUBECONFIG_PATH' ) } ` ) ;
12- cy . exec (
13- `sleep 15 && oc wait --for=condition=Ready pods --selector=app.kubernetes.io/instance=monitoring -n ${ MCP . namespace } --timeout=60s --kubeconfig ${ Cypress . env ( 'KUBECONFIG_PATH' ) } ` ,
14- {
15- timeout : readyTimeoutMilliseconds ,
16- failOnNonZeroExit : true ,
17- } ,
18- ) . then ( ( result ) => {
19- expect ( result . code ) . to . eq ( 0 ) ;
20- cy . log ( `Monitoring plugin pod is now running in namespace: ${ MCP . namespace } ` ) ;
21- } ) ;
13+ waitForPodsReady ( 'app.kubernetes.io/instance=monitoring' , MCP . namespace , readyTimeoutMilliseconds ) ;
14+ cy . log ( `Monitoring plugin pod is now running in namespace: ${ MCP . namespace } ` ) ;
2215 } ,
2316
2417 setupDashboardsAndPlugins ( MCP : { namespace : string } ) : void {
@@ -68,27 +61,16 @@ export const dashboardsUtils = {
6861 `oc label namespace ${ MCP . namespace } openshift.io/cluster-monitoring=true --overwrite=true --kubeconfig ${ Cypress . env ( 'KUBECONFIG_PATH' ) } ` ,
6962 ) ;
7063
71- cy . exec (
72- `sleep 15 && oc wait --for=condition=Ready pods --selector=app.kubernetes.io/instance=perses -n ${ MCP . namespace } --timeout=600s --kubeconfig ${ Cypress . env ( 'KUBECONFIG_PATH' ) } ` ,
73- {
74- timeout : installTimeoutMilliseconds ,
75- failOnNonZeroExit : true ,
76- } ,
77- ) . then ( ( result ) => {
78- expect ( result . code ) . to . eq ( 0 ) ;
79- cy . log ( `Perses-0 pod is now running in namespace: ${ MCP . namespace } ` ) ;
80- } ) ;
64+ waitForPodsReady ( 'app.kubernetes.io/instance=perses' , MCP . namespace , installTimeoutMilliseconds ) ;
65+ cy . log ( `Perses-0 pod is now running in namespace: ${ MCP . namespace } ` ) ;
8166
82- cy . exec (
83- `sleep 15 && oc wait --for=jsonpath='{.metadata.name}'=health-analyzer --timeout=60s servicemonitor/health-analyzer -n ${ MCP . namespace } --timeout=60s --kubeconfig ${ Cypress . env ( 'KUBECONFIG_PATH' ) } ` ,
84- {
85- timeout : readyTimeoutMilliseconds ,
86- failOnNonZeroExit : true ,
87- } ,
88- ) . then ( ( result ) => {
89- expect ( result . code ) . to . eq ( 0 ) ;
90- cy . log ( `Health-analyzer service monitor is now running in namespace: ${ MCP . namespace } ` ) ;
91- } ) ;
67+ waitForResourceCondition (
68+ 'servicemonitor/health-analyzer' ,
69+ "jsonpath='{.metadata.name}'=health-analyzer" ,
70+ MCP . namespace ,
71+ readyTimeoutMilliseconds ,
72+ ) ;
73+ cy . log ( `Health-analyzer service monitor is now running in namespace: ${ MCP . namespace } ` ) ;
9274
9375 cy . reload ( true ) ;
9476 cy . visit ( '/monitoring/v2/dashboards' ) ;
@@ -100,34 +82,14 @@ export const dashboardsUtils = {
10082 cy . exec ( `oc apply -f ./cypress/fixtures/coo/troubleshooting-panel-ui-plugin.yaml --kubeconfig ${ Cypress . env ( 'KUBECONFIG_PATH' ) } ` ) ;
10183
10284 cy . log ( 'Troubleshooting panel instance created. Waiting for pods to be ready.' ) ;
103- cy . exec (
104- `sleep 15 && oc wait --for=condition=Ready pods --selector=app.kubernetes.io/instance=troubleshooting-panel -n ${ MCP . namespace } --timeout=60s --kubeconfig ${ Cypress . env ( 'KUBECONFIG_PATH' ) } ` ,
105- {
106- timeout : readyTimeoutMilliseconds ,
107- failOnNonZeroExit : true ,
108- } ,
109- ) . then ( ( result ) => {
110- expect ( result . code ) . to . eq ( 0 ) ;
111- cy . log ( `Troubleshooting panel pod is now running in namespace: ${ MCP . namespace } ` ) ;
112- } ) ;
85+ waitForPodsReady ( 'app.kubernetes.io/instance=troubleshooting-panel' , MCP . namespace , readyTimeoutMilliseconds ) ;
86+ cy . log ( `Troubleshooting panel pod is now running in namespace: ${ MCP . namespace } ` ) ;
87+
88+ waitForPodsReady ( 'app.kubernetes.io/instance=korrel8r' , MCP . namespace , installTimeoutMilliseconds ) ;
89+ cy . log ( `Korrel8r pod is now running in namespace: ${ MCP . namespace } ` ) ;
11390
114- cy . exec (
115- `sleep 15 && oc wait --for=condition=Ready pods --selector=app.kubernetes.io/instance=korrel8r -n ${ MCP . namespace } --timeout=600s --kubeconfig ${ Cypress . env ( 'KUBECONFIG_PATH' ) } ` ,
116- {
117- timeout : installTimeoutMilliseconds ,
118- failOnNonZeroExit : true ,
119- } ,
120- ) . then ( ( result ) => {
121- expect ( result . code ) . to . eq ( 0 ) ;
122- cy . log ( `Korrel8r pod is now running in namespace: ${ MCP . namespace } ` ) ;
123- } ) ;
124-
125- cy . log ( 'Reloading the page' ) ;
12691 cy . reload ( true ) ;
127- cy . log ( 'Waiting for 10 seconds before clicking the application launcher' ) ;
128- cy . wait ( 10000 ) ;
129- cy . log ( 'Clicking the application launcher' ) ;
130- cy . byLegacyTestID ( LegacyTestIDs . ApplicationLauncher ) . should ( 'be.visible' ) . click ( ) ;
92+ cy . byLegacyTestID ( LegacyTestIDs . ApplicationLauncher , { timeout : 30000 } ) . should ( 'be.visible' ) . click ( ) ;
13193 cy . byTestID ( DataTestIDs . MastHeadApplicationItem ) . contains ( 'Signal Correlation' ) . should ( 'be.visible' ) ;
13294 } ,
13395
0 commit comments