@@ -4,6 +4,7 @@ import * as types from 'node:util/types';
4
4
import { expect } from 'chai' ;
5
5
import { type Context } from 'mocha' ;
6
6
import ConnectionString from 'mongodb-connection-string-url' ;
7
+ import { type CompressorName } from 'mongodb-legacy' ;
7
8
import * as qs from 'querystring' ;
8
9
import * as url from 'url' ;
9
10
@@ -64,6 +65,19 @@ function convertToConnStringMap(obj: Record<string, any>) {
64
65
return result . join ( ',' ) ;
65
66
}
66
67
68
+ function getCompressor ( compressor : string ) : CompressorName {
69
+ switch ( compressor ) {
70
+ case 'zstd' :
71
+ return 'zstd' ;
72
+ case 'zlib' :
73
+ return 'zlib' ;
74
+ case 'snappy' :
75
+ return 'snappy' ;
76
+ default :
77
+ return 'none' ;
78
+ }
79
+ }
80
+
67
81
export class TestConfiguration {
68
82
version : string ;
69
83
clientSideEncryption : {
@@ -94,6 +108,7 @@ export class TestConfiguration {
94
108
activeResources : number ;
95
109
isSrv : boolean ;
96
110
filters : Record < string , Filter > ;
111
+ compressor : CompressorName | null ;
97
112
98
113
constructor (
99
114
private uri : string ,
@@ -111,6 +126,7 @@ export class TestConfiguration {
111
126
this . buildInfo = context . buildInfo ;
112
127
this . serverApi = context . serverApi ;
113
128
this . isSrv = uri . indexOf ( 'mongodb+srv' ) > - 1 ;
129
+ this . compressor = getCompressor ( process . env . COMPRESSOR ) ;
114
130
this . options = {
115
131
hosts,
116
132
hostAddresses,
@@ -121,11 +137,11 @@ export class TestConfiguration {
121
137
replicaSet : url . searchParams . get ( 'replicaSet' ) ,
122
138
proxyURIParams : url . searchParams . get ( 'proxyHost' )
123
139
? {
124
- proxyHost : url . searchParams . get ( 'proxyHost' ) ,
125
- proxyPort : Number ( url . searchParams . get ( 'proxyPort' ) ) ,
126
- proxyUsername : url . searchParams . get ( 'proxyUsername' ) ,
127
- proxyPassword : url . searchParams . get ( 'proxyPassword' )
128
- }
140
+ proxyHost : url . searchParams . get ( 'proxyHost' ) ,
141
+ proxyPort : Number ( url . searchParams . get ( 'proxyPort' ) ) ,
142
+ proxyUsername : url . searchParams . get ( 'proxyUsername' ) ,
143
+ proxyPassword : url . searchParams . get ( 'proxyPassword' )
144
+ }
129
145
: undefined
130
146
} ;
131
147
if ( url . username ) {
@@ -200,7 +216,13 @@ export class TestConfiguration {
200
216
}
201
217
202
218
newClient ( urlOrQueryOptions ?: string | Record < string , any > , serverOptions ?: MongoClientOptions ) {
203
- serverOptions = Object . assign ( { } , getEnvironmentalOptions ( ) , serverOptions ) ;
219
+ serverOptions = Object . assign (
220
+ < MongoClientOptions > {
221
+ compressors : this . compressor
222
+ } ,
223
+ getEnvironmentalOptions ( ) ,
224
+ serverOptions
225
+ ) ;
204
226
205
227
if ( this . loggingEnabled && ! Object . hasOwn ( serverOptions , 'mongodbLogPath' ) ) {
206
228
serverOptions = this . setupLogging ( serverOptions ) ;
@@ -314,12 +336,14 @@ export class TestConfiguration {
314
336
authSource ?: string ;
315
337
authMechanism ?: string ;
316
338
authMechanismProperties ?: Record < string , any > ;
339
+ compressors ?: CompressorName ;
317
340
}
318
341
) {
319
342
options = {
320
343
db : this . options . db ,
321
344
replicaSet : this . options . replicaSet ,
322
345
proxyURIParams : this . options . proxyURIParams ,
346
+ compressors : this . compressor ,
323
347
...options
324
348
} ;
325
349
0 commit comments