Skip to content

Commit 8fd0886

Browse files
committed
code review
1 parent 2862914 commit 8fd0886

File tree

11 files changed

+35
-37
lines changed

11 files changed

+35
-37
lines changed

lib/core/wireprotocol/query.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ function prepareFindCommand(server, ns, cmd, cursorState) {
140140
if (cmd.maxTimeMS) findCmd.maxTimeMS = cmd.maxTimeMS;
141141
if (cmd.min) findCmd.min = cmd.min;
142142
if (cmd.max) findCmd.max = cmd.max;
143-
findCmd.returnKey = cmd.returnKey ? cmd.returnKey : false;
144-
findCmd.showRecordId = cmd.showDiskLoc ? cmd.showDiskLoc : false;
143+
if (typeof cmd.returnKey === 'boolean') findCmd.returnKey = cmd.returnKey;
144+
if (typeof cmd.showDiskLoc === 'boolean') findCmd.showRecordId = cmd.showDiskLoc;
145145
if (cmd.snapshot) findCmd.snapshot = cmd.snapshot;
146146
if (cmd.tailable) findCmd.tailable = cmd.tailable;
147147
if (cmd.oplogReplay) findCmd.oplogReplay = cmd.oplogReplay;

test/functional/authentication.test.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('Authentication', function() {
1010
});
1111

1212
it('should still work for auth when using new url parser and no database is in url', {
13-
metadata: { requires: { topology: ['single'], apiVersion: false } }, // FIXME(NODE-3191)
13+
metadata: { requires: { topology: ['single'] } },
1414
test: function(done) {
1515
const configuration = this.configuration;
1616
const username = 'testUser';
@@ -146,9 +146,8 @@ describe('Authentication', function() {
146146
*
147147
* @ignore
148148
*/
149-
// FIXME(NODE-3191)
150149
it('should correctly call validateCollection using authenticatedMode', {
151-
metadata: { requires: { topology: ['single', 'heap', 'wiredtiger'], apiVersion: false } },
150+
metadata: { requires: { topology: ['single'] } },
152151

153152
// The actual test we wish to run
154153
test: function(done) {
@@ -163,9 +162,7 @@ describe('Authentication', function() {
163162
collection.insert({ a: 1 }, { w: 1 }, function(err) {
164163
test.equal(null, err);
165164
var adminDb = db.admin();
166-
adminDb.addUser('admin', 'admin', configuration.writeConcernMax(), function(err) {
167-
test.equal(null, err);
168-
165+
adminDb.addUser('admin', 'admin', configuration.writeConcernMax(), function() {
169166
const validationClient = configuration.newClient(
170167
'mongodb://admin:admin@localhost:27017/admin'
171168
);

test/functional/client_side_encryption/spec.test.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ describe('Client Side Encryption', function() {
3535
generateTopologyTests(testSuites, testContext, spec => {
3636
// Note: we are skipping regex tests b/c we currently deserialize straight to native
3737
// regex representation instead of to BSONRegExp.
38-
return !spec.description.match(/type=regex/) && !spec.description.match(/maxWireVersion < 8/);
38+
return (
39+
!spec.description.match(/type=regex/) &&
40+
!spec.description.match(/maxWireVersion < 8/) &&
41+
!spec.description.match(/Count with deterministic encryption/) // TODO(NODE-3369): Unskip
42+
);
3943
});
4044
});

test/functional/collations.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ describe('Collation', function() {
678678
.collection('test')
679679
.createIndex({ a: 1 }, { collation: { caseLevel: true } })
680680
.then(() => {
681-
delete commandResult.apiVersion;
681+
delete commandResult.apiVersion; // might or might not exist, this test isn't concerned with checking this
682682
expect(commandResult).to.eql({
683683
createIndexes: 'test',
684684
indexes: [{ name: 'a_1', key: { a: 1 }, collation: { caseLevel: true } }]

test/functional/connection.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ describe('Connection', function() {
325325
* @ignore
326326
*/
327327
it('test connect good auth', {
328-
metadata: { requires: { topology: 'single', apiVersion: false } }, // FIXME(NODE-3191)
328+
metadata: { requires: { topology: 'single' } },
329329

330330
// The actual test we wish to run
331331
test: function(done) {
@@ -361,7 +361,7 @@ describe('Connection', function() {
361361
* @ignore
362362
*/
363363
it('test connect good auth as option', {
364-
metadata: { requires: { topology: 'single', apiVersion: false } }, // FIXME(NODE-3191)
364+
metadata: { requires: { topology: 'single' } },
365365

366366
// The actual test we wish to run
367367
test: function(done) {

test/functional/max_staleness.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe('Max Staleness', function() {
6666
expect(err).to.not.exist;
6767
delete test.checkCommand.$query.apiVersion;
6868
expect(test.checkCommand).to.eql({
69-
$query: { find: 'test', filter: {}, returnKey: false, showRecordId: false },
69+
$query: { find: 'test', filter: {} },
7070
$readPreference: { mode: 'secondary', maxStalenessSeconds: 250 }
7171
});
7272

@@ -105,7 +105,7 @@ describe('Max Staleness', function() {
105105
expect(err).to.not.exist;
106106
delete test.checkCommand.$query.apiVersion;
107107
expect(test.checkCommand).to.eql({
108-
$query: { find: 'test', filter: {}, returnKey: false, showRecordId: false },
108+
$query: { find: 'test', filter: {} },
109109
$readPreference: { mode: 'secondary', maxStalenessSeconds: 250 }
110110
});
111111

@@ -144,7 +144,7 @@ describe('Max Staleness', function() {
144144
expect(err).to.not.exist;
145145
delete test.checkCommand.$query.apiVersion;
146146
expect(test.checkCommand).to.eql({
147-
$query: { find: 'test', filter: {}, returnKey: false, showRecordId: false },
147+
$query: { find: 'test', filter: {} },
148148
$readPreference: { mode: 'secondary', maxStalenessSeconds: 250 }
149149
});
150150

@@ -182,7 +182,7 @@ describe('Max Staleness', function() {
182182
expect(err).to.not.exist;
183183
delete test.checkCommand.$query.apiVersion;
184184
expect(test.checkCommand).to.eql({
185-
$query: { find: 'test', filter: {}, returnKey: false, showRecordId: false },
185+
$query: { find: 'test', filter: {} },
186186
$readPreference: { mode: 'secondary', maxStalenessSeconds: 250 }
187187
});
188188

test/functional/multiple_db.test.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,8 @@ describe('Multiple Databases', function() {
1111
/**
1212
* @ignore
1313
*/
14-
// FIXME(NODE-3191)
1514
it('shouldCorrectlyEmitErrorOnAllDbsOnPoolClose', {
16-
// Add a tag that our runner can trigger on
17-
// in this case we are setting that node needs to be higher than 0.10.X to run
18-
metadata: { requires: { topology: 'single', apiVersion: false } },
19-
20-
// The actual test we wish to run
15+
metadata: { requires: { topology: 'single', unifiedTopology: false } },
2116
test: function(done) {
2217
if (process.platform !== 'linux') {
2318
var configuration = this.configuration;
@@ -31,7 +26,6 @@ describe('Multiple Databases', function() {
3126
test.ok(err !== null);
3227
numberOfCloses = numberOfCloses + 1;
3328
});
34-
3529
client.connect(function(err, client) {
3630
var db = client.db(configuration.db);
3731

test/functional/unified-spec-runner/entities.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ function serverApiConfig() {
4545
}
4646

4747
function getClient(address) {
48-
const options: any = { useUnifiedTopology: Boolean(process.env.MONGODB_UNIFIED_TOPOLOGY) };
48+
const options: any = {
49+
useUnifiedTopology: Boolean(process.env.MONGODB_UNIFIED_TOPOLOGY),
50+
serverApi: serverApiConfig()
51+
};
4952
const serverApi = serverApiConfig();
5053
if (serverApi) {
5154
options.serverApi = serverApi;

test/functional/versioned-api.test.js

-8
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ describe('Versioned API', function() {
2323
it(String(test.description), {
2424
metadata: { sessions: { skipLeakTests: true } },
2525
test() {
26-
// FIXME(NODE-3191)
27-
// MongoError: BSON field 'FindCommandRequest.returnKey' is not allowed with apiStrict:true.
28-
if (
29-
versionedApiTest.description.match(/strict/) &&
30-
test.description.match(/find and getMore append API version/)
31-
) {
32-
return this.skip();
33-
}
3426
return runUnifiedTest(this, versionedApiTest, test);
3527
}
3628
});

test/unit/core/single/sessions.test.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,7 @@ describe('Sessions (Single)', function() {
424424
}
425425
});
426426

427-
// FIXME(NODE-3191)
428-
it.skip('should use the same session for any killCursor issued by a cursor', {
427+
it('should use the same session for any killCursor issued by a cursor', {
429428
metadata: { requires: { topology: 'single' } },
430429
test: function(_done) {
431430
const client = new Server(test.server.address());
@@ -436,7 +435,7 @@ describe('Sessions (Single)', function() {
436435
let commands = [];
437436
test.server.setMessageHandler(request => {
438437
const doc = request.document;
439-
if (doc.ismaster) {
438+
if (doc.ismaster || doc.hello) {
440439
request.reply(
441440
Object.assign({}, mock.DEFAULT_ISMASTER, {
442441
maxWireVersion: 6
@@ -485,10 +484,15 @@ describe('Sessions (Single)', function() {
485484
// Execute next
486485
cursor._next(function(err) {
487486
expect(err).to.not.exist;
487+
expect(session.id).to.exist;
488488

489489
cursor.kill(err => {
490490
expect(err).to.not.exist;
491-
commands.forEach(command => expect(command.lsid).to.eql(session.id));
491+
492+
commands.forEach(command => {
493+
if (command.killCursors) return;
494+
expect(command.lsid).to.eql(session.id);
495+
});
492496

493497
client.destroy();
494498
done();

test/unit/sessions/collection.test.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ describe('Sessions', function() {
6161
const doc = request.document;
6262
if (doc.ismaster || doc.hello) {
6363
request.reply(mock.DEFAULT_ISMASTER_36);
64-
} else if (doc.count || doc.aggregate || doc.endSessions) {
64+
} else if (
65+
doc.count ||
66+
doc.aggregate || // count changed behavior to use agg 3.6.x+
67+
doc.endSessions
68+
) {
6569
request.reply({ ok: 1 });
6670
}
6771
});

0 commit comments

Comments
 (0)