mirror of https://gitee.com/bigwinds/arangodb
Bugfix/fix recovery testsuite (#7396)
This commit is contained in:
parent
b360c21f32
commit
a905b2ca35
|
@ -247,6 +247,9 @@ function cleanupLastDirectory (options) {
|
||||||
if (options.cleanup) {
|
if (options.cleanup) {
|
||||||
while (cleanupDirectories.length) {
|
while (cleanupDirectories.length) {
|
||||||
const cleanupDirectory = cleanupDirectories.shift();
|
const cleanupDirectory = cleanupDirectories.shift();
|
||||||
|
if (options.extremeVerbosity === true) {
|
||||||
|
print("Cleaning up: " + cleanupDirectory);
|
||||||
|
}
|
||||||
// Avoid attempting to remove the same directory multiple times
|
// Avoid attempting to remove the same directory multiple times
|
||||||
if ((cleanupDirectories.indexOf(cleanupDirectory) === -1) &&
|
if ((cleanupDirectories.indexOf(cleanupDirectory) === -1) &&
|
||||||
(fs.exists(cleanupDirectory))) {
|
(fs.exists(cleanupDirectory))) {
|
||||||
|
|
|
@ -633,6 +633,57 @@ function runThere (options, instanceInfo, file) {
|
||||||
}
|
}
|
||||||
runThere.info = 'runThere';
|
runThere.info = 'runThere';
|
||||||
|
|
||||||
|
function readTestResult(path, rc) {
|
||||||
|
const jsonFN = fs.join(path, 'testresult.json');
|
||||||
|
let buf;
|
||||||
|
try {
|
||||||
|
buf = fs.read(jsonFN);
|
||||||
|
fs.remove(jsonFN);
|
||||||
|
} catch (x) {
|
||||||
|
let msg = 'failed to read ' + jsonFN + " - " + x;
|
||||||
|
print(RED + msg + RESET);
|
||||||
|
return {
|
||||||
|
status: false,
|
||||||
|
message: msg,
|
||||||
|
duration: -1
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let result;
|
||||||
|
try {
|
||||||
|
result = JSON.parse(buf);
|
||||||
|
} catch (x) {
|
||||||
|
let msg = 'failed to parse ' + jsonFN + "'" + buf + "' - " + x;
|
||||||
|
print(RED + msg + RESET);
|
||||||
|
return {
|
||||||
|
status: false,
|
||||||
|
message: msg,
|
||||||
|
duration: -1
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(result)) {
|
||||||
|
if (result.length === 0) {
|
||||||
|
// spec-files - don't have parseable results.
|
||||||
|
rc.failed = rc.status ? 0 : 1;
|
||||||
|
return rc;
|
||||||
|
} else if ((result.length >= 1) &&
|
||||||
|
(typeof result[0] === 'object') &&
|
||||||
|
result[0].hasOwnProperty('status')) {
|
||||||
|
return result[0];
|
||||||
|
} else {
|
||||||
|
rc.failed = rc.status ? 0 : 1;
|
||||||
|
rc.message = "don't know howto handle '" + buf + "'";
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
} else if (_.isObject(result)) {
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
rc.failed = rc.status ? 0 : 1;
|
||||||
|
rc.message = "don't know howto handle '" + buf + "'";
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
}
|
||||||
// //////////////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////////////
|
||||||
// / @brief runs a local unittest file using arangosh
|
// / @brief runs a local unittest file using arangosh
|
||||||
// //////////////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -653,27 +704,8 @@ function runInArangosh (options, instanceInfo, file, addArgs) {
|
||||||
args = Object.assign(args, addArgs);
|
args = Object.assign(args, addArgs);
|
||||||
}
|
}
|
||||||
require('internal').env.INSTANCEINFO = JSON.stringify(instanceInfo);
|
require('internal').env.INSTANCEINFO = JSON.stringify(instanceInfo);
|
||||||
const jsonFN = fs.join(instanceInfo.rootDir, 'testresult.json');
|
|
||||||
let rc = pu.executeAndWait(pu.ARANGOSH_BIN, toArgv(args), options, 'arangosh', instanceInfo.rootDir, false, options.coreCheck);
|
let rc = pu.executeAndWait(pu.ARANGOSH_BIN, toArgv(args), options, 'arangosh', instanceInfo.rootDir, false, options.coreCheck);
|
||||||
let result;
|
return readTestResult(instanceInfo.rootDir, rc);
|
||||||
try {
|
|
||||||
result = JSON.parse(fs.read(jsonFN));
|
|
||||||
|
|
||||||
fs.remove(jsonFN);
|
|
||||||
} catch (x) {
|
|
||||||
if (options.extremeVerbosity) {
|
|
||||||
print('failed to read ' + jsonFN);
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((typeof result[0] === 'object') &&
|
|
||||||
result[0].hasOwnProperty('status')) {
|
|
||||||
return result[0];
|
|
||||||
} else {
|
|
||||||
rc.failed = rc.status ? 0 : 1;
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
runInArangosh.info = 'arangosh';
|
runInArangosh.info = 'arangosh';
|
||||||
|
|
||||||
|
@ -845,54 +877,6 @@ function runInRSpec (options, instanceInfo, file, addArgs) {
|
||||||
}
|
}
|
||||||
runInRSpec.info = 'runInRSpec';
|
runInRSpec.info = 'runInRSpec';
|
||||||
|
|
||||||
// //////////////////////////////////////////////////////////////////////////////
|
|
||||||
// / @brief
|
|
||||||
// //////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
function makeResults (testname, instanceInfo) {
|
|
||||||
const startTime = time();
|
|
||||||
|
|
||||||
return function (status, message) {
|
|
||||||
let duration = time() - startTime;
|
|
||||||
let results;
|
|
||||||
|
|
||||||
if (status) {
|
|
||||||
let result;
|
|
||||||
|
|
||||||
try {
|
|
||||||
result = JSON.parse(fs.read(instanceInfo.rootDir + '/testresult.json'));
|
|
||||||
|
|
||||||
if ((typeof result[0] === 'object') &&
|
|
||||||
result[0].hasOwnProperty('status')) {
|
|
||||||
results = result[0];
|
|
||||||
}
|
|
||||||
} catch (x) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (results === undefined) {
|
|
||||||
results = {
|
|
||||||
status: status,
|
|
||||||
duration: duration,
|
|
||||||
total: 1,
|
|
||||||
failed: status ? 0 : 1,
|
|
||||||
'testing.js': {
|
|
||||||
status: status,
|
|
||||||
duration: duration
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (message) {
|
|
||||||
results['testing.js'].message = message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let full = {};
|
|
||||||
full[testname] = results;
|
|
||||||
|
|
||||||
return full;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.runThere = runThere;
|
exports.runThere = runThere;
|
||||||
exports.runInArangosh = runInArangosh;
|
exports.runInArangosh = runInArangosh;
|
||||||
exports.runInLocalArangosh = runInLocalArangosh;
|
exports.runInLocalArangosh = runInLocalArangosh;
|
||||||
|
@ -901,10 +885,10 @@ exports.runInRSpec = runInRSpec;
|
||||||
exports.makePathUnix = makePathUnix;
|
exports.makePathUnix = makePathUnix;
|
||||||
exports.makePathGeneric = makePathGeneric;
|
exports.makePathGeneric = makePathGeneric;
|
||||||
exports.performTests = performTests;
|
exports.performTests = performTests;
|
||||||
|
exports.readTestResult = readTestResult;
|
||||||
exports.filterTestcaseByOptions = filterTestcaseByOptions;
|
exports.filterTestcaseByOptions = filterTestcaseByOptions;
|
||||||
exports.splitBuckets = splitBuckets;
|
exports.splitBuckets = splitBuckets;
|
||||||
exports.doOnePathInner = doOnePathInner;
|
exports.doOnePathInner = doOnePathInner;
|
||||||
exports.scanTestPaths = scanTestPaths;
|
exports.scanTestPaths = scanTestPaths;
|
||||||
exports.makeResults = makeResults;
|
|
||||||
exports.diffArray = diffArray;
|
exports.diffArray = diffArray;
|
||||||
exports.pathForTesting = pathForTesting;
|
exports.pathForTesting = pathForTesting;
|
||||||
|
|
|
@ -677,7 +677,7 @@ function iterateTests(cases, options, jsonReply) {
|
||||||
delete result.failed;
|
delete result.failed;
|
||||||
delete result.crashed;
|
delete result.crashed;
|
||||||
|
|
||||||
let status = Object.values(result).every(testCase => testCase.status === true);
|
status = Object.values(result).every(testCase => testCase.status === true);
|
||||||
let failed = Object.values(result).reduce((prev, testCase) => prev + !testCase.status, 0);
|
let failed = Object.values(result).reduce((prev, testCase) => prev + !testCase.status, 0);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
globalStatus = false;
|
globalStatus = false;
|
||||||
|
|
|
@ -50,97 +50,85 @@ const testPaths = {
|
||||||
// / @brief TEST: recovery
|
// / @brief TEST: recovery
|
||||||
// //////////////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
function runArangodRecovery (instanceInfo, options, script, setup, count) {
|
function runArangodRecovery (params) {
|
||||||
let tmpDir;
|
let argv = [];
|
||||||
if (!instanceInfo.recoveryArgs) {
|
|
||||||
let tempDir = fs.getTempPath();
|
|
||||||
let td = fs.join(tempDir, `${count}`);
|
|
||||||
if (setup) {
|
|
||||||
pu.cleanupDBDirectoriesAppend(td);
|
|
||||||
}
|
|
||||||
td = fs.join(td, 'data');
|
|
||||||
fs.makeDirectoryRecursive(td);
|
|
||||||
instanceInfo.tmpDataDir = td;
|
|
||||||
|
|
||||||
let appDir = fs.join(td, 'app');
|
if (params.setup) {
|
||||||
fs.makeDirectoryRecursive(appDir);
|
params.options.disableMonitor = true;
|
||||||
tmpDir = fs.join(td, 'tmp');
|
params.testDir = fs.join(params.tempDir, `${params.count}`);
|
||||||
|
pu.cleanupDBDirectoriesAppend(params.testDir);
|
||||||
|
let dataDir = fs.join(params.testDir, 'data');
|
||||||
|
let appDir = fs.join(params.testDir, 'app');
|
||||||
|
let tmpDir = fs.join(params.testDir, 'tmp');
|
||||||
|
fs.makeDirectoryRecursive(params.testDir);
|
||||||
|
fs.makeDirectoryRecursive(dataDir);
|
||||||
fs.makeDirectoryRecursive(tmpDir);
|
fs.makeDirectoryRecursive(tmpDir);
|
||||||
|
fs.makeDirectoryRecursive(appDir);
|
||||||
|
|
||||||
let args = pu.makeArgs.arangod(options, appDir, '', tmpDir);
|
let args = pu.makeArgs.arangod(params.options, appDir, '', tmpDir);
|
||||||
args['wal.reserve-logfiles'] = 1;
|
|
||||||
args['rocksdb.wal-file-timeout-initial'] = 10;
|
|
||||||
args['database.directory'] = instanceInfo.tmpDataDir + '/db';
|
|
||||||
|
|
||||||
args = Object.assign(args, options.extraArgs);
|
|
||||||
|
|
||||||
instanceInfo.recoveryArgv = toArgv(args).concat(['--server.rest-server', 'false', '--replication.auto-start', 'true']);
|
|
||||||
}
|
|
||||||
|
|
||||||
let argv = instanceInfo.recoveryArgv;
|
|
||||||
|
|
||||||
if (setup) {
|
|
||||||
argv = argv.concat([
|
|
||||||
'--javascript.script-parameter', 'setup'
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
argv = argv.concat([
|
|
||||||
'--wal.ignore-logfile-errors', 'true',
|
|
||||||
'--javascript.script-parameter', 'recovery'
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// enable development debugging if extremeVerbosity is set
|
// enable development debugging if extremeVerbosity is set
|
||||||
if (options.extremeVerbosity === true) {
|
if (params.options.extremeVerbosity === true) {
|
||||||
argv = argv.concat([
|
args['log.level'] = 'development=info';
|
||||||
'--log.level', 'development=info'
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
args = Object.assign(args, params.options.extraArgs);
|
||||||
|
args = Object.assign(args, {
|
||||||
|
'wal.reserve-logfiles': 1,
|
||||||
|
'rocksdb.wal-file-timeout-initial': 10,
|
||||||
|
'database.directory': fs.join(dataDir + 'db'),
|
||||||
|
'server.rest-server': 'false',
|
||||||
|
'replication.auto-start': 'true',
|
||||||
|
'javascript.script': params.script
|
||||||
|
});
|
||||||
|
params.args = args;
|
||||||
|
|
||||||
argv = argv.concat([
|
argv = toArgv(
|
||||||
'--javascript.script', script
|
Object.assign(params.args,
|
||||||
]);
|
{
|
||||||
|
'javascript.script-parameter': 'setup'
|
||||||
let binary = pu.ARANGOD_BIN;
|
|
||||||
|
|
||||||
instanceInfo.pid = pu.executeAndWait(binary, argv, options, 'recovery', instanceInfo.rootDir, setup, !setup && options.coreCheck);
|
|
||||||
if (!setup) {
|
|
||||||
let jsonFN = fs.join(tmpDir, 'testresult.json');
|
|
||||||
try {
|
|
||||||
let result = JSON.parse(fs.read(jsonFN));
|
|
||||||
fs.remove(jsonFN);
|
|
||||||
return result;
|
|
||||||
} catch (x) {
|
|
||||||
print(RED + 'failed to read ' + jsonFN + RESET);
|
|
||||||
return {
|
|
||||||
status: false,
|
|
||||||
message: 'failed to read ' + jsonFN + x,
|
|
||||||
duration: -1
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
argv = toArgv(
|
||||||
|
Object.assign(params.args,
|
||||||
|
{
|
||||||
|
'wal.ignore-logfile-errors': 'true',
|
||||||
|
'javascript.script-parameter': 'recovery'
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
params.instanceInfo.pid = pu.executeAndWait(
|
||||||
|
pu.ARANGOD_BIN,
|
||||||
|
argv,
|
||||||
|
params.options,
|
||||||
|
'recovery',
|
||||||
|
params.instanceInfo.rootDir,
|
||||||
|
params.setup,
|
||||||
|
!params.setup && params.options.coreCheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
function recovery (options) {
|
function recovery (options) {
|
||||||
let results = {};
|
|
||||||
|
|
||||||
if (!global.ARANGODB_CLIENT_VERSION(true)['failure-tests'] ||
|
if (!global.ARANGODB_CLIENT_VERSION(true)['failure-tests'] ||
|
||||||
global.ARANGODB_CLIENT_VERSION(true)['failure-tests'] === 'false') {
|
global.ARANGODB_CLIENT_VERSION(true)['failure-tests'] === 'false') {
|
||||||
results.recovery = {
|
return {
|
||||||
|
recovery: {
|
||||||
status: false,
|
status: false,
|
||||||
message: 'failure-tests not enabled. please recompile with -DUSE_FAILURE_TESTS=On'
|
message: 'failure-tests not enabled. please recompile with -DUSE_FAILURE_TESTS=On'
|
||||||
|
},
|
||||||
|
status: false
|
||||||
};
|
};
|
||||||
return results;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let status = true;
|
let results = {
|
||||||
|
status: true
|
||||||
|
};
|
||||||
|
|
||||||
let recoveryTests = tu.scanTestPaths(testPaths.recovery);
|
let recoveryTests = tu.scanTestPaths(testPaths.recovery);
|
||||||
|
|
||||||
recoveryTests = tu.splitBuckets(options, recoveryTests);
|
recoveryTests = tu.splitBuckets(options, recoveryTests);
|
||||||
|
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
||||||
let orgTmp = process.env.TMPDIR;
|
let orgTmp = process.env.TMPDIR;
|
||||||
let tempDir = fs.join(fs.getTempPath(), 'crashtmp');
|
let tempDir = fs.join(fs.getTempPath(), 'crashtmp');
|
||||||
fs.makeDirectoryRecursive(tempDir);
|
fs.makeDirectoryRecursive(tempDir);
|
||||||
|
@ -150,28 +138,43 @@ function recovery (options) {
|
||||||
for (let i = 0; i < recoveryTests.length; ++i) {
|
for (let i = 0; i < recoveryTests.length; ++i) {
|
||||||
let test = recoveryTests[i];
|
let test = recoveryTests[i];
|
||||||
let filtered = {};
|
let filtered = {};
|
||||||
let localOptions = _.cloneDeep(options);
|
|
||||||
let disableMonitor = localOptions.disableMonitor;
|
|
||||||
|
|
||||||
if (tu.filterTestcaseByOptions(test, localOptions, filtered)) {
|
if (tu.filterTestcaseByOptions(test, options, filtered)) {
|
||||||
let instanceInfo = {
|
|
||||||
rootDir: pu.UNITTESTS_DIR
|
|
||||||
};
|
|
||||||
count += 1;
|
count += 1;
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
print(BLUE + "running setup of test " + count + " - " + test + RESET);
|
||||||
|
let params = {
|
||||||
|
tempDir: tempDir,
|
||||||
|
instanceInfo: {
|
||||||
|
rootDir: pu.UNITTESTS_DIR
|
||||||
|
},
|
||||||
|
options: _.cloneDeep(options),
|
||||||
|
script: test,
|
||||||
|
setup: true,
|
||||||
|
count: count,
|
||||||
|
testDir: ""
|
||||||
|
};
|
||||||
|
runArangodRecovery(params);
|
||||||
|
|
||||||
print(BLUE + "running setup of " + test + RESET);
|
////////////////////////////////////////////////////////////////////////
|
||||||
localOptions.disableMonitor = true;
|
print(BLUE + "running recovery of test " + count + " - " + test + RESET);
|
||||||
runArangodRecovery(instanceInfo, localOptions, test, true, count);
|
params.options.disableMonitor = options.disableMonitor;
|
||||||
localOptions.disableMonitor = disableMonitor;
|
params.setup = false;
|
||||||
|
runArangodRecovery(params);
|
||||||
print(BLUE + "running recovery of " + test + RESET);
|
|
||||||
results[test] = runArangodRecovery(instanceInfo, localOptions, test, false, count);
|
|
||||||
|
|
||||||
|
results[test] = tu.readTestResult(
|
||||||
|
params.args['temp.path'],
|
||||||
|
{
|
||||||
|
status: false
|
||||||
|
}
|
||||||
|
);
|
||||||
if (!results[test].status) {
|
if (!results[test].status) {
|
||||||
status = false;
|
print("Not cleaning up " + params.testDir);
|
||||||
|
results.status = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pu.cleanupLastDirectory(localOptions);
|
options.cleanup = false;
|
||||||
|
pu.cleanupLastDirectory(params.options);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (options.extremeVerbosity) {
|
if (options.extremeVerbosity) {
|
||||||
|
@ -181,14 +184,15 @@ function recovery (options) {
|
||||||
}
|
}
|
||||||
process.env.TMPDIR = orgTmp;
|
process.env.TMPDIR = orgTmp;
|
||||||
if (count === 0) {
|
if (count === 0) {
|
||||||
results['ALLTESTS'] = {
|
print(RED + 'No testcase matched the filter.' + RESET);
|
||||||
|
return {
|
||||||
|
ALLTESTS: {
|
||||||
status: false,
|
status: false,
|
||||||
skipped: true
|
skipped: true
|
||||||
|
},
|
||||||
|
status: false
|
||||||
};
|
};
|
||||||
status = false;
|
|
||||||
print(RED + 'No testcase matched the filter.' + RESET);
|
|
||||||
}
|
}
|
||||||
results.status = status;
|
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue