mirror of https://gitee.com/bigwinds/arangodb
Feature 3.4/kill em all (#7590)
This commit is contained in:
parent
743ede87ea
commit
d5a64629f8
|
@ -10,6 +10,7 @@ const internalMembers = UnitTest.internalMembers;
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const internal = require('internal'); // js/common/bootstrap/modules/internal.js
|
const internal = require('internal'); // js/common/bootstrap/modules/internal.js
|
||||||
const inspect = internal.inspect;
|
const inspect = internal.inspect;
|
||||||
|
const abortSignal = 6;
|
||||||
|
|
||||||
let testOutputDirectory;
|
let testOutputDirectory;
|
||||||
|
|
||||||
|
@ -242,10 +243,10 @@ function main (argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// run the test and store the result
|
// run the test and store the result
|
||||||
let r = {}; // result
|
let res = {}; // result
|
||||||
try {
|
try {
|
||||||
// run tests
|
// run tests
|
||||||
r = UnitTest.unitTest(testSuits, options, testOutputDirectory) || {};
|
res = UnitTest.unitTest(testSuits, options, testOutputDirectory) || {};
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
print('caught exception during test execution!');
|
print('caught exception during test execution!');
|
||||||
|
|
||||||
|
@ -259,18 +260,18 @@ function main (argv) {
|
||||||
print(x);
|
print(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
print(JSON.stringify(r));
|
print(JSON.stringify(res));
|
||||||
}
|
}
|
||||||
|
|
||||||
_.defaults(r, {
|
_.defaults(res, {
|
||||||
status: false,
|
status: false,
|
||||||
crashed: true
|
crashed: true
|
||||||
});
|
});
|
||||||
|
|
||||||
// whether or not there was an error
|
// whether or not there was an error
|
||||||
try {
|
try {
|
||||||
fs.write(testOutputDirectory + '/UNITTEST_RESULT_EXECUTIVE_SUMMARY.json', String(r.status), true);
|
fs.write(testOutputDirectory + '/UNITTEST_RESULT_EXECUTIVE_SUMMARY.json', String(res.status), true);
|
||||||
fs.write(testOutputDirectory + '/UNITTEST_RESULT_CRASHED.json', String(r.crashed), true);
|
fs.write(testOutputDirectory + '/UNITTEST_RESULT_CRASHED.json', String(res.crashed), true);
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
print('failed to write test result: ' + x.message);
|
print('failed to write test result: ' + x.message);
|
||||||
}
|
}
|
||||||
|
@ -279,9 +280,9 @@ function main (argv) {
|
||||||
let j;
|
let j;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
j = JSON.stringify(r);
|
j = JSON.stringify(res);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
j = inspect(r);
|
j = inspect(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.write(testOutputDirectory + '/UNITTEST_RESULT.json', j, true);
|
fs.write(testOutputDirectory + '/UNITTEST_RESULT.json', j, true);
|
||||||
|
@ -300,19 +301,25 @@ function main (argv) {
|
||||||
isRocksDb = (options.storageEngine === 'rocksdb');
|
isRocksDb = (options.storageEngine === 'rocksdb');
|
||||||
}
|
}
|
||||||
|
|
||||||
resultsToXml(r, 'UNITTEST_RESULT_' + prefix, isCluster, isRocksDb);
|
resultsToXml(res, 'UNITTEST_RESULT_' + prefix, isCluster, isRocksDb);
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
print('exception while serializing status xml!');
|
print('exception while serializing status xml!');
|
||||||
print(x.message);
|
print(x.message);
|
||||||
print(x.stack);
|
print(x.stack);
|
||||||
print(inspect(r));
|
print(inspect(res));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// creates yaml like dump at the end
|
// creates yaml like dump at the end
|
||||||
UnitTest.unitTestPrettyPrintResults(r, testOutputDirectory, options);
|
UnitTest.unitTestPrettyPrintResults(res, testOutputDirectory, options);
|
||||||
|
|
||||||
return r.status;
|
let running = require("internal").getExternalSpawned();
|
||||||
|
let i = 0;
|
||||||
|
for (i = 0; i < running.length; i++) {
|
||||||
|
print("Killing remaining process: " + JSON.stringify(running[i]));
|
||||||
|
print(require("internal").killExternal(running[i].pid, abortSignal));
|
||||||
|
};
|
||||||
|
return res.status && running.length === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = main(ARGUMENTS);
|
let result = main(ARGUMENTS);
|
||||||
|
|
|
@ -635,6 +635,15 @@ global.DEFINE_MODULE('internal', (function () {
|
||||||
delete global.SYS_EXECUTE_EXTERNAL_AND_WAIT;
|
delete global.SYS_EXECUTE_EXTERNAL_AND_WAIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// //////////////////////////////////////////////////////////////////////////////
|
||||||
|
// / @brief getExternalSpawned
|
||||||
|
// //////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
if (global.SYS_GET_EXTERNAL_SPAWNED) {
|
||||||
|
exports.getExternalSpawned = global.SYS_GET_EXTERNAL_SPAWNED;
|
||||||
|
delete global.SYS_GET_EXTERNAL_SPAWNED;
|
||||||
|
}
|
||||||
|
|
||||||
// //////////////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////////////
|
||||||
// / @brief killExternal
|
// / @brief killExternal
|
||||||
// //////////////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -66,7 +66,7 @@ uint64_t TRI_PhysicalMemory;
|
||||||
/// @brief all external processes
|
/// @brief all external processes
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static std::vector<ExternalProcess*> ExternalProcesses;
|
std::vector<ExternalProcess*> ExternalProcesses;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief lock for protected access to vector ExternalProcesses
|
/// @brief lock for protected access to vector ExternalProcesses
|
||||||
|
|
|
@ -127,6 +127,12 @@ struct ExternalProcess {
|
||||||
/// @brief external process status
|
/// @brief external process status
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
extern std::vector<ExternalProcess*> ExternalProcesses;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief external process status
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
struct ExternalProcessStatus {
|
struct ExternalProcessStatus {
|
||||||
TRI_external_status_e _status;
|
TRI_external_status_e _status;
|
||||||
int64_t _exitStatus;
|
int64_t _exitStatus;
|
||||||
|
|
|
@ -3616,6 +3616,38 @@ static void convertStatusToV8(v8::FunctionCallbackInfo<v8::Value> const& args,
|
||||||
TRI_V8_TRY_CATCH_END;
|
TRI_V8_TRY_CATCH_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief lists all running external processes
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
static void JS_GetExternalSpawned(
|
||||||
|
v8::FunctionCallbackInfo<v8::Value> const& args) {
|
||||||
|
TRI_V8_TRY_CATCH_BEGIN(isolate);
|
||||||
|
v8::HandleScope scope(isolate);
|
||||||
|
|
||||||
|
// extract the arguments
|
||||||
|
if (args.Length() != 0) {
|
||||||
|
TRI_V8_THROW_EXCEPTION_USAGE("getExternalSpawned()");
|
||||||
|
}
|
||||||
|
|
||||||
|
v8::Handle<v8::Array> spawnedProcesses =
|
||||||
|
v8::Array::New(isolate, static_cast<int>(ExternalProcesses.size()));
|
||||||
|
|
||||||
|
uint32_t i = 0;
|
||||||
|
for (auto const& process : ExternalProcesses) {
|
||||||
|
v8::Handle<v8::Object> oneProcess = v8::Object::New(isolate);
|
||||||
|
ExternalId external;
|
||||||
|
external._pid = process->_pid;
|
||||||
|
auto external_status = TRI_CheckExternalProcess(external, false);
|
||||||
|
convertStatusToV8(args, oneProcess, external_status, external);
|
||||||
|
spawnedProcesses->Set(i, oneProcess);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
TRI_V8_RETURN(spawnedProcesses);
|
||||||
|
TRI_V8_TRY_CATCH_END
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief executes a external program
|
/// @brief executes a external program
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -4793,6 +4825,11 @@ void TRI_InitV8Utils(v8::Isolate* isolate, v8::Handle<v8::Context> context,
|
||||||
TRI_AddGlobalFunctionVocbase(isolate,
|
TRI_AddGlobalFunctionVocbase(isolate,
|
||||||
TRI_V8_ASCII_STRING(isolate, "SYS_SPLIT_WORDS_ICU"),
|
TRI_V8_ASCII_STRING(isolate, "SYS_SPLIT_WORDS_ICU"),
|
||||||
JS_SplitWordlist);
|
JS_SplitWordlist);
|
||||||
|
|
||||||
|
|
||||||
|
TRI_AddGlobalFunctionVocbase(isolate,
|
||||||
|
TRI_V8_ASCII_STRING(isolate, "SYS_GET_EXTERNAL_SPAWNED"),
|
||||||
|
JS_GetExternalSpawned);
|
||||||
TRI_AddGlobalFunctionVocbase(isolate,
|
TRI_AddGlobalFunctionVocbase(isolate,
|
||||||
TRI_V8_ASCII_STRING(isolate, "SYS_KILL_EXTERNAL"),
|
TRI_V8_ASCII_STRING(isolate, "SYS_KILL_EXTERNAL"),
|
||||||
JS_KillExternal);
|
JS_KillExternal);
|
||||||
|
|
Loading…
Reference in New Issue