0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-24 00:17:37 +01:00
mongodb/jstests/sharding/stale_version_write.js
Matt Broadstone 771dabd098 SERVER-81339 Convert ReplSetTest and ShardingTest to modules (#26332)
GitOrigin-RevId: 744aa110a53786b23c62ff53f87a1418b5991e8d
2024-08-20 22:00:49 +00:00

41 lines
1.2 KiB
JavaScript

// Tests whether a reset sharding version triggers errors
// @tags: [
// # TODO (SERVER-88123): Re-enable this test.
// # Test doesn't start enough mongods to have num_mongos routers
// embedded_router_incompatible,
// ]
import {ShardingTest} from "jstests/libs/shardingtest.js";
var st = new ShardingTest({shards: 1, mongos: 2});
var mongosA = st.s0;
var mongosB = st.s1;
jsTest.log("Adding new collections...");
var collA = mongosA.getCollection(jsTestName() + ".coll");
assert.commandWorked(collA.insert({hello: "world"}));
var collB = mongosB.getCollection("" + collA);
assert.commandWorked(collB.insert({hello: "world"}));
jsTest.log("Enabling sharding...");
assert.commandWorked(mongosA.getDB("admin").adminCommand({enableSharding: "" + collA.getDB()}));
assert.commandWorked(
mongosA.getDB("admin").adminCommand({shardCollection: "" + collA, key: {_id: 1}}));
// MongoD doesn't know about the config shard version *until* MongoS tells it
collA.findOne();
jsTest.log("Trigger shard version mismatch...");
assert.commandWorked(collB.insert({goodbye: "world"}));
print("Inserted...");
assert.eq(3, collA.find().itcount());
assert.eq(3, collB.find().itcount());
st.stop();