8000 fix test timeout handling (#11118) · arangodb/arangodb@c9abf9d · GitHub
[go: up one dir, main page]

Skip to content

Commit c9abf9d

Browse files
authored
fix test timeout handling (#11118)
1 parent 94ce46a commit c9abf9d

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,8 @@ function executeAndWait (cmd, args, options, valgrindTest, rootDir, coreCheck =
694694
instanceInfo.exitStatus = res;
695695
}
696696
} else {
697-
// V8 executeExternalAndWait thinks that timeout is in ms, so *100
698-
res = executeExternalAndWait(cmd, args, false, timeout*100, coverageEnvironment());
697+
// V8 executeExternalAndWait thinks that timeout is in ms, so *1000
698+
res = executeExternalAndWait(cmd, args, false, timeout*1000, coverageEnvironment());
699699
instanceInfo.pid = res.pid;
700700
instanceInfo.exitStatus = res;
701701
crashUtils.calculateMonitorValues(options, instanceInfo, res.pid, cmd);
@@ -761,6 +761,29 @@ function executeAndWait (cmd, args, options, valgrindTest, rootDir, coreCheck =
761761
' exit signal: ' + instanceInfo.exitStatus.signal + errorMessage,
762762
duration: deltaTime
763763
};
764+
} else if (res.status === 'TIMEOUT') {
765+
print('Killing ' + cmd + ' - ' + JSON.stringify(args));
766+
8000 let resKill = killExternal(res.pid, abortSignal);
767+
if (coreCheck) {
768+
print(Date() + " executeAndWait: Marking crashy because of timeout - " + JSON.stringify(instanceInfo));
769+
crashUtils.analyzeCrash(cmd,
770+
instanceInfo,
771+
options,
772+
'execution of ' + cmd + ' - kill because of timeout');
773+
if (options.coreCheck) {
774+
print(instanceInfo.exitStatus.gdbHint);
775+
}
776+
serverCrashedLocal = true;
777+
}
778+
instanceInfo.pid = res.pid;
779+
instanceInfo.exitStatus = res;
780+
return {
781+
timeout: true,
782+
status: false,
783+
message: 'termination by timeout: ' + instanceInfo.exitStatus.status +
784+
' killed by : ' + abortSignal + errorMessage,
785+
duration: deltaTime
786+
};
764787
} else {
765788
if (typeof (instanceInfo.exitStatus.errorMessage) !== 'undefined') {
766789
errorMessage += instanceInfo.exitStatus.errorMessage;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ const optionsDefaults = {
199199
'skipNondeterministic': false,
200200
'skipGrey': false,
201201
'onlyGrey': false,
202-
'oneTestTimeout': 2700,
202+
'oneTestTimeout': 10 * 60,
203203
'isAsan': false,
204204
'skipTimeCritical': false,
205205
'storageEngine': 'rocksdb',

lib/Basics/process-utils.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,7 @@ ExternalProcessStatus TRI_CheckExternalProcess(ExternalId pid, bool wait, uint32
994994

995995
int loc = 0;
996996
TRI_pid_t res = 0;
997+
bool timeoutHappened = false;
997998
if (timeout) {
998999
TRI_ASSERT((opts & WNOHANG) != 0);
9991000
double endTime = 0.0;
@@ -1003,11 +1004,11 @@ ExternalProcessStatus TRI_CheckExternalProcess(ExternalId pid, bool wait, uint32
10031004
break;
10041005
}
10051006
double now = TRI_microtime();
1006-
if (endTime <= 0.000001) {
1007-
// set endtime only once
1007+
if (endTime == 0.0) {
10081008
endTime = now + timeout / 1000.0;
10091009
} else if (now >= endTime) {
1010-
// timeout
1010+
res = external->_pid;
1011+
timeoutHappened = true;
10111012
break;
10121013
}
10131014
std::this_thread::sleep_for(std::chrono::milliseconds(20));
@@ -1021,8 +1022,10 @@ ExternalProcessStatus TRI_CheckExternalProcess(ExternalId pid, bool wait, uint32
10211022
status._errorMessage =
10221023
std::string("waitpid returned 0 for pid while it shouldn't ") +
10231024
arangodb::basics::StringUtils::itoa(external->_pid);
1024-
1025-
if (WIFEXITED(loc)) {
1025+
if (timeoutHappened) {
1026+
external->_status = TRI_EXT_TIMEOUT;
1027+
external->_exitStatus = -1;
1028+
} else if (WIFEXITED(loc)) {
10261029
external->_status = TRI_EXT_TERMINATED;
10271030
external->_exitStatus = WEXITSTATUS(loc);
10281031
} else if (WIFSIGNALED(loc)) {
@@ -1050,7 +1053,10 @@ ExternalProcessStatus TRI_CheckExternalProcess(ExternalId pid, bool wait, uint32
10501053
arangodb::basics::StringUtils::itoa(external->_pid) +
10511054
std::string(": ") + std::string(TRI_last_error());
10521055
} else if (static_cast<TRI_pid_t>(external->_pid) == static_cast<TRI_pid_t>(res)) {
1053-
if (WIFEXITED(loc)) {
1056+
if (timeoutHappened) {
1057+
external->_status = TRI_EXT_TIMEOUT;
1058+
external->_exitStatus = -1;
1059+
} else if (WIFEXITED(loc)) {
10541060
external->_status = TRI_EXT_TERMINATED;
10551061
external->_exitStatus = WEXITSTATUS(loc);
10561062
} else if (WIFSIGNALED(loc)) {

0 commit comments

Comments
 (0)
0