Skip to content

Commit

Permalink
fix(NODE-1837): update for pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed May 11, 2022
1 parent 515fe9f commit dd4ee1b
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 42 deletions.
48 changes: 32 additions & 16 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1138,19 +1138,6 @@ tasks:
- func: start-load-balancer
- func: run-lb-tests
- func: stop-load-balancer
- name: test-zstd-compression
tags:
- latest
- zstd
commands:
- func: install dependencies
- func: bootstrap mongo-orchestration
vars:
VERSION: latest
TOPOLOGY: server
AUTH: auth
COMPRESSOR: zstd
- func: run-compression-tests
- name: test-auth-kerberos
tags:
- auth
Expand Down Expand Up @@ -1187,6 +1174,32 @@ tasks:
- func: run socks5 tests
vars:
SSL: ssl
- name: test-zstd-compression
tags:
- latest
- zstd
commands:
- func: install dependencies
- func: bootstrap mongo-orchestration
vars:
VERSION: latest
TOPOLOGY: server
AUTH: auth
COMPRESSOR: zstd
- func: run-compression-tests
- name: test-snappy-compression
tags:
- latest
- snappy
commands:
- func: install dependencies
- func: bootstrap mongo-orchestration
vars:
VERSION: latest
TOPOLOGY: server
AUTH: auth
COMPRESSOR: snappy
- func: run-compression-tests
- name: test-tls-support-latest
tags:
- tls-support
Expand Down Expand Up @@ -1993,11 +2006,12 @@ buildvariants:
- test-latest-server-v1-api
- test-atlas-connectivity
- test-atlas-data-lake
- test-zstd-compression
- test-auth-kerberos
- test-auth-ldap
- test-socks5
- test-socks5-tls
- test-zstd-compression
- test-snappy-compression
- test-tls-support-latest
- test-tls-support-6.0
- test-tls-support-5.0
Expand Down Expand Up @@ -2049,11 +2063,12 @@ buildvariants:
- test-atlas-connectivity
- test-atlas-data-lake
- test-load-balancer
- test-zstd-compression
- test-auth-kerberos
- test-auth-ldap
- test-socks5
- test-socks5-tls
- test-zstd-compression
- test-snappy-compression
- test-tls-support-latest
- test-tls-support-6.0
- test-tls-support-5.0
Expand Down Expand Up @@ -2103,9 +2118,10 @@ buildvariants:
- test-3.6-sharded_cluster
- test-latest-server-v1-api
- test-atlas-data-lake
- test-zstd-compression
- test-socks5
- test-socks5-tls
- test-zstd-compression
- test-snappy-compression
- test-tls-support-latest
- test-tls-support-6.0
- test-tls-support-5.0
Expand Down
37 changes: 20 additions & 17 deletions .evergreen/generate_evergreen_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,23 +144,6 @@ TASKS.push(
{ func: 'stop-load-balancer' }
]
},
{
name: 'test-zstd-compression',
tags: ['latest', 'zstd'],
commands: [
{ func: 'install dependencies' },
{
func: 'bootstrap mongo-orchestration',
vars: {
VERSION: 'latest',
TOPOLOGY: 'server',
AUTH: 'auth',
COMPRESSOR: 'zstd'
}
},
{ func: 'run-compression-tests' }
]
},
{
name: 'test-auth-kerberos',
tags: ['auth', 'kerberos'],
Expand Down Expand Up @@ -206,6 +189,26 @@ TASKS.push(
]
);

['zstd', 'snappy'].forEach(compressor => {
TASKS.push({
name: `test-${compressor}-compression`,
tags: ['latest', compressor],
commands: [
{ func: 'install dependencies' },
{
func: 'bootstrap mongo-orchestration',
vars: {
VERSION: 'latest',
TOPOLOGY: 'server',
AUTH: 'auth',
COMPRESSOR: compressor
}
},
{ func: 'run-compression-tests' }
]
});
});

