mongo/jstests/hooks/run_check_metadata_consistency.js
Denis Trailin e203a39bac SERVER-120773: Move server-catalog-and-routing-ddl files to subdirectory (#49035)
GitOrigin-RevId: db8e16887e4ebbdc66f16c98f1d1516cad8a4af8
2026-03-11 16:25:07 +00:00

32 lines
1.0 KiB
JavaScript

import {MetadataConsistencyChecker} from "jstests/libs/server_catalog/check_metadata_consistency_helpers.js";
import {DiscoverTopology, Topology} from "jstests/libs/discover_topology.js";
assert.neq(typeof db, "undefined", "No `db` object, is the shell connected to a server?");
const conn = db.getMongo();
const assertNonShardedCluster = (conn) => {
let topology;
try {
topology = DiscoverTopology.findConnectedNodes(conn);
} catch (e) {
jsTest.log.info(`Aborted metadata consistency check due to an error during topology discovery: ${e}`);
return;
}
assert(
topology &&
topology.type != Topology.kShardedCluster &&
!(topology.type == Topology.kReplicaSet && topology.configsvr && TestData.testingReplicaSetEndpoint),
"Metadata consistency check command not found, but we are unexpectedly on a sharded cluster",
);
};
try {
MetadataConsistencyChecker.run(conn);
} catch (e) {
if (e.code === ErrorCodes.CommandNotFound) {
assertNonShardedCluster(conn);
}
}