Skip to content

Commit

Permalink
SERVER-65491 Fix broken JS tests that query for shardVersion match
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloianm authored and Evergreen Agent committed Apr 13, 2022
1 parent 58fc271 commit 5d5ee59
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 4 deletions.
Expand Up @@ -506,8 +506,52 @@ for (let command of commands) {
profileDB: recipientShardSecondary.getDB(db),
filter: Object.extend({
"command.shardVersion": {"$exists": true},
"command.shardVersion.0": {$ne: ShardVersioningUtil.kIgnoredShardVersion[0]},
"command.shardVersion.1": {$ne: ShardVersioningUtil.kIgnoredShardVersion[1]},
"$and": [
{
"$or": [
{
"$and": [
{"command.shardVersion.0": {"$exists": true}},
{
"command.shardVersion.0":
{$ne: ShardVersioningUtil.kIgnoredShardVersion[0]}
},
]
},
{
"$and": [
{"command.shardVersion.v": {"$exists": true}},
{
"command.shardVersion.v":
{$ne: ShardVersioningUtil.kIgnoredShardVersion[0]}
},
]
},
]
},
{
"$or": [
{
"$and": [
{"command.shardVersion.1": {"$exists": true}},
{
"command.shardVersion.1":
{$ne: ShardVersioningUtil.kIgnoredShardVersion[1]}
},
]
},
{
"$and": [
{"command.shardVersion.e": {"$exists": true}},
{
"command.shardVersion.e":
{$ne: ShardVersioningUtil.kIgnoredShardVersion[1]}
},
]
},
]
}
],
"command.$readPreference": {"mode": "secondary"},
"command.readConcern": {"level": "local"},
"errCode": {"$ne": ErrorCodes.StaleConfig},
Expand Down
33 changes: 31 additions & 2 deletions jstests/sharding/timeseries_multiple_mongos.js
Expand Up @@ -12,6 +12,7 @@
"use strict";

load("jstests/core/timeseries/libs/timeseries.js"); // For 'TimeseriesTest' helpers.
load('jstests/sharding/libs/shard_versioning_util.js');

Random.setRandomSeed();

Expand Down Expand Up @@ -106,7 +107,29 @@ function runTest({shardKey, cmdObj, numProfilerEntries}) {
}

const queryField = `command.${Object.keys(cmdObj)[0]}`;
let filter = {[queryField]: cmdCollName, "command.shardVersion.0": {$ne: Timestamp(0, 0)}};
let filter = {
[queryField]: cmdCollName,
"$or": [
{
"$and": [
{"command.shardVersion.0": {"$exists": true}},
{
"command.shardVersion.0":
{$ne: ShardVersioningUtil.kIgnoredShardVersion[0]}
},
]
},
{
"$and": [
{"command.shardVersion.v": {"$exists": true}},
{
"command.shardVersion.v":
{$ne: ShardVersioningUtil.kIgnoredShardVersion[0]}
},
]
},
]
};

// We currently do not log 'shardVersion' for updates. See SERVER-60354 for details.
if (isUpdate) {
Expand All @@ -117,7 +140,13 @@ function runTest({shardKey, cmdObj, numProfilerEntries}) {
const command = unVersioned ? "_shardsvrCollMod" : "_shardsvrCollModParticipant";
filter = {[`command.${command}`]: cmdCollName, "ok": {$ne: 0}};
} else if (unVersioned && !isCollMod) {
filter["command.shardVersion.0"] = Timestamp(0, 0);
filter = {
[queryField]: cmdCollName,
"$or": [
{"command.shardVersion.0": ShardVersioningUtil.kIgnoredShardVersion[0]},
{"command.shardVersion.v": ShardVersioningUtil.kIgnoredShardVersion[0]},
]
};
}

// Filter out the profiler entries with $indexStats pipeline stage, as the
Expand Down

0 comments on commit 5d5ee59

Please sign in to comment.