1
0
Fork 0
This commit is contained in:
Frank Celler 2016-04-16 17:39:20 -07:00
parent 040104ebb5
commit 9d26ab1bbc
4 changed files with 177 additions and 140 deletions

View File

@ -188,10 +188,12 @@ const toArgv = require("internal").toArgv;
const wait = require("internal").wait; const wait = require("internal").wait;
const platform = require("internal").platform; const platform = require("internal").platform;
const BLUE = require("internal").COLORS.COLOR_BLUE;
const CYAN = require("internal").COLORS.COLOR_CYAN; const CYAN = require("internal").COLORS.COLOR_CYAN;
const GREEN = require("internal").COLORS.COLOR_GREEN; const GREEN = require("internal").COLORS.COLOR_GREEN;
const RED = require("internal").COLORS.COLOR_RED; const RED = require("internal").COLORS.COLOR_RED;
const RESET = require("internal").COLORS.COLOR_RESET; const RESET = require("internal").COLORS.COLOR_RESET;
const YELLOW = require("internal").COLORS.COLOR_YELLOW;
let cleanupDirectories = []; let cleanupDirectories = [];
let serverCrashed = false; let serverCrashed = false;
@ -1089,7 +1091,8 @@ function runArangoBenchmark(options, instanceInfo, cmds) {
args = _.extend(args, cmds); args = _.extend(args, cmds);
if (!args.hasOwnProperty('verbose')) { if (!args.hasOwnProperty('verbose')) {
args.quiet = true; args["log.level"] = "warning";
args["flatCommands"] = ["--quiet"];
} }
return executeAndWait(ARANGOB_BIN, toArgv(args), options); return executeAndWait(ARANGOB_BIN, toArgv(args), options);
@ -1314,6 +1317,7 @@ function startArango(protocol, options, addArgs, name, rootDir, isAgency) {
let args = makeArgsArangod(options, appDir); let args = makeArgsArangod(options, appDir);
let endpoint; let endpoint;
let port; let port;
if (!addArgs["server.endpoint"]) { if (!addArgs["server.endpoint"]) {
port = findFreePort(); port = findFreePort();
endpoint = protocol + "://127.0.0.1:" + port; endpoint = protocol + "://127.0.0.1:" + port;
@ -1321,6 +1325,7 @@ function startArango(protocol, options, addArgs, name, rootDir, isAgency) {
endpoint = addArgs["server.endpoint"]; endpoint = addArgs["server.endpoint"];
port = endpoint.split(":").pop(); port = endpoint.split(":").pop();
} }
let instanceInfo = { let instanceInfo = {
isAgency, port, endpoint, rootDir isAgency, port, endpoint, rootDir
}; };
@ -1328,7 +1333,12 @@ function startArango(protocol, options, addArgs, name, rootDir, isAgency) {
args["server.endpoint"] = endpoint; args["server.endpoint"] = endpoint;
args["database.directory"] = dataDir; args["database.directory"] = dataDir;
args["log.file"] = fs.join(rootDir, "log"); args["log.file"] = fs.join(rootDir, "log");
args["log.level"] = 'info';
if (options.verbose) {
args["log.level"] = 'info';
} else {
args["log.level"] = 'error';
}
if (protocol === "ssl") { if (protocol === "ssl") {
args["server.keyfile"] = fs.join("UnitTests", "server.pem"); args["server.keyfile"] = fs.join("UnitTests", "server.pem");
@ -1339,8 +1349,8 @@ function startArango(protocol, options, addArgs, name, rootDir, isAgency) {
if (addArgs !== undefined) { if (addArgs !== undefined) {
args = _.extend(args, addArgs); args = _.extend(args, addArgs);
} }
instanceInfo.url = endpointToURL(instanceInfo.endpoint);
instanceInfo.url = endpointToURL(instanceInfo.endpoint);
instanceInfo.pid = executeValgrind(ARANGOD_BIN, toArgv(args), options, name).pid; instanceInfo.pid = executeValgrind(ARANGOD_BIN, toArgv(args), options, name).pid;
if (platform.substr(0, 3) === 'win') { if (platform.substr(0, 3) === 'win') {
@ -1860,21 +1870,19 @@ let testFuncs = {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
testFuncs.arangosh = function(options) { testFuncs.arangosh = function(options) {
let args = makeArgsArangosh(options);
let ret = { let ret = {
"ArangoshExitCodeTest": { "testArangoshExitCodeFail": { status: true, total: 0 },
"testArangoshExitCodeFail": {}, "testArangoshExitCodeSuccess": { status: true, total: 0 },
"testArangoshExitCodeSuccess": {}, "testArangoshShebang": { status: true, total: 0 },
"testArangoshebang": {},
"total": 2,
"duration": 0.0
}
}; };
// termination by throw print("--------------------------------------------------------------------------------");
print("Starting arangosh with exception throwing script:"); print("Starting arangosh with exception throwing script:");
print("--------------------------------------------------------------------------------");
let args = makeArgsArangosh(options);
args["javascript.execute-string"] = "throw('foo')"; args["javascript.execute-string"] = "throw('foo')";
args["log.level"] = "fatal";
const startTime = time(); const startTime = time();
let rc = executeExternalAndWait(ARANGOSH_BIN, toArgv(args)); let rc = executeExternalAndWait(ARANGOSH_BIN, toArgv(args));
@ -1882,18 +1890,22 @@ testFuncs.arangosh = function(options) {
const failSuccess = (rc.hasOwnProperty('exit') && rc.exit === 1); const failSuccess = (rc.hasOwnProperty('exit') && rc.exit === 1);
if (!failSuccess) { if (!failSuccess) {
ret.ArangoshExitCodeTest.testArangoshExitCodeFail['message'] = ret.testArangoshExitCodeFail['message'] =
"didn't get expected return code (1): \n" + "didn't get expected return code (1): \n" +
yaml.safeDump(rc); yaml.safeDump(rc);
} }
ret.ArangoshExitCodeTest.testArangoshExitCodeFail['status'] = failSuccess; ++ret.testArangoshExitCodeFail['total'];
ret.ArangoshExitCodeTest.testArangoshExitCodeFail['duration'] = deltaTime; ret.testArangoshExitCodeFail['status'] = failSuccess;
print("Status: " + ((failSuccess) ? "SUCCESS" : "FAIL") + "\n"); ret.testArangoshExitCodeFail['duration'] = deltaTime;
print((failSuccess ? GREEN : RED) + "Status: " + (failSuccess ? "SUCCESS" : "FAIL") + RESET);
// regular termination print("\n--------------------------------------------------------------------------------");
print("Starting arangosh with regular terminating script:"); print("Starting arangosh with regular terminating script:");
print("--------------------------------------------------------------------------------");
args["javascript.execute-string"] = ";"; args["javascript.execute-string"] = ";";
args["log.level"] = "fatal";
const startTime2 = time(); const startTime2 = time();
rc = executeExternalAndWait(ARANGOSH_BIN, toArgv(args)); rc = executeExternalAndWait(ARANGOSH_BIN, toArgv(args));
@ -1902,25 +1914,32 @@ testFuncs.arangosh = function(options) {
const successSuccess = (rc.hasOwnProperty('exit') && rc.exit === 0); const successSuccess = (rc.hasOwnProperty('exit') && rc.exit === 0);
if (!successSuccess) { if (!successSuccess) {
ret.ArangoshExitCodeTest.testArangoshExitCodeFail['message'] = ret.testArangoshExitCodeFail['message'] =
"didn't get expected return code (0): \n" + "didn't get expected return code (0): \n" +
yaml.safeDump(rc); yaml.safeDump(rc);
} }
ret.ArangoshExitCodeTest.testArangoshExitCodeSuccess['status'] = failSuccess; ++ret.testArangoshExitCodeSuccess['total'];
ret.ArangoshExitCodeTest.testArangoshExitCodeSuccess['duration'] = deltaTime2; ret.testArangoshExitCodeSuccess['status'] = failSuccess;
print("Status: " + ((successSuccess) ? "SUCCESS" : "FAIL") + "\n"); ret.testArangoshExitCodeSuccess['duration'] = deltaTime2;
print((successSuccess ? GREEN : RED) + "Status: " + (successSuccess ? "SUCCESS" : "FAIL") + RESET);
// test shebang execution with arangosh // test shebang execution with arangosh
var shebangSuccess = true;
var deltaTime3 = 0;
if (!options.skipShebang && platform.substr(0, 3) !== "win") { if (!options.skipShebang && platform.substr(0, 3) !== "win") {
var shebangSuccess = true;
var deltaTime3 = 0;
var shebangFile = fs.getTempFile(); var shebangFile = fs.getTempFile();
print("Starting arangosh via shebang script: " + shebangFile); print("\n--------------------------------------------------------------------------------");
print("Starting arangosh via shebang script");
print("--------------------------------------------------------------------------------");
if (options.verbose) {
print(CYAN + "shebang script: " + shebangFile + RESET);
}
fs.write(shebangFile, fs.write(shebangFile,
"#!" + fs.makeAbsolute(ARANGOSH_BIN) + " --javascript.execute \n" + "#!" + fs.makeAbsolute(ARANGOSH_BIN) + " --log.level fatal --javascript.execute \n" +
"print('hello world');\n"); "print('hello world');\n");
executeExternalAndWait("sh", ["-c", "chmod a+x " + shebangFile]); executeExternalAndWait("sh", ["-c", "chmod a+x " + shebangFile]);
@ -1928,27 +1947,31 @@ testFuncs.arangosh = function(options) {
const startTime3 = time(); const startTime3 = time();
rc = executeExternalAndWait("sh", ["-c", shebangFile]); rc = executeExternalAndWait("sh", ["-c", shebangFile]);
deltaTime3 = time() - startTime3; deltaTime3 = time() - startTime3;
print(rc);
if (options.verbose) {
print(CYAN + "execute returned: " + RESET, rc);
}
shebangSuccess = (rc.hasOwnProperty('exit') && rc.exit === 0); shebangSuccess = (rc.hasOwnProperty('exit') && rc.exit === 0);
if (!shebangSuccess) { if (!shebangSuccess) {
ret.ArangoshExitCodeTest.testArangoshebang['message'] = ret.testArangoshShebang['message'] =
"didn't get expected return code (0): \n" + "didn't get expected return code (0): \n" +
yaml.safeDump(rc); yaml.safeDump(rc);
} }
fs.remove(shebangFile); fs.remove(shebangFile);
print("Status: " + ((successSuccess) ? "SUCCESS" : "FAIL") + "\n"); ++ret.testArangoshShebang['total'];
ret.testArangoshShebang['status'] = shebangSuccess;
ret.testArangoshShebang['duration'] = deltaTime3;
print((shebangSuccess ? GREEN : RED) + "Status: " + (shebangSuccess ? "SUCCESS" : "FAIL") + RESET);
} else {
ret.testArangoshShebang['skipped'] = true;
} }
ret.ArangoshExitCodeTest.testArangoshebang['status'] = shebangSuccess; print();
ret.ArangoshExitCodeTest.testArangoshebang['duration'] = deltaTime3;
// return result
ret.ArangoshExitCodeTest.status = failSuccess && successSuccess && shebangSuccess;
ret.ArangoshExitCodeTest.duration = deltaTime + deltaTime2 + deltaTime3;
return ret; return ret;
}; };
@ -2059,7 +2082,7 @@ testFuncs.arangob = function(options) {
}; };
} }
print("arangob tests..."); print(CYAN + "arangob tests..." + RESET);
let instanceInfo = startInstance("tcp", options, {}, "arangob"); let instanceInfo = startInstance("tcp", options, {}, "arangob");
@ -2072,12 +2095,7 @@ testFuncs.arangob = function(options) {
}; };
} }
let results = { let results = {};
arangob: {
status: true,
total: 0
}
};
let continueTesting = true; let continueTesting = true;
@ -2094,9 +2112,9 @@ testFuncs.arangob = function(options) {
if (!options.cluster || !benchTodo.transaction) { if (!options.cluster || !benchTodo.transaction) {
if (!continueTesting) { if (!continueTesting) {
print("Skipping " + benchTodo + ", server is gone."); print(RED + "Skipping " + benchTodo + ", server is gone." + RESET);
results.arangob[i] = { results[name] = {
status: false, status: false,
message: instanceInfo.exitStatus message: instanceInfo.exitStatus
}; };
@ -2114,12 +2132,15 @@ testFuncs.arangob = function(options) {
} }
let oneResult = runArangoBenchmark(options, instanceInfo, args); let oneResult = runArangoBenchmark(options, instanceInfo, args);
print();
results.arangob[i] = oneResult; let name = "case" + i;
results.arangob.total++;
if (!results.arangob[i].status) { results[name] = oneResult;
results.arangob.status = false; results[name].total++;
if (!results[name].status) {
results.status = false;
} }
continueTesting = checkInstanceAlive(instanceInfo, options); continueTesting = checkInstanceAlive(instanceInfo, options);
@ -2130,9 +2151,9 @@ testFuncs.arangob = function(options) {
} }
} }
print("Shutting down..."); print(CYAN + "Shutting down..." + RESET);
shutdownInstance(instanceInfo, options); shutdownInstance(instanceInfo, options);
print("done."); print(CYAN + "done." + RESET);
return results; return results;
}; };
@ -2404,7 +2425,6 @@ testFuncs.config = function(options) {
results.absolut[test] = executeAndWait(run, toArgv(args), options, test); results.absolut[test] = executeAndWait(run, toArgv(args), options, test);
/* XX */ results.absolut[test].status = false;
if (!results.absolut[test].status) { if (!results.absolut[test].status) {
results.absolut.status = false; results.absolut.status = false;
} }
@ -2418,7 +2438,7 @@ testFuncs.config = function(options) {
} }
} }
print("--------------------------------------------------------------------------------"); print("\n--------------------------------------------------------------------------------");
print("relative config tests"); print("relative config tests");
print("--------------------------------------------------------------------------------"); print("--------------------------------------------------------------------------------");
@ -2448,6 +2468,8 @@ testFuncs.config = function(options) {
} }
} }
print();
return results; return results;
}; };
@ -3635,113 +3657,118 @@ testFuncs.agency = function(options) {
/// @brief pretty prints the result /// @brief pretty prints the result
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
function unitTestPrettyPrintResults(r) { function testCaseMessage(test) {
let testFail = 0; if (typeof test.message === "object" && test.message.hasOwnProperty('body')) {
let testSuiteFail = 0; return test.message.body;
} else {
return test.message;
}
}
let header = ""; function unitTestPrettyPrintResults(r) {
let success = ""; print(BLUE + "================================================================================");
let fail = ""; print("TEST RESULTS");
print("================================================================================\n" + RESET);
let failedSuite = 0;
let failedTests = 0;
try { try {
/*jshint forin: false */ /*jshint forin: false */
for (let testrun in r) { for (let testrunName in r) {
if (skipInternalMember(r, testrun)) { if (skipInternalMember(r, testrunName)) {
continue; continue;
} }
let testrun = r[testrunName];
print("* Test '" + testrunName + "'");
let successCases = {};
let failedCases = {};
let isSuccess = true; let isSuccess = true;
let successTests = {};
let oneOutput = "";
print("* Test '" + testrun + "'"); for (let testName in testrun) {
if (skipInternalMember(testrun, testName)) {
continue;
}
for (let test in r[testrun]) { let test = testrun[testName];
if (r[testrun].hasOwnProperty(test) &&
(internalMembers.indexOf(test) === -1)) {
if (r[testrun][test].status) { if (test.status) {
const where = test.lastIndexOf(fs.pathSeparator); successCases[testName] = test;
let which; } else {
isSuccess = false;
++failedSuite;
if (where < 0) { if (test.hasOwnProperty('message')) {
which = 'Unittests'; ++failedTests;
} else { failedCases[testName] = {
which = test.substring(0, where); test: testCaseMessage(test)
test = test.substring(where + 1, test.length); };
} } else {
let fails = failedCases[testName] = {};
if (!successTests.hasOwnProperty(which)) { for (let oneName in test) {
successTests[which] = []; if (skipInternalMember(test, oneName)) {
} continue;
}
successTests[which].push(test); let oneTest = test[oneName];
} else {
testSuiteFail++;
if (r[testrun][test].hasOwnProperty('message')) { if (!oneTest.status) {
isSuccess = false; ++failedTests;
oneOutput += " [ Fail ] " + test + fails[oneName] = testCaseMessage(oneTest);
": Whole testsuite failed!\n"; }
}
if (typeof r[testrun][test].message === "object" && }
r[testrun][test].message.hasOwnProperty('body')) { }
oneOutput += r[testrun][test].message.body + "\n";
} else {
oneOutput += r[testrun][test].message + "\n";
}
} else {
isSuccess = false;
oneOutput += " [ Fail ] " + test + "\n";
for (let oneTest in r[testrun][test]) {
if (r[testrun][test].hasOwnProperty(oneTest) &&
(internalMembers.indexOf(oneTest) === -1) &&
(!r[testrun][test][oneTest].status)) {
++testFail;
oneOutput += " -> " + oneTest +
" Failed; Verbose message:\n" +
r[testrun][test][oneTest].message + "\n";
}
}
}
}
}
} }
if (successTests !== "") { for (let name in successCases) {
for (let key in successTests) { if (!successCases.hasOwnProperty(name)) {
if (successTests.hasOwnProperty(key)) { continue;
oneOutput = " [Success] " + key + }
" / [" + successTests[key].join(', ') + ']\n' + oneOutput;
} let details = successCases[name];
}
if (details.skipped) {
print(YELLOW + " [SKIPPED] " + name + RESET);
}
else {
print(GREEN + " [SUCCESS] " + name + RESET);
}
} }
if (isSuccess) { for (let name in failedCases) {
success += oneOutput; if (!failedCases.hasOwnProperty(name)) {
} else { continue;
fail += oneOutput; }
print(RED + " [FAILED] " + name + RESET);
let details = failedCases[name];
for (let one in details) {
if (!details.hasOwnProperty(one)) {
continue;
}
print(RED + " '" + one + "' failed: " + details[one] + RESET);
}
} }
} }
/*jshint forin: true */ /*jshint forin: true */
if (success !== "") { let color = (r.status === true) ? GREEN : RED;
print(success); print("\n" + color + "* Overall state: " + ((r.status === true) ? "Success" : "Fail") + RESET);
}
if (fail !== "") {
print(fail);
}
print("Overall state: " + ((r.status === true) ? "Success" : "Fail"));
if (r.status !== true) { if (r.status !== true) {
print(" Suites failed: " + testSuiteFail + " Tests Failed: " + testFail); print(color + " Suites failed: " + failedSuite + " Tests Failed: " + failedTests + RESET);
} }
if (r.crashed === true) { if (r.crashed === true) {
print(" We had at least one unclean shutdown of an arangod during the testrun."); print("\nWe had at least one unclean shutdown or crash during the testrun.");
} }
} catch (x) { } catch (x) {
print("exception caught while pretty printing result: "); print("exception caught while pretty printing result: ");
@ -3888,10 +3915,12 @@ function unitTest(cases, options) {
for (let n = 0; n < caselist.length; ++n) { for (let n = 0; n < caselist.length; ++n) {
const currentTest = caselist[n]; const currentTest = caselist[n];
print(BLUE + "================================================================================");
print("Executing test", currentTest);
print("================================================================================\n" + RESET);
if (options.verbose) { if (options.verbose) {
print("Executing test", currentTest, "with options", options); print(CYAN + "with options:", options, RESET);
} else {
print("Executing test", currentTest);
} }
let result = testFuncs[currentTest](options); let result = testFuncs[currentTest](options);

View File

@ -93,6 +93,16 @@ void SslFeature::prepare() {
createSslContext(); createSslContext();
} }
void SslFeature::start() {
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::start";
LOG(INFO) << "using SSL options: " << stringifySslOptions(_options);
if (!_cipherList.empty()) {
LOG(INFO) << "using SSL cipher-list '" << _cipherList << "'";
}
}
void SslFeature::stop() { void SslFeature::stop() {
if (_sslContext != nullptr) { if (_sslContext != nullptr) {
SSL_CTX_free(_sslContext); SSL_CTX_free(_sslContext);
@ -152,15 +162,11 @@ void SslFeature::createSslContext() {
// set options // set options
SSL_CTX_set_options(_sslContext, (long)_options); SSL_CTX_set_options(_sslContext, (long)_options);
LOG(INFO) << "using SSL options: " << stringifySslOptions(_options);
if (!_cipherList.empty()) { if (!_cipherList.empty()) {
if (SSL_CTX_set_cipher_list(_sslContext, _cipherList.c_str()) != 1) { if (SSL_CTX_set_cipher_list(_sslContext, _cipherList.c_str()) != 1) {
LOG(FATAL) << "cannot set SSL cipher list '" << _cipherList LOG(FATAL) << "cannot set SSL cipher list '" << _cipherList
<< "': " << lastSSLError(); << "': " << lastSSLError();
FATAL_ERROR_EXIT(); FATAL_ERROR_EXIT();
} else {
LOG(INFO) << "using SSL cipher-list '" << _cipherList << "'";
} }
} }
@ -170,7 +176,7 @@ void SslFeature::createSslContext() {
sslEcdhNid = OBJ_sn2nid(_ecdhCurve.c_str()); sslEcdhNid = OBJ_sn2nid(_ecdhCurve.c_str());
if (sslEcdhNid == 0) { if (sslEcdhNid == 0) {
LOG(ERR) << "SSL error: " << lastSSLError() LOG(FATAL) << "SSL error: " << lastSSLError()
<< " Unknown curve name: " << _ecdhCurve; << " Unknown curve name: " << _ecdhCurve;
FATAL_ERROR_EXIT(); FATAL_ERROR_EXIT();
} }
@ -178,7 +184,7 @@ void SslFeature::createSslContext() {
// https://www.openssl.org/docs/manmaster/apps/ecparam.html // https://www.openssl.org/docs/manmaster/apps/ecparam.html
ecdhKey = EC_KEY_new_by_curve_name(sslEcdhNid); ecdhKey = EC_KEY_new_by_curve_name(sslEcdhNid);
if (ecdhKey == nullptr) { if (ecdhKey == nullptr) {
LOG(ERR) << "SSL error: " << lastSSLError() LOG(FATAL) << "SSL error: " << lastSSLError()
<< " Unable to create curve by name: " << _ecdhCurve; << " Unable to create curve by name: " << _ecdhCurve;
FATAL_ERROR_EXIT(); FATAL_ERROR_EXIT();
} }

View File

@ -35,6 +35,7 @@ class SslFeature final : public application_features::ApplicationFeature {
public: public:
void collectOptions(std::shared_ptr<options::ProgramOptions>) override final; void collectOptions(std::shared_ptr<options::ProgramOptions>) override final;
void prepare() override final; void prepare() override final;
void start() override final;
void stop() override final; void stop() override final;
public: public:

View File

@ -27,6 +27,7 @@ fi
exec $ARANGOSH \ exec $ARANGOSH \
-c etc${PS}relative${PS}arangosh.conf \ -c etc${PS}relative${PS}arangosh.conf \
--log.level warning \
--server.endpoint tcp://127.0.0.1:${PORT} \ --server.endpoint tcp://127.0.0.1:${PORT} \
--javascript.execute UnitTests${PS}unittest.js \ --javascript.execute UnitTests${PS}unittest.js \
-- \ -- \