summaryrefslogtreecommitdiff
path: root/jstests/sharding/ssv_nochunk.js
blob: 7d3f8bfdbb215d7843f09437cd797cb8ef085682 (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
38
39
40
/**
 * Tests setShardVersion, particularly on the case where mongos sends it to a
 * shard that does not have any chunks.
 */

var st = new ShardingTest({ shards: 2, mongos: 2 });
st.stopBalancer();

var configDB = st.s.getDB('config');
configDB.adminCommand({ enableSharding: 'test' });
configDB.adminCommand({ movePrimary: 'test', to: 'shard0000' });
configDB.adminCommand({ shardCollection: 'test.user', key: { x: 1 }});

var testDB = st.s.getDB('test');

assert.writeOK(testDB.user.insert({ x: 1 }));

var doc = testDB.user.findOne();

var testDB2 = st.s1.getDB('test');

configDB.adminCommand({ moveChunk: 'test.user', find: { x: 0 }, to: 'shard0001' });

assert.eq(1, testDB.user.find().itcount());
assert.eq(1, testDB2.user.find().itcount());

assert.eq(1, testDB.user.find({ x: 1 }).itcount());
assert.eq(1, testDB2.user.find({ x: 1 }).itcount());

var configDB2 = st.s1.getDB('config');
configDB2.adminCommand({ moveChunk: 'test.user', find: { x: 0 }, to: 'shard0000' });

assert.eq(1, testDB.user.find().itcount());
assert.eq(1, testDB2.user.find().itcount());

assert.eq(1, testDB.user.find({ x: 1 }).itcount());
assert.eq(1, testDB2.user.find({ x: 1 }).itcount());

st.stop();