Skip to content

Commit dd4ee1b

Browse files
committed
fix(NODE-1837): update for pr comments
1 parent 515fe9f commit dd4ee1b

File tree

6 files changed

+68
-42
lines changed

6 files changed

+68
-42
lines changed

.evergreen/config.yml

+32-16
Original file line numberDiff line numberDiff line change
@@ -1138,19 +1138,6 @@ tasks:
11381138
- func: start-load-balancer
11391139
- func: run-lb-tests
11401140
- func: stop-load-balancer
1141-
- name: test-zstd-compression
1142-
tags:
1143-
- latest
1144-
- zstd
1145-
commands:
1146-
- func: install dependencies
1147-
- func: bootstrap mongo-orchestration
1148-
vars:
1149-
VERSION: latest
1150-
TOPOLOGY: server
1151-
AUTH: auth
1152-
COMPRESSOR: zstd
1153-
- func: run-compression-tests
11541141
- name: test-auth-kerberos
11551142
tags:
11561143
- auth
@@ -1187,6 +1174,32 @@ tasks:
11871174
- func: run socks5 tests
11881175
vars:
11891176
SSL: ssl
1177+
- name: test-zstd-compression
1178+
tags:
1179+
- latest
1180+
- zstd
1181+
commands:
1182+
- func: install dependencies
1183+
- func: bootstrap mongo-orchestration
1184+
vars:
1185+
VERSION: latest
1186+
TOPOLOGY: server
1187+
AUTH: auth
1188+
COMPRESSOR: zstd
1189+
- func: run-compression-tests
1190+
- name: test-snappy-compression
1191+
tags:
1192+
- latest
1193+
- snappy
1194+
commands:
1195+
- func: install dependencies
1196+
- func: bootstrap mongo-orchestration
1197+
vars:
1198+
VERSION: latest
1199+
TOPOLOGY: server
1200+
AUTH: auth
1201+
COMPRESSOR: snappy
1202+
- func: run-compression-tests
11901203
- name: test-tls-support-latest
11911204
tags:
11921205
- tls-support
@@ -1993,11 +2006,12 @@ buildvariants:
19932006
- test-latest-server-v1-api
19942007
- test-atlas-connectivity
19952008
- test-atlas-data-lake
1996-
- test-zstd-compression
19972009
- test-auth-kerberos
19982010
- test-auth-ldap
19992011
- test-socks5
20002012
- test-socks5-tls
2013+
- test-zstd-compression
2014+
- test-snappy-compression
20012015
- test-tls-support-latest
20022016
- test-tls-support-6.0
20032017
- test-tls-support-5.0
@@ -2049,11 +2063,12 @@ buildvariants:
20492063
- test-atlas-connectivity
20502064
- test-atlas-data-lake
20512065
- test-load-balancer
2052-
- test-zstd-compression
20532066
- test-auth-kerberos
20542067
- test-auth-ldap
20552068
- test-socks5
20562069
- test-socks5-tls
2070+
- test-zstd-compression
2071+
- test-snappy-compression
20572072
- test-tls-support-latest
20582073
- test-tls-support-6.0
20592074
- test-tls-support-5.0
@@ -2103,9 +2118,10 @@ buildvariants:
21032118
- test-3.6-sharded_cluster
21042119
- test-latest-server-v1-api
21052120
- test-atlas-data-lake
2106-
- test-zstd-compression
21072121
- test-socks5
21082122
- test-socks5-tls
2123+
- test-zstd-compression
2124+
- test-snappy-compression
21092125
- test-tls-support-latest
21102126
- test-tls-support-6.0
21112127
- test-tls-support-5.0

.evergreen/generate_evergreen_tasks.js

+20-17
Original file line numberDiff line numberDiff line change
@@ -144,23 +144,6 @@ TASKS.push(
144144
{ func: 'stop-load-balancer' }
145145
]
146146
},
147-
{
148-
name: 'test-zstd-compression',
149-
tags: ['latest', 'zstd'],
150-
commands: [
151-
{ func: 'install dependencies' },
152-
{
153-
func: 'bootstrap mongo-orchestration',
154-
vars: {
155-
VERSION: 'latest',
156-
TOPOLOGY: 'server',
157-
AUTH: 'auth',
158-
COMPRESSOR: 'zstd'
159-
}
160-
},
161-
{ func: 'run-compression-tests' }
162-
]
163-
},
164147
{
165148
name: 'test-auth-kerberos',
166149
tags: ['auth', 'kerberos'],
@@ -206,6 +189,26 @@ TASKS.push(
206189
]
207190
);
208191

192+
['zstd', 'snappy'].forEach(compressor => {
193+
TASKS.push({
194+
name: `test-${compressor}-compression`,
195+
tags: ['latest', compressor],
196+
commands: [
197+
{ func: 'install dependencies' },
198+
{
199+
func: 'bootstrap mongo-orchestration',
200+
vars: {
201+
VERSION: 'latest',
202+
TOPOLOGY: 'server',
203+
AUTH: 'auth',
204+
COMPRESSOR: compressor
205+
}
206+
},
207+
{ func: 'run-compression-tests' }
208+
]
209+
});
210+
});
211+
209212
TLS_VERSIONS.forEach(VERSION => {
210213
TASKS.push({
211214
name: `test-tls-support-${VERSION}`,

.evergreen/run-tests.sh

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ fi
5858

5959
npm install mongodb-client-encryption@">=2.2.0-alpha.0"
6060
npm install @mongodb-js/zstd
61+
npm install snappy
6162

6263
export AUTH=$AUTH
6364
export SINGLE_MONGOS_LB_URI=${SINGLE_MONGOS_LB_URI}
@@ -66,5 +67,6 @@ export MONGODB_API_VERSION=${MONGODB_API_VERSION}
6667
export MONGODB_URI=${MONGODB_URI}
6768
export LOAD_BALANCER=${LOAD_BALANCER}
6869
export TEST_CSFLE=${TEST_CSFLE}
70+
export COMPRESSOR=${COMPRESSOR}
6971
# Do not add quotes, due to the way NO_EXIT is handled
7072
npm run ${TEST_NPM_SCRIPT}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"email": "[email protected]"
2626
},
2727
"dependencies": {
28-
"@mongodb-js/zstd": "^0.0.5",
2928
"bson": "^4.6.3",
3029
"denque": "^2.0.1",
3130
"mongodb-connection-string-url": "^2.5.2",
@@ -36,6 +35,7 @@
3635
"@istanbuljs/nyc-config-typescript": "^1.0.2",
3736
"@microsoft/api-extractor": "^7.20.0",
3837
"@microsoft/tsdoc-config": "^0.15.2",
38+
"@mongodb-js/zstd": "^0.0.5",
3939
"@types/chai": "^4.3.0",
4040
"@types/chai-subset": "^1.3.3",
4141
"@types/express": "^4.17.13",

src/cmap/wire_protocol/compression.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export const uncompressibleCommands = new Set([
3333
'copydb'
3434
]);
3535

36+
const MAX_COMPRESSOR_ID = 3;
37+
3638
// Facilitate compressing a message using an agreed compressor
3739
export function compress(
3840
self: { options: OperationDescription & zlib.ZlibOptions },
@@ -66,9 +68,10 @@ export function compress(
6668
if ('kModuleError' in ZStandard) {
6769
return callback(ZStandard['kModuleError']);
6870
}
69-
ZStandard.compress(dataToBeCompressed, self.options.zstdCompressionLevel)
70-
.then(buffer => callback(undefined, buffer))
71-
.catch(error => callback(error));
71+
ZStandard.compress(dataToBeCompressed, self.options.zstdCompressionLevel).then(
72+
buffer => callback(undefined, buffer),
73+
error => callback(error)
74+
);
7275
break;
7376
default:
7477
throw new MongoInvalidArgumentError(
@@ -83,7 +86,7 @@ export function decompress(
8386
compressedData: Buffer,
8487
callback: Callback<Buffer>
8588
): void {
86-
if (compressorID < 0 || compressorID > Math.max(3)) {
89+
if (compressorID < 0 || compressorID > MAX_COMPRESSOR_ID) {
8790
throw new MongoDecompressionError(
8891
`Server sent message compressed using an unsupported compressor. (Received compressor ID ${compressorID})`
8992
);
@@ -109,9 +112,10 @@ export function decompress(
109112
return callback(ZStandard['kModuleError']);
110113
}
111114

112-
ZStandard.decompress(compressedData)
113-
.then(buffer => callback(undefined, buffer))
114-
.catch(error => callback(error));
115+
ZStandard.decompress(compressedData).then(
116+
buffer => callback(undefined, buffer),
117+
error => callback(error)
118+
);
115119
break;
116120
}
117121
case Compressor.zlib:

test/tools/runner/hooks/configuration.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ const testConfigBeforeHook = async function () {
140140
kerberos: process.env.KRB5_PRINCIPAL != null,
141141
ldap: MONGODB_URI.includes('authMechanism=PLAIN'),
142142
ocsp: process.env.OCSP_TLS_SHOULD_SUCCEED != null && process.env.CA_FILE != null,
143-
socks5: MONGODB_URI.includes('proxyHost=')
143+
socks5: MONGODB_URI.includes('proxyHost='),
144+
compressor: process.env.COMPRESSOR
144145
};
145146

146147
console.error(inspect(currentEnv, { colors: true }));

0 commit comments

Comments
 (0)