From 972b18d844588b6fa381213dc7a7f19273da08b7 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Tue, 8 Oct 2024 19:50:27 +0200 Subject: [PATCH] More test output --- .github/workflows/python-package.yml | 4 ++-- src/unoserver/server.py | 23 +++++++++++++++++++++++ tests/test_integration.py | 6 +++--- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index deb1c1a..0840819 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -18,7 +18,7 @@ jobs: os: [ubuntu-20.04, ubuntu-22.04] fail-fast: true steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install Package run: | python -m pip install virtualenv @@ -33,4 +33,4 @@ jobs: - name: Test with pytest run: | source ve/bin/activate - make test + pytest -s diff --git a/src/unoserver/server.py b/src/unoserver/server.py index 35dfa17..b39f748 100644 --- a/src/unoserver/server.py +++ b/src/unoserver/server.py @@ -97,7 +97,9 @@ def signal_handler(signum, frame): raise if self.xmlrcp_server is not None: + logger.error("A") self.stop() # Ensure the server stops + logger.error("B") signal.signal(signal.SIGTERM, signal_handler) signal.signal(signal.SIGINT, signal_handler) @@ -115,7 +117,9 @@ def signal_handler(signum, frame): # Check if it succeeded if not self.xmlrcp_thread.is_alive(): logger.info("Failed to start servers") + logger.error("C") self.stop() + logger.error("D") return None return self.libreoffice_process @@ -195,22 +199,33 @@ def compare( server.serve_forever() def stop(self): + logger.info("STOP1") if self.libreoffice_process: + logger.info("STOP2") self.libreoffice_process.terminate() if self.xmlrcp_server is not None: + logger.info("STOP2") self.xmlrcp_server.shutdown() # Make a dummy connection to unblock accept() - otherwise it will # hang indefinitely in the accept() call. # noinspection PyBroadException try: + logger.info("STOP4") with socket.create_connection( (self.interface, int(self.port)), timeout=1 ): + logger.info("STOP5") pass + except Exception: + logger.info("STOP6") pass # Ignore any except + logger.info("STOP7") if self.xmlrcp_thread is not None: + logger.info("STOP8") self.xmlrcp_thread.join() + logger.info("STOP9") + logger.info("STOP10") def main(): @@ -304,7 +319,11 @@ def main(): logger.error(f"Looks like LibreOffice died. PID: {pid}") # The RPC thread needs to be stopped before the process can exit + logger.error("E") server.stop() + logger.error("F") + + logger.error("OK?") if args.libreoffice_pid_file: # Remove the PID file @@ -312,15 +331,19 @@ def main(): try: # Make sure it's really dead + logger.error("Hmm?") os.kill(pid, 0) + logger.error("OK!") if server.intentional_exit: return 0 else: + logger.error("NO!") return 1 except OSError as e: if e.errno == 3: # All good, it was already dead. + logger.error("Yes") return 0 raise diff --git a/tests/test_integration.py b/tests/test_integration.py index de13b7d..099950a 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -107,7 +107,7 @@ def test_multiple_servers(server_fixture): # Now kill the process process.terminate() # Wait for it to terminate - process.wait() + process.wait(10) # And verify that it was killed assert process.returncode == 0 @@ -222,7 +222,7 @@ def test_convert_not_local(): # Now kill the process process.terminate() # Wait for it to terminate - process.wait() + process.wait(timeout=10) # And verify that it was killed assert process.returncode == 0 @@ -262,6 +262,6 @@ def skip_test_compare_not_local(): # Now kill the process process.terminate() # Wait for it to terminate - process.wait() + process.wait(10) # And verify that it was killed assert process.returncode == 0