summaryrefslogtreecommitdiff
path: root/jstests/sharding/timeseries_user_system_buckets_sharding.js
blob: cd4c8ae6bf3cbdb207112548d08da05a4cca46f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
 * Technically this is not time series colleciton test; however, due to legacy behavior, a user
 * inserts into a collection in time series bucket namespace is required not to fail.  Please note
 * this behavior is likely going to be corrected in 6.3 or after. The presence of this test does
 * not imply such behavior is supported.
 *
 * As this tests code path relevant to time series, the requires_tiemseries flag is set to avoid
 * incompatible behavior related to multi statement transactions.
 *
 * @tags: [
 *   # We need a timeseries collection.
 *   requires_timeseries,
 *   requires_fcv_63
 * ]
 */
(function() {
"use strict";

var st = new ShardingTest({shards: 2});
assert.commandWorked(st.s0.adminCommand({enableSharding: 'test'}));
st.ensurePrimaryShard('test', st.shard1.shardName);
var testDB = st.getDB('test');

// shard the collection on x
assert.commandWorked(st.s0.adminCommand({shardcollection: "test.coll", key: {x: 1}}));

assert.commandWorked(testDB.system.buckets.coll.insert({a: 1}));
assert.commandWorked(testDB.coll.insert({b: 1}));

var docs = testDB.coll.find().toArray();
assert.eq(1, docs.length);

var docsSystemBuckets = testDB.system.buckets.coll.find().toArray();
assert.eq(1, docsSystemBuckets.length);

st.stop();
})();