@@ -29,7 +29,7 @@ export const cooInstallUtils = {
2929 `oc --kubeconfig ${ Cypress . env ( 'KUBECONFIG_PATH' ) } apply -f ./cypress/fixtures/coo/coo-imagecontentsourcepolicy.yaml` ,
3030 ) ;
3131 cy . exec (
32- `oc create namespace ${ MCP . namespace } --kubeconfig ${ Cypress . env ( 'KUBECONFIG_PATH' ) } ` ,
32+ `oc create namespace ${ MCP . namespace } --kubeconfig ${ Cypress . env ( 'KUBECONFIG_PATH' ) } --dry-run=client -o yaml | oc apply --kubeconfig ${ Cypress . env ( 'KUBECONFIG_PATH' ) } -f - ` ,
3333 ) ;
3434 cy . exec (
3535 `oc label namespace ${ MCP . namespace } openshift.io/cluster-monitoring=true --overwrite=true --kubeconfig ${ Cypress . env ( 'KUBECONFIG_PATH' ) } ` ,
@@ -45,7 +45,7 @@ export const cooInstallUtils = {
4545 `oc --kubeconfig ${ Cypress . env ( 'KUBECONFIG_PATH' ) } apply -f ./cypress/fixtures/coo/coo-imagecontentsourcepolicy.yaml` ,
4646 ) ;
4747 cy . exec (
48- `oc create namespace ${ MCP . namespace } --kubeconfig ${ Cypress . env ( 'KUBECONFIG_PATH' ) } ` ,
48+ `oc create namespace ${ MCP . namespace } --kubeconfig ${ Cypress . env ( 'KUBECONFIG_PATH' ) } --dry-run=client -o yaml | oc apply --kubeconfig ${ Cypress . env ( 'KUBECONFIG_PATH' ) } -f - ` ,
4949 ) ;
5050 cy . exec (
5151 `oc label namespace ${ MCP . namespace } openshift.io/cluster-monitoring=true --overwrite=true --kubeconfig ${ Cypress . env ( 'KUBECONFIG_PATH' ) } ` ,
@@ -122,7 +122,7 @@ export const cooInstallUtils = {
122122 cy . byTestID ( 'name-filter-input' ) . should ( 'be.visible' ) . type ( 'Observability{enter}' ) ;
123123 cy . get ( '[data-test="status-text"]' , { timeout : installTimeoutMilliseconds } )
124124 . eq ( 0 )
125- . should ( 'contain.text' , 'Succeeded' , { timeout : installTimeoutMilliseconds } ) ;
125+ . should ( 'contain.text' , 'Succeeded' ) ;
126126 }
127127 } ,
128128
@@ -197,6 +197,10 @@ export const cooInstallUtils = {
197197 `oc get ns ${ MCP . namespace } --kubeconfig ${ Cypress . env ( 'KUBECONFIG_PATH' ) } -o jsonpath='{.status.phase}'` ,
198198 { failOnNonZeroExit : false } ,
199199 ) . then ( ( result ) => {
200+ if ( result . code !== 0 ) {
201+ cy . log ( `${ elapsed } ms - ${ MCP . namespace } is successfully deleted.` ) ;
202+ return ;
203+ }
200204 const status = result . stdout . trim ( ) ;
201205
202206 if ( status === 'Terminating' ) {
@@ -211,8 +215,6 @@ export const cooInstallUtils = {
211215 }
212216 } ) ;
213217 cy . wait ( checkIntervalMs ) . then ( checkStatus ) ;
214- } else if ( status === 'NotFound' ) {
215- cy . log ( `${ elapsed } ms - ${ MCP . namespace } is successfully deleted.` ) ;
216218 } else {
217219 cy . log ( `${ elapsed } ms - ${ MCP . namespace } changed to unexpected state: ${ status } . Stopping monitoring.` ) ;
218220 }
@@ -244,15 +246,27 @@ export const cooInstallUtils = {
244246 }
245247
246248 cy . exec (
247- `oc get pods -n ${ namespace } --kubeconfig ${ kubeconfigPath } -o name 2>&1 | grep -E ' ${ podPatterns } ' | wc -l ` ,
249+ `oc get pods -n ${ namespace } --kubeconfig ${ kubeconfigPath } -o name` ,
248250 { failOnNonZeroExit : false } ,
249251 ) . then ( ( result ) => {
250- const count = parseInt ( result . stdout . trim ( ) , 10 ) ;
252+ if ( result . code !== 0 ) {
253+ if ( result . stderr . includes ( 'not found' ) ) {
254+ cy . log ( `All target pods deleted after ${ elapsed } ms (namespace gone)` ) ;
255+ } else {
256+ cy . log ( `${ elapsed } ms - oc get pods failed: ${ result . stderr } , retrying...` ) ;
257+ cy . wait ( checkIntervalMs ) . then ( checkPods ) ;
258+ }
259+ return ;
260+ }
261+
262+ const matchingPods = result . stdout
263+ . split ( '\n' )
264+ . filter ( ( line ) => new RegExp ( podPatterns ) . test ( line ) ) ;
251265
252- if ( count === 0 || result . stderr . includes ( 'not found' ) ) {
266+ if ( matchingPods . length === 0 ) {
253267 cy . log ( `All target pods deleted after ${ elapsed } ms` ) ;
254268 } else {
255- cy . log ( `${ elapsed } ms - ${ count } pod(s) still exist, retrying...` ) ;
269+ cy . log ( `${ elapsed } ms - ${ matchingPods . length } pod(s) still exist, retrying...` ) ;
256270 cy . wait ( checkIntervalMs ) . then ( checkPods ) ;
257271 }
258272 } ) ;
0 commit comments