1
0
Fork 0

Merge branch 'devel' of https://github.com/arangodb/arangodb into engine-api

This commit is contained in:
jsteemann 2017-01-24 16:27:32 +01:00
commit 2b66199204
6 changed files with 34 additions and 32 deletions

View File

@ -23,6 +23,8 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include "AgencyComm.h" #include "AgencyComm.h"
#include "ApplicationFeatures/ApplicationServer.h"
#include "RestServer/ServerFeature.h"
#include <thread> #include <thread>
#ifdef DEBUG_SYNC_REPLICATION #ifdef DEBUG_SYNC_REPLICATION
@ -1322,6 +1324,18 @@ AgencyCommResult AgencyComm::sendWithFailover(
// timeout exit startegy // timeout exit startegy
if (std::chrono::steady_clock::now() < timeOut) { if (std::chrono::steady_clock::now() < timeOut) {
if (tries > 0) { if (tries > 0) {
auto serverFeature =
application_features::ApplicationServer::getFeature<ServerFeature>(
"Server");
if (serverFeature->isStopping()) {
LOG_TOPIC(INFO, Logger::AGENCYCOMM)
<< "Unsuccessful AgencyComm: Timeout because of shutdown "
<< "errorCode: " << result.errorCode()
<< " errorMessage: " << result.errorMessage()
<< " errorDetails: " << result.errorDetails();
return result;
}
std::this_thread::sleep_for(waitUntil-std::chrono::steady_clock::now()); std::this_thread::sleep_for(waitUntil-std::chrono::steady_clock::now());
if (waitInterval.count() == 0.0) { if (waitInterval.count() == 0.0) {
waitInterval = std::chrono::duration<double>(0.25); waitInterval = std::chrono::duration<double>(0.25);

View File

@ -190,6 +190,7 @@ void ServerFeature::beginShutdown() {
std::string msg = std::string msg =
ArangoGlobalContext::CONTEXT->binaryName() + " [shutting down]"; ArangoGlobalContext::CONTEXT->binaryName() + " [shutting down]";
TRI_SetProcessTitle(msg.c_str()); TRI_SetProcessTitle(msg.c_str());
_isStopping = true;
} }
void ServerFeature::waitForHeartbeat() { void ServerFeature::waitForHeartbeat() {

View File

@ -47,6 +47,7 @@ class ServerFeature final : public application_features::ApplicationFeature {
void validateOptions(std::shared_ptr<options::ProgramOptions>) override final; void validateOptions(std::shared_ptr<options::ProgramOptions>) override final;
void start() override final; void start() override final;
void beginShutdown() override final; void beginShutdown() override final;
bool isStopping() const { return _isStopping; }
public: public:
OperationMode operationMode() const { return _operationMode; } OperationMode operationMode() const { return _operationMode; }
@ -70,6 +71,7 @@ class ServerFeature final : public application_features::ApplicationFeature {
uint32_t _vppMaxSize; uint32_t _vppMaxSize;
int* _result; int* _result;
OperationMode _operationMode; OperationMode _operationMode;
bool _isStopping = false;
}; };
} }

View File

@ -248,7 +248,7 @@ let LOGS_DIR;
let UNITTESTS_DIR; let UNITTESTS_DIR;
let GDB_OUTPUT=""; let GDB_OUTPUT="";
function makeResults (testname) { function makeResults (testname, instanceInfo) {
const startTime = time(); const startTime = time();
return function (status, message) { return function (status, message) {
@ -259,7 +259,7 @@ function makeResults (testname) {
let result; let result;
try { try {
result = JSON.parse(fs.read('testresult.json')); result = JSON.parse(fs.read(instanceInfo.rootDir + '/testresult.json'));
if ((typeof result[0] === 'object') && if ((typeof result[0] === 'object') &&
result[0].hasOwnProperty('status')) { result[0].hasOwnProperty('status')) {
@ -691,9 +691,7 @@ function runThere (options, instanceInfo, file) {
'return runTest(' + JSON.stringify(file) + ', true' + mochaGrep + ');'; 'return runTest(' + JSON.stringify(file) + ', true' + mochaGrep + ');';
} }
if (options.propagateInstanceInfo) {
testCode = 'global.instanceInfo = ' + JSON.stringify(instanceInfo) + ';\n' + testCode; testCode = 'global.instanceInfo = ' + JSON.stringify(instanceInfo) + ';\n' + testCode;
}
let httpOptions = makeAuthorizationHeaders(options); let httpOptions = makeAuthorizationHeaders(options);
httpOptions.method = 'POST'; httpOptions.method = 'POST';
@ -1078,12 +1076,12 @@ function runInArangosh (options, instanceInfo, file, addArgs) {
if (addArgs !== undefined) { if (addArgs !== undefined) {
args = Object.assign(args, addArgs); args = Object.assign(args, addArgs);
} }
fs.write('instanceinfo.json', JSON.stringify(instanceInfo)); require('internal').env.INSTANCEINFO = JSON.stringify(instanceInfo);
let rc = executeAndWait(ARANGOSH_BIN, toArgv(args), options); let rc = executeAndWait(ARANGOSH_BIN, toArgv(args), options);
let result; let result;
try { try {
result = JSON.parse(fs.read('testresult.json')); result = JSON.parse(fs.read(instanceInfo.rootDir + '/testresult.json'));
} catch (x) { } catch (x) {
return rc; return rc;
} }
@ -1116,6 +1114,7 @@ function runArangoshCmd (options, instanceInfo, addArgs, cmds) {
args = Object.assign(args, addArgs); args = Object.assign(args, addArgs);
} }
require('internal').env.INSTANCEINFO = JSON.stringify(instanceInfo);
const argv = toArgv(args).concat(cmds); const argv = toArgv(args).concat(cmds);
return executeAndWait(ARANGOSH_BIN, argv, options); return executeAndWait(ARANGOSH_BIN, argv, options);
} }
@ -3357,10 +3356,10 @@ testFuncs.recovery = function (options) {
// ////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////
testFuncs.replication_ongoing = function (options) { testFuncs.replication_ongoing = function (options) {
const mr = makeResults('replication');
let master = startInstance('tcp', options, {}, 'master_ongoing'); let master = startInstance('tcp', options, {}, 'master_ongoing');
const mr = makeResults('replication', master);
if (master === false) { if (master === false) {
return mr(false, 'failed to start master!'); return mr(false, 'failed to start master!');
} }
@ -3399,12 +3398,12 @@ testFuncs.replication_ongoing = function (options) {
// ////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////
testFuncs.replication_static = function (options) { testFuncs.replication_static = function (options) {
const mr = makeResults('replication');
let master = startInstance('tcp', options, { let master = startInstance('tcp', options, {
'server.authentication': 'true' 'server.authentication': 'true'
}, 'master_static'); }, 'master_static');
const mr = makeResults('replication', master);
if (master === false) { if (master === false) {
return mr(false, 'failed to start master!'); return mr(false, 'failed to start master!');
} }
@ -3455,9 +3454,9 @@ testFuncs.replication_static = function (options) {
// ////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////
testFuncs.replication_sync = function (options) { testFuncs.replication_sync = function (options) {
const mr = makeResults('replication');
let master = startInstance('tcp', options, {}, 'master_sync'); let master = startInstance('tcp', options, {}, 'master_sync');
const mr = makeResults('replication', master);
if (master === false) { if (master === false) {
return mr(false, 'failed to start master!'); return mr(false, 'failed to start master!');
} }

View File

@ -56,25 +56,7 @@ function agencyTestSuite () {
/// @brief the agency servers /// @brief the agency servers
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
var count = 20; var instanceInfo = JSON.parse(require('internal').env.INSTANCEINFO);
while (true) {
if (require('fs').exists('instanceinfo.json')) {
var instanceInfoData = require('fs').read('instanceinfo.json');
var instanceInfo;
try {
instanceInfo = JSON.parse(instanceInfoData);
break;
} catch (err) {
console.error('Failed to parse JSON: instanceinfo.json');
console.error(instanceInfoData);
}
}
wait(1.0);
if (--count <= 0) {
throw 'peng';
}
}
var agencyServers = instanceInfo.arangods.map(arangod => { var agencyServers = instanceInfo.arangods.map(arangod => {
return arangod.url; return arangod.url;
}); });

View File

@ -10,6 +10,10 @@ var runTest = require('jsunity').runTest,
// ////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////
function runJSUnityTests (tests) { function runJSUnityTests (tests) {
let instanceinfo = JSON.parse(require('internal').env.INSTANCEINFO);
if (!instanceinfo) {
throw new Error('env.INSTANCEINFO was not set by caller!');
}
var result = true; var result = true;
var allResults = []; var allResults = [];
var failed = []; var failed = [];
@ -45,7 +49,7 @@ function runJSUnityTests (tests) {
internal.wait(0); // force GC internal.wait(0); // force GC
}); });
require('fs').write('testresult.json', JSON.stringify(allResults)); require('fs').write(instanceinfo.rootDir + '/testresult.json', JSON.stringify(allResults));
if (failed.length > 1) { if (failed.length > 1) {
print('The following ' + failed.length + ' test files produced errors: ', failed.join(', ')); print('The following ' + failed.length + ' test files produced errors: ', failed.join(', '));