Skip to content

Commit 9f0e81e

Browse files
nbbeekenljhaywar
authored andcommitted
test: remove chai settings and improve multi topology cluster script (#2731)
Remove chai's stack traces and fix reporter on early exit. Improve cluster script to permit multiple topologies.
1 parent 91c7521 commit 9f0e81e

File tree

7 files changed

+21
-20
lines changed

7 files changed

+21
-20
lines changed

test/functional/client_side_encryption/corpus.test.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ const fs = require('fs');
66
const path = require('path');
77
const BSON = require('bson');
88
const { EJSON } = require('bson');
9-
const chai = require('chai');
10-
const expect = chai.expect;
11-
chai.config.includeStack = true;
12-
chai.config.showDiff = true;
13-
chai.config.truncateThreshold = 0;
9+
const { expect } = require('chai');
1410

1511
describe('Client Side Encryption Corpus', function () {
1612
const metadata = {

test/functional/client_side_encryption/driver.test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ const crypto = require('crypto');
44
const BSON = require('bson');
55
const chai = require('chai');
66
const expect = chai.expect;
7-
chai.config.includeStack = true;
8-
chai.config.showDiff = true;
9-
chai.config.truncateThreshold = 0;
107
chai.use(require('chai-subset'));
118

129
describe('Client Side Encryption Functional', function () {

test/functional/spec-runner/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ function promiseTry(callback) {
2121

2222
chai.use(require('chai-subset'));
2323
chai.use(require('./matcher').default);
24-
chai.config.includeStack = true;
25-
chai.config.showDiff = true;
26-
chai.config.truncateThreshold = 0;
2724

2825
function escape(string) {
2926
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');

test/functional/spec-runner/matcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ function matchMongoSpec(chai, utils) {
187187
'expected #{act} to not match spec #{exp}',
188188
result.expected,
189189
result.actual,
190-
chai.config.showDiff
190+
chai.config.showDiff || true
191191
);
192192
});
193193

test/tools/cluster_setup.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,26 @@
22

33
if [ "$#" -ne 1 ]; then
44
echo "usage: cluster_setup <server|replica_set|sharded_cluster>"
5+
echo "override <DATA_DIR | SINGLE_DIR | REPLICASET_DIR | SHARDED_DIR> env variables to change dbPath"
56
exit
67
fi
78

9+
DATA_DIR=${DATA_DIR:-data}
10+
SINGLE_DIR=${SINGLE_DIR:-$DATA_DIR/server}
11+
REPLICASET_DIR=${REPLICASET_DIR:-$DATA_DIR/replica_set}
12+
SHARDED_DIR=${SHARDED_DIR:-$DATA_DIR/sharded_cluster}
13+
814
if [[ $1 == "replica_set" ]]; then
9-
mlaunch init --replicaset --nodes 3 --arbiter --name rs --port 31000 --enableMajorityReadConcern --setParameter enableTestCommands=1
10-
echo "mongodb://localhost:31000/?replicaSet=rs"
15+
mkdir -p $REPLICASET_DIR
16+
mlaunch init --dir $REPLICASET_DIR --replicaset --nodes 3 --arbiter --name rs --port 31000 --enableMajorityReadConcern --setParameter enableTestCommands=1
17+
echo "mongodb://localhost:31000,localhost:31001,localhost:31002/?replicaSet=rs"
1118
elif [[ $1 == "sharded_cluster" ]]; then
12-
mlaunch init --replicaset --nodes 3 --arbiter --name rs --port 51000 --enableMajorityReadConcern --setParameter enableTestCommands=1 --sharded 1 --mongos 2
13-
echo "mongodb://localhost:51000,localhost:51001/"
19+
mkdir -p $SHARDED_DIR
20+
mlaunch init --dir $SHARDED_DIR --replicaset --nodes 3 --arbiter --name rs --port 51000 --enableMajorityReadConcern --setParameter enableTestCommands=1 --sharded 1 --mongos 2
21+
echo "mongodb://localhost:51000,localhost:51001"
1422
elif [[ $1 == "server" ]]; then
15-
mlaunch init --single --setParameter enableTestCommands=1
23+
mkdir -p $SINGLE_DIR
24+
mlaunch init --dir $SINGLE_DIR --single --setParameter enableTestCommands=1
1625
echo "mongodb://localhost:27017"
1726
else
1827
echo "unsupported topology: $1"

test/tools/reporter/mongodb_reporter.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,11 @@ function replaceIllegalXMLCharacters(string) {
249249
const ANSI_ESCAPE_REGEX = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
250250
function outputToXML(output) {
251251
function cdata(str) {
252-
return `<![CDATA[${str.split(ANSI_ESCAPE_REGEX).join('').split(']]>').join('\\]\\]\\>')}]]>`;
252+
return `<![CDATA[${String(str)
253+
.split(ANSI_ESCAPE_REGEX)
254+
.join('')
255+
.split(']]>')
256+
.join('\\]\\]\\>')}]]>`;
253257
}
254258

255259
function makeTag(name, attributes, selfClose, content) {

test/tools/runner/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ const chai = require('chai');
9797
chai.use(require('sinon-chai'));
9898
chai.use(require('chai-subset'));
9999
chai.use(require('../../functional/spec-runner/matcher').default);
100-
chai.config.includeStack = true;
101-
chai.config.showDiff = true;
102100
chai.config.truncateThreshold = 0;
103101

104102
// install signal handlers for printing open/active handles

0 commit comments

Comments
 (0)