From 9f8c8ea85175eb652b7d50b1c9dedf37aeb2240c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= Date: Thu, 15 May 2025 10:31:30 +0200 Subject: [PATCH] tools.testing: Add way to re-play recorded queries in gatekeeper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit to simplify gatekeeper development add support for DEBUG_INPUT which can be used to report content from files gathered in DEBUG run. Signed-off-by: Lukáš Doktor --- tools/testing/gatekeeper/jobs.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tools/testing/gatekeeper/jobs.py b/tools/testing/gatekeeper/jobs.py index 04f72c7651..d40427c991 100644 --- a/tools/testing/gatekeeper/jobs.py +++ b/tools/testing/gatekeeper/jobs.py @@ -43,6 +43,10 @@ if os.environ.get("DEBUG", "false") == "true": os.makedirs(DEBUG_DIR) else: DEBUG_DIR = None +if os.environ.get("DEBUG_INPUT", "") == "": + DEBUG_INPUT = None +else: + DEBUG_INPUT = os.path.abspath(os.environ["DEBUG_INPUT"]) class Checker: @@ -153,10 +157,15 @@ class Checker: def fetch_json_from_url(self, url, task, params=None): """Fetches URL and reports json output""" print(url, file=sys.stderr) - response = requests.get(url, headers=_GH_HEADERS, params=params, - timeout=60) - response.raise_for_status() - output = response.json() + if DEBUG_INPUT: + with open(f"{os.path.join(DEBUG_INPUT, task)}.json", "r", + encoding="utf8") as inp: + output = json.load(inp) + else: + response = requests.get(url, headers=_GH_HEADERS, params=params, + timeout=60) + response.raise_for_status() + output = response.json() if DEBUG_DIR: with open(f"{os.path.join(DEBUG_DIR, task)}.json", "w", encoding="utf8") as out: