Merge branch 'fix-tests-for-replacing-s3cmd-and-libcloud' into 'master'

Fix tests for replacing s3cmd and libcloud

See merge request fdroid/fdroidserver!1703
This commit is contained in:
Hans-Christoph Steiner 2025-09-25 14:21:02 +00:00
commit 7c2a0aa6c2
2 changed files with 26 additions and 8 deletions

View file

@ -190,6 +190,8 @@ ubuntu_lts_ppa:
test_deploy_to_s3_with_rclone: test_deploy_to_s3_with_rclone:
image: debian:bookworm-slim image: debian:bookworm-slim
<<: *apt-template <<: *apt-template
tags:
- saas-linux-small-amd64 # the shared runners are known to support Docker.
services: services:
- name: docker:dind - name: docker:dind
command: ["--tls=false"] command: ["--tls=false"]
@ -208,6 +210,8 @@ test_deploy_to_s3_with_rclone:
git git
python3-venv python3-venv
rclone rclone
# This job requires working docker but will silently fail if docker is not available
- docker info
- python3 -m venv --system-site-packages test-venv - python3 -m venv --system-site-packages test-venv
- . test-venv/bin/activate - . test-venv/bin/activate
- pip install testcontainers[minio] - pip install testcontainers[minio]

View file

@ -5,7 +5,6 @@ import platform
import re import re
import shlex import shlex
import shutil import shutil
import stat
import subprocess import subprocess
import sys import sys
import threading import threading
@ -43,8 +42,13 @@ common.find_apksigner(conf)
USE_APKSIGNER = "apksigner" in conf USE_APKSIGNER = "apksigner" in conf
def docker_socket_exists(path="/var/run/docker.sock"): def docker_exists():
return os.path.exists(path) and stat.S_ISSOCK(os.stat(path).st_mode) try:
subprocess.check_output(["docker", "info"])
except Exception:
return False
else:
return True
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian') @unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
@ -1565,8 +1569,11 @@ class IntegrationTest(unittest.TestCase):
) )
self.assertIn("CurrentVersionCode: 1", Path("metadata/fake.yml").read_text()) self.assertIn("CurrentVersionCode: 1", Path("metadata/fake.yml").read_text())
@unittest.skipUnless(docker_socket_exists(), "Docker is not available") @unittest.skipUnless(docker_exists(), "Docker is not available")
def test_update_remote_storage_with_rclone_and_minio(self): def test_update_remote_storage_with_rclone_and_minio(self):
# This test shows how an entire repo can be deployed using rclone.
# To avoid multiple files being copied in the repo since the repo
# directory can change, only two files are used.
try: try:
from testcontainers.minio import MinioContainer from testcontainers.minio import MinioContainer
except ImportError: except ImportError:
@ -1621,7 +1628,7 @@ class IntegrationTest(unittest.TestCase):
{'fdroid/repo/SpeedoMeterApp.main_1.apk', 'fdroid/repo/index-v2.json'}, {'fdroid/repo/SpeedoMeterApp.main_1.apk', 'fdroid/repo/index-v2.json'},
) )
@unittest.skipUnless(docker_socket_exists(), "Docker is not available") @unittest.skipUnless(docker_exists(), "Docker is not available")
def test_update_remote_storage_with_rclone_and_minio_in_index_only_mode(self): def test_update_remote_storage_with_rclone_and_minio_in_index_only_mode(self):
try: try:
from testcontainers.minio import MinioContainer from testcontainers.minio import MinioContainer
@ -1638,8 +1645,7 @@ class IntegrationTest(unittest.TestCase):
repo_section = 'repo' repo_section = 'repo'
repo = Path(repo_section) repo = Path(repo_section)
repo.mkdir(parents=True, exist_ok=True) repo.mkdir(parents=True, exist_ok=True)
shutil.copy(basedir / 'SpeedoMeterApp.main_1.apk', repo) shutil.copytree(basedir / repo, repo, dirs_exist_ok=True)
shutil.copy(basedir / 'repo/index-v2.json', repo)
# write out config for test use # write out config for test use
rclone_config = configparser.ConfigParser() rclone_config = configparser.ConfigParser()
@ -1674,4 +1680,12 @@ class IntegrationTest(unittest.TestCase):
# check if apk and index file are available # check if apk and index file are available
bucket_content = client.list_objects('test-bucket', recursive=True) bucket_content = client.list_objects('test-bucket', recursive=True)
files_in_bucket = {obj.object_name for obj in bucket_content} files_in_bucket = {obj.object_name for obj in bucket_content}
self.assertEqual(files_in_bucket, {'fdroid/repo/index-v2.json'}) self.assertEqual(
files_in_bucket,
{
'fdroid/repo/index-v2.json',
'fdroid/repo/index.xml',
'fdroid/repo/entry.json',
'fdroid/repo/index-v1.json',
},
)