diff options
author | Mihai Andrei <mihai.andrei@10gen.com> | 2020-04-06 16:00:39 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-09 18:11:40 +0000 |
commit | 09bdc6a1761293384732fef37db5dc00f65ddd6c (patch) | |
tree | 713b1cc69bd9340bd3cccb66c320133a6dcd1f40 /jstests/aggregation | |
parent | d18f59ceeb4ecfb83be86cb90482f1f621499d64 (diff) | |
download | mongo-09bdc6a1761293384732fef37db5dc00f65ddd6c.tar.gz |
SERVER-46544 Unblacklist tests in aggregation_secondary_reads passthrough
(cherry picked from commit c2d9a6418ae34bd0821cfbc84cf78c854d058dd3)
Diffstat (limited to 'jstests/aggregation')
6 files changed, 57 insertions, 42 deletions
diff --git a/jstests/aggregation/bugs/server21632.js b/jstests/aggregation/bugs/server21632.js index d0b64d88437..00262070121 100644 --- a/jstests/aggregation/bugs/server21632.js +++ b/jstests/aggregation/bugs/server21632.js @@ -13,6 +13,8 @@ (function() { "use strict"; +load('jstests/libs/fixture_helpers.js'); // For isReplSet() and awaitReplication(). + var coll = db.server21632; coll.drop(); @@ -23,6 +25,13 @@ assert.eq([], coll.aggregate([{$sample: {size: 10}}]).toArray()); db.createCollection(coll.getName()); +// If we are performing secondary reads against a replica set, we need to wait for the created +// collection to replicate to all of the secondaries before we attempt to run coll.stats() on it +// since coll.stats() is not causally consistent. +if (FixtureHelpers.isReplSet(db)) { + FixtureHelpers.awaitReplication(db); +} + // Test if we are running WT + LSM and if so, skip the test. // WiredTiger LSM random cursor implementation doesn't currently give random enough // distribution to pass this test case, so disable the test when checking an LSM @@ -31,7 +40,7 @@ db.createCollection(coll.getName()); var storageEngine = jsTest.options().storageEngine || "wiredTiger"; -if (storageEngine == "wiredTiger" && coll.stats().wiredTiger.type == 'lsm') { +if (storageEngine === "wiredTiger" && coll.stats().wiredTiger.type === 'lsm') { return; } diff --git a/jstests/aggregation/bugs/server5932.js b/jstests/aggregation/bugs/server5932.js index 1c2752297c5..db6be7d3f50 100644 --- a/jstests/aggregation/bugs/server5932.js +++ b/jstests/aggregation/bugs/server5932.js @@ -1,4 +1,14 @@ -// server-5932 Cursor-based aggregation +/** + * server-5932 Cursor-based aggregation + * + * This test will not work with causal consistency because an aggregate and its subsequent + * getMores act as one operation, which means that there are no guarantees that future cursor + * commands will read any writes which occur in between cursor commands. + * @tags: [does_not_support_causal_consistency] + */ + +(function() { +"use strict"; var t = db.server5932; t.drop(); @@ -89,4 +99,5 @@ t.drop(); assert.throws(function() { cursor.itcount(); }); +})(); // DON'T ADD NEW TEST TO THIS FILE AFTER THIS ONE (unless you reseed the data) diff --git a/jstests/aggregation/expressions/collation_expressions.js b/jstests/aggregation/expressions/collation_expressions.js index c8445eb5b60..1b8b98eda2b 100644 --- a/jstests/aggregation/expressions/collation_expressions.js +++ b/jstests/aggregation/expressions/collation_expressions.js @@ -202,20 +202,24 @@ coll.drop(); assert.commandWorked(coll.insert({_id: 1, a: "A"})); assert.commandWorked(coll.insert({_id: 2, b: "B"})); assert.commandWorked(coll.insert({_id: 3, c: "C"})); -results = coll.aggregate([{ - $project: { - out: { - $switch: { - branches: [ - {case: {$eq: ["$a", "a"]}, then: "foo"}, - {case: {$eq: ["$b", "b"]}, then: "bar"} - ], - default: "baz" - } - } - } - }], - {collation: caseInsensitive}) +results = coll.aggregate( + [ + {$sort: {_id: 1}}, + { + $project: { + out: { + $switch: { + branches: [ + {case: {$eq: ["$a", "a"]}, then: "foo"}, + {case: {$eq: ["$b", "b"]}, then: "bar"} + ], + default: "baz" + } + } + } + } + ], + {collation: caseInsensitive}) .toArray(); assert.eq(3, results.length); assert.eq("foo", results[0].out); diff --git a/jstests/aggregation/group_conversion_to_distinct_scan.js b/jstests/aggregation/group_conversion_to_distinct_scan.js index 47cf5005a09..f99c8a072da 100644 --- a/jstests/aggregation/group_conversion_to_distinct_scan.js +++ b/jstests/aggregation/group_conversion_to_distinct_scan.js @@ -6,9 +6,12 @@ * distinct field exactly once among matching documents and also provides any requested sort. The * test queries below show most $match/$sort/$group combinations where that is possible. * - * The sharding and $facet passthrough suites modifiy aggregation pipelines in a way that prevents - * the DISTINCT_SCAN optimization from being applied, which breaks the test. - * @tags: [assumes_unsharded_collection, do_not_wrap_aggregations_in_facets] + * @tags: [ + * # The sharding and $facet passthrough suites modifiy aggregation pipelines in a way that + * # prevents the DISTINCT_SCAN optimization from being applied, which breaks the test. + * assumes_unsharded_collection, do_not_wrap_aggregations_in_facets, + * # Index filter commands do not support causal consistency. + * does_not_support_causal_consistency] */ (function() { diff --git a/jstests/aggregation/sources/lookup/lookup_subpipeline.js b/jstests/aggregation/sources/lookup/lookup_subpipeline.js index 59a1ddd552b..5e04bdb4665 100644 --- a/jstests/aggregation/sources/lookup/lookup_subpipeline.js +++ b/jstests/aggregation/sources/lookup/lookup_subpipeline.js @@ -2,7 +2,7 @@ (function() { "use strict"; -load("jstests/aggregation/extras/utils.js"); // For assertErrorCode. +load("jstests/aggregation/extras/utils.js"); // For assertErrorCode and anyEq. const testName = "lookup_subpipeline"; @@ -11,17 +11,6 @@ const from = db.from; const thirdColl = db.thirdColl; const fourthColl = db.fourthColl; -// Used by testPipeline to sort result documents. All _ids must be primitives. -function compareId(a, b) { - if (a._id < b._id) { - return -1; - } - if (a._id > b._id) { - return 1; - } - return 0; -} - function generateNestedPipeline(foreignCollName, numLevels) { let pipeline = [{"$lookup": {pipeline: [], from: foreignCollName, as: "same"}}]; @@ -34,8 +23,7 @@ function generateNestedPipeline(foreignCollName, numLevels) { // Helper for testing that pipeline returns correct set of results. function testPipeline(pipeline, expectedResult, collection) { - assert.eq(collection.aggregate(pipeline).toArray().sort(compareId), - expectedResult.sort(compareId)); + assert(anyEq(collection.aggregate(pipeline).toArray(), expectedResult)); } // diff --git a/jstests/aggregation/sources/unionWith/unionWith_collation.js b/jstests/aggregation/sources/unionWith/unionWith_collation.js index ca52619aa7b..e6bd9c8d98c 100644 --- a/jstests/aggregation/sources/unionWith/unionWith_collation.js +++ b/jstests/aggregation/sources/unionWith/unionWith_collation.js @@ -31,16 +31,16 @@ assert.commandWorked( testDB.createCollection(caseInsensitiveColl.getName(), {collation: caseInsensitiveCollation})); assert.commandWorked(noCollationColl.insert([ - {val: "a"}, - {val: "b", caseSensitiveColl: true}, - {val: "B", caseSensitiveColl: true}, - {val: "c"} + {_id: 0, val: "a"}, + {_id: 1, val: "b", caseSensitiveColl: true}, + {_id: 2, val: "B", caseSensitiveColl: true}, + {_id: 3, val: "c"} ])); assert.commandWorked(caseInsensitiveColl.insert([ - {val: "a"}, - {val: "B", caseSensitiveColl: false}, - {val: "b", caseSensitiveColl: false}, - {val: "c"} + {_id: 0, val: "a"}, + {_id: 1, val: "B", caseSensitiveColl: false}, + {_id: 2, val: "b", caseSensitiveColl: false}, + {_id: 3, val: "c"} ])); const unionWith = (foreignCollName, values) => { @@ -48,7 +48,7 @@ const unionWith = (foreignCollName, values) => { {$match: {val: {$in: values}}}, {$unionWith: {coll: foreignCollName, pipeline: [{$match: {val: {$in: values}}}]}}, { - $sort: {"val": 1, caseSensitiveColl: 1}, + $sort: {"val": 1, caseSensitiveColl: 1, _id: 1}, }, {$project: {_id: 0}} ]; |