diff options
author | Félix Baylac-Jacqué <felix@alternativebit.fr> | 2022-11-23 11:01:04 +0100 |
---|---|---|
committer | Félix Baylac-Jacqué <felix@alternativebit.fr> | 2022-11-23 11:03:00 +0100 |
commit | 501d684de8fb70cac2e72eaaff0dcc94aa2af459 (patch) | |
tree | 84fedbe94187b4589d938df125b3142bb2d60f88 /nixos/tests/xmpp | |
parent | 5ab18b18ed158e2daf924b2a40fc91224804abd2 (diff) |
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.
Diffstat (limited to 'nixos/tests/xmpp')
-rw-r--r-- | nixos/tests/xmpp/xmpp-sendmessage.nix | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/nixos/tests/xmpp/xmpp-sendmessage.nix b/nixos/tests/xmpp/xmpp-sendmessage.nix index 4c009464b7041..781cd55c0766e 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') |