var replTest = new ReplSetTest({nodes: 1});
var version = "latest";
var storageEngine = "wiredTiger";
var nodes = replTest.startSet({binVersion: version, storageEngine: storageEngine});
replTest.initiate();
var db = replTest.getPrimary().getDB("test");
print(tojson(db.serverStatus()));
var res = db.adminCommand('listDatabases');
var invalidColls = [];
var ebusyColls = [];
var totalNumEbusy = 0;
var ebusyCollectionWait = 2000;
var ebusyCollectionLoops = 30;
var ebusyAllLoops = 300000;
res.databases.forEach(dbInfo => {
var colls = db.getSiblingDB(dbInfo.name).getCollectionInfos();
colls.forEach(coll => {
print(dbInfo.name, coll.name);
var numEbusy = 0;
var timeStart = new Date().getTime();
while (true) {
var val = db.getSiblingDB(dbInfo.name)[coll.name].validate(true);
var ebusy = val.errors.toString().match('EBUSY');
if (!ebusy ||
++totalNumEbusy >= ebusyAllLoops ||
++numEbusy >= ebusyCollectionLoops) {
if (ebusy) {
ebusyColls.push(val.ns);
}
break;
}
sleep(ebusyCollectionWait);
}
var timeEnd = new Date().getTime();
print(tojson(val), '\ntime to validate(msecs)', timeEnd - timeStart);
if (!val.valid) {
invalidColls.push(val.ns);
}
});
});
if (ebusyColls.length) {
print('EBUSY collections', ebusyColls.join(' '));
}
if (invalidColls.length) {
print('Invalid collections', invalidColls.join(' '));
}
replTest.stopSet();