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

47 lines
1.7 KiB
JavaScript

/**
* Tests that the mongo shell can use a cluster time with a valid signature to advance a server's
* cluster time.
* @tags: [
* # TODO (SERVER-88129): Re-enable this test or add an explanation why it is incompatible.
* embedded_router_incompatible,
* ]
*/
import {ShardingTest} from "jstests/libs/shardingtest.js";
// Setup 2 mongos processes with mongobridge.
let st = new ShardingTest({shards: 1, mongos: 2, useBridge: true});
// Sever outgoing communications from the second mongos.
st.s0.disconnect(st.s1);
st.forEachConfigServer(function(configSvr) {
configSvr.disconnect(st.s1);
});
st._rsObjects.forEach(function(rsNodes) {
rsNodes.nodes.forEach(function(conn) {
conn.disconnect(st.s1);
});
});
let connectedDB = st.s0.getDB("test");
let disconnectedDB = st.s1.getDB("test");
// Send an insert to the connected mongos to advance its cluster time.
let res = assert.commandWorked(connectedDB.runCommand({insert: "foo", documents: [{x: 1}]}));
// Get logicalTime metadata from the connected mongos's response and send it in a hello
// command to the disconnected mongos. hello does not require mongos to contact any other
// servers, so the command should succeed.
let lt = res.$clusterTime;
res =
assert.commandWorked(disconnectedDB.runCommand({hello: 1, $clusterTime: lt}),
"expected the disconnected mongos to accept cluster time: " + tojson(lt));
// Verify cluster time response from the disconnected mongos matches what was passed.
assert.eq(lt,
res.$clusterTime,
"expected the disconnected mongos to send cluster time: " + tojson(lt) +
", received: " + tojson(res.$clusterTime));
st.stop();