summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kangas <matt.kangas@mongodb.com>2015-01-23 18:26:42 -0500
committerRamon Fernandez <ramon.fernandez@mongodb.com>2015-02-09 16:50:53 -0500
commit7f5df52b3a48b1ab028e8453443de67f8fe46155 (patch)
tree96e014d8f9fc18b6c7104989d50289cb2c47b4aa
parentb42f74998bd3d4aa3bfc940999d0d3d2648e0e6b (diff)
downloadmongo-7f5df52b3a48b1ab028e8453443de67f8fe46155.tar.gz
SERVER-17233 32bit.js make jstest reproducible
Also check for write error each time through loop (cherry picked from commit 8d3013163471f805fa68fbaa027d5686c4beb762)
-rw-r--r--jstests/slow2/32bit.js101
1 files changed, 55 insertions, 46 deletions
diff --git a/jstests/slow2/32bit.js b/jstests/slow2/32bit.js
index 9e125eafdf7..91ac9082d6a 100644
--- a/jstests/slow2/32bit.js
+++ b/jstests/slow2/32bit.js
@@ -1,16 +1,26 @@
// 32bit.js dm
+// Use Random.rand() and helpers, not Math.random()
+
+var abortSlowHost = true;
var forceSeedToBe = null;
-if (forceSeedToBe)
- print("\n32bit.js WARNING FORCING A SPECIFIC SEED - TEST WILL RUN DURING DAY");
+if (forceSeedToBe) {
+ print("\n32bit.js WARNING FORCING A SPECIFIC SEED");
+ print("seed="+ forceSeedToBe)
+ Random.srand(forceSeedToBe);
+}
+else {
+ Random.setRandomSeed();
+}
function f() {
- seed = forceSeedToBe || Math.random();
-
- pass = 1;
+ 'use strict';
+ var pass = 1;
var mydb = db.getSisterDB( "test_32bit" );
+ var t = mydb.colltest_32bit;
+
mydb.dropDatabase();
while (1) {
@@ -20,73 +30,78 @@ function f() {
print("32bit.js PASS #" + pass);
pass++;
- t = mydb.colltest_32bit;
-
- print("seed=" + seed);
-
t.insert({x:1});
t.ensureIndex({a:1});
t.ensureIndex({b:1}, true);
t.ensureIndex({x:1});
- if (Math.random() < 0.3) {
+ if (Random.rand() < 0.3) {
t.ensureIndex({c:1});
}
t.ensureIndex({d:1});
t.ensureIndex({e:1});
t.ensureIndex({f:1});
- big = 'a b';
+ // create 448 byte string
+ var big = 'a b';
big = big + big;
- k = big;
big = big + big;
big = big + big;
big = big + big;
- a = 0;
- c = 'kkk';
+ var a = 0;
+ var c = 'kkk';
var start = new Date();
+ var b, d, f, cc;
while (1) {
- b = Math.random(seed);
+ // Insert:
+ // a: number, integer count of documents inserted
+ // b: number, random in range [0.0, 1.0)
+ // c: null (10% chance) or string big (90% chance)
+ // d: string "kkk-<value of a>"
+ // f: number, a + random in range [0.0, 1.0)
+
+ b = Random.rand();
d = c + -a;
- f = Math.random(seed) + a;
+ f = Random.rand() + a;
a++;
cc = big;
- if (Math.random(seed) < .1) {
+ if (Random.rand() < 0.1) {
cc = null;
}
+
var res = t.insert({ a: a, b: b, c: cc, d: d, f: f });
- if (Math.random(seed) < 0.01) {
- if (res.hasWriteError()) {
- // Presumably we have mmap error on 32 bit. try a few more manipulations
- // attempting to break things.
- t.insert({a:33,b:44,c:55,d:66,f:66});
- t.insert({a:33,b:44000,c:55,d:66});
- t.insert({a:33,b:440000,c:55});
- t.insert({a:33,b:4400000});
- t.update({a:20},{'$set':{c:'abc'}});
- t.update({a:21},{'$set':{c:'aadsfbc'}});
- t.update({a:22},{'$set':{c:'c'}});
- t.update({a:23},{'$set':{b:cc}});
- t.remove({a:22});
- break;
- }
+ if (res.hasWriteError()) {
+ // Presumably we have mmap error on 32 bit. try a few more manipulations
+ // attempting to break things.
+ t.insert({a:33,b:44,c:55,d:66,f:66});
+ t.insert({a:33,b:44000,c:55,d:66});
+ t.insert({a:33,b:440000,c:55});
+ t.insert({a:33,b:4400000});
+ t.update({a:20},{'$set':{c:'abc'}});
+ t.update({a:21},{'$set':{c:'aadsfbc'}});
+ t.update({a:22},{'$set':{c:'c'}});
+ t.update({a:23},{'$set':{b:cc}});
+ t.remove({a:22});
+ break;
+ }
+ if (Random.rand() < 0.01) {
t.remove({a:a});
- t.remove({b:Math.random(seed)});
+ t.remove({b:Random.rand()});
t.insert({e:1});
t.insert({f:'aaaaaaaaaa'});
- if (Math.random() < 0.00001) { print("remove cc"); t.remove({c:cc}); }
- if (Math.random() < 0.0001) { print("update cc"); t.update({c:cc},{'$set':{c:1}},false,true); }
- if (Math.random() < 0.00001) { print("remove e"); t.remove({e:1}); }
+ if (Random.rand() < 0.00001) { print("remove cc"); t.remove({c:cc}); }
+ if (Random.rand() < 0.0001) { print("update cc"); t.update({c:cc},{'$set':{c:1}},false,true); }
+ if (Random.rand() < 0.00001) { print("remove e"); t.remove({e:1}); }
}
- if (a == 20000 ) {
+ if (a == 20000) {
var delta_ms = (new Date())-start;
// 2MM / 20000 = 100. 1000ms/sec.
var eta_secs = delta_ms * (100 / 1000);
print("32bit.js eta_secs:" + eta_secs);
- if (eta_secs > 1000) {
+ if (eta_secs > 1000 && abortSlowHost) {
print("32bit.js machine is slow, stopping early. a:" + a);
mydb.dropDatabase();
return;
@@ -119,11 +134,5 @@ function f() {
print("32bit.js SUCCESS");
}
-if (!db._adminCommand("buildInfo").debug && !db.runCommand( { serverStatus : 1 , repl : 1 } ).repl ){
- /* this test is slow, so don't run during the day */
- print("\n32bit.js running - this test is slow so only runs at night.");
- f();
-}
-else {
- print("32bit.js skipping this test - debug server build would be too slow");
-}
+print("\n32bit.js running - this test is slow.");
+f();