Skip to content

Commit 9a34c7d

Browse files
full set of tests
1 parent 5b1dfef commit 9a34c7d

File tree

3 files changed

+33
-57
lines changed

3 files changed

+33
-57
lines changed

test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.prose.test.ts

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
SERVER_HEARTBEAT_FAILED,
1313
SERVER_HEARTBEAT_SUCCEEDED
1414
} from '../../../src/constants';
15+
import { sleep } from '../../tools/utils';
1516

1617
describe('Server Discovery and Monitoring Prose Tests', function () {
1718
context('Monitors sleep at least minHeartbeatFrequencyMS between checks', function () {
@@ -194,28 +195,18 @@ describe('Server Discovery and Monitoring Prose Tests', function () {
194195

195196
context('Connection Pool Backpressure', function () {
196197
let client: MongoClient;
197-
let utilClient: MongoClient;
198198
const checkoutFailedEvents: Array<ConnectionCheckOutFailedEvent> = [];
199199
const poolClearedEvents: Array<ConnectionPoolClearedEvent> = [];
200200

201-
const metadata: MongoDBMetadataUI = {
202-
requires: {
203-
mongodb: '>=7.0'
204-
}
205-
};
206-
207201
beforeEach(async function () {
208-
client = this.configuration.newClient({}, { maxConnecting: 20 });
202+
client = this.configuration.newClient({}, { maxConnecting: 100 });
209203

210204
client.on('connectionCheckOutFailed', e => checkoutFailedEvents.push(e));
211205
client.on('connectionPoolCleared', e => poolClearedEvents.push(e));
212206

213207
await client.connect();
214208

215-
utilClient = this.configuration.newClient();
216-
await utilClient.connect();
217-
218-
const admin = utilClient.db('admin').admin();
209+
const admin = client.db('admin').admin();
219210
await admin.command({
220211
setParameter: 1,
221212
ingressConnectionEstablishmentRateLimiterEnabled: true
@@ -233,41 +224,42 @@ describe('Server Discovery and Monitoring Prose Tests', function () {
233224
ingressConnectionEstablishmentMaxQueueDepth: 1
234225
});
235226

236-
await utilClient.db('test').collection('test').insertOne({});
227+
await client.db('test').collection('test').insertOne({});
237228
});
238229

239230
afterEach(async function () {
240-
const admin = utilClient.db('admin').admin();
231+
// give the time to recover from the connection storm before cleaning up.
232+
await sleep(1000);
233+
234+
const admin = client.db('admin').admin();
241235
await admin.command({
242236
setParameter: 1,
243237
ingressConnectionEstablishmentRateLimiterEnabled: false
244238
});
245239

246-
await utilClient.close();
247240
await client.close();
248241
});
249242

250-
it('runs', metadata, async function () {
251-
await Promise.allSettled(
252-
Array.from({ length: 10 }).map(() =>
253-
client
254-
.db('test')
255-
.collection('test')
256-
.findOne({ $where: 'function() { sleep(2000); return true; }' })
257-
)
258-
);
259-
260-
await Promise.allSettled(
261-
Array.from({ length: 100 }).map(() =>
262-
client
263-
.db('test')
264-
.collection('test')
265-
.findOne({ $where: 'function() { sleep(2000); return true; }' })
266-
)
267-
);
268-
269-
expect(poolClearedEvents).to.be.empty;
270-
expect(checkoutFailedEvents.length).to.be.greaterThan(10);
271-
});
243+
it(
244+
'does not clear the pool when connections are closed due to connection storms',
245+
{
246+
requires: {
247+
mongodb: '>=7.0' // rate limiting added in 7.0
248+
}
249+
},
250+
async function () {
251+
await Promise.allSettled(
252+
Array.from({ length: 100 }).map(() =>
253+
client
254+
.db('test')
255+
.collection('test')
256+
.findOne({ $where: 'function() { sleep(2000); return true; }' })
257+
)
258+
);
259+
260+
expect(poolClearedEvents).to.be.empty;
261+
expect(checkoutFailedEvents.length).to.be.greaterThan(10);
262+
}
263+
);
272264
});
273265
});

test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ const skipTable: { pattern: string; reason: string }[] = [
1515
{
1616
pattern: 'connect with serverMonitoringMode=auto >=4.4',
1717
reason: 'TODO(NODE-6045): Ensure that first server hearbeat does not report that it is awaited'
18-
},
19-
{
20-
pattern: 'Pool is not cleared on handshake error during minPoolSize ',
21-
reason: 'broken'
2218
}
2319
];
2420

test/spec/server-discovery-and-monitoring/unified/backpressure-pool-no-clear-min-pool-size-error.json

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@
3232
"id": "client",
3333
"observeEvents": [
3434
"serverDescriptionChangedEvent",
35-
"connectionCreatedEvent",
36-
"poolClearedEvent",
37-
"connectionClosedEvent",
38-
"connectionReadyEvent"
35+
"connectionClosedEvent"
3936
],
4037
"uriOptions": {
4138
"appname": "authErrorTest",
@@ -96,23 +93,14 @@
9693
"expectEvents": [
9794
{
9895
"client": "client",
99-
"eventType": "cmap",
96+
"eventType": "sdam",
10097
"events": [
10198
{
102-
"connectionCreatedEvent": {}
103-
},
104-
{
105-
"connectionReadyEvent": {}
106-
},
107-
{
108-
"connectionCreatedEvent": {}
109-
},
110-
{
111-
"connectionClosedEvent": {}
99+
"serverDescriptionChangedEvent": {}
112100
}
113101
]
114102
}
115103
]
116104
}
117105
]
118-
}
106+
}

0 commit comments

Comments
 (0)