mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-24 00:17:37 +01:00
8dabd67451
GitOrigin-RevId: d5a1fb056144efac5baf4b3c0b4166ac3bc7944e
41 lines
1.3 KiB
JavaScript
41 lines
1.3 KiB
JavaScript
/**
|
|
* Tests that a warning log message is emitted when a time series is sharded using a timeField as
|
|
* part of the shard key.
|
|
*
|
|
* @tags: [
|
|
* requires_fcv_80,
|
|
* ]
|
|
*/
|
|
|
|
import {ShardingTest} from "jstests/libs/shardingtest.js";
|
|
|
|
const st = new ShardingTest({shards: 1});
|
|
|
|
const dbName = 'test';
|
|
assert.commandWorked(st.s.adminCommand({enableSharding: dbName}));
|
|
const timeseries = {
|
|
timeField: 'time',
|
|
metaField: 'hostId',
|
|
};
|
|
|
|
jsTestLog("Creating sharded time series");
|
|
assert.commandWorked(
|
|
st.s.adminCommand({shardCollection: 'test.meta_only', key: {'hostId': 1}, timeseries}));
|
|
assert.soon(() => checkLog.checkContainsWithCountJson(st.rs0.getPrimary(), 8864700, {}, 0));
|
|
|
|
assert.commandWorked(
|
|
st.s.adminCommand({shardCollection: 'test.time_only', key: {'time': 1}, timeseries}));
|
|
assert.soon(() => checkLog.checkContainsWithCountJson(st.rs0.getPrimary(), 8864700, {}, 1));
|
|
|
|
assert.commandWorked(st.s.adminCommand(
|
|
{shardCollection: 'test.time_meta_compund', key: {'hostId': 1, 'time': 1}, timeseries}));
|
|
assert.soon(() => checkLog.checkContainsWithCountJson(st.rs0.getPrimary(), 8864700, {}, 2));
|
|
|
|
jsTestLog("Restarting sharded cluster");
|
|
st.stopAllConfigServers({}, true /* forRestart */);
|
|
st.restartAllConfigServers();
|
|
|
|
assert.soon(() => checkLog.checkContainsWithCountJson(st.configRS.getPrimary(), 8864701, {}, 2));
|
|
|
|
st.stop();
|