From ae3d701cd8ccfefeda8e0d062edb2fa06b3db1e7 Mon Sep 17 00:00:00 2001 From: Alan Rominger Date: Wed, 8 Jan 2025 09:34:02 -0500 Subject: [PATCH 1/3] Add test to ensure bootstrap reqs are good --- .../functional/test_python_requirements.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/awx/main/tests/functional/test_python_requirements.py b/awx/main/tests/functional/test_python_requirements.py index d363b91db1f4..33b3be59b90e 100644 --- a/awx/main/tests/functional/test_python_requirements.py +++ b/awx/main/tests/functional/test_python_requirements.py @@ -5,6 +5,33 @@ from django.conf import settings +def test_bootstrap_consistent(): + with open('Makefile', 'r') as f: + mk_data = f.read() + bootstrap_reqs = None + for line in mk_data.split('\n'): + if line.startswith('VENV_BOOTSTRAP'): + parts = line.split() + bootstrap_reqs = parts[parts.index('?=') + 1 :] + break + else: + raise RuntimeError('Cound not find bootstrap line') + + req_data = None + with open('requirements/requirements.txt', 'r') as f: + req_data = f.read() + + for req in bootstrap_reqs: + boot_req_name, _ = req.split('=', 1) + for line in req_data.split('\n'): + if '=' not in line: + continue + req_name, _ = line.split('=', 1) + if req_name == boot_req_name: + assert req == line + break + + @pytest.mark.skip(reason="This test needs some love") def test_env_matches_requirements_txt(): from pip.operations import freeze From 532332d54ec1bd138c0c398fdb80e1767469994b Mon Sep 17 00:00:00 2001 From: Alan Rominger Date: Wed, 8 Jan 2025 10:06:33 -0500 Subject: [PATCH 2/3] Give full diff list in assert --- awx/main/tests/functional/test_python_requirements.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/awx/main/tests/functional/test_python_requirements.py b/awx/main/tests/functional/test_python_requirements.py index 33b3be59b90e..535cf0572169 100644 --- a/awx/main/tests/functional/test_python_requirements.py +++ b/awx/main/tests/functional/test_python_requirements.py @@ -21,6 +21,7 @@ def test_bootstrap_consistent(): with open('requirements/requirements.txt', 'r') as f: req_data = f.read() + different_requirements = [] for req in bootstrap_reqs: boot_req_name, _ = req.split('=', 1) for line in req_data.split('\n'): @@ -28,9 +29,11 @@ def test_bootstrap_consistent(): continue req_name, _ = line.split('=', 1) if req_name == boot_req_name: - assert req == line + different_requirements.append((req, line)) break + assert not different_requirements + @pytest.mark.skip(reason="This test needs some love") def test_env_matches_requirements_txt(): From e9e124a3d1b033342e01515a1e990c7018b662c5 Mon Sep 17 00:00:00 2001 From: Alan Rominger Date: Mon, 13 Jan 2025 14:07:01 -0500 Subject: [PATCH 3/3] Fix goof --- awx/main/tests/functional/test_python_requirements.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/awx/main/tests/functional/test_python_requirements.py b/awx/main/tests/functional/test_python_requirements.py index 535cf0572169..577c7ee5bb92 100644 --- a/awx/main/tests/functional/test_python_requirements.py +++ b/awx/main/tests/functional/test_python_requirements.py @@ -29,7 +29,8 @@ def test_bootstrap_consistent(): continue req_name, _ = line.split('=', 1) if req_name == boot_req_name: - different_requirements.append((req, line)) + if req != line: + different_requirements.append((req, line)) break assert not different_requirements