diff options
author | Benety Goh <benety@mongodb.com> | 2021-11-10 17:47:01 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-11-10 23:27:25 +0000 |
commit | 762ba9922d4cbdaef88e30c9567e4541e8172820 (patch) | |
tree | a46df012d789bc504f4564d13651130cbf6c40ed | |
parent | 7673b195c85582a7a8295f508ae61cc50bb9c628 (diff) | |
download | mongo-762ba9922d4cbdaef88e30c9567e4541e8172820.tar.gz |
SERVER-61245 clean up orp.js
-rw-r--r-- | jstests/core/orp.js | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/jstests/core/orp.js b/jstests/core/orp.js index 443128b471f..738e2330f69 100644 --- a/jstests/core/orp.js +++ b/jstests/core/orp.js @@ -6,46 +6,53 @@ const collNamePrefix = 'jstests_orp_'; let collCount = 0; +let docId = 0; let t = db.getCollection(collNamePrefix + collCount++); t.drop(); -t.createIndex({a: 1}); -t.createIndex({b: 1}); -t.createIndex({c: 1}); +assert.commandWorked(t.createIndexes([{a: 1}, {b: 1}, {c: 1}])); -for (let i = 0; i < 200; ++i) { - t.save({a: 1, b: 1}); +let docs = []; +for (let i = 0; i < 110; ++i) { + docs.push({_id: docId++, a: 1, b: 1}); } +assert.commandWorked(t.insert(docs)); // Deduping results from the previous clause. -assert.eq(200, t.count({$or: [{a: 1}, {b: 1}]})); +assert.eq(docs.length, t.countDocuments({$or: [{a: 1}, {b: 1}]})); // Deduping results from a prior clause. -assert.eq(200, t.count({$or: [{a: 1}, {c: 1}, {b: 1}]})); -t.save({c: 1}); -assert.eq(201, t.count({$or: [{a: 1}, {c: 1}, {b: 1}]})); +assert.eq(docs.length, t.countDocuments({$or: [{a: 1}, {c: 1}, {b: 1}]})); +assert.commandWorked(t.insert({_id: docId++, c: 1})); +assert.eq(docs.length + 1, t.countDocuments({$or: [{a: 1}, {c: 1}, {b: 1}]})); // Deduping results that would normally be index only matches on overlapping and double scanned $or // field regions. t = db.getCollection(collNamePrefix + collCount++); t.drop(); -t.createIndex({a: 1, b: 1}); -for (let i = 0; i < 16; ++i) { - for (let j = 0; j < 16; ++j) { - t.save({a: i, b: j}); +assert.commandWorked(t.createIndex({a: 1, b: 1})); +docs = []; +let k = 11; +for (let i = 0; i < k; ++i) { + for (let j = 0; j < k; ++j) { + docs.push({_id: docId++, a: i, b: j}); } } -assert.eq(16 * 16, t.count({$or: [{a: {$gte: 0}, b: {$gte: 0}}, {a: {$lte: 16}, b: {$lte: 16}}]})); +assert.commandWorked(t.insert(docs)); +assert.eq(k * k, + t.countDocuments({$or: [{a: {$gte: 0}, b: {$gte: 0}}, {a: {$lte: k}, b: {$lte: k}}]})); // Deduping results from a clause that completed before the multi cursor takeover. t = db.getCollection(collNamePrefix + collCount++); t.drop(); -t.createIndex({a: 1}); -t.createIndex({b: 1}); -t.save({a: 1, b: 200}); -for (let i = 0; i < 200; ++i) { - t.save({b: i}); +assert.commandWorked(t.createIndexes([{a: 1}, {b: 1}])); +docs = []; +k = 120; +docs.push({_id: docId++, a: 1, b: k}); +for (let i = 0; i < k; ++i) { + docs.push({_id: docId++, b: i}); } -assert.eq(201, t.count({$or: [{a: 1}, {b: {$gte: 0}}]})); +assert.commandWorked(t.insert(docs)); +assert.eq(k + 1, t.countDocuments({$or: [{a: 1}, {b: {$gte: 0}}]})); })(); |