@@ -87,7 +87,10 @@ export class TestConfiguration {
87
87
hostAddresses,
88
88
hostAddress : hostAddresses [ 0 ] ,
89
89
host : hostAddresses [ 0 ] . host ,
90
- port : typeof hostAddresses [ 0 ] . host === 'string' ? hostAddresses [ 0 ] . port : undefined ,
90
+ port :
91
+ typeof hostAddresses [ 0 ] . host === 'string' && ! this . isServerless
92
+ ? hostAddresses [ 0 ] . port
93
+ : undefined ,
91
94
db : url . pathname . slice ( 1 ) ? url . pathname . slice ( 1 ) : 'integration_tests' ,
92
95
replicaSet : url . searchParams . get ( 'replicaSet' ) ,
93
96
proxyURIParams : url . searchParams . get ( 'proxyHost' )
@@ -112,7 +115,9 @@ export class TestConfiguration {
112
115
}
113
116
114
117
get isLoadBalanced ( ) {
115
- return ! ! this . singleMongosLoadBalancerUri && ! ! this . multiMongosLoadBalancerUri ;
118
+ return (
119
+ ! ! this . singleMongosLoadBalancerUri && ! ! this . multiMongosLoadBalancerUri && ! this . isServerless
120
+ ) ;
116
121
}
117
122
118
123
writeConcern ( ) {
@@ -194,7 +199,7 @@ export class TestConfiguration {
194
199
delete dbOptions . writeConcern ;
195
200
}
196
201
197
- if ( this . topologyType === TopologyType . LoadBalanced ) {
202
+ if ( this . topologyType === TopologyType . LoadBalanced && ! this . isServerless ) {
198
203
dbOptions . loadBalanced = true ;
199
204
}
200
205
@@ -203,10 +208,10 @@ export class TestConfiguration {
203
208
}
204
209
205
210
const urlOptions : url . UrlObject = {
206
- protocol : 'mongodb' ,
211
+ protocol : this . isServerless ? 'mongodb+srv' : 'mongodb' ,
207
212
slashes : true ,
208
213
hostname : dbHost ,
209
- port : dbPort ,
214
+ port : this . isServerless ? null : dbPort ,
210
215
query : dbOptions ,
211
216
pathname : '/'
212
217
} ;
@@ -267,7 +272,8 @@ export class TestConfiguration {
267
272
268
273
const FILLER_HOST = 'fillerHost' ;
269
274
270
- const url = new URL ( `mongodb://${ FILLER_HOST } ` ) ;
275
+ const protocol = this . isServerless ? 'mongodb+srv' : 'mongodb' ;
276
+ const url = new URL ( `${ protocol } ://${ FILLER_HOST } ` ) ;
271
277
272
278
if ( options . replicaSet ) {
273
279
url . searchParams . append ( 'replicaSet' , options . replicaSet ) ;
@@ -294,7 +300,7 @@ export class TestConfiguration {
294
300
url . password = password ;
295
301
}
296
302
297
- if ( this . isLoadBalanced ) {
303
+ if ( this . isLoadBalanced && ! this . isServerless ) {
298
304
url . searchParams . append ( 'loadBalanced' , 'true' ) ;
299
305
}
300
306
@@ -319,7 +325,8 @@ export class TestConfiguration {
319
325
}
320
326
321
327
let actualHostsString ;
322
- if ( options . useMultipleMongoses ) {
328
+ // Ignore multi mongos options in serverless testing.
329
+ if ( options . useMultipleMongoses && ! this . isServerless ) {
323
330
if ( this . isLoadBalanced ) {
324
331
const multiUri = new ConnectionString ( this . multiMongosLoadBalancerUri ) ;
325
332
if ( multiUri . isSRV ) {
@@ -331,7 +338,7 @@ export class TestConfiguration {
331
338
actualHostsString = this . options . hostAddresses . map ( ha => ha . toString ( ) ) . join ( ',' ) ;
332
339
}
333
340
} else {
334
- if ( this . isLoadBalanced ) {
341
+ if ( this . isLoadBalanced || this . isServerless ) {
335
342
const singleUri = new ConnectionString ( this . singleMongosLoadBalancerUri ) ;
336
343
actualHostsString = singleUri . hosts [ 0 ] . toString ( ) ;
337
344
} else {
0 commit comments