From 174ced253f0a7f23ab9e14d82ce6dd285064032b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Roth?= Date: Thu, 14 May 2026 20:38:59 +0200 Subject: [PATCH] system-tests: add debug flag --- Makefile | 9 +++++++-- system/api_lib.py | 2 +- system/run.py | 10 ++++++++-- system/t12_api/unix_socket.py | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 770d9d9d..d497df45 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,11 @@ ifeq ($(CAPTURE),1) CAPTURE_ARG := --capture endif +# export DEBUG=1 to enable debug output in system tests +ifeq ($(DEBUG),1) +DEBUG_ARG := --debug +endif + help: ## Print this help @grep -E '^[a-zA-Z][a-zA-Z0-9_-]*:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' @@ -121,7 +126,7 @@ system-test: prepare swagger etcd-install ## Run system tests if [ ! -e ~/aptly-fixture-pool ]; then git clone https://github.com/aptly-dev/aptly-fixture-pool.git ~/aptly-fixture-pool/; fi test -f ~/etcd.db || (curl -o ~/etcd.db.xz http://repo.aptly.info/system-tests/etcd.db.xz && xz -d ~/etcd.db.xz) # Run system tests - PATH=$(BINPATH)/:$(PATH) FORCE_COLOR=1 $(PYTHON) system/run.py --long $(COVERAGE_ARG_TEST) $(CAPTURE_ARG) $(TEST) + PATH=$(BINPATH)/:$(PATH) FORCE_COLOR=1 $(PYTHON) system/run.py --long $(COVERAGE_ARG_TEST) $(CAPTURE_ARG) $(DEBUG_ARG) $(TEST) bench: @echo "\e[33m\e[1mRunning benchmark ...\e[0m" @@ -211,7 +216,7 @@ docker-system-test: ## Run system tests in docker container (add TEST=t04_mirro AZURE_STORAGE_ACCESS_KEY="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==" \ AWS_ACCESS_KEY_ID=$(AWS_ACCESS_KEY_ID) \ AWS_SECRET_ACCESS_KEY=$(AWS_SECRET_ACCESS_KEY) \ - system-test TEST=$(TEST) CAPTURE=$(CAPTURE) COVERAGE_SKIP=$(COVERAGE_SKIP) \ + system-test TEST=$(TEST) CAPTURE=$(CAPTURE) COVERAGE_SKIP=$(COVERAGE_SKIP) DEBUG=$(DEBUG) \ azurite-stop docker-serve: ## Run development server (auto recompiling) on http://localhost:3142 diff --git a/system/api_lib.py b/system/api_lib.py index 26245c81..f22c1ce7 100644 --- a/system/api_lib.py +++ b/system/api_lib.py @@ -25,7 +25,7 @@ class APITest(BaseTest): """ aptly_server = None aptly_out = None - debugOutput = True + debugOutput = False # Controlled by --debug flag in run.py base_url = "127.0.0.1:8765" configOverride = { "FileSystemPublishEndpoints": { diff --git a/system/run.py b/system/run.py index 56c39160..47465412 100755 --- a/system/run.py +++ b/system/run.py @@ -36,7 +36,7 @@ def natural_key(string_): return [int(s) if s.isdigit() else s for s in re.split(r'(\d+)', string_)] -def run(include_long_tests=False, capture_results=False, tests=None, filters=None, coverage_dir=None, coverage_skip=False): +def run(include_long_tests=False, capture_results=False, tests=None, filters=None, coverage_dir=None, coverage_skip=False, debug=False): """ Run system test. """ @@ -50,6 +50,9 @@ def run(include_long_tests=False, capture_results=False, tests=None, filters=Non if not coverage_dir and not coverage_skip: coverage_dir = mkdtemp(suffix="aptly-coverage") + # Set debug output globally for all test classes + BaseTest.debugOutput = debug + failed = False for test in tests: orig_stdout = sys.stdout @@ -215,6 +218,7 @@ if __name__ == "__main__": capture_results = False coverage_dir = None coverage_skip = False + debug = False tests = None args = sys.argv[1:] @@ -228,6 +232,8 @@ if __name__ == "__main__": args = args[1:] elif args[0] == "--coverage-skip": coverage_skip = True + elif args[0] == "--debug": + debug = True args = args[1:] @@ -240,4 +246,4 @@ if __name__ == "__main__": else: filters.append(arg) - run(include_long_tests, capture_results, tests, filters, coverage_dir, coverage_skip) + run(include_long_tests, capture_results, tests, filters, coverage_dir, coverage_skip, debug) diff --git a/system/t12_api/unix_socket.py b/system/t12_api/unix_socket.py index 075ff688..e9aec986 100644 --- a/system/t12_api/unix_socket.py +++ b/system/t12_api/unix_socket.py @@ -14,7 +14,7 @@ class UnixSocketAPITest(BaseTest): socket_path = "/tmp/_aptly_test.sock" base_url = ("unix://%s" % socket_path) aptly_out = None - debugOutput = True + debugOutput = False # Controlled by --debug flag in run.py def prepare(self): if self.aptly_server is None: