From 501d684de8fb70cac2e72eaaff0dcc94aa2af459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Baylac-Jacqu=C3=A9?= Date: Wed, 23 Nov 2022 11:01:04 +0100 Subject: [PATCH] nixosTests/prosody: add timeout The xmpp-sendmessage the slixmpp-powered python script tend to timeout and block the nixos channels. Adding a signal-based timeout making sure that whatever happens, the script won't run for more than 2 minutes. That should be pleinty enough time to finish regardless of the runner specs. As a data point, it runs in about 10 secs on my desktop machine. --- nixos/tests/xmpp/xmpp-sendmessage.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nixos/tests/xmpp/xmpp-sendmessage.nix b/nixos/tests/xmpp/xmpp-sendmessage.nix index 4c009464b704..781cd55c0766 100644 --- a/nixos/tests/xmpp/xmpp-sendmessage.nix +++ b/nixos/tests/xmpp/xmpp-sendmessage.nix @@ -12,6 +12,7 @@ in writeScriptBin "send-message" '' #!${(python3.withPackages (ps: [ ps.slixmpp ])).interpreter} import logging import sys +import signal from types import MethodType from slixmpp import ClientXMPP @@ -64,8 +65,13 @@ class CthonTest(ClientXMPP): log.info('MUC join success!') log.info('XMPP SCRIPT TEST SUCCESS') +def timeout_handler(signalnum, stackframe): + print('ERROR: xmpp-sendmessage timed out') + sys.exit(1) if __name__ == '__main__': + signal.signal(signal.SIGALRM, timeout_handler) + signal.alarm(120) logging.basicConfig(level=logging.DEBUG, format='%(levelname)-8s %(message)s')