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.
This commit is contained in:
Félix Baylac-Jacqué
2022-11-23 11:03:00 +01:00
parent 5ab18b18ed
commit 501d684de8
+6
View File
@@ -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')