From 520068d0926032c3c332270228a7c70f66605bfb Mon Sep 17 00:00:00 2001 From: Erik Skultety Date: Mon, 7 Oct 2024 11:13:47 +0200 Subject: [PATCH] tests: Replace "localhost" domain name with the equivalent IPv4 address It's common that "localhost" translates with both IPv4 and IPv6. The simple containerized test PyPI server we use in our CI doesn't listen on IPv6 which may cause unpredictable issues on hosts where IPv6 is enabled and IPv6 would get prioritized by the low level network stack connection primitives. Therefore, use an IP explicitly to avoid any potential issues during pytest run, e.g.: DEBUG Starting new HTTP connection (1): localhost:8080 DEBUG ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')) Signed-off-by: Erik Skultety --- tests/integration/conftest.py | 2 +- tests/integration/test_data/pip_custom_index/bom.json | 6 +++--- tests/integration/test_pip.py | 4 ++-- tests/pypiserver/start.sh | 2 +- tox.ini | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index bfdb5c0d6..1e89054c0 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -59,7 +59,7 @@ def local_pypiserver() -> Iterator[None]: for _ in range(60): time.sleep(1) try: - resp = requests.get(f"http://localhost:{pypiserver_port}") + resp = requests.get(f"http://127.0.0.1:{pypiserver_port}") resp.raise_for_status() log.debug(resp.text) break diff --git a/tests/integration/test_data/pip_custom_index/bom.json b/tests/integration/test_data/pip_custom_index/bom.json index 98086ac4b..870754cae 100644 --- a/tests/integration/test_data/pip_custom_index/bom.json +++ b/tests/integration/test_data/pip_custom_index/bom.json @@ -2,14 +2,14 @@ "bomFormat": "CycloneDX", "components": [ { - "name": "cachi2-pip-custom-index", + "name": "cachito-testing-cachi2-pip-custom-index", "properties": [ { "name": "cachi2:found_by", "value": "cachi2" } ], - "purl": "pkg:pypi/cachi2-pip-custom-index?vcs_url=git%2Bhttps://github.com/cachito-testing/cachi2-pip-custom-index.git%404d6fe87e62b984cf420e6c8377821a76895b72a8", + "purl": "pkg:pypi/cachito-testing-cachi2-pip-custom-index?vcs_url=git%2Bhttps://github.com/eskultety/cachito-testing-cachi2-pip-custom-index%4086e3030d3d2261bff099bffdce264af2c1f09e30", "type": "library" }, { @@ -24,7 +24,7 @@ "value": "true" } ], - "purl": "pkg:pypi/requests@2.32.3?repository_url=http://localhost:8080/simple/", + "purl": "pkg:pypi/requests@2.32.3?repository_url=http://127.0.0.1:8080/simple/", "type": "library", "version": "2.32.3" } diff --git a/tests/integration/test_pip.py b/tests/integration/test_pip.py index 4dfae338d..ca53cb288 100644 --- a/tests/integration/test_pip.py +++ b/tests/integration/test_pip.py @@ -135,8 +135,8 @@ ), pytest.param( utils.TestParameters( - repo="https://github.com/cachito-testing/cachi2-pip-custom-index.git", - ref="4d6fe87e62b984cf420e6c8377821a76895b72a8", + repo="https://github.com/eskultety/cachito-testing-cachi2-pip-custom-index", + ref="86e3030d3d2261bff099bffdce264af2c1f09e30", packages=({"path": ".", "type": "pip", "allow_binary": True},), check_vendor_checksums=False, expected_exit_code=0, diff --git a/tests/pypiserver/start.sh b/tests/pypiserver/start.sh index 601c753dc..6591c893e 100755 --- a/tests/pypiserver/start.sh +++ b/tests/pypiserver/start.sh @@ -45,7 +45,7 @@ setup() { ls -lA "$WORKDIR/auth" tar cf - -C "$WORKDIR/auth" . | podman volume import cachi2-pypiserver-auth - - echo -e "\n--- Starting pypiserver on http://localhost:${PYPISERVER_PORT:-8080} ---\n" + echo -e "\n--- Starting pypiserver on http://127.0.0.1:${PYPISERVER_PORT:-8080} ---\n" } setup >&2 diff --git a/tox.ini b/tox.ini index 27cac1aa0..352ad3511 100644 --- a/tox.ini +++ b/tox.ini @@ -54,7 +54,7 @@ passenv = PYPISERVER_IMAGE PYPISERVER_PORT setenv = - CACHI2_TEST_NETRC_CONTENT={env:CACHI2_TEST_NETRC_CONTENT:machine localhost login cachi2-user password cachi2-pass} + CACHI2_TEST_NETRC_CONTENT={env:CACHI2_TEST_NETRC_CONTENT:machine 127.0.0.1 login cachi2-user password cachi2-pass} basepython = python3 skip_install = true commands =