~evarlast/ubuntu/utopic/mongodb/upstart-workaround-debian-bug-718702

« back to all changes in this revision

Viewing changes to jstests/sharding/empty_cluster_init.js

  • Committer: Package Import Robot
  • Author(s): James Page, James Page, Robie Basak
  • Date: 2013-05-29 17:44:42 UTC
  • mfrom: (44.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20130529174442-z0a4qmoww4y0t458
Tags: 1:2.4.3-1ubuntu1
[ James Page ]
* Merge from Debian unstable, remaining changes:
  - Enable SSL support:
    + d/control: Add libssl-dev to BD's.
    + d/rules: Enabled --ssl option.
    + d/mongodb.conf: Add example SSL configuration options.
  - d/mongodb-server.mongodb.upstart: Add upstart configuration.
  - d/rules: Don't strip binaries during scons build for Ubuntu.
  - d/control: Add armhf to target archs.
  - d/p/SConscript.client.patch: fixup install of client libraries.
  - d/p/0010-install-libs-to-usr-lib-not-usr-lib64-Closes-588557.patch:
    Install libraries to lib not lib64.
* Dropped changes:
  - d/p/arm-support.patch: Included in Debian.
  - d/p/double-alignment.patch: Included in Debian.
  - d/rules,control: Debian also builds with avaliable system libraries
    now.
* Fix FTBFS due to gcc and boost upgrades in saucy:
  - d/p/0008-ignore-unused-local-typedefs.patch: Add -Wno-unused-typedefs
    to unbreak building with g++-4.8.
  - d/p/0009-boost-1.53.patch: Fixup signed/unsigned casting issue.

[ Robie Basak ]
* d/p/0011-Use-a-signed-char-to-store-BSONType-enumerations.patch: Fixup
  build failure on ARM due to missing signed'ness of char cast.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// Tests initialization of an empty cluster with multiple mongoses.
 
3
// Starts a bunch of mongoses in parallel, and ensures that there's only a single config 
 
4
// version initialization.
 
5
//
 
6
 
 
7
jsTest.log("Start config servers...")
 
8
 
 
9
var configSvrA = MongoRunner.runMongod({ verbose : 2 });
 
10
var configSvrB = MongoRunner.runMongod({ verbose : 2 });
 
11
var configSvrC = MongoRunner.runMongod({ verbose : 2 });
 
12
 
 
13
var configConnStr = [configSvrA.host, configSvrB.host, configSvrC.host].join(",");
 
14
 
 
15
var configConn = configSvrA;
 
16
 
 
17
// Start profiling the config db
 
18
configConn.getDB("config").setProfilingLevel(2);
 
19
 
 
20
//
 
21
// Start a bunch of mongoses which will probably interfere
 
22
//
 
23
 
 
24
jsTest.log("Starting first set of mongoses in parallel...");
 
25
 
 
26
var mongoses = [];
 
27
for (var i = 0; i < 3; i++) {
 
28
    var mongos = MongoRunner.runMongos({ binVersion : "latest", 
 
29
                                         configdb : configConnStr,
 
30
                                         waitForConnect : false });
 
31
    
 
32
    mongoses.push(mongos);
 
33
}
 
34
 
 
35
// Eventually connect to a mongo host, to be sure that the config upgrade happened
 
36
var mongosConn = null;
 
37
assert.soon(function() {
 
38
    try {
 
39
        mongosConn = new Mongo(mongoses[0].host);
 
40
        return true;
 
41
    }
 
42
    catch (e) {
 
43
        print("Waiting for connect...");
 
44
        printjson(e);
 
45
        return false;
 
46
    }
 
47
});
 
48
 
 
49
var version = mongosConn.getCollection("config.version").findOne();
 
50
 
 
51
//
 
52
// Start a second set of mongoses which should respect the initialized version
 
53
//
 
54
 
 
55
jsTest.log("Starting second set of mongoses...");
 
56
 
 
57
for (var i = 0; i < 3; i++) {
 
58
    var mongos = MongoRunner.runMongos({ binVersion : "latest", 
 
59
                                         configdb : configConnStr,
 
60
                                         waitForConnect : false });
 
61
    
 
62
    mongoses.push(mongos);
 
63
}
 
64
 
 
65
// Eventually connect to a host
 
66
assert.soon(function() {
 
67
    try {
 
68
        mongosConn = new Mongo(mongoses[mongoses.length - 1].host);
 
69
        return true;
 
70
    }
 
71
    catch (e) {
 
72
        print("Waiting for connect...");
 
73
        printjson(e);
 
74
        return false;
 
75
    }
 
76
});
 
77
 
 
78
// Shut down our mongoses now that we've tested them
 
79
for (var i = 0; i < mongoses.length; i++) {
 
80
    MongoRunner.stopMongos(mongoses[i]);
 
81
}
 
82
 
 
83
jsTest.log("Mongoses stopped...");
 
84
 
 
85
//
 
86
// Check version and that the version was only updated once
 
87
//
 
88
 
 
89
printjson(version);
 
90
 
 
91
assert.eq(version.version, 3);
 
92
assert.eq(version.minCompatibleVersion, 3);
 
93
assert.eq(version.currentVersion, 4);
 
94
assert(version.clusterId);
 
95
assert.eq(version.excluding, undefined);
 
96
 
 
97
jsTest.log("Ensuring config.version collection only written once...");
 
98
 
 
99
var updates = configConn.getDB("config").system.profile.find({ op : "update", 
 
100
                                                               ns : "config.version" }).toArray();
 
101
printjson(updates);
 
102
assert.eq(updates.length, 1);
 
103
 
 
104
MongoRunner.stopMongod(configSvrA);
 
105
MongoRunner.stopMongod(configSvrB);
 
106
MongoRunner.stopMongod(configSvrC);
 
107
 
 
108
jsTest.log("DONE!");
 
109