0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00
mongodb/jstests/32bit.js

129 lines
3.7 KiB
JavaScript
Raw Normal View History

2010-08-24 18:36:06 +02:00
// 32bit.js dm
2010-08-25 18:18:57 +02:00
var forceSeedToBe = null;
2010-08-24 18:36:06 +02:00
if (forceSeedToBe)
2010-08-25 18:18:38 +02:00
print("\n32bit.js WARNING FORCING A SPECIFIC SEED - TEST WILL RUN DURING DAY");
2010-08-24 18:36:06 +02:00
2010-08-22 22:11:38 +02:00
function f() {
2010-08-24 18:36:06 +02:00
seed = forceSeedToBe || Math.random();
2010-08-25 17:47:28 +02:00
2010-08-24 15:37:01 +02:00
pass = 1;
2010-08-22 18:42:34 +02:00
2010-08-24 18:36:06 +02:00
var mydb = db.getSisterDB( "test_32bit" );
2010-08-24 15:37:01 +02:00
mydb.dropDatabase();
2010-08-22 18:42:34 +02:00
2010-08-24 15:37:01 +02:00
while( 1 ) {
2010-08-25 17:47:28 +02:00
if( pass >= 2 )
break;
2010-08-24 15:37:01 +02:00
print("32bit.js PASS #" + pass);
pass++;
2010-08-24 18:36:06 +02:00
t = mydb.colltest_32bit;
2010-08-24 15:37:01 +02:00
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 )
t.ensureIndex({c:1});
t.ensureIndex({d:1});
t.ensureIndex({e:1});
t.ensureIndex({f:1});
big = 'a b';
big = big + big;
k = big;
big = big + big;
big = big + big;
big = big + big;
a = 0;
c = 'kkk';
2010-08-25 17:47:28 +02:00
var start = new Date();
2010-08-24 15:37:01 +02:00
while( 1 ) {
b = Math.random(seed);
d = c + -a;
f = Math.random(seed) + a;
a++;
cc = big;
2010-08-25 17:47:28 +02:00
if( Math.random(seed) < .1 )
cc = null;
2010-08-24 15:37:01 +02:00
t.insert({a:a,b:b,c:cc,d:d,f:f});
if( Math.random(seed) < 0.01 ) {
2010-08-22 18:42:34 +02:00
2010-08-24 15:37:01 +02:00
if( mydb.getLastError() ) {
/* 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;
}
t.remove({a:a});
t.remove({b:Math.random(seed)});
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}); }
2010-08-22 18:42:34 +02:00
}
2010-08-26 18:49:04 +02:00
if (a == 20000 ) {
2010-08-25 17:47:28 +02:00
var delta_ms = (new Date())-start;
2010-08-26 18:49:04 +02:00
// 2MM / 20000 = 100. 1000ms/sec.
var eta_secs = delta_ms * (100 / 1000);
print("32bit.js eta_secs:" + eta_secs);
if( eta_secs > 1000 ) {
print("32bit.js machine is slow, stopping early. a:" + a);
2010-08-25 17:50:32 +02:00
mydb.dropDatabase();
return;
}
2010-08-25 17:47:28 +02:00
}
2010-08-24 15:37:01 +02:00
if( a % 100000 == 0 ) {
print(a);
// on 64 bit we won't error out, so artificially stop. on 32 bit we will hit mmap limit ~1.6MM but may
// vary by a factor of 2x by platform
2010-08-25 17:47:28 +02:00
if( a >= 2200000 ) {
mydb.dropDatabase();
2010-08-25 17:50:32 +02:00
return;
2010-08-25 17:47:28 +02:00
}
}
2010-08-24 15:37:01 +02:00
}
print("count: " + t.count());
2010-08-22 18:42:34 +02:00
2010-08-24 17:53:37 +02:00
var res = t.validate();
2010-08-24 18:41:22 +02:00
if( !res.valid ) {
2010-08-24 17:53:37 +02:00
print("32bit.js FAIL validating");
2010-08-24 18:36:06 +02:00
print(res.result);
2010-08-24 17:53:37 +02:00
printjson(res);
2010-08-24 18:36:06 +02:00
//mydb.dropDatabase();
2010-08-24 17:53:37 +02:00
throw "fail validating 32bit.js";
2010-08-24 15:37:01 +02:00
}
2010-08-22 18:42:34 +02:00
2010-08-24 15:37:01 +02:00
mydb.dropDatabase();
}
2010-08-22 18:42:34 +02:00
2010-08-24 15:37:01 +02:00
print("32bit.js SUCCESS");
2010-08-22 22:11:38 +02:00
}
2010-08-22 18:42:34 +02:00
2010-08-22 22:11:38 +02:00
var h = (new Date()).getHours();
if (!db._adminCommand("buildInfo").debug && !db.runCommand( { serverStatus : 1 , repl : 1 } ).repl ){
2010-08-29 00:27:34 +02:00
if (forceSeedToBe || h <= 2 || h >= 22) {
/* 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");
2010-08-22 22:11:38 +02:00
}