var st = new ShardingTest({ shards: 2, mongos: 4 });
st.stopBalancer();
var testDB_s0 = st.s.getDB('test');
testDB_s0.adminCommand({ enableSharding: 'test' });
testDB_s0.adminCommand({ movePrimary: 'test', to: 'shard0001' });
testDB_s0.adminCommand({ shardCollection: 'test.user', key: { x: 1 }});
var checkShardMajorVersion = function(conn, expectedVersion) {
var shardVersionInfo = conn.adminCommand({ getShardVersion: 'test.user' });
assert.eq(expectedVersion, shardVersionInfo.global.getTime());
};
var testDB_s1 = st.s1.getDB('test');
assert.writeOK(testDB_s1.user.insert({ x: 1 }));
assert.commandWorked(testDB_s1.adminCommand({ moveChunk: 'test.user',
find: { x: 0 },
to: 'shard0000' }));
var testDB_s2 = st.s2.getDB('test');
assert.neq(null, testDB_s2.user.findOne({ x: 1 }));
testDB_s1.user.drop();
testDB_s1.adminCommand({ shardCollection: 'test.user', key: { x: 1 }});
testDB_s1.adminCommand({ split: 'test.user', middle: { x: 0 }});
testDB_s1.user.insert({ x: 1 });
testDB_s1.user.insert({ x: -11 });
assert.commandWorked(testDB_s1.adminCommand({ moveChunk: 'test.user',
find: { x: -1 },
to: 'shard0000' }));
checkShardMajorVersion(st.d0, 0);
checkShardMajorVersion(st.d1, 2);
assert.neq(null, testDB_s2.user.findOne({ x: 1 }));
checkShardMajorVersion(st.d0, 2);
st.stop();