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 1/2] 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') From 8040c468ed9188c33fb851921327d9d9d6850f2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Baylac-Jacqu=C3=A9?= Date: Wed, 23 Nov 2022 11:05:12 +0100 Subject: [PATCH 2/2] nixosTests/prosody[-mysql]: fix tests TLS setup The tests TLS setup was bogus: the xmpp-send-message script was trying to connect to the server through a bogus domain name. Injecting the right one. I'm a bit confused about that one. I know for sure this NixOS test succeeded last time I checked it, but the TLS conf is bogus for sure. I assume the slixmpp SNI validation was a bit too loose and was tightened at some point. --- nixos/tests/xmpp/prosody.nix | 3 ++- nixos/tests/xmpp/xmpp-sendmessage.nix | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/nixos/tests/xmpp/prosody.nix b/nixos/tests/xmpp/prosody.nix index 14eab56fb821..045ae6430fd4 100644 --- a/nixos/tests/xmpp/prosody.nix +++ b/nixos/tests/xmpp/prosody.nix @@ -42,7 +42,7 @@ in import ../make-test-python.nix { ${nodes.server.config.networking.primaryIPAddress} uploads.example.com ''; environment.systemPackages = [ - (pkgs.callPackage ./xmpp-sendmessage.nix { connectTo = nodes.server.config.networking.primaryIPAddress; }) + (pkgs.callPackage ./xmpp-sendmessage.nix { connectTo = "example.com"; }) ]; }; server = { config, pkgs, ... }: { @@ -82,6 +82,7 @@ in import ../make-test-python.nix { testScript = { nodes, ... }: '' # Check with sqlite storage + start_all() server.wait_for_unit("prosody.service") server.succeed('prosodyctl status | grep "Prosody is running"') diff --git a/nixos/tests/xmpp/xmpp-sendmessage.nix b/nixos/tests/xmpp/xmpp-sendmessage.nix index 781cd55c0766..8ccac0612491 100644 --- a/nixos/tests/xmpp/xmpp-sendmessage.nix +++ b/nixos/tests/xmpp/xmpp-sendmessage.nix @@ -82,7 +82,7 @@ if __name__ == '__main__': ct.register_plugin('xep_0363') # MUC ct.register_plugin('xep_0045') - ct.connect(("server", 5222)) + ct.connect(("${connectTo}", 5222)) ct.process(forever=False) if not ct.test_succeeded: