1
1
import { Session } from "../../../../src/session.js" ;
2
2
import { expectDefined } from "../../helpers.js" ;
3
3
import { describeWithAtlas , withProject , randomId } from "./atlasHelpers.js" ;
4
+ import { ClusterDescription20240805 } from "../../../../src/common/atlas/openapi.js" ;
4
5
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js" ;
5
6
6
7
function sleep ( ms : number ) {
@@ -33,7 +34,12 @@ async function deleteAndWaitCluster(session: Session, projectId: string, cluster
33
34
}
34
35
}
35
36
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
+ ) {
37
43
while ( true ) {
38
44
const cluster = await session . apiClient . getCluster ( {
39
45
params : {
@@ -43,7 +49,7 @@ async function waitClusterState(session: Session, projectId: string, clusterName
43
49
} ,
44
50
} ,
45
51
} ) ;
46
- if ( cluster ?. stateName === state ) {
52
+ if ( await check ( cluster ) ) {
47
53
return ;
48
54
}
49
55
await sleep ( 1000 ) ;
@@ -142,7 +148,12 @@ describeWithAtlas("clusters", (integration) => {
142
148
describe ( "atlas-connect-cluster" , ( ) => {
143
149
beforeAll ( async ( ) => {
144
150
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
+ } ) ;
146
157
await integration . mcpServer ( ) . session . apiClient . createProjectIpAccessList ( {
147
158
params : {
148
159
path : {
0 commit comments