summaryrefslogtreecommitdiff
path: root/jstests/sharding/rs_stepdown_and_pooling.js
diff options
context:
space:
mode:
authorGreg Studer <greg@10gen.com>2013-05-13 19:04:53 -0400
committerGreg Studer <greg@10gen.com>2013-05-13 19:06:08 -0400
commit62fec3e663bf160aafc7663bb5b35a28da314fc2 (patch)
tree96bb0edbcaf540b23dd817bbffa9c2d54d7b952a /jstests/sharding/rs_stepdown_and_pooling.js
parenta7c21d7416d0c80e35e34baeed6040710de1ebd4 (diff)
downloadmongo-62fec3e663bf160aafc7663bb5b35a28da314fc2.tar.gz
SERVER-9041 try num 2, disable inapplicable tests for win32
Diffstat (limited to 'jstests/sharding/rs_stepdown_and_pooling.js')
-rw-r--r--jstests/sharding/rs_stepdown_and_pooling.js172
1 files changed, 93 insertions, 79 deletions
diff --git a/jstests/sharding/rs_stepdown_and_pooling.js b/jstests/sharding/rs_stepdown_and_pooling.js
index 5ce5399f536..4207f33a59e 100644
--- a/jstests/sharding/rs_stepdown_and_pooling.js
+++ b/jstests/sharding/rs_stepdown_and_pooling.js
@@ -2,8 +2,6 @@
// Tests what happens when a replica set primary goes down with pooled connections.
//
-// Helper for running arbitrary commands
-
var options = {separateConfig : true, sync : true};
var st = new ShardingTest({shards : {rs0 : {nodes : 2}}, mongos : 1, other : options});
@@ -13,90 +11,106 @@ st.stopBalancer();
var mongos = st.s0;
var coll = mongos.getCollection("foo.bar");
-var primary = st.rs0.getPrimary();
-var secondary = st.rs0.getSecondary();
-
-jsTest.log("Creating new connections...");
-
-// Create a bunch of connections to the primary node through mongos.
-// jstest ->(x10)-> mongos ->(x10)-> primary
-var conns = [];
-for ( var i = 0; i < 50; i++) {
- conns.push(new Mongo(mongos.host));
- conns[i].getCollection(coll + "").findOne();
-}
+var db = coll.getDB();
-assert.eq(primary.port, 31100);
+//Test is not valid for Win32
+var is32Bits = ( db.serverBuildInfo().bits == 32 );
+if ( is32Bits && _isWindows() ) {
-jsTest.log("Returning the connections back to the pool.");
+ // Win32 doesn't provide the polling interface we need to implement the check tested here
+ jsTest.log( "Test is not valid on Win32 platform." );
-for ( var i = 0; i < conns.length; i++ ) {
- conns[i] = null;
}
-// Make sure we return connections back to the pool
-gc();
-
-// Don't make test fragile by linking to format of shardConnPoolStats, but this is useful if
-// something goes wrong.
-var connPoolStats = mongos.getDB("admin").runCommand({ shardConnPoolStats : 1 });
-printjson( connPoolStats );
-
-jsTest.log("Stepdown primary and then step back up...");
-
-var stepDown = function(node, timeSecs) {
- var result = null;
- try {
- result = node.getDB("admin").runCommand({ replSetStepDown : timeSecs, force : true });
- // Should not get here
- } catch (e) {
- printjson(e);
+else {
+
+ // Non-Win32 platform
+
+ var primary = st.rs0.getPrimary();
+ var secondary = st.rs0.getSecondary();
+
+ jsTest.log("Creating new connections...");
+
+ // Create a bunch of connections to the primary node through mongos.
+ // jstest ->(x10)-> mongos ->(x10)-> primary
+ var conns = [];
+ for ( var i = 0; i < 50; i++) {
+ conns.push(new Mongo(mongos.host));
+ conns[i].getCollection(coll + "").findOne();
}
-
- if (result != null) printjson(result);
- assert.eq(null, result);
-}
-
-stepDown(primary, 0);
-
-jsTest.log("Waiting for mongos to acknowledge stepdown...");
-
-ReplSetTest.awaitRSClientHosts( mongos,
- secondary,
- { ismaster : true },
- st.rs0,
- 2 * 60 * 1000 ); // slow hosts can take longer to recognize the sd
-
-jsTest.log("Stepping back up...");
-
-stepDown(secondary, 10000);
-
-jsTest.log("Waiting for mongos to acknowledge step up...");
-
-ReplSetTest.awaitRSClientHosts( mongos,
- primary,
- { ismaster : true },
- st.rs0,
- 2 * 60 * 1000 );
-
-jsTest.log("Waiting for socket timeout time...");
-
-// Need to wait longer than the socket polling time.
-sleep(2 * 5000);
-
-jsTest.log("Run queries using new connections.");
-
-var numErrors = 0;
-for ( var i = 0; i < conns.length; i++) {
- var newConn = new Mongo(mongos.host);
- try {
- printjson(newConn.getCollection("foo.bar").findOne());
- } catch (e) {
- printjson(e);
- numErrors++;
+
+ assert.eq(primary.port, 31100);
+
+ jsTest.log("Returning the connections back to the pool.");
+
+ for ( var i = 0; i < conns.length; i++ ) {
+ conns[i] = null;
}
-}
+ // Make sure we return connections back to the pool
+ gc();
+
+ // Don't make test fragile by linking to format of shardConnPoolStats, but this is useful if
+ // something goes wrong.
+ var connPoolStats = mongos.getDB("admin").runCommand({ shardConnPoolStats : 1 });
+ printjson( connPoolStats );
+
+ jsTest.log("Stepdown primary and then step back up...");
+
+ var stepDown = function(node, timeSecs) {
+ var result = null;
+ try {
+ result = node.getDB("admin").runCommand({ replSetStepDown : timeSecs, force : true });
+ // Should not get here
+ } catch (e) {
+ printjson(e);
+ }
+
+ if (result != null) printjson(result);
+ assert.eq(null, result);
+ }
+
+ stepDown(primary, 0);
+
+ jsTest.log("Waiting for mongos to acknowledge stepdown...");
+
+ ReplSetTest.awaitRSClientHosts( mongos,
+ secondary,
+ { ismaster : true },
+ st.rs0,
+ 2 * 60 * 1000 ); // slow hosts can take longer to recognize sd
+
+ jsTest.log("Stepping back up...");
+
+ stepDown(secondary, 10000);
+
+ jsTest.log("Waiting for mongos to acknowledge step up...");
+
+ ReplSetTest.awaitRSClientHosts( mongos,
+ primary,
+ { ismaster : true },
+ st.rs0,
+ 2 * 60 * 1000 );
+
+ jsTest.log("Waiting for socket timeout time...");
+
+ // Need to wait longer than the socket polling time.
+ sleep(2 * 5000);
+
+ jsTest.log("Run queries using new connections.");
+
+ var numErrors = 0;
+ for ( var i = 0; i < conns.length; i++) {
+ var newConn = new Mongo(mongos.host);
+ try {
+ printjson(newConn.getCollection("foo.bar").findOne());
+ } catch (e) {
+ printjson(e);
+ numErrors++;
+ }
+ }
+
+ assert.eq(0, numErrors);
-assert.eq(0, numErrors);
+} // End Win32 check
jsTest.log("DONE!");