TLS_VERSIONS.forEach(VERSION => {
TASKS.push({
name: `test-tls-support-${VERSION}`,
Expand Down
2 changes: 2 additions & 0 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ fi

npm install mongodb-client-encryption@">=2.2.0-alpha.0"
npm install @mongodb-js/zstd
npm install snappy

export AUTH=$AUTH
export SINGLE_MONGOS_LB_URI=${SINGLE_MONGOS_LB_URI}
Expand All @@ -66,5 +67,6 @@ export MONGODB_API_VERSION=${MONGODB_API_VERSION}
export MONGODB_URI=${MONGODB_URI}
export LOAD_BALANCER=${LOAD_BALANCER}
export TEST_CSFLE=${TEST_CSFLE}
export COMPRESSOR=${COMPRESSOR}
# Do not add quotes, due to the way NO_EXIT is handled
npm run ${TEST_NPM_SCRIPT}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"email": "dbx-node@mongodb.com"
},
"dependencies": {
"@mongodb-js/zstd": "^0.0.5",
"bson": "^4.6.3",
"denque": "^2.0.1",
"mongodb-connection-string-url": "^2.5.2",
Expand All @@ -36,6 +35,7 @@
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@microsoft/api-extractor": "^7.20.0",
"@microsoft/tsdoc-config": "^0.15.2",
"@mongodb-js/zstd": "^0.0.5",
"@types/chai": "^4.3.0",
"@types/chai-subset": "^1.3.3",
"@types/express": "^4.17.13",
Expand Down
18 changes: 11 additions & 7 deletions src/cmap/wire_protocol/compression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export const uncompressibleCommands = new Set([
'copydb'
]);

const MAX_COMPRESSOR_ID = 3;

// Facilitate compressing a message using an agreed compressor
export function compress(
self: { options: OperationDescription & zlib.ZlibOptions },
Expand Down Expand Up @@ -66,9 +68,10 @@ export function compress(
if ('kModuleError' in ZStandard) {
return callback(ZStandard['kModuleError']);
}
ZStandard.compress(dataToBeCompressed, self.options.zstdCompressionLevel)
.then(buffer => callback(undefined, buffer))
.catch(error => callback(error));
ZStandard.compress(dataToBeCompressed, self.options.zstdCompressionLevel).then(
buffer => callback(undefined, buffer),
error => callback(error)
);
break;
default:
throw new MongoInvalidArgumentError(
Expand All @@ -83,7 +86,7 @@ export function decompress(
compressedData: Buffer,
callback: Callback<Buffer>
): void {
if (compressorID < 0 || compressorID > Math.max(3)) {
if (compressorID < 0 || compressorID > MAX_COMPRESSOR_ID) {
throw new MongoDecompressionError(
`Server sent message compressed using an unsupported compressor. (Received compressor ID ${compressorID})`
);
Expand All @@ -109,9 +112,10 @@ export function decompress(
return callback(ZStandard['kModuleError']);
}

ZStandard.decompress(compressedData)
.then(buffer => callback(undefined, buffer))
.catch(error => callback(error));
ZStandard.decompress(compressedData).then(
buffer => callback(undefined, buffer),
error => callback(error)
);
break;
}
case Compressor.zlib:
Expand Down
3 changes: 2 additions & 1 deletion test/tools/runner/hooks/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ const testConfigBeforeHook = async function () {
kerberos: process.env.KRB5_PRINCIPAL != null,
ldap: MONGODB_URI.includes('authMechanism=PLAIN'),
ocsp: process.env.OCSP_TLS_SHOULD_SUCCEED != null && process.env.CA_FILE != null,
socks5: MONGODB_URI.includes('proxyHost=')
socks5: MONGODB_URI.includes('proxyHost='),
compressor: process.env.COMPRESSOR
};

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

0 comments on commit dd4ee1b

Please sign in to comment.