File: shard_gle_insert.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 (57 lines) | stat: -rw-r--r-- 1,443 bytes parent folder | download | duplicates (3)
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
52
53
54
55
56
57
// Test for SERVER-3763

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

var coll = st.s.getCollection( jsTestName() + ".coll" )
coll.drop()

// Shard collection over two shards
st.shardColl( coll, { _id : 1 }, { _id : 0 } )

var negShard = st.getShard( coll, { _id : -1 }, true )
var posShard = st.getShard( coll, { _id : 1 }, true )

jsTestLog( "Sharding status..." )

st.printShardingStatus()

jsTestLog( "Shutting down negative shard..." )

MongoRunner.stopMongod( negShard )

jsTestLog( "Inserting into negative shard..." )

coll.insert({ _id : -1 })
print( "GLE start" )
var gle_state = 0;
try{
    var err = coll.getDB().getLastError();
    
    // for example -- err : "socket exception [SEND_ERROR] for 127.0.0.1:30001"
    //  or            err : "socket exception [CONNECT_ERROR] for localhost:30001"
    
    if (err && !/socket exception/.test(err)) {
        gle_state = 1;
        print( "Test failure -- received response from getLastError:" + err );
    }
    else if(!err) {
        gle_state = 1;
        print("Test failure -- no response from getLastError.");
    }
    else {
        print("Normal socket error detected: " + err);
    }
}
catch( e ){
    print("Error detected when calling GLE, this is normal:")
    printjson( e )
}
assert( !gle_state );
jsTestLog( "Inserting into positive shard..." )

coll.insert({ _id : 1 })
print( "GLE start" )
printjson( coll.getDB().getLastError() )
print( "test ending" )
st.stop()