@@ -596,46 +596,14 @@ class TestRunner {
596596
597597 // If not deleted yet, try alternative methods
598598 if ( ! deleted ) {
599- // For v2 functions, try to delete the Cloud Run service directly
599+ // For v2 functions, use gcloud functions delete with --gen2 flag
600600 if ( metadata . projectId === "functions-integration-tests-v2" ) {
601- this . log ( ` Attempting Cloud Run service deletion for v2 function...` , "warn" ) ;
602- // Cloud Run service names are lowercase
603- const cloudRunServiceName = functionName . toLowerCase ( ) ;
604- try {
605- await this . exec (
606- `gcloud run services delete ${ cloudRunServiceName } --region=${
607- metadata . region || DEFAULT_REGION
608- } --project=${ metadata . projectId } --quiet`,
609- { silent : true }
610- ) ;
611-
612- // Verify deletion
613- try {
614- await this . exec (
615- `gcloud run services describe ${ cloudRunServiceName } --region=${
616- metadata . region || DEFAULT_REGION
617- } --project=${ metadata . projectId } `,
618- { silent : true }
619- ) ;
620- // If describe succeeds, function still exists
621- this . log ( ` ⚠️ Cloud Run service still exists after deletion: ${ functionName } ` , "warn" ) ;
622- } catch {
623- // If describe fails, function was deleted
624- this . log ( ` ✅ Deleted function as Cloud Run service: ${ functionName } ` , "success" ) ;
625- deleted = true ;
626- }
627- } catch ( runError ) {
628- this . log ( ` ⚠️ Cloud Run delete failed: ${ runError . message } ` , "warn" ) ;
629- }
630- }
631-
632- // If still not deleted, try gcloud functions delete as last resort
633- if ( ! deleted ) {
601+ this . log ( ` Attempting gcloud functions delete with --gen2 flag...` , "warn" ) ;
634602 try {
635603 await this . exec (
636604 `gcloud functions delete ${ functionName } --region=${
637605 metadata . region || DEFAULT_REGION
638- } --project=${ metadata . projectId } --quiet`,
606+ } --project=${ metadata . projectId } --gen2 -- quiet`,
639607 { silent : true }
640608 ) ;
641609
@@ -644,15 +612,15 @@ class TestRunner {
644612 await this . exec (
645613 `gcloud functions describe ${ functionName } --region=${
646614 metadata . region || DEFAULT_REGION
647- } --project=${ metadata . projectId } `,
615+ } --project=${ metadata . projectId } --gen2 `,
648616 { silent : true }
649617 ) ;
650618 // If describe succeeds, function still exists
651619 this . log ( ` ⚠️ Function still exists after gcloud delete: ${ functionName } ` , "warn" ) ;
652620 deleted = false ;
653621 } catch {
654622 // If describe fails, function was deleted
655- this . log ( ` ✅ Deleted function via gcloud: ${ functionName } ` , "success" ) ;
623+ this . log ( ` ✅ Deleted function via gcloud gen2 : ${ functionName } ` , "success" ) ;
656624 deleted = true ;
657625 }
658626 } catch ( e ) {
0 commit comments