11import { Session } from "../../../../src/session.js" ;
22import { expectDefined } from "../../helpers.js" ;
33import { describeWithAtlas , withProject , randomId } from "./atlasHelpers.js" ;
4+ import { ClusterDescription20240805 } from "../../../../src/common/atlas/openapi.js" ;
45import { CallToolResult } from "@modelcontextprotocol/sdk/types.js" ;
56
67function sleep ( ms : number ) {
@@ -33,7 +34,12 @@ async function deleteAndWaitCluster(session: Session, projectId: string, cluster
3334 }
3435}
3536
36- async function waitClusterState ( session : Session , projectId : string , clusterName : string , state : string ) {
37+ async function waitCluster (
38+ session : Session ,
39+ projectId : string ,
40+ clusterName : string ,
41+ check : ( cluster : ClusterDescription20240805 ) => boolean | Promise < boolean >
42+ ) {
3743 while ( true ) {
3844 const cluster = await session . apiClient . getCluster ( {
3945 params : {
@@ -43,7 +49,7 @@ async function waitClusterState(session: Session, projectId: string, clusterName
4349 } ,
4450 } ,
4551 } ) ;
46- if ( cluster ?. stateName === state ) {
52+ if ( await check ( cluster ) ) {
4753 return ;
4854 }
4955 await sleep ( 1000 ) ;
@@ -142,7 +148,12 @@ describeWithAtlas("clusters", (integration) => {
142148 describe ( "atlas-connect-cluster" , ( ) => {
143149 beforeAll ( async ( ) => {
144150 const projectId = getProjectId ( ) ;
145- await waitClusterState ( integration . mcpServer ( ) . session , projectId , clusterName , "IDLE" ) ;
151+ await waitCluster ( integration . mcpServer ( ) . session , projectId , clusterName , ( cluster ) => {
152+ return (
153+ cluster . stateName === "IDLE" &&
154+ ( cluster . connectionStrings ?. standardSrv || cluster . connectionStrings ?. standard ) !== undefined
155+ ) ;
156+ } ) ;
146157 await integration . mcpServer ( ) . session . apiClient . createProjectIpAccessList ( {
147158 params : {
148159 path : {
0 commit comments