From 031ef1b370ea9138b0609d9dd6a4bae7f7cb18ff Mon Sep 17 00:00:00 2001 From: Yujin Kang Park <36410031+ykangpark@users.noreply.github.com> Date: Thu, 24 Oct 2024 17:27:23 +0200 Subject: [PATCH] SERVER-96030 Make interface parity test join metadata refresh (#28343) GitOrigin-RevId: 82ec56dfdc78a9e42031167af31a27ece71a3d6c --- ...mands_interface_parity_with_replica_set.js | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/jstests/sharding/mongos_unsharded_commands_interface_parity_with_replica_set.js b/jstests/sharding/mongos_unsharded_commands_interface_parity_with_replica_set.js index ac529c33dd2..08aa4ae4ee0 100644 --- a/jstests/sharding/mongos_unsharded_commands_interface_parity_with_replica_set.js +++ b/jstests/sharding/mongos_unsharded_commands_interface_parity_with_replica_set.js @@ -70,6 +70,20 @@ import { stopReplicationOnSecondariesOfAllShards } from "jstests/libs/write_concern_util.js"; +function joinFilteringMetadataRefresh(db, collName, mongoConfig) { + if (mongoConfig instanceof ShardingTest) { + const fullName = db.getName() + "." + collName; + // On a sharded environment we want to ensure that the filtering metadata refresh is + // finished before running our tests. + assert.soon(() => { + let shard = mongoConfig.getPrimaryShard(db.getName()); + const shardVersion = assert.commandWorked( + shard.rs.getPrimary().adminCommand({getShardVersion: fullName})); + return shardVersion !== 'UNKNOWN'; + }); + } +} + const tests = [ { @@ -91,8 +105,9 @@ const tests = [ }, { shortDescription: "Runs validate on an empty collection.", - testCaseSetup: function(db) { + testCaseSetup: function(db, mongoConfig) { assert.commandWorked(db.createCollection("x")); + joinFilteringMetadataRefresh(db, "x", mongoConfig); }, command: {validate: "x"}, skipSetup: true, @@ -255,8 +270,9 @@ const tests = [ }, { shortDescription: "Runs createIndexes on an existing empty collection.", - testCaseSetup: function(db) { + testCaseSetup: function(db, mongoConfig) { assert.commandWorked(db.createCollection("x")); + joinFilteringMetadataRefresh(db, "x", mongoConfig); }, command: {createIndexes: "x", indexes: [{key: {a: 1}, name: "a_1"}]}, }, @@ -351,6 +367,9 @@ function collModParity(db, collModCommand) { } function collModParityTests(db) { + const isSharded = FixtureHelpers.isMongos(db); + jsTestLog(`collModParityTests: sharded=${isSharded}`); + collModParity(db, { command: { collMod: "", // Filled by collModParity @@ -402,13 +421,17 @@ function runAndAssertTestCase(testCase, db) { * and returns the result. */ function runTestCase(test, testCase, forceWriteConcernError, testFixture) { + const isSharded = testFixture.mongoConfig instanceof ShardingTest; + jsTestLog(`Test case: '${testCase.shortDescription}'` + + `\nEnv: sharded=${isSharded}, forceWriteConcernError=${forceWriteConcernError}`); + var ctx; const db = testFixture.db; if (!testCase.skipSetup && test.setup) { ctx = test.setup(db); } if (testCase.testCaseSetup) { - testCase.testCaseSetup(db); + testCase.testCaseSetup(db, testFixture.mongoConfig); } let result;