2024-04-17 16:47:12 +02:00
|
|
|
/**
|
|
|
|
|
* Test verifying that the system variables are resolved before sent to the shards.
|
|
|
|
|
*
|
|
|
|
|
* Always ensure that there are enough shards in the pool to guarantee non-synced time resolution on
|
|
|
|
|
* shard side.
|
|
|
|
|
*
|
|
|
|
|
* @tags: [
|
|
|
|
|
* requires_fcv_80
|
|
|
|
|
* ]
|
|
|
|
|
*
|
|
|
|
|
*/
|
2024-08-20 17:54:15 -04:00
|
|
|
import {ShardingTest} from "jstests/libs/shardingtest.js";
|
|
|
|
|
|
2024-04-17 16:47:12 +02:00
|
|
|
const numIterations = 5;
|
|
|
|
|
|
|
|
|
|
const st = new ShardingTest({shards: 5});
|
|
|
|
|
const db = st.s.getDB("find_initialize_runtime_variables");
|
|
|
|
|
st.s.adminCommand({shardCollection: "find_initialize_runtime_variables.c", key: {a: "hashed"}});
|
2025-08-28 15:11:44 -04:00
|
|
|
let coll = db.getCollection("find_initialize_runtime_variables");
|
2024-04-17 16:47:12 +02:00
|
|
|
|
|
|
|
|
coll.insert([{a: 1}, {a: 2}, {a: 3}]);
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < numIterations; ++i) {
|
2025-08-28 15:11:44 -04:00
|
|
|
let res = coll.find({}, {a: 1, b: "$$NOW"}).toArray();
|
2024-04-17 16:47:12 +02:00
|
|
|
for (const e of res) {
|
|
|
|
|
// Check consistency of the returned $$NOW values.
|
|
|
|
|
assert.eq(res[0].b, e.b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res = coll.find({}, {a: 1, b: "$$CLUSTER_TIME"}).toArray();
|
|
|
|
|
for (const e of res) {
|
|
|
|
|
// Check consistency of the returned $$CLUSTER_TIME values.
|
|
|
|
|
assert.eq(res[0].b, e.b);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
st.stop();
|