-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test-suite now gets a new module (test_mirrors) that checks a few things regarding mirrorbrain and out mirrors - mirrors.html is there and enough populated - ZIM permalinks are working - release (APK) permalink are working - Load balancer is working (redirecting) - ZIM file is present on all mirrors - APK is present on all mirrors mirroring releases - ZIM files are sent with a Content-Type header - APK files are sent with a Content-Type header - ZIM files are served with `application/octet-stream` - APK files are served with `application/vnd.android.package-archive`
- Loading branch information
Showing
8 changed files
with
413 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Mirrors Check | ||
|
||
on: | ||
schedule: | ||
- cron: "0 8 * * *" | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
|
||
mirrors: | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.12 | ||
architecture: x64 | ||
- name: Install dependencies | ||
run: pip install -r test-suite/requirements.txt | ||
- name: Test mirrors | ||
working-directory: test-suite | ||
run: pytest -vvv test_mirrors.py |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
requests==2.31.0 | ||
pytest==7.4.0 | ||
beautifulsoup4==4.12.3 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
from http import HTTPStatus | ||
from urllib.parse import urljoin | ||
|
||
import pytest | ||
import requests | ||
from conftest import ( | ||
APK_MIRRORS, | ||
APK_MIRRORS_IDS, | ||
EXPECTED_APK_MIRRORS, | ||
ZIM_MIRRORS, | ||
ZIM_MIRRORS_IDS, | ||
) | ||
from utils import TIMEOUT, Mirror | ||
|
||
|
||
def test_mirrors_list_reachable(mirrors_list_url): | ||
assert requests.head(mirrors_list_url).status_code == HTTPStatus.FOUND | ||
assert ( | ||
requests.head(mirrors_list_url, allow_redirects=True).status_code | ||
== HTTPStatus.OK | ||
) | ||
|
||
|
||
def test_zim_exists(permanent_zim_url, current_zim_url): | ||
assert ( | ||
requests.head(permanent_zim_url, allow_redirects=True).status_code | ||
== HTTPStatus.OK | ||
) | ||
assert ( | ||
requests.head(current_zim_url, allow_redirects=True).status_code | ||
== HTTPStatus.OK | ||
) | ||
|
||
|
||
def test_zim_permalink(permanent_zim_url, current_zim_url): | ||
assert ( | ||
requests.head(permanent_zim_url, allow_redirects=True, timeout=TIMEOUT).url | ||
== requests.head(current_zim_url, allow_redirects=True, timeout=TIMEOUT).url | ||
) | ||
|
||
|
||
def test_zim_mirrors_list(current_zim_mirrors): | ||
# arbitrary number ; should fail if we dont get this (currently it's 14) | ||
assert len(current_zim_mirrors) >= 12 | ||
|
||
|
||
@pytest.mark.parametrize("mirror", ZIM_MIRRORS, ids=ZIM_MIRRORS_IDS) | ||
def test_mirror_has_zim_file(mirror: Mirror, current_zim_path: str): | ||
url = urljoin(mirror.base_url, current_zim_path) | ||
assert ( | ||
requests.head(url, timeout=TIMEOUT, allow_redirects=False).status_code | ||
== HTTPStatus.OK | ||
) | ||
|
||
|
||
@pytest.mark.parametrize("mirror", ZIM_MIRRORS, ids=ZIM_MIRRORS_IDS) | ||
def test_mirror_zim_has_contenttype(mirror: Mirror, current_zim_path: str): | ||
url = urljoin(mirror.base_url, current_zim_path) | ||
assert requests.head(url, timeout=TIMEOUT, allow_redirects=False).headers.get( | ||
"content-type" | ||
) | ||
|
||
|
||
@pytest.mark.parametrize("mirror", ZIM_MIRRORS, ids=ZIM_MIRRORS_IDS) | ||
def test_mirror_zim_contenttype(mirror: Mirror, current_zim_path: str): | ||
url = urljoin(mirror.base_url, current_zim_path) | ||
print(url) | ||
ctype = requests.head(url, timeout=TIMEOUT, allow_redirects=False).headers.get( | ||
"content-type" | ||
) | ||
if ctype is None: | ||
pytest.xfail("no content-type") | ||
assert ctype == "application/octet-stream" | ||
|
||
|
||
def test_apk_exists(permanent_apk_url, current_apk_url): | ||
assert ( | ||
requests.head(permanent_apk_url, allow_redirects=True).status_code | ||
== HTTPStatus.OK | ||
) | ||
assert ( | ||
requests.head(current_apk_url, allow_redirects=True).status_code | ||
== HTTPStatus.OK | ||
) | ||
|
||
|
||
def test_apk_permalink(permanent_apk_url, current_apk_url): | ||
assert ( | ||
requests.head(permanent_apk_url, allow_redirects=True, timeout=TIMEOUT).url | ||
== requests.head(current_apk_url, allow_redirects=True, timeout=TIMEOUT).url | ||
) | ||
|
||
|
||
def test_apk_mirrors_list(current_apk_mirrors): | ||
# ATM this is no-op but prevents further issues | ||
assert len(current_apk_mirrors) >= len(EXPECTED_APK_MIRRORS) | ||
|
||
|
||
@pytest.mark.parametrize("mirror", APK_MIRRORS, ids=APK_MIRRORS_IDS) | ||
def test_mirror_has_apk_file(mirror: Mirror, current_apk_path: str): | ||
url = urljoin(mirror.base_url, current_apk_path) | ||
assert ( | ||
requests.head(url, timeout=TIMEOUT, allow_redirects=False).status_code | ||
== HTTPStatus.OK | ||
) | ||
|
||
|
||
@pytest.mark.parametrize("mirror", APK_MIRRORS, ids=APK_MIRRORS_IDS) | ||
def test_mirror_apk_has_contenttype(mirror: Mirror, current_apk_path: str): | ||
url = urljoin(mirror.base_url, current_apk_path) | ||
assert requests.head(url, timeout=TIMEOUT, allow_redirects=False).headers.get( | ||
"content-type" | ||
) | ||
|
||
|
||
@pytest.mark.parametrize("mirror", APK_MIRRORS, ids=APK_MIRRORS_IDS) | ||
def test_mirror_apk_contenttype(mirror: Mirror, current_apk_path: str): | ||
url = urljoin(mirror.base_url, current_apk_path) | ||
ctype = requests.head(url, timeout=TIMEOUT, allow_redirects=False).headers.get( | ||
"content-type" | ||
) | ||
if ctype is None: | ||
pytest.xfail("no content-type") | ||
assert ctype == "application/vnd.android.package-archive" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters