Skip to content

Commit f2f56a0

Browse files
author
dalyd
committed
PERF-1097: Fix mongo-perf to run on 3.0
1 parent 4f8f6bb commit f2f56a0

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

util/utils.js

+24-1
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,37 @@ function checkForDroppedCollections(database){
6565
// collection name.
6666
var pendingDropRegex = new RegExp("system\.drop\..*\.");
6767
collections = database.runCommand("listCollections", {includePendingDrops: true}).cursor.firstBatch;
68-
collection = collections.find(c => pendingDropRegex.test(c.name));
68+
collection = collections.find(function(c){pendingDropRegex.test(c.name)});
6969
return collection;
7070
}
7171

72+
/*
73+
* Cast a string number to an integer, and throw an exception if it fails.
74+
*/
75+
function toInt(string_number){
76+
var number = parseInt(string_number);
77+
if (isNaN(number)) {
78+
throw "parseInt returned NaN";
79+
}
80+
return number;
81+
}
82+
7283
function checkForDroppedCollectionsTestDBs(db, multidb){
7384
// Check for any collections in 'drop-pending' state in any test
7485
// database. The test databases have name testN, where N is 0 to
7586
// multidb - 1;
87+
88+
// The checks only matter for versions 3.5 and later.
89+
// The shell has some issues with the checks before 3.2
90+
var serverVersion = db.version().split(".");
91+
var clientVersion = version().split(".");
92+
93+
if ( toInt(serverVersion[0]) < 3 || (toInt(serverVersion[0]) == 3 && toInt(serverVersion[1]) < 5 )) {
94+
return;
95+
}
96+
if ( toInt(clientVersion[0]) < 3 || (toInt(clientVersion[0]) == 3 && toInt(clientVersion[1]) < 2 )) {
97+
return;
98+
}
7699
for (var i = 0; i < multidb; i++) {
77100
var sibling_db = db.getSiblingDB('test' + i);
78101
var retries = 0;

0 commit comments

Comments
 (0)