diff options
author | Tommaso Tocci <tommaso.tocci@mongodb.com> | 2022-03-07 22:32:59 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-03-08 02:25:52 +0000 |
commit | 49d052e7c0679471a72a7db03982d4c5053d9bca (patch) | |
tree | 2c9e31a2d117bec9d56dec4594dc68a0375593d2 | |
parent | 1462e3f77868ceb1b9989e63840a701d40cb9256 (diff) | |
download | mongo-49d052e7c0679471a72a7db03982d4c5053d9bca.tar.gz |
SERVER-64240 Speedup long running tests on core suite
-rw-r--r-- | jstests/core/bench_test1.js | 2 | ||||
-rw-r--r-- | jstests/core/collection_truncate.js | 16 | ||||
-rw-r--r-- | jstests/core/dbadmin.js | 8 | ||||
-rw-r--r-- | jstests/core/fsync.js | 24 | ||||
-rw-r--r-- | jstests/core/index_many2.js | 22 | ||||
-rw-r--r-- | jstests/core/mr_killop.js | 4 |
6 files changed, 56 insertions, 20 deletions
diff --git a/jstests/core/bench_test1.js b/jstests/core/bench_test1.js index d527f6d07b8..9defe88749e 100644 --- a/jstests/core/bench_test1.js +++ b/jstests/core/bench_test1.js @@ -18,7 +18,7 @@ const ops = [ {op: "update", ns: t.getFullName(), query: {_id: 1}, update: {$inc: {x: 1}}, writeCmd: true} ]; -const seconds = 10; +const seconds = 2; const benchArgs = { ops: ops, diff --git a/jstests/core/collection_truncate.js b/jstests/core/collection_truncate.js index a6a38420015..fc10262bd1e 100644 --- a/jstests/core/collection_truncate.js +++ b/jstests/core/collection_truncate.js @@ -37,10 +37,22 @@ truncate(); assertEmpty(); // Multi-extent case. -var initialStorageSize = t.stats().storageSize; +const initialStorageSize = t.stats().storageSize; +const long_string = Array(1024 * 1024).toString(); + +let idx = 0; while (t.stats().storageSize == initialStorageSize) { - t.insert({a: 1}); + let bulk = t.initializeUnorderedBulkOp(); + const nDocs = 300; + for (let i = 0; i < nDocs; i++) { + bulk.insert({a: ++idx, text: long_string}); + } + assert.commandWorked(bulk.execute()); } +jsTest.log("Initial storage size: " + initialStorageSize); +jsTest.log("Num inserts: " + idx); +jsTest.log("Storage size after inserts: " + t.stats().storageSize); + truncate(); assertEmpty(); diff --git a/jstests/core/dbadmin.js b/jstests/core/dbadmin.js index 29aaae432db..b41771d513e 100644 --- a/jstests/core/dbadmin.js +++ b/jstests/core/dbadmin.js @@ -31,10 +31,10 @@ if (localTimeSkew >= 50) { assert.lt(localTimeSkew, 60 * 60 * 1000 /* one minute */, "hello.localTime"); var before = db.runCommand("serverStatus"); -print(before.uptimeEstimate); -sleep(5000); +print(before.uptimeMillis); +sleep(100); var after = db.runCommand("serverStatus"); -print(after.uptimeEstimate); -assert.gte(after.uptimeEstimate, before.uptimeEstimate, "uptime estimate should be non-decreasing"); +print(after.uptimeMillis); +assert.gte(after.uptimeMillis, before.uptimeMillis, "uptime estimate should be non-decreasing"); })(); diff --git a/jstests/core/fsync.js b/jstests/core/fsync.js index c8508e1811e..ee66fcb313f 100644 --- a/jstests/core/fsync.js +++ b/jstests/core/fsync.js @@ -15,6 +15,23 @@ (function() { "use strict"; +function waitUntilOpCountIs(opFilter, num) { + assert.soon(() => { + let ops = db.getSiblingDB('admin') + .aggregate([ + {$currentOp: {}}, + {$match: opFilter}, + ]) + .toArray(); + if (ops.length != num) { + jsTest.log("Num opeartions: " + ops.length + ", expected: " + num); + jsTest.log(ops); + return false; + } + return true; + }); +} + // Start with a clean DB. var fsyncLockDB = db.getSiblingDB('fsyncLockTestDB'); fsyncLockDB.dropDatabase(); @@ -56,7 +73,7 @@ assert(db.getSiblingDB('admin').runCommand({currentOp: 1}).fsyncLock, // is blocked. There is really no way to do that currently, so just check that the write didn't // go through. var writeOpHandle = startParallelShell("db.getSiblingDB('fsyncLockTestDB').coll.insert({x:1});"); -sleep(3000); +waitUntilOpCountIs({op: 'insert', ns: 'fsyncLockTestDB.coll', waitingForLock: true}, 1); // Make sure reads can still run even though there is a pending write and also that the write // didn't get through. @@ -103,13 +120,14 @@ assert(currentOp.fsyncLock, "Value in currentOp result incorrect for fsyncLocked let shellHandle2 = startParallelShell("db.getSiblingDB('fsyncLockTestDB').multipleLock.insert({x:1});"); -sleep(3000); +waitUntilOpCountIs({op: 'insert', ns: 'fsyncLockTestDB.multipleLock', waitingForLock: true}, 2); + assert.eq(0, fsyncLockDB.multipleLock.find({}).itcount()); fsyncUnlockRes = db.fsyncUnlock(); assert.commandWorked(fsyncUnlockRes); assert(fsyncUnlockRes.lockCount == 1, tojson(fsyncLockRes)); -sleep(3000); +sleep(1000); assert.eq(0, fsyncLockDB.multipleLock.find({}).itcount()); fsyncUnlockRes = db.fsyncUnlock(); diff --git a/jstests/core/index_many2.js b/jstests/core/index_many2.js index d923ad5cf13..a92da63c406 100644 --- a/jstests/core/index_many2.js +++ b/jstests/core/index_many2.js @@ -31,16 +31,22 @@ const maxNumIndexesAllowed = collectionIsClustered ? 65 : 64; jsTestLog("Creating " + (maxNumIndexesAllowed - 1) + " indexes."); // Only 63 will succeed because 64 is the maximum number of indexes allowed on a collection. -let i = 1; assert.soon(() => { - const key = make(i++); - // May fail due to stepdowns and shutdowns. Keep trying until we reach the + // Index creation May fail due to stepdowns and shutdowns. Keep trying until we reach the // server limit for indexes in a collection. - const res = t.createIndex(key); - const num = t.getIndexKeys().length; - jsTestLog('createIndex: ' + tojson(key) + ': ' + - ' (num indexes: ' + num + '): ' + tojson(res)); - return num === maxNumIndexesAllowed; + try { + const numCurrentIndexes = t.getIndexKeys().length; + for (let i = numCurrentIndexes + 1; i <= maxNumIndexesAllowed; i++) { + const key = make(i); + const res = assert.commandWorked(t.createIndex(key)); + jsTestLog('createIndex: ' + tojson(key) + ': ' + tojson(res)); + } + assert.eq(t.getIndexKeys().length, maxNumIndexesAllowed); + return true; + } catch (e) { + jsTest.log("Failed to create indexes: " + e); + return false; + } }); const indexKeys = t.getIndexKeys(); diff --git a/jstests/core/mr_killop.js b/jstests/core/mr_killop.js index 52423248d08..df5de3e1003 100644 --- a/jstests/core/mr_killop.js +++ b/jstests/core/mr_killop.js @@ -74,7 +74,7 @@ function runTest(map, reduce, finalize, scope, wait) { startParallelShell("assert.commandWorked( db.runCommand( " + stringifiedSpec + " ) );"); if (wait) { - sleep(2000); + sleep(20); } let opCode = null; @@ -180,7 +180,7 @@ function runFinalizeTests(loop) { const loop = function() { while (1) { - sleep(1000); + sleep(10); } }; runMapTests(loop, false); |