File: upgrade_cluster_v3_to_v4_wait_for_mongos.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 (74 lines) | stat: -rw-r--r-- 1,984 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
 * Tests upgrading a cluster where there was a recently active mongos process.
 */

load( './jstests/multiVersion/libs/multi_rs.js' )
load( './jstests/multiVersion/libs/multi_cluster.js' )

jsTest.log( "Starting 2.2 cluster..." );

var options = {
    
    mongosOptions : { binVersion : "2.2" },
    configOptions : { binVersion : "2.2" },
    shardOptions : { binVersion : "2.2" },
    
    separateConfig : true,
    sync : false
};

var st = new ShardingTest({ shards : 1, mongos : 1, other : options });

// Turn balancer off, don't wait
st.setBalancer(false);

var mongos = st.s0;

jsTest.log( "Starting v2.0 mongos..." );

var mongos20 = MongoRunner.runMongos({ binVersion : "2.0", configdb : st._configDB })

jsTest.log( "Waiting for 2.0 ping document..." );

var hasPing = function() {
  return mongos.getCollection("config.mongos").findOne({ _id : RegExp(":" + mongos20.port + "$") }) != null;
}

assert.soon( hasPing );

jsTest.log( "Stopping 2.0 mongos..." );

MongoRunner.stopMongos(mongos20);

jsTest.log( "Upgrade should be unsuccessful..." );

// Make sure down
var mongosNew = MongoRunner.runMongos({ binVersion : "2.4", configdb : st._configDB, upgrade : "" })
assert.eq(null, mongosNew);

jsTest.log("Resetting time to zero...");

printjson(mongos.getCollection("config.mongos").findOne({ _id : RegExp(":" + mongos20.port + "$") }));

mongos.getCollection("config.mongos").update({ _id : RegExp(":" + mongos20.port + "$") },
                                             { $set : { ping : new Date(0) } });
assert.eq(null, mongos.getDB("config").getLastError());

printjson(mongos.getCollection("config.mongos").findOne({ _id : RegExp(":" + mongos20.port + "$") }));

jsTest.log("Trying to restart mongos...");

// Make sure up
var mongosNew = MongoRunner.runMongos({ binVersion : "2.4", configdb : st._configDB, upgrade : "" })
assert.neq(null, mongosNew);

jsTest.log("Mongos started!");

MongoRunner.stopMongos(mongosNew);

jsTest.log("DONE!")

st.stop();