Skip to content

Commit e482c07

Browse files
authored
Merge branch 'NODE-6090' into NODE-6120
2 parents c0cc23f + 4d126eb commit e482c07

File tree

1 file changed

+39
-20
lines changed

1 file changed

+39
-20
lines changed

test/integration/client-side-operations-timeout/node_csot.test.ts

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -105,43 +105,62 @@ describe('CSOT driver tests', () => {
105105
});
106106

107107
describe('when failing autoconnect with timeoutMS defined', () => {
108+
let configClient: MongoClient;
109+
108110
beforeEach(async function () {
109-
client = this.configuration.newClient();
110-
await client
111+
configClient = this.configuration.newClient();
112+
await configClient
113+
.db()
114+
.admin()
115+
.command({
116+
configureFailPoint: 'failCommand',
117+
mode: 'alwaysOn',
118+
data: {
119+
failCommands: ['ping'],
120+
blockConnection: true,
121+
blockTimeMS: 10
122+
}
123+
});
124+
});
125+
126+
afterEach(async function () {
127+
await configClient
111128
.db()
112129
.admin()
113130
.command({
114131
configureFailPoint: 'failCommand',
115-
mode: { times: 1 },
132+
mode: 'off',
116133
data: {
117134
failCommands: ['ping'],
118135
blockConnection: true,
119136
blockTimeMS: 10
120137
}
121138
});
122-
await client.close();
123-
client = undefined;
139+
await configClient.close();
124140
});
125141

126-
it('throws a MongoOperationTimeoutError', async function () {
127-
const commandsStarted = [];
128-
client = this.configuration.newClient(undefined, { timeoutMS: 1, monitorCommands: true });
142+
it('throws a MongoOperationTimeoutError', {
143+
metadata: { requires: { mongodb: '>=4.2' } },
144+
test: async function () {
145+
const commandsStarted = [];
146+
client = this.configuration.newClient(undefined, { timeoutMS: 1, monitorCommands: true });
129147

130-
client.on('commandStarted', ev => commandsStarted.push(ev));
148+
client.on('commandStarted', ev => commandsStarted.push(ev));
131149

132-
const maybeError = await client
133-
.db('test')
134-
.collection('test')
135-
.insertOne({ a: 19 })
136-
.then(
137-
() => null,
138-
e => e
139-
);
150+
const maybeError = await client
151+
.db('test')
152+
.collection('test')
153+
.insertOne({ a: 19 })
154+
.then(
155+
() => null,
156+
e => e
157+
);
140158

141-
expect(commandsStarted).to.have.length(0); // Ensure that we fail before we start the insertOne
159+
expect(commandsStarted).to.have.length(0); // Ensure that we fail before we start the insertOne
142160

143-
expect(maybeError).to.exist;
144-
expect(maybeError).to.be.instanceof(MongoOperationTimeoutError);
161+
expect(maybeError).to.exist;
162+
expect(maybeError).to.be.instanceof(MongoOperationTimeoutError);
163+
}
145164
});
146165
});
147166
});

0 commit comments

Comments
 (0)