File: reset_shard_version.js

package info (click to toggle)
mongodb 1%3A2.4.10-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 82,464 kB
  • sloc: cpp: 740,225; ansic: 152,098; sh: 13,820; python: 11,864; makefile: 1,012; perl: 922; pascal: 617; java: 452; lisp: 222; asm: 174
file content (51 lines) | stat: -rw-r--r-- 1,409 bytes parent folder | download | duplicates (4)
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
41
42
43
44
45
46
47
48
49
50
51
// Tests whether a reset sharding version triggers errors

jsTestLog( "Starting sharded cluster..." )

var st = new ShardingTest( { shards : 1, mongos : 2 } )

var mongosA = st.s0
var mongosB = st.s1

var collA = mongosA.getCollection( jsTestName() + ".coll" )
collA.drop()
var collB = mongosB.getCollection( "" + collA )

st.shardColl( collA, { _id : 1 }, false )

jsTestLog( "Inserting data..." )

// Insert some data
for ( var i = 0; i < 100; i++ ) {
    collA.insert( { _id : i } )
}

jsTestLog( "Setting connection versions on both mongoses..." )

assert.eq( collA.find().itcount(), 100 )
assert.eq( collB.find().itcount(), 100 )

jsTestLog( "Resetting connection version on shard..." )

var admin = st.shard0.getDB( "admin" )

printjson( admin.runCommand( {
    setShardVersion : "" + collA, version : new Timestamp( 0, 0 ), configdb : st._configDB, serverID : new ObjectId(),
    authoritative : true } ) )

jsTestLog( "Querying with version reset..." )

// This will cause a version check
assert.eq(0, collA.findOne({_id:0})['_id'])

jsTestLog( "Resetting connection version on shard again..." )

printjson( admin.runCommand( {
    setShardVersion : "" + collA, version : new Timestamp( 0, 0 ), configdb : st._configDB, serverID : new ObjectId(),
    authoritative : true } ) )

jsTestLog( "Doing count command with version reset..." )

assert.eq(100, collA.count()) // Test for SERVER-4196

st.stop()