From e183f9a419b1f8a4e624ce1739a3989291f1bbc7 Mon Sep 17 00:00:00 2001 From: Paul Kronenwetter Date: Mon, 6 Jun 2022 20:26:41 -0400 Subject: [PATCH] Adjust checks to use SOCKET_QUEUE. --- test/test_tnc.py | 4 ++-- test/util_tnc_IRS.py | 17 ++++++++++++++--- test/util_tnc_ISS.py | 18 ++++++++++++++---- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/test/test_tnc.py b/test/test_tnc.py index 3ad59638..816183bc 100755 --- a/test/test_tnc.py +++ b/test/test_tnc.py @@ -16,8 +16,8 @@ from test import util_tnc_ISS as iss import pytest -# These do not update static.INFO: -# "CONNECT", "SEND_TEST_FRAME" +# These do not update sock.SOCKET_QUEUE: +# "CONNECT" # This test is currently a little inconsistent. @pytest.mark.flaky(reruns=2) @pytest.mark.parametrize("command", ["CQ", "PING", "BEACON"]) diff --git a/test/util_tnc_IRS.py b/test/util_tnc_IRS.py index b1aba6e0..c6197002 100644 --- a/test/util_tnc_IRS.py +++ b/test/util_tnc_IRS.py @@ -10,26 +10,37 @@ import os import sys import time +import structlog + sys.path.insert(0, "..") sys.path.insert(0, "../tnc") import data_handler import helpers import modem +import sock import static IRS_original_arq_cleanup = object MESSAGE: str +log = structlog.get_logger("util_tnc_IRS") + def irs_arq_cleanup(): """Replacement for modem.arq_cleanup to detect when to exit process.""" - if "TRANSMISSION;STOPPED" in static.INFO: - print(f"{static.INFO=}") + log.info( + "irs_arq_cleanup", socket_queue=sock.SOCKET_QUEUE.queue, message=MESSAGE.lower() + ) + if '"arq":"transmission","status":"stopped"' in str(sock.SOCKET_QUEUE.queue): + # log.info("irs_arq_cleanup", socket_queue=sock.SOCKET_QUEUE.queue) time.sleep(2) # sys.exit does not terminate threads. # pylint: disable=protected-access - if f"{MESSAGE};RECEIVING" not in static.INFO: + if f'"{MESSAGE.lower()}":"receiving"' not in str( + sock.SOCKET_QUEUE.queue + ) and f'"{MESSAGE.lower()}":"received"' not in str(sock.SOCKET_QUEUE.queue): print(f"{MESSAGE} was not received.") + log.info("irs_arq_cleanup", socket_queue=sock.SOCKET_QUEUE.queue) os._exit(1) os._exit(0) diff --git a/test/util_tnc_ISS.py b/test/util_tnc_ISS.py index 303f3fd9..16f6f043 100644 --- a/test/util_tnc_ISS.py +++ b/test/util_tnc_ISS.py @@ -10,26 +10,36 @@ import os import sys import time -sys.path.insert(0, "..") +import structlog + sys.path.insert(0, "../tnc") import data_handler import helpers import modem +import sock import static ISS_original_arq_cleanup = object MESSAGE: str +log = structlog.get_logger("util_tnc_ISS") + def iss_arq_cleanup(): """Replacement for modem.arq_cleanup to detect when to exit process.""" - if "TRANSMISSION;STOPPED" in static.INFO: - print(f"{static.INFO=}") + log.info( + "irs_arq_cleanup", socket_queue=sock.SOCKET_QUEUE.queue, message=MESSAGE.lower() + ) + if '"arq":"transmission","status":"stopped"' in str(sock.SOCKET_QUEUE.queue): + # log.info("iss_arq_cleanup", socket_queue=sock.SOCKET_QUEUE.queue) time.sleep(1) # sys.exit does not terminate threads. # pylint: disable=protected-access - if f"{MESSAGE};SENDING" not in static.INFO: + if f'"{MESSAGE.lower()}":"transmitting"' not in str( + sock.SOCKET_QUEUE.queue + ) and f'"{MESSAGE.lower()}":"sending"' not in str(sock.SOCKET_QUEUE.queue): print(f"{MESSAGE} was not sent.") + log.info("iss_arq_cleanup", socket_queue=sock.SOCKET_QUEUE.queue) os._exit(1) os._exit(0)