@@ -703,82 +703,80 @@ class TestRunner {
703
703
async cleanupExistingResources ( ) {
704
704
this . log ( "🧹 Checking for existing test functions..." , "warn" ) ;
705
705
706
- const { v1ProjectId, v2ProjectId } = this . getProjectIds ( ) ;
707
- const projects = [ v1ProjectId , v2ProjectId ] ;
706
+ // Only clean up the project that's being used for this test run
707
+ const projectId = this . projectId ;
708
+ this . log ( ` Checking project: ${ projectId } ` , "warn" ) ;
708
709
709
- for ( const projectId of projects ) {
710
- this . log ( ` Checking project: ${ projectId } ` , "warn" ) ;
711
-
712
- try {
713
- // List functions and find test functions
714
- const result = await this . exec ( `firebase functions:list --project ${ projectId } ` , {
715
- silent : true ,
716
- } ) ;
710
+ try {
711
+ // List functions and find test functions
712
+ const result = await this . exec ( `firebase functions:list --project ${ projectId } ` , {
713
+ silent : true ,
714
+ } ) ;
717
715
718
- // Parse the table output from firebase functions:list
719
- const lines = result . stdout . split ( "\n" ) ;
720
- const testFunctions = [ ] ;
721
-
722
- for ( const line of lines ) {
723
- // Look for table rows with function names (containing │)
724
- if ( line . includes ( "│" ) && line . includes ( "Test" ) ) {
725
- const parts = line . split ( "│" ) ;
726
- if ( parts . length >= 2 ) {
727
- const functionName = parts [ 1 ] . trim ( ) ;
728
- // Check if it's a test function (contains Test + test run ID pattern)
729
- if ( functionName . match ( / T e s t .* t [ a - z 0 - 9 ] { 7 , 10 } / ) ) {
730
- testFunctions . push ( functionName ) ;
731
- }
716
+ // Parse the table output from firebase functions:list
717
+ const lines = result . stdout . split ( "\n" ) ;
718
+ const testFunctions = [ ] ;
719
+
720
+ for ( const line of lines ) {
721
+ // Look for table rows with function names (containing │)
722
+ if ( line . includes ( "│" ) && line . includes ( "Test" ) ) {
723
+ const parts = line . split ( "│" ) ;
724
+ if ( parts . length >= 2 ) {
725
+ const functionName = parts [ 1 ] . trim ( ) ;
726
+ // Check if it's a test function (contains Test + test run ID pattern)
727
+ if ( functionName . match ( / T e s t .* t [ a - z 0 - 9 ] { 7 , 10 } / ) ) {
728
+ testFunctions . push ( functionName ) ;
732
729
}
733
730
}
734
731
}
732
+ }
735
733
736
- if ( testFunctions . length > 0 ) {
737
- this . log (
738
- ` Found ${ testFunctions . length } test function(s) in ${ projectId } . Cleaning up...` ,
739
- "warn"
740
- ) ;
734
+ if ( testFunctions . length > 0 ) {
735
+ this . log (
736
+ ` Found ${ testFunctions . length } test function(s) in ${ projectId } . Cleaning up...` ,
737
+ "warn"
738
+ ) ;
741
739
742
- for ( const func of testFunctions ) {
743
- try {
744
- // Function names from firebase functions:list are just the name, no region suffix
745
- const functionName = func . trim ( ) ;
746
- const region = DEFAULT_REGION ;
740
+ for ( const func of testFunctions ) {
741
+ try {
742
+ // Function names from firebase functions:list are just the name, no region suffix
743
+ const functionName = func . trim ( ) ;
744
+ const region = DEFAULT_REGION ;
747
745
748
- this . log ( ` Deleting function: ${ functionName } in region: ${ region } ` , "warn" ) ;
746
+ this . log ( ` Deleting function: ${ functionName } in region: ${ region } ` , "warn" ) ;
749
747
750
- // Try Firebase CLI first
748
+ // Try Firebase CLI first
749
+ try {
750
+ await this . exec (
751
+ `firebase functions:delete ${ functionName } --project ${ projectId } --region ${ region } --force` ,
752
+ { silent : true }
753
+ ) ;
754
+ this . log ( ` ✅ Deleted via Firebase CLI: ${ functionName } ` ) ;
755
+ } catch ( firebaseError ) {
756
+ // If Firebase CLI fails, try gcloud as fallback
757
+ this . log ( ` Firebase CLI failed, trying gcloud for: ${ functionName } ` , "warn" ) ;
751
758
try {
752
759
await this . exec (
753
- `firebase functions: delete ${ functionName } --project ${ projectId } --region ${ region } --force ` ,
760
+ `gcloud functions delete ${ functionName } --region= ${ region } --project= ${ projectId } --quiet ` ,
754
761
{ silent : true }
755
762
) ;
756
- this . log ( ` ✅ Deleted via Firebase CLI: ${ functionName } ` ) ;
757
- } catch ( firebaseError ) {
758
- // If Firebase CLI fails, try gcloud as fallback
759
- this . log ( ` Firebase CLI failed, trying gcloud for: ${ functionName } ` , "warn" ) ;
760
- try {
761
- await this . exec (
762
- `gcloud functions delete ${ functionName } --region=${ region } --project=${ projectId } --quiet` ,
763
- { silent : true }
764
- ) ;
765
- this . log ( ` ✅ Deleted via gcloud: ${ functionName } ` ) ;
766
- } catch ( gcloudError ) {
767
- this . log ( ` ❌ Failed to delete: ${ functionName } ` , "error" ) ;
768
- this . log ( ` Firebase error: ${ firebaseError . message } ` , "error" ) ;
769
- this . log ( ` Gcloud error: ${ gcloudError . message } ` , "error" ) ;
770
- }
763
+ this . log ( ` ✅ Deleted via gcloud: ${ functionName } ` ) ;
764
+ } catch ( gcloudError ) {
765
+ this . log ( ` ❌ Failed to delete: ${ functionName } ` , "error" ) ;
766
+ this . log ( ` Firebase error: ${ firebaseError . message } ` , "error" ) ;
767
+ this . log ( ` Gcloud error: ${ gcloudError . message } ` , "error" ) ;
771
768
}
772
- } catch ( e ) {
773
- this . log ( ` ❌ Unexpected error deleting ${ func } : ${ e . message } ` , "error" ) ;
774
769
}
770
+ } catch ( e ) {
771
+ this . log ( ` ❌ Unexpected error deleting ${ func } : ${ e . message } ` , "error" ) ;
775
772
}
776
- } else {
777
- this . log ( ` ✅ No test functions found in ${ projectId } ` , "success" ) ;
778
773
}
779
- } catch ( e ) {
780
- // Project might not be accessible
774
+ } else {
775
+ this . log ( ` ✅ No test functions found in ${ projectId } ` , "success" ) ;
781
776
}
777
+ } catch ( e ) {
778
+ this . log ( ` ⚠️ Could not check functions in ${ projectId } : ${ e . message } ` , "warn" ) ;
779
+ // Project might not be accessible
782
780
}
783
781
784
782
// Clean up orphaned Cloud Tasks queues
@@ -797,58 +795,55 @@ class TestRunner {
797
795
async cleanupOrphanedCloudTasksQueues ( ) {
798
796
this . log ( " Checking for orphaned Cloud Tasks queues..." , "warn" ) ;
799
797
800
- const { v1ProjectId , v2ProjectId } = this . getProjectIds ( ) ;
801
- const projects = [ v1ProjectId , v2ProjectId ] ;
798
+ // Only clean up the project that's being used for this test run
799
+ const projectId = this . projectId ;
802
800
const region = DEFAULT_REGION ;
801
+ this . log ( ` Checking Cloud Tasks queues in project: ${ projectId } ` , "warn" ) ;
803
802
804
- for ( const projectId of projects ) {
805
- this . log ( ` Checking Cloud Tasks queues in project: ${ projectId } ` , "warn" ) ;
806
-
807
- try {
808
- // List all queues in the project
809
- const result = await this . exec (
810
- `gcloud tasks queues list --location=${ region } --project=${ projectId } --format="value(name)"` ,
811
- { silent : true }
812
- ) ;
813
-
814
- const queueNames = result . stdout
815
- . split ( "\n" )
816
- . map ( ( line ) => line . trim ( ) )
817
- . filter ( ( line ) => line . length > 0 ) ;
803
+ try {
804
+ // List all queues in the project
805
+ const result = await this . exec (
806
+ `gcloud tasks queues list --location=${ region } --project=${ projectId } --format="value(name)"` ,
807
+ { silent : true }
808
+ ) ;
818
809
819
- // Find test queues (containing "Tests" and test run ID pattern)
820
- const testQueues = queueNames . filter ( ( queueName ) => {
821
- const queueId = queueName . split ( "/" ) . pop ( ) ; // Extract queue ID from full path
822
- return queueId && queueId . match ( / T e s t s .* t [ a - z 0 - 9 ] { 7 , 10 } / ) ;
823
- } ) ;
810
+ const queueNames = result . stdout
811
+ . split ( "\n" )
812
+ . map ( ( line ) => line . trim ( ) )
813
+ . filter ( ( line ) => line . length > 0 ) ;
824
814
825
- if ( testQueues . length > 0 ) {
826
- this . log (
827
- ` Found ${ testQueues . length } orphaned test queue(s) in ${ projectId } . Cleaning up...` ,
828
- "warn"
829
- ) ;
815
+ // Find test queues (containing "Tests" and test run ID pattern)
816
+ const testQueues = queueNames . filter ( ( queueName ) => {
817
+ const queueId = queueName . split ( "/" ) . pop ( ) ; // Extract queue ID from full path
818
+ return queueId && queueId . match ( / T e s t s . * t [ a - z 0 - 9 ] { 7 , 10 } / ) ;
819
+ } ) ;
830
820
831
- for ( const queuePath of testQueues ) {
832
- try {
833
- const queueId = queuePath . split ( "/" ) . pop ( ) ;
834
- this . log ( ` Deleting orphaned queue: ${ queueId } ` , "warn" ) ;
821
+ if ( testQueues . length > 0 ) {
822
+ this . log (
823
+ ` Found ${ testQueues . length } orphaned test queue(s) in ${ projectId } . Cleaning up...` ,
824
+ "warn"
825
+ ) ;
835
826
836
- await this . exec (
837
- `gcloud tasks queues delete ${ queueId } --location=${ region } --project=${ projectId } --quiet` ,
838
- { silent : true }
839
- ) ;
840
- this . log ( ` ✅ Deleted orphaned queue: ${ queueId } ` ) ;
841
- } catch ( error ) {
842
- this . log ( ` ⚠️ Could not delete queue ${ queuePath } : ${ error . message } ` , "warn" ) ;
843
- }
827
+ for ( const queuePath of testQueues ) {
828
+ try {
829
+ const queueId = queuePath . split ( "/" ) . pop ( ) ;
830
+ this . log ( ` Deleting orphaned queue: ${ queueId } ` , "warn" ) ;
831
+
832
+ await this . exec (
833
+ `gcloud tasks queues delete ${ queueId } --location=${ region } --project=${ projectId } --quiet` ,
834
+ { silent : true }
835
+ ) ;
836
+ this . log ( ` ✅ Deleted orphaned queue: ${ queueId } ` ) ;
837
+ } catch ( error ) {
838
+ this . log ( ` ⚠️ Could not delete queue ${ queuePath } : ${ error . message } ` , "warn" ) ;
844
839
}
845
- } else {
846
- this . log ( ` ✅ No orphaned test queues found in ${ projectId } ` , "success" ) ;
847
840
}
848
- } catch ( e ) {
849
- // Project might not be accessible or Cloud Tasks API not enabled
850
- this . log ( ` ⚠️ Could not check queues in ${ projectId } : ${ e . message } ` , "warn" ) ;
841
+ } else {
842
+ this . log ( ` ✅ No orphaned test queues found in ${ projectId } ` , "success" ) ;
851
843
}
844
+ } catch ( e ) {
845
+ // Project might not be accessible or Cloud Tasks API not enabled
846
+ this . log ( ` ⚠️ Could not check queues in ${ projectId } : ${ e . message } ` , "warn" ) ;
852
847
}
853
848
}
854
849
0 commit comments