Last active
March 1, 2022 14:37
-
-
Save flavianmissi/616ce803d69c9cf0dacbd0f51886f799 to your computer and use it in GitHub Desktop.
WIP: Quay podman/docker integration tests
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
""" | |
dependencies: | |
* docker | |
* podman | |
* Quay up and running | |
* no tls verify | |
""" | |
import subprocess | |
import os | |
import pytest | |
from app import app | |
from data.database import configure, Repository | |
from data.model.organization import create_organization | |
from data.model.proxy_cache import create_proxy_cache_config | |
from data.model.user import create_user | |
QUAY_API_ROOT = os.environ.get("QUAY_API_ROOT", "localhost:8080") | |
REPOSITORY = "library/hello-world:latest" | |
@pytest.fixture | |
def setup(): | |
username = "test-user-661" | |
password = "very-secret" | |
orgname = "teste-cache-661" | |
user = create_user(username, password, f"{username}@localhost.local", auto_verify=True) | |
org = create_organization(orgname, f"{orgname}@example.com", user) | |
cache_config = create_proxy_cache_config(org.username, "docker.io") | |
yield (username, password, cache_config, orgname) | |
def test_pull_thru_whole_registry(setup): | |
configure(app.config) | |
username = setup[0] | |
password = setup[1] | |
cache_config = setup[2] | |
orgname = setup[3] | |
cmd = ["docker", "login", "-u", username, "-p", password, QUAY_API_ROOT] | |
subprocess.run(cmd, check=True) | |
cmd = ["docker", "pull", f"{QUAY_API_ROOT}/{orgname}/{REPOSITORY}"] | |
subprocess.run(cmd, check=True) | |
cmd = ["docker", "run", "--rm", f"{QUAY_API_ROOT}/{orgname}/{REPOSITORY}"] | |
subprocess.run(cmd, check=True) | |
# disable proxy cache for org and pull image again, to assert that the image is | |
# saved locally in quay | |
cache_config.delete().execute() | |
cmd = ["docker", "rmi", f"{QUAY_API_ROOT}/{orgname}/{REPOSITORY}"] | |
subprocess.run(cmd, check=True) | |
cmd = ["docker", "run", "--rm", f"{QUAY_API_ROOT}/{orgname}/{REPOSITORY}"] | |
subprocess.run(cmd, check=True) |
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
# NOTE: the below has not been tested | |
integration-test: | |
@docker run -d --name integration_test -v "${PWD}:/quay-registry" -w "/quay-registry" docker:20.10.12-dind-alpine3.15 | |
@docker exec integration_test apk add curl | |
@docker exec integration_test curl -L "https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
@docker exec integration_test chmod +x /usr/local/bin/docker-compose | |
@docker exec -d integration_test docker-compose up | |
@docker stop integration_test | |
@docker rm integration_test | |
# TODO: | |
# 1. start a docker in docker container (docker.io/library/docker) | |
# 2. start Quay inside that container | |
# 3. run the integration tests | |
# 4. do the same for podman (quay.io/podman/stable) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment