Skip to content

Commit 98f435c

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/development-dependencies-bc0aa38724
2 parents 0c1d0bd + b717a5d commit 98f435c

11 files changed

+345
-122
lines changed

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

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,49 +1359,62 @@ describe('CSOT driver tests', metadata, () => {
13591359
});
13601360
});
13611361

1362-
describe('Connection after timeout', { requires: { mongodb: '>=4.4' } }, function () {
1363-
let client: MongoClient;
1364-
1365-
beforeEach(async function () {
1366-
client = this.configuration.newClient({ timeoutMS: 500 });
1367-
1368-
const failpoint: FailPoint = {
1369-
configureFailPoint: 'failCommand',
1370-
mode: {
1371-
times: 1
1372-
},
1373-
data: {
1374-
failCommands: ['insert'],
1375-
blockConnection: true,
1376-
blockTimeMS: 700
1377-
}
1378-
};
1379-
1380-
await client.db('admin').command(failpoint);
1381-
});
1362+
// TODO(NODE-7118): Find a way to reimplement this test for latest server.
1363+
describe(
1364+
'Connection after timeout',
1365+
{
1366+
requires: {
1367+
// 4.4 for use of failCommands
1368+
// < 8.3 because of https://jira.mongodb.org/browse/SERVER-101116
1369+
mongodb: '>=4.4 <=8.2'
1370+
}
1371+
},
1372+
function () {
1373+
let client: MongoClient;
13821374

1383-
afterEach(async function () {
1384-
await client.close();
1385-
});
1375+
beforeEach(async function () {
1376+
client = this.configuration.newClient({ timeoutMS: 500 });
13861377

1387-
it('closes so pending messages are not read by another operation', async function () {
1388-
const cmap = [];
1389-
client.on('connectionCheckedOut', ev => cmap.push(ev));
1390-
client.on('connectionClosed', ev => cmap.push(ev));
1378+
const failpoint: FailPoint = {
1379+
configureFailPoint: 'failCommand',
1380+
mode: {
1381+
times: 1
1382+
},
1383+
data: {
1384+
failCommands: ['insert'],
1385+
blockConnection: true,
1386+
blockTimeMS: 700
1387+
}
1388+
};
13911389

1392-
const error = await client
1393-
.db('socket')
1394-
.collection('closes')
1395-
.insertOne({})
1396-
.catch(error => error);
1390+
await client.db('admin').command(failpoint);
1391+
});
13971392

1398-
expect(error).to.be.instanceOf(MongoOperationTimeoutError);
1399-
expect(cmap).to.have.lengthOf(2);
1393+
afterEach(async function () {
1394+
await client.close();
1395+
});
14001396

1401-
const [checkedOut, closed] = cmap;
1402-
expect(checkedOut).to.have.property('name', 'connectionCheckedOut');
1403-
expect(closed).to.have.property('name', 'connectionClosed');
1404-
expect(checkedOut).to.have.property('connectionId', closed.connectionId);
1405-
});
1406-
});
1397+
it('closes so pending messages are not read by another operation', async function () {
1398+
const cmap = [];
1399+
client.on('connectionCheckedOut', ev => cmap.push(ev));
1400+
client.on('connectionClosed', ev => cmap.push(ev));
1401+
1402+
const error = await client
1403+
.db('socket')
1404+
.collection('closes')
1405+
.insertOne({})
1406+
.catch(error => error);
1407+
1408+
// Note: In the case where the timeout comes from the server, the driver does not
1409+
// need to close the connection as no more potential messages are expected.
1410+
expect(error).to.be.instanceOf(MongoOperationTimeoutError);
1411+
expect(cmap).to.have.lengthOf(2);
1412+
1413+
const [checkedOut, closed] = cmap;
1414+
expect(checkedOut).to.have.property('name', 'connectionCheckedOut');
1415+
expect(closed).to.have.property('name', 'connectionClosed');
1416+
expect(checkedOut).to.have.property('connectionId', closed.connectionId);
1417+
});
1418+
}
1419+
);
14071420
});

test/spec/client-side-operations-timeout/deprecated-options.json

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6750,16 +6750,23 @@
67506750
}
67516751
}
67526752
},
6753+
{
6754+
"name": "createIndex",
6755+
"object": "collection",
6756+
"arguments": {
6757+
"keys": {
6758+
"x": 1
6759+
},
6760+
"timeoutMS": 100000,
6761+
"name": "x_1"
6762+
}
6763+
},
67536764
{
67546765
"name": "dropIndex",
67556766
"object": "collection",
67566767
"arguments": {
67576768
"timeoutMS": 100000,
67586769
"name": "x_1"
6759-
},
6760-
"expectError": {
6761-
"isClientError": false,
6762-
"isTimeoutError": false
67636770
}
67646771
}
67656772
]
@@ -6815,23 +6822,36 @@
68156822
]
68166823
}
68176824
},
6825+
{
6826+
"name": "createIndex",
6827+
"object": "collection",
6828+
"arguments": {
6829+
"keys": {
6830+
"x": 1
6831+
},
6832+
"timeoutMS": 100000,
6833+
"name": "x_1"
6834+
}
6835+
},
68186836
{
68196837
"name": "dropIndex",
68206838
"object": "collection",
68216839
"arguments": {
68226840
"timeoutMS": 100000,
68236841
"name": "x_1"
6824-
},
6825-
"expectError": {
6826-
"isClientError": false,
6827-
"isTimeoutError": false
68286842
}
68296843
}
68306844
],
68316845
"expectEvents": [
68326846
{
68336847
"client": "client",
68346848
"events": [
6849+
{
6850+
"commandStartedEvent": {
6851+
"commandName": "createIndexes",
6852+
"databaseName": "test"
6853+
}
6854+
},
68356855
{
68366856
"commandStartedEvent": {
68376857
"commandName": "dropIndexes",
@@ -6903,24 +6923,36 @@
69036923
]
69046924
}
69056925
},
6926+
{
6927+
"name": "createIndex",
6928+
"object": "collection",
6929+
"arguments": {
6930+
"keys": {
6931+
"x": 1
6932+
},
6933+
"name": "x_1"
6934+
}
6935+
},
69066936
{
69076937
"name": "dropIndex",
69086938
"object": "collection",
69096939
"arguments": {
69106940
"timeoutMS": 1000,
69116941
"maxTimeMS": 5000,
69126942
"name": "x_1"
6913-
},
6914-
"expectError": {
6915-
"isClientError": false,
6916-
"isTimeoutError": false
69176943
}
69186944
}
69196945
],
69206946
"expectEvents": [
69216947
{
69226948
"client": "client",
69236949
"events": [
6950+
{
6951+
"commandStartedEvent": {
6952+
"commandName": "createIndexes",
6953+
"databaseName": "test"
6954+
}
6955+
},
69246956
{
69256957
"commandStartedEvent": {
69266958
"commandName": "dropIndexes",
@@ -7003,6 +7035,17 @@
70037035
}
70047036
}
70057037
},
7038+
{
7039+
"name": "createIndex",
7040+
"object": "collection",
7041+
"arguments": {
7042+
"keys": {
7043+
"x": 1
7044+
},
7045+
"name": "x_1",
7046+
"timeoutMS": 100000
7047+
}
7048+
},
70067049
{
70077050
"name": "dropIndexes",
70087051
"object": "collection",

test/spec/client-side-operations-timeout/deprecated-options.yml

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3743,16 +3743,19 @@ tests:
37433743
failCommands: ["dropIndexes"]
37443744
blockConnection: true
37453745
blockTimeMS: 5
3746+
# Create the index first so dropIndex doesn't return IndexNotFound on
3747+
# servers prior to 8.3.
3748+
- name: createIndex
3749+
object: *collection
3750+
arguments:
3751+
keys: { x: 1 }
3752+
timeoutMS: 100000
3753+
name: "x_1"
37463754
- name: dropIndex
37473755
object: *collection
37483756
arguments:
37493757
timeoutMS: 100000
37503758
name: "x_1"
3751-
3752-
expectError:
3753-
isClientError: false
3754-
isTimeoutError: false
3755-
37563759
- description: "wTimeoutMS is ignored if timeoutMS is set - dropIndex on collection"
37573760
operations:
37583761
- name: createEntities
@@ -3781,18 +3784,26 @@ tests:
37813784
- session:
37823785
id: &session session
37833786
client: *client
3787+
# Create the index first so dropIndex doesn't return IndexNotFound on
3788+
# servers prior to 8.3.
3789+
- name: createIndex
3790+
object: *collection
3791+
arguments:
3792+
keys: { x: 1 }
3793+
timeoutMS: 100000
3794+
name: "x_1"
37843795
- name: dropIndex
37853796
object: *collection
37863797
arguments:
37873798
timeoutMS: 100000
37883799
name: "x_1"
3789-
3790-
expectError:
3791-
isClientError: false
3792-
isTimeoutError: false
37933800
expectEvents:
37943801
- client: *client
37953802
events:
3803+
- commandStartedEvent:
3804+
commandName: createIndexes
3805+
databaseName: *databaseName
3806+
37963807
- commandStartedEvent:
37973808
commandName: dropIndexes
37983809
databaseName: *databaseName
@@ -3828,19 +3839,26 @@ tests:
38283839
- session:
38293840
id: &session session
38303841
client: *client
3842+
# Create the index first so dropIndex doesn't return IndexNotFound on
3843+
# servers prior to 8.3.
3844+
- name: createIndex
3845+
object: *collection
3846+
arguments:
3847+
keys: { x: 1 }
3848+
name: "x_1"
38313849
- name: dropIndex
38323850
object: *collection
38333851
arguments:
38343852
timeoutMS: &timeoutMS 1000
38353853
maxTimeMS: 5000
38363854
name: "x_1"
3837-
3838-
expectError:
3839-
isClientError: false
3840-
isTimeoutError: false
38413855
expectEvents:
38423856
- client: *client
38433857
events:
3858+
- commandStartedEvent:
3859+
commandName: createIndexes
3860+
databaseName: *databaseName
3861+
38443862
- commandStartedEvent:
38453863
commandName: dropIndexes
38463864
databaseName: *databaseName
@@ -3884,6 +3902,14 @@ tests:
38843902
failCommands: ["dropIndexes"]
38853903
blockConnection: true
38863904
blockTimeMS: 5
3905+
# Create the index first so dropIndex doesn't return IndexNotFound on
3906+
# servers prior to 8.3.
3907+
- name: createIndex
3908+
object: *collection
3909+
arguments:
3910+
keys: { x: 1 }
3911+
name: "x_1"
3912+
timeoutMS: 100000
38873913
- name: dropIndexes
38883914
object: *collection
38893915
arguments:
@@ -3979,4 +4005,4 @@ tests:
39794005
command:
39804006
dropIndexes: *collectionName
39814007
maxTimeMS: { $$lte: *timeoutMS }
3982-
4008+

test/spec/client-side-operations-timeout/global-timeoutMS.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5621,22 +5621,34 @@
56215621
}
56225622
}
56235623
},
5624+
{
5625+
"name": "createIndex",
5626+
"object": "collection",
5627+
"arguments": {
5628+
"keys": {
5629+
"x": 1
5630+
},
5631+
"name": "x_1"
5632+
}
5633+
},
56245634
{
56255635
"name": "dropIndex",
56265636
"object": "collection",
56275637
"arguments": {
56285638
"name": "x_1"
5629-
},
5630-
"expectError": {
5631-
"isClientError": false,
5632-
"isTimeoutError": false
56335639
}
56345640
}
56355641
],
56365642
"expectEvents": [
56375643
{
56385644
"client": "client",
56395645
"events": [
5646+
{
5647+
"commandStartedEvent": {
5648+
"commandName": "createIndexes",
5649+
"databaseName": "test"
5650+
}
5651+
},
56405652
{
56415653
"commandStartedEvent": {
56425654
"commandName": "dropIndexes",

0 commit comments

Comments
 (0)