@@ -720,6 +720,71 @@ func deleteAllPrivateEndpoints(t *testing.T, cliPath, projectID, provider string
720720 require .True (t , done , "failed to clean all private endpoints" )
721721}
722722
723+ func deleteAllStreams (t * testing.T , cliPath , projectID string ) {
724+ t .Helper ()
725+
726+ streams := listStreamsByProject (t , cliPath , projectID )
727+ if streams .GetTotalCount () == 0 {
728+ return
729+ }
730+
731+ for _ , stream := range streams .GetResults () {
732+ deleteStream (t , cliPath , projectID , * stream .Name )
733+ }
734+
735+ done := false
736+ for attempt := 0 ; attempt < 10 ; attempt ++ {
737+ streams = listStreamsByProject (t , cliPath , projectID )
738+ if streams .GetTotalCount () == 0 {
739+ t .Logf ("all streams successfully deleted" )
740+ done = true
741+ break
742+ }
743+ time .Sleep (sleep )
744+ }
745+
746+ require .True (t , done , "failed to clean all streams" )
747+ }
748+
749+ func listStreamsByProject (t * testing.T , cliPath , projectID string ) * atlasv2.PaginatedApiStreamsTenant {
750+ t .Helper ()
751+ cmd := exec .Command (cliPath ,
752+ streamsEntity ,
753+ "instance" ,
754+ "list" ,
755+ "--projectId" ,
756+ projectID ,
757+ "-o=json" ,
758+ )
759+
760+ cmd .Env = os .Environ ()
761+ resp , err := e2e .RunAndGetStdOut (cmd )
762+ t .Log (string (resp ))
763+ require .NoError (t , err , string (resp ))
764+ var streams * atlasv2.PaginatedApiStreamsTenant
765+ require .NoError (t , json .Unmarshal (resp , & streams ))
766+
767+ return streams
768+ }
769+
770+ func deleteStream (t * testing.T , cliPath , projectID , streamID string ) {
771+ t .Helper ()
772+
773+ cmd := exec .Command (cliPath ,
774+ streamsEntity ,
775+ "instance" ,
776+ "delete" ,
777+ "--force" ,
778+ streamID ,
779+ "--projectId" ,
780+ projectID ,
781+ "--force" ,
782+ )
783+ cmd .Env = os .Environ ()
784+ resp , err := e2e .RunAndGetStdOut (cmd )
785+ require .NoError (t , err , string (resp ))
786+ }
787+
723788func listPrivateEndpointsByProject (t * testing.T , cliPath , projectID , provider string ) []atlasv2.EndpointService {
724789 t .Helper ()
725790 cmd := exec .Command (cliPath ,
0 commit comments