Skip to content

Commit 6b32b70

Browse files
committed
test: reap the timed-out test before its return code is used
Review catch. The TimeoutExpired handler called kill() and drained stdout but never wait()ed, so fop.returncode stayed None -- and the shared exit path below evaluates: rc += abs(int(fop.returncode)) which raises TypeError on None. The first timed-out test would therefore abort the whole group as a Python exception instead of failing one test. Latent until now: the timeout could never fire while the read loop blocked in readline(), so this path was unreachable. Enabling the timeout in the previous commit makes it reachable, so it has to be fixed in the same PR. wait() after the drain yields -SIGKILL, so abs(int(...)) contributes 9 and the timed-out test is correctly scored as failed. Verified directly: returncode None before wait(), -9 after. Also switches the drain's decode to errors='replace', matching the main read loop -- a hung test is exactly the case likely to emit a truncated multi-byte sequence, which would otherwise throw inside the handler.
1 parent 81c5290 commit 6b32b70

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

test/scripts/bin/proxysql-tester.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,15 @@ def disk_usage():
886886
self.padmin_command(f"LOGENTRY '{TAP} test {fo_num+1}/{len(tap_tests)} \'{os.path.basename(fo_cmd)}\' timed out after {tap_timeout} seconds'")
887887
# Drain any remaining output
888888
for line in fop.stdout:
889-
log.debug(f"msg: {line.decode('utf-8').strip()}")
889+
log.debug(f"msg: {line.decode('utf-8', 'replace').strip()}")
890+
# Reap the child. kill() signals but does not wait, so
891+
# returncode stays None until we do -- and the shared exit
892+
# path below evaluates abs(int(fop.returncode)), which
893+
# raises TypeError on None. That path was unreachable while
894+
# the timeout could never fire; now that it can, a timed-out
895+
# test would abort the whole group instead of failing one
896+
# test. wait() yields -SIGKILL, so the test scores non-zero.
897+
fop.wait()
890898
except Exception as e:
891899
log.critical(f"TAP test {fo_num+1}/{len(tap_tests)} '{os.path.basename(fo_cmd)}' - test threw an exception !!!: {e}")
892900
self.padmin_command(f"LOGENTRY '{TAP} test {fo_num+1}/{len(tap_tests)} \'{os.path.basename(fo_cmd)}\' - test threw an exception !!!'")

0 commit comments

Comments
 (0)