8000 Cleaner test output, enhanced filters. (#16021) · arangodb/arangodb@a752455 · GitHub
[go: up one dir, main page]

Skip to content

Commit a752455

Browse files
author
Aditya Mukhopadhyay
authored
Cleaner test output, enhanced filters. (#16021)
1 parent 9fcfb12 commit a752455

File tree

4 files changed

+72
-30
lines changed

4 files changed

+72
-30
lines changed

js/client/modules/@arangodb/testutils/process-utils.js

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ function killRemainingProcesses(results) {
815815
print(killExternal(running[i].pid, abortSignal));
816816
}
817817
results.crashed = true;
818-
};
818+
}
819819
}
820820

821821
// //////////////////////////////////////////////////////////////////////////////
@@ -1364,7 +1364,9 @@ function checkInstanceAlive(instanceInfo, options, {skipHealthCheck = false} = {
13641364
) {
13651365
rc = checkServersGOOD(instanceInfo);
13661366
if (first) {
1367-
print(RESET + "Waiting for all servers to go GOOD...");
1367+
if (!options.noStartStopLogs) {
1368+
print(RESET + "Waiting for all servers to go GOOD...");
1369+
}
13681370
first = false;
13691371
}
13701372
}
@@ -1532,7 +1534,9 @@ function shutdownArangod (arangod, options, forceTerminate) {
15321534
const requestOptions = makeAuthorizationHeaders(options);
15331535
requestOptions.method = 'DELETE';
15341536
requestOptions.timeout = 60; // 60 seconds hopefully are enough for getting a response
1535-
print(Date() + ' ' + arangod.url + '/_admin/shutdown');
1537+
if (!options.noStartStopLogs) {
1538+
print(Date() + ' ' + arangod.url + '/_admin/shutdown');
1539+
}
15361540
let sockStat = getSockStat(arangod, options, "Sock stat for: ");
15371541
const reply = download(arangod.url + '/_admin/shutdown', '', requestOptions);
15381542
if ((reply.code !== 200) && // if the server should reply, we expect 200 - if not:
@@ -1545,7 +1549,7 @@ function shutdownArangod (arangod, options, forceTerminate) {
15451549
print(Date() + ' Wrong shutdown response: ' + JSON.stringify(reply) + "' " + sockStat + " continuing with hard kill!");
15461550
shutdownArangod(arangod, options, true);
15471551
}
1548-
else {
1552+
else if (!options.noStartStopLogs) {
15491553
print(sockStat);
15501554
}
15511555
if (options.extremeVerbosity) {
@@ -1622,7 +1626,9 @@ function shutDownOneInstance(options, arangod, fullInstance, counters, forceTerm
16221626
if (arangod.role !== 'agent') {
16231627
counters.nonAgenciesCount--;
16241628
}
1625-
print(Date() + ' Server "' + arangod.role + '" shutdown: Success: pid', arangod.pid);
1629+
if (!options.noStartStopLogs) {
1630+
print(Date() + ' Server "' + arangod.role + '" shutdown: Success: pid', arangod.pid);
1631+
}
16261632
crashUtils.stopProcdump(options, arangod);
16271633
return false;
16281634
}
@@ -1664,7 +1670,9 @@ function shutdownInstance (instanceInfo, options, forceTerminate) {
16641670
let requestOptions = makeAuthorizationHeaders(options);
16651671
requestOptions.method = 'PUT';
16661672

1667-
print(coords[0].url + "/_admin/cluster/maintenance");
1673+
if (!options.noStartStopLogs) {
1674+
print(coords[0].url + "/_admin/cluster/maintenance");
1675+
}
16681676
download(coords[0].url + "/_admin/cluster/maintenance", JSON.stringify("on"), requestOptions);
16691677
}
16701678
} catch (err) {
@@ -1697,7 +1705,10 @@ function shutdownInstance (instanceInfo, options, forceTerminate) {
16971705
if (b.role === 'agent') return -1;
16981706
return 0;
16991707
});
1700-
print(Date() + ' Shutdown order ' + JSON.stringify(toShutdown));
1708+
1709+
if (!options.noStartStopLogs) {
1710+
print(Date() + ' Shutdown order ' + JSON.stringify(toShutdown));
1711+
}
17011712

17021713
let nonAgenciesCount = instanceInfo.arangods
17031714
.filter(arangod => {
@@ -1733,7 +1744,10 @@ function shutdownInstance (instanceInfo, options, forceTerminate) {
17331744
arangod.exitStatus = {
17341745
status: 'RUNNING'
17351746
};
1736-
print(Date() + " Commanded shut down: " + JSON.stringify(arangod));
1747+
1748+
if (!options.noStartStopLogs) {
1749+
print(Date() + " Commanded shut down: " + JSON.stringify(arangod));
1750+
}
17371751
}
17381752
return true;
17391753
}
@@ -1787,7 +1801,9 @@ function shutdownInstance (instanceInfo, options, forceTerminate) {
17871801
if (arangod.role !== 'agent') {
17881802
nonAgenciesCount--;
17891803
}
1790-
print(Date() + ' Server "' + arangod.role + '" shutdown: Success: pid', arangod.pid);
1804+
if (!options.noStartStopLogs) {
1805+
print(Date() + ' Server "' + arangod.role + '" shutdown: Success: pid', arangod.pid);
1806+
}
17911807
crashUtils.stopProcdump(options, arangod);
17921808
return false;
17931809
}
@@ -1805,7 +1821,9 @@ function shutdownInstance (instanceInfo, options, forceTerminate) {
18051821
// e.g. 2 + coordinator + (s)
18061822
roleNames.push(roles[r] + ' ' + r + '(s)');
18071823
}
1808-
print(roleNames.join(', ') + ' are still running...');
1824+
if (!options.noStartStopLogs) {
1825+
print(roleNames.join(', ') + ' are still running...');
1826+
}
18091827
require('internal').wait(1, false);
18101828
}
18111829
}
@@ -1895,7 +1913,9 @@ function checkClusterAlive(options, instanceInfo, addArgs) {
18951913
arangod.upAndRunning = true;
18961914
return;
18971915
}
1898-
print(Date() + " tickeling cluster node " + arangod.url + " - " + arangod.role);
1916+
if (!options.noStartStopLogs) {
1917+
print(Date() + " tickeling cluster node " + arangod.url + " - " + arangod.role);
1918+
}
18991919
let url = arangod.url;
19001920
if (arangod.role === "coordinator" && arangod.args["javascript.enabled"] !== "false") {
19011921
url += '/_admin/aardvark/index.html';
@@ -1944,7 +1964,9 @@ function checkClusterAlive(options, instanceInfo, addArgs) {
19441964
}
19451965
}
19461966

1947-
print("Determining server IDs");
1967+
if (!options.noStartStopLogs) {
1968+
print("Determining server IDs");
1969+
}
19481970
instanceInfo.arangods.forEach(arangod => {
19491971
if (arangod.suspended) {
19501972
return;
@@ -2151,7 +2173,9 @@ function launchFinalize(options, instanceInfo, startTime) {
21512173
}
21522174
});
21532175
}
2154-
print(CYAN + Date() + ' up and running in ' + (time() - startTime) + ' seconds' + RESET);
2176+
if (!options.noStartStopLogs) {
2177+
print(CYAN + Date() + ' up and running in ' + (time() - startTime) + ' seconds' + RESET);
2178+
}
21552179
var matchPort = /.*:.*:([0-9]*)/;
21562180
var ports = [];
21572181
var processInfo = [];
@@ -2178,7 +2202,6 @@ function launchFinalize(options, instanceInfo, startTime) {
21782202
' - ' + arangod.args['database.directory']);
21792203
});
21802204

2181-
print(Date() + ' sniffing template:\n tcpdump -ni lo -s0 -w /tmp/out.pcap ' + ports.join(' or ') + '\n');
21822205
if (options.sniff !== undefined && options.sniff !== false) {
21832206
options.cleanup = false;
21842207
let device = 'lo';
@@ -2218,7 +2241,9 @@ function launchFinalize(options, instanceInfo, startTime) {
22182241
print(CYAN + 'launching ' + prog + ' ' + JSON.stringify(args) + RESET);
22192242
tcpdump = executeExternal(prog, args);
22202243
}
2221-
print(processInfo.join('\n') + '\n');
2244+
if (!options.noStartStopLogs) {
2245+
print(processInfo.join('\n') + '\n');
2246+
}
22222247
internal.sleep(options.sleepBeforeStart);
22232248
initProcessStats(instanceInfo);
22242249
}
@@ -2282,6 +2307,8 @@ function startArango (protocol, options, addArgs, rootDir, role) {
22822307

22832308
if (options.verbose) {
22842309
args['log.level'] = 'debug';
2310+
} else if (options.noStartStopLogs) {
2311+
args['log.level'] = 'all=error';
22852312
}
22862313

22872314
instanceInfo.url = endpointToURL(instanceInfo.endpoint);
@@ -2367,7 +2394,9 @@ function startInstanceAgency (instanceInfo, protocol, options, addArgs, rootDir)
23672394
instanceInfo.endpoint = instanceInfo.arangods[instanceInfo.arangods.length - 1].endpoint;
23682395
instanceInfo.url = instanceInfo.arangods[instanceInfo.arangods.length - 1].url;
23692396
instanceInfo.role = 'agent';
2370-
print(Date() + ' Agency Endpoint: ' + instanceInfo.endpoint);
2397+
if (!options.noStartStopLogs) {
2398+
print(Date() + ' Agency Endpoint: ' + instanceInfo.endpoint);
2399+
}
23712400
}
23722401

23732402
checkClusterAlive(options, instanceInfo, addArgs);

js/client/modules/@arangodb/testutils/test-utils.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,9 @@ function performTests (options, testList, testname, runFn, serverOptions, startS
466466

467467
let shutDownStart = time();
468468
results['testDuration'] = shutDownStart - testrunStart;
469-
print(Date() + ' Shutting down...');
469+
if (!options.noStartStopLogs) {
470+
print(Date() + ' Shutting down...');
471+
}
470472
if (startStopHandlers !== undefined && startStopHandlers.hasOwnProperty('preStop')) {
471473
customInstanceInfos['preStop'] = startStopHandlers.preStop(options,
472474
serverOptions,
@@ -507,7 +509,9 @@ function performTests (options, testList, testname, runFn, serverOptions, startS
507509
}
508510
results['shutdownTime'] = time() - shutDownStart;
509511

510-
print('done.');
512+
if (!options.noStartStopLogs) {
513+
print('done.');
514+
}
511515

512516
return results;
513517
}

js/client/modules/@arangodb/testutils/testing.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ let optionsDocumentation = [
152152
' - `crashAnalysisText`: output of debugger in case of crash',
153153
' - `getSockStat`: on linux collect socket stats before shutdown',
154154
' - `verbose`: if set to true, be more verbose',
155+
' - `noStartStopLogs`: if set to true, suppress startup and shutdown messages printed by process manager. Overridden by `extremeVerbosity`',
155156
' - `extremeVerbosity`: if set to true, then there will be more test run',
156157
' output, especially for cluster tests.',
157158
' - `testCase`: filter a jsunity testsuite for one special test case',
@@ -229,6 +230,7 @@ const optionsDefaults = {
229230
'valgrindArgs': {},
230231
'valgrindHosts': false,
231232
'verbose': false,
233+
'noStartStopLogs': internal.isATTy(),
232234
'vst': false,
233235
'http2': false,
234236
'walFlushTimeout': 30000,
@@ -588,6 +590,9 @@ function unitTest (cases, options) {
588590
loadTestSuites(options);
589591
// testsuites may register more defaults...
590592
_.defaults(options, optionsDefaults);
593+
594+
options.noStartStopLogs = !options.extremeVerbosity && options.noStartStopLogs;
595+
591596
if (options.failed ||
592597
(Array.isArray(options.commandSwitches) && options.commandSwitches.includes("failed"))) {
593598
options.failed = rp.getFailedTestCases(options);

js/common/modules/jsunity.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var internal = require('internal');
3030
var print = internal.print;
3131
var fs = require('fs');
3232
var console = require('console');
33+
var minimatch = require('minimatch');
3334

3435
var TOTAL = 0;
3536
var PASSED = 0;
@@ -50,6 +51,7 @@ var ENDTEST = 0.0;
5051
var STARTSUITE = 0.0;
5152
var ENDTEARDOWN = 0.0;
5253
var testFilter = "undefined";
54+
var suiteName = "undefined";
5355
var currentSuiteName = "undefined";
5456
var testCount = 0;
5557
var startMessage = "";
@@ -193,15 +195,22 @@ jsUnity.results.endTeardownAll = function(index) {
193195
TOTALTEARDOWNS += RESULTS.teardownAllDuration;
194196
};
195197

196-
function MatchesTestFilter(key) {
198+
function matchesTestFilter(suiteName, key) {
197199
if (testFilter === "undefined" || testFilter === undefined || testFilter === null) {
198200
return true;
199201
}
200202
if (typeof testFilter === 'string') {
201-
return key === testFilter;
203+
var suiteMatched = true;
204+
if (testFilter.includes('::')) {
205+
var [suiteFilter, testCaseFilter] = testFilter.split('::');
206+
suiteMatched = minimatch(suiteName, suiteFilter);
207+
testFilter = testCaseFilter;
208+
}
209+
210+
return suiteMatched && minimatch(key, testFilter);
202211
}
203212
if (Array.isArray(testFilter)) {
204-
return testFilter.includes(key);
213+
return testFilter.some(key => matchesTestFilter(suiteName, key));
205214
}
206215
return false;
207216
}
@@ -244,7 +253,7 @@ function Run (testsuite) {
244253

245254
for (var key in definition) {
246255
if (key.indexOf('test') === 0) {
247-
if (!MatchesTestFilter(key)) {
256+
if (!matchesTestFilter(suite.suiteName, key)) {
248257
// print(`test "${key}" doesn't match "${testFilter}", skipping`);
249258
nonMatchedTests.push(key);
250259
continue;
@@ -258,21 +267,16 @@ function Run (testsuite) {
258267
}
259268
}
260269
if (tests.length === 0) {
261-
let err = `There is no test in testsuite "${suite.suiteName}" or your filter "${testFilter}" didn't match on anything. We have: [${nonMatchedTests}]`;
262-
print(`${internal.COLORS.COLOR_RED}${err}${internal.COLORS.COLOR_RESET}`);
263270
let res = {
264271
suiteName: suite.suiteName,
265-
message: err,
266272
duration: 0,
267273
setUpDuration: 0,
268274
tearDownDuration: 0,
269275
passed: 0,
270-
status: false,
271-
failed: 1,
272-
total: 1
276+
status: true,
277+
failed: 0,
278+
total: 0
273279
};
274-
TOTAL += 1;
275-
FAILED += 2;
276280
COMPLETE[suite.suiteName] = res;
277281
return res;
278282
}

0 commit comments

Comments
 (0)
0