Skip to content

Commit 07b21f1

Browse files
Merge branch 'main' into NODE-4845
2 parents 4758723 + 52ed3d1 commit 07b21f1

18 files changed

+120
-170
lines changed

.evergreen/config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,7 @@ tasks:
17881788
- {key: VERSION, value: latest}
17891789
- {key: SSL, value: ssl}
17901790
- {key: TOPOLOGY, value: server}
1791+
- {key: AUTH, value: auth}
17911792
- func: install dependencies
17921793
- func: bootstrap mongo-orchestration
17931794
- func: run tls tests
@@ -1802,6 +1803,7 @@ tasks:
18021803
- {key: VERSION, value: '8.0'}
18031804
- {key: SSL, value: ssl}
18041805
- {key: TOPOLOGY, value: server}
1806+
- {key: AUTH, value: auth}
18051807
- func: install dependencies
18061808
- func: bootstrap mongo-orchestration
18071809
- func: run tls tests
@@ -1816,6 +1818,7 @@ tasks:
18161818
- {key: VERSION, value: '7.0'}
18171819
- {key: SSL, value: ssl}
18181820
- {key: TOPOLOGY, value: server}
1821+
- {key: AUTH, value: auth}
18191822
- func: install dependencies
18201823
- func: bootstrap mongo-orchestration
18211824
- func: run tls tests
@@ -1830,6 +1833,7 @@ tasks:
18301833
- {key: VERSION, value: '6.0'}
18311834
- {key: SSL, value: ssl}
18321835
- {key: TOPOLOGY, value: server}
1836+
- {key: AUTH, value: auth}
18331837
- func: install dependencies
18341838
- func: bootstrap mongo-orchestration
18351839
- func: run tls tests
@@ -1844,6 +1848,7 @@ tasks:
18441848
- {key: VERSION, value: '5.0'}
18451849
- {key: SSL, value: ssl}
18461850
- {key: TOPOLOGY, value: server}
1851+
- {key: AUTH, value: auth}
18471852
- func: install dependencies
18481853
- func: bootstrap mongo-orchestration
18491854
- func: run tls tests
@@ -1858,6 +1863,7 @@ tasks:
18581863
- {key: VERSION, value: '4.4'}
18591864
- {key: SSL, value: ssl}
18601865
- {key: TOPOLOGY, value: server}
1866+
- {key: AUTH, value: auth}
18611867
- func: install dependencies
18621868
- func: bootstrap mongo-orchestration
18631869
- func: run tls tests
@@ -1872,6 +1878,7 @@ tasks:
18721878
- {key: VERSION, value: '4.2'}
18731879
- {key: SSL, value: ssl}
18741880
- {key: TOPOLOGY, value: server}
1881+
- {key: AUTH, value: auth}
18751882
- func: install dependencies
18761883
- func: bootstrap mongo-orchestration
18771884
- func: run tls tests

