diff options
author | Nicholas Zolnierz <nicholas.zolnierz@mongodb.com> | 2019-11-27 15:43:51 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-11-27 15:43:51 +0000 |
commit | e69f595582a1c0f0cfd585048015ab0b44e09230 (patch) | |
tree | bd6fc35d4c7488c30288e5593b644bcaa5b94133 /jstests/sharding/collation_targeting.js | |
parent | ffb879d9c4a51a08162ee8c0f54c2a9581e3fe1e (diff) | |
download | mongo-e69f595582a1c0f0cfd585048015ab0b44e09230.tar.gz |
SERVER-44751 Update mapReduce collation tests to respect the collation on emit key comparisons
Diffstat (limited to 'jstests/sharding/collation_targeting.js')
-rw-r--r-- | jstests/sharding/collation_targeting.js | 81 |
1 files changed, 56 insertions, 25 deletions
diff --git a/jstests/sharding/collation_targeting.js b/jstests/sharding/collation_targeting.js index 3fb27342ca4..0e1f06de5b3 100644 --- a/jstests/sharding/collation_targeting.js +++ b/jstests/sharding/collation_targeting.js @@ -214,31 +214,62 @@ assert.eq(1, explain.queryPlanner.winningPlan.shards.length); // MapReduce. -// Test mapReduce on strings with a non-simple collation. -assert.eq(2, - assert - .commandWorked(coll.mapReduce( - function() { - emit(this.a, 1); - }, - function(key, values) { - return Array.sum(values); - }, - {out: {inline: 1}, query: {a: "foo"}, collation: caseInsensitive})) - .results.length); - -// Test mapReduce on strings with a simple collation. -assert.eq(1, - assert - .commandWorked(coll.mapReduce( - function() { - emit(this.a, 1); - }, - function(key, values) { - return Array.sum(values); - }, - {out: {inline: 1}, query: {a: "foo"}})) - .results.length); +// The following set of tests assume that we're running against the new version of MR. +if (TestData.setParameters.internalQueryUseAggMapReduce == 1) { + // Test that the filter on mapReduce respects the non-simple collation from the user. + assert.eq(2, + assert + .commandWorked(coll.mapReduce( + function() { + emit(this._id, 1); + }, + function(key, values) { + return Array.sum(values); + }, + {out: {inline: 1}, query: {a: "foo"}, collation: caseInsensitive})) + .results.length); + + // Test that mapReduce respects the non-simple collation for the emitted keys. In this case, the + // emitted keys "foo" and "FOO" should be considered equal. + assert.eq(1, + assert + .commandWorked(coll.mapReduce( + function() { + emit(this.a, 1); + }, + function(key, values) { + return Array.sum(values); + }, + {out: {inline: 1}, query: {a: "foo"}, collation: caseInsensitive})) + .results.length); + + // Test that the filter on mapReduce respects the simple collation if none is specified. + assert.eq(1, + assert + .commandWorked(coll.mapReduce( + function() { + emit(this._id, 1); + }, + function(key, values) { + return Array.sum(values); + }, + {out: {inline: 1}, query: {a: "foo"}})) + .results.length); + + // Test that mapReduce respects the simple collation for the emitted keys. In this case, the + // emitted keys "foo" and "FOO" should *not* be considered equal. + assert.eq(2, + assert + .commandWorked(coll.mapReduce( + function() { + emit(this.a, 1); + }, + function(key, values) { + return Array.sum(values); + }, + {out: {inline: 1}, query: {a: {$type: "string"}}})) + .results.length); +} // Remove. |