Unverified Commit 501d684d authored by Félix Baylac-Jacqué's avatar Félix Baylac-Jacqué
Browse files

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.
parent 5ab18b18
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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')