.evergreen/generate_evergreen_tasks.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,8 @@ for (const VERSION of TLS_VERSIONS) {
317317
updateExpansions({
318318
VERSION,
319319
SSL: 'ssl',
320-
TOPOLOGY: 'server'
321-
// TODO: NODE-3891 - fix tests broken when AUTH enabled
322-
// AUTH: 'auth'
320+
TOPOLOGY: 'server',
321+
AUTH: 'auth'
323322
}),
324323
{ func: 'install dependencies' },
325324
{ func: 'bootstrap mongo-orchestration' },

src/cmap/connection_pool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
691691

692692
private ensureMinPoolSize() {
693693
const minPoolSize = this.options.minPoolSize;
694-
if (this.poolState !== PoolState.ready || minPoolSize === 0) {
694+
if (this.poolState !== PoolState.ready) {
695695
return;
696696
}
697697

test/integration/causal-consistency/causal_consistency.prose.test.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const { LEGACY_HELLO_COMMAND } = require('../../mongodb');
44

55
const { setupDatabase } = require('../shared');
66
const { expect } = require('chai');
7-
const { skipBrokenAuthTestBeforeEachHook } = require('../../tools/runner/hooks/configuration');
87

98
const ignoredCommands = [LEGACY_HELLO_COMMAND, 'endSessions'];
109
const test = { commands: { started: [], succeeded: [] } };
@@ -15,21 +14,12 @@ describe('Causal Consistency - prose tests', function () {
1514
return setupDatabase(this.configuration);
1615
});
1716

18-
beforeEach(
19-
skipBrokenAuthTestBeforeEachHook({
20-
skippedTests: [
21-
'2. The first read in a causally consistent session must not send afterClusterTime to the server',
22-
'case: successful read with causal consistency',
23-
'case: second operation is findOne',
24-
'case: successful insert',
25-
'6. A read operation in a ClientSession that is not causally consistent should not include the afterClusterTime parameter in the command sent to the server'
26-
]
27-
})
28-
);
29-
3017
beforeEach(function () {
3118
test.commands = { started: [], succeeded: [] };
32-
test.client = this.configuration.newClient({ w: 1 }, { maxPoolSize: 1, monitorCommands: true });
19+
test.client = this.configuration.newClient(
20+
{ w: 1 },
21+
{ maxPoolSize: 1, monitorCommands: true, __skipPingOnConnect: true }
22+
);
3323
test.client.on('commandStarted', event => {
3424
if (ignoredCommands.indexOf(event.commandName) === -1) test.commands.started.push(event);
3525
});

test/integration/client-side-encryption/client_side_encryption.spec.test.ts

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,53 +8,6 @@ import {
88
} from '../../tools/spec-runner';
99
import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner';
1010

11-
const isAuthEnabled = process.env.AUTH === 'auth';
12-
13-
// 'TODO: NODE-3891 - fix tests broken when AUTH enabled'
14-
const skippedAuthTests = [
15-
'Insert a document with auto encryption using the AWS provider with temporary credentials',
16-
'Insert a document with auto encryption using Azure KMS provider',
17-
'$rename works if target value has same encryption options',
18-
'Bulk write with encryption',
19-
'Insert with bypassAutoEncryption',
20-
'Insert with bypassAutoEncryption for local schema',
21-
'ping is bypassed',
22-
'deleteOne with deterministic encryption',
23-
'deleteMany with deterministic encryption',
24-
'distinct with deterministic encryption',
25-
'Find with deterministic encryption',
26-
'Find with $in with deterministic encryption',
27-
'findOneAndReplace with deterministic encryption',
28-
'findOneAndUpdate with deterministic encryption',
29-
'Insert a document with auto encryption using GCP KMS provider',
30-
'getMore with encryption',
31-
'unset works with an encrypted field',
32-
'updateOne with deterministic encryption',
33-
'updateMany with deterministic encryption',
34-
'replaceOne with encryption',
35-
'Insert with encryption on a missing key',
36-
'A local schema should override',
37-
'Count with deterministic encryption',
38-
'Insert a document with auto encryption using local KMS provider',
39-
'Insert with encryption using key alt name',
40-
'insertMany with encryption',
41-
'insertOne with encryption',
42-
'findOneAndDelete with deterministic encryption',
43-
'$unset works with an encrypted field',
44-
'Insert a document with auto encryption using KMIP KMS provider'
45-
];
46-
47-
// TODO(NODE-6048): Int32 and Long not allowed as batchSize option to cursor.
48-
const skippedNoAuthTests = ['getMore with encryption'];
49-
50-
const SKIPPED_TESTS = new Set([
51-
...(isAuthEnabled ? skippedAuthTests.concat(skippedNoAuthTests) : skippedNoAuthTests),
52-
...[
53-
// the node driver does not have a mapReduce helper
54-
'mapReduce deterministic encryption (unsupported)'
55-
]
56-
]);
57-
5811
describe('Client Side Encryption (Legacy)', function () {
5912
const testContext = new TestRunnerContext({ requiresCSFLE: true });
6013
const testSuites = gatherTestSuites(
@@ -70,8 +23,11 @@ describe('Client Side Encryption (Legacy)', function () {
7023

7124
generateTopologyTests(testSuites, testContext, (test, configuration) => {
7225
const { description } = test;
73-
if (SKIPPED_TESTS.has(description)) {
74-
return 'Skipped by generic test name skip filter.';
26+
if (description === 'getMore with encryption') {
27+
return `TODO(NODE-6048): Int32 and Long not allowed as batchSize option to cursor`;
28+
}
29+
if (description === 'mapReduce deterministic encryption (unsupported)') {
30+
return `the Node driver does not have a mapReduce helper.`;
7531
}
7632
if (
7733
[

test/integration/connection-monitoring-and-pooling/connection.test.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ import {
1414
makeClientMetadata,
1515
MongoClient,
1616
MongoClientAuthProviders,
17+
type MongoClientOptions,
1718
MongoDBResponse,
1819
MongoServerError,
1920
ns,
2021
ServerHeartbeatStartedEvent,
2122
Topology
2223
} from '../../mongodb';
2324
import * as mock from '../../tools/mongodb-mock/index';
24-
import { skipBrokenAuthTestBeforeEachHook } from '../../tools/runner/hooks/configuration';
2525
import { processTick, sleep } from '../../tools/utils';
2626
import { assert as test, setupDatabase } from '../shared';
2727

@@ -37,15 +37,6 @@ const commonConnectOptions = {
3737
};
3838

3939
describe('Connection', function () {
40-
beforeEach(
41-
skipBrokenAuthTestBeforeEachHook({
42-
skippedTests: [
43-
'should support calling back multiple times on exhaust commands',
44-
'should correctly connect to server using domain socket'
45-
]
46-
})
47-
);
48-
4940
before(function () {
5041
return setupDatabase(this.configuration);
5142
});
@@ -182,13 +173,16 @@ describe('Connection', function () {
182173
metadata: {
183174
requires: { topology: 'single', os: '!win32' }
184175
},
185-
186176
test: function (done) {
187177
const configuration = this.configuration;
188-
client = configuration.newClient(
189-
`mongodb://${encodeURIComponent('/tmp/mongodb-27017.sock')}?w=1`,
190-
{ maxPoolSize: 1 }
191-
);
178+
const uri = `mongodb://${encodeURIComponent('/tmp/mongodb-27017.sock')}?w=1`;
179+
const options: MongoClientOptions = {
180+
maxPoolSize: 1
181+
};
182+
if (this.configuration.options.auth) {
183+
options.auth = this.configuration.options.auth;
184+
}
185+
client = configuration.newClient(uri, options);
192186

193187
const db = client.db(configuration.db);
194188

test/integration/connection-monitoring-and-pooling/connection_pool.test.ts

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import { once } from 'node:events';
22

33
import { expect } from 'chai';
4-
5-
import { type ConnectionPoolCreatedEvent, type Db, type MongoClient } from '../../mongodb';
4+
import * as sinon from 'sinon';
5+
6+
import {
7+
type ConnectionPoolCreatedEvent,
8+
type Db,
9+
type MongoClient,
10+
type Server
11+
} from '../../mongodb';
612
import { clearFailPoint, configureFailPoint, sleep } from '../../tools/utils';
713

814
describe('Connection Pool', function () {
@@ -150,4 +156,51 @@ describe('Connection Pool', function () {
150156
});
151157
});
152158
});
159+
160+
describe(
161+
'background task cleans up connections when minPoolSize=0',
162+
{ requires: { topology: 'single' } },
163+
function () {
164+
let server: Server;
165+
let ensureMinPoolSizeSpy: sinon.SinonSpy;
166+
167+
beforeEach(async function () {
168+
client = this.configuration.newClient(
169+
{},
170+
{
171+
maxConnecting: 10,
172+
minPoolSize: 0,
173+
maxIdleTimeMS: 100
174+
}
175+
);
176+
177+
await client.connect();
178+
179+
await Promise.all(
180+
Array.from({ length: 10 }).map(() => {
181+
return client.db('foo').collection('bar').insertOne({ a: 1 });
182+
})
183+
);
184+
185+
server = Array.from(client.topology.s.servers.entries())[0][1];
186+
expect(
187+
server.pool.availableConnectionCount,
188+
'pool was not filled with connections'
189+
).to.be.greaterThan(0);
190+
191+
ensureMinPoolSizeSpy = sinon.spy(server.pool, 'ensureMinPoolSize');
192+
});
193+
194+
it(
195+
'prunes idle connections when minPoolSize=0',
196+
{ requires: { topology: 'single' } },
197+
async function () {
198+
await sleep(500);
199+
expect(server.pool.availableConnectionCount).to.equal(0);
200+
201+
expect(ensureMinPoolSizeSpy).to.have.been.called;
202+
}
203+
);
204+
}
205+
);
153206
});

test/integration/enumerate_databases.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ import { TestBuilder, UnifiedTestSuiteBuilder } from '../tools/utils';
66

77
const metadata: MongoDBMetadataUI = {
88
requires: {
9-
auth: 'enabled',
10-
11-
// 'TODO: NODE-3891 - fix tests broken when AUTH enabled'
12-
// These tests should work on a load balanced topology
13-
topology: '!load-balanced'
9+
auth: 'enabled'
1410
}
1511
};
1612

test/integration/load-balancers/load_balancers.spec.test.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,9 @@ const filter = ({ description }) => {
2626

2727
if (
2828
process.env.AUTH === 'auth' &&
29-
[
30-
'errors during authentication are processed',
31-
'wait queue timeout errors include cursor statistics',
32-
'wait queue timeout errors include transaction statistics',
33-
'operations against non-load balanced clusters fail if URI contains loadBalanced=true',
34-
'operations against non-load balanced clusters succeed if URI contains loadBalanced=false'
35-
].includes(description)
29+
['errors during authentication are processed'].includes(description)
3630
) {
37-
return 'TODO(NODE-3891): fix tests broken when AUTH enabled';
31+
return 'TODO(NODE-7014): clear pool after handshake error in lb mode';
3832
}
3933

4034
return false;

0 commit comments

Comments
 (0)