From: Vsevolod Stakhov Date: Sat, 6 Dec 2025 09:37:32 +0000 (+0000) Subject: [Test] Add diagnostic logging to dummy_http.py X-Git-Tag: 3.14.2~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17f43999db66cf90f6b9497e098f107cd3690e37;p=thirdparty%2Frspamd.git [Test] Add diagnostic logging to dummy_http.py - Add startup progress messages to stderr - Capture exceptions with full traceback - Write PID only after successful server start - Log output on failure in robot tests --- diff --git a/test/functional/lib/rspamd.robot b/test/functional/lib/rspamd.robot index eb69fed4ef..d59f158f23 100644 --- a/test/functional/lib/rspamd.robot +++ b/test/functional/lib/rspamd.robot @@ -495,14 +495,34 @@ Sync Fuzzy Storage Run Dummy Http ${result} = Start Process ${RSPAMD_TESTDIR}/util/dummy_http.py -pf /tmp/dummy_http.pid - Wait Until Created /tmp/dummy_http.pid timeout=2 second + ... stderr=/tmp/dummy_http.log stdout=/tmp/dummy_http.log + ${status} ${error} = Run Keyword And Ignore Error Wait Until Created /tmp/dummy_http.pid timeout=2 second + IF '${status}' == 'FAIL' + ${logstatus} ${log} = Run Keyword And Ignore Error Get File /tmp/dummy_http.log + IF '${logstatus}' == 'PASS' + Log dummy_http.py failed to start. Log output:\n${log} level=ERROR + ELSE + Log dummy_http.py failed to start. No log file found at /tmp/dummy_http.log level=ERROR + END + Fail dummy_http.py did not create PID file in 2 seconds + END Export Scoped Variables ${RSPAMD_SCOPE} DUMMY_HTTP_PROC=${result} Run Dummy Https ${result} = Start Process ${RSPAMD_TESTDIR}/util/dummy_http.py ... -c ${RSPAMD_TESTDIR}/util/server.pem -k ${RSPAMD_TESTDIR}/util/server.pem ... -pf /tmp/dummy_https.pid -p 18081 - Wait Until Created /tmp/dummy_https.pid timeout=2 second + ... stderr=/tmp/dummy_https.log stdout=/tmp/dummy_https.log + ${status} ${error} = Run Keyword And Ignore Error Wait Until Created /tmp/dummy_https.pid timeout=2 second + IF '${status}' == 'FAIL' + ${logstatus} ${log} = Run Keyword And Ignore Error Get File /tmp/dummy_https.log + IF '${logstatus}' == 'PASS' + Log dummy_https.py failed to start. Log output:\n${log} level=ERROR + ELSE + Log dummy_https.py failed to start. No log file found at /tmp/dummy_https.log level=ERROR + END + Fail dummy_https.py did not create PID file in 2 seconds + END Export Scoped Variables ${RSPAMD_SCOPE} DUMMY_HTTPS_PROC=${result} Run Dummy Llm diff --git a/test/functional/util/dummy_http.py b/test/functional/util/dummy_http.py index 832dbdc797..c1f573390a 100755 --- a/test/functional/util/dummy_http.py +++ b/test/functional/util/dummy_http.py @@ -8,6 +8,8 @@ import tornado.httpserver import ssl import argparse import os +import sys +import traceback class MainHandler(tornado.web.RequestHandler): @tornado.gen.coroutine @@ -118,27 +120,39 @@ async def main(): parser.add_argument("--pidfile", "-pf", help="path to the PID file") args = parser.parse_args() + print(f"dummy_http.py: Starting server on {args.bind}:{args.port}", file=sys.stderr) + # Create the Tornado application app = make_app() # If keyfile and certfile are provided, create an HTTPS server. # Otherwise, create an HTTP server. if args.keyfile and args.certfile: + print(f"dummy_http.py: Using SSL with cert={args.certfile}, key={args.keyfile}", file=sys.stderr) ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) ssl_ctx.load_cert_chain(args.certfile, args.keyfile) server = tornado.httpserver.HTTPServer(app, ssl_options=ssl_ctx) else: server = tornado.httpserver.HTTPServer(app) + # Start the server + server.bind(args.port, args.bind) + server.start(1) + # Write the PID to the specified PID file, if provided + # Do this AFTER successful bind/start so we know the server is actually running if args.pidfile: dummy_killer.write_pid(args.pidfile) + print(f"dummy_http.py: PID file written to {args.pidfile}", file=sys.stderr) - # Start the server - server.bind(args.port, args.bind) - server.start(1) + print(f"dummy_http.py: Server started successfully, listening on {args.bind}:{args.port}", file=sys.stderr) await asyncio.Event().wait() if __name__ == "__main__": - asyncio.run(main()) + try: + asyncio.run(main()) + except Exception as e: + print(f"dummy_http.py: FATAL ERROR: {type(e).__name__}: {e}", file=sys.stderr) + traceback.print_exc(file=sys.stderr) + sys.exit(1)