From 4a84b57a2cdd78a8c2675bd0a01e1cb4a38101d0 Mon Sep 17 00:00:00 2001 From: K mehant Date: Mon, 16 Dec 2019 05:51:12 +0530 Subject: [PATCH 1/5] Add regex to constants --- tests/constants.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/constants.py b/tests/constants.py index a3b9129c..7b786e15 100644 --- a/tests/constants.py +++ b/tests/constants.py @@ -34,3 +34,6 @@ CENTOS_POSTGRES_9_6_TAG = "9.6" DJANGO_POSTGRES_TEMPLATE = "django-psql-example" INTERNAL_REGISTRY_URL = "172.30.1.1:5000" + +FEDORA_MINIMAL_IMAGE_REGEX = "registry\.fedoraproject\.org\/fedora-minimal\:+([0-9])+" +FEDORA_MINIMAL_NAME_REGEX = "fedora-minimal:([0-9])+" \ No newline at end of file From df8187eadfa6a5837616205896833998c8316c7a Mon Sep 17 00:00:00 2001 From: K mehant Date: Mon, 16 Dec 2019 05:51:49 +0530 Subject: [PATCH 2/5] Update tests with regex assertions to avoid hardcoding --- tests/integration/test_buildah.py | 5 +++-- tests/integration/test_docker.py | 7 ++++--- tests/integration/test_podman.py | 7 ++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/integration/test_buildah.py b/tests/integration/test_buildah.py index acb96c06..e0ba6b8e 100644 --- a/tests/integration/test_buildah.py +++ b/tests/integration/test_buildah.py @@ -11,7 +11,8 @@ from conu.backend.buildah.image import BuildahImage, BuildahImagePullPolicy from conu.utils import check_buildah_command_works from tests.constants import FEDORA_MINIMAL_IMAGE -from ..constants import FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG +from ..constants import FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG, \ + FEDORA_MINIMAL_IMAGE_REGEX def test_buildah_command(): @@ -28,7 +29,7 @@ def test_buildah_image(buildah_backend): insp = image.inspect() assert "Config" in insp assert isinstance(insp["Config"], str) - assert "registry.fedoraproject.org/fedora-minimal:26" == str(image) + assert re.match(FEDORA_MINIMAL_IMAGE_REGEX, str(image)) assert "BuildahImage(repository=%s, tag=%s)" % (FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG) == repr(image) assert isinstance(image.get_id(), string_types) diff --git a/tests/integration/test_docker.py b/tests/integration/test_docker.py index 59e85c57..f7689e6f 100644 --- a/tests/integration/test_docker.py +++ b/tests/integration/test_docker.py @@ -27,7 +27,7 @@ from conu.utils import parse_reference from ..constants import FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG, \ - FEDORA_REPOSITORY + FEDORA_REPOSITORY, FEDORA_MINIMAL_IMAGE_REGEX, FEDORA_MINIMAL_NAME_REGEX from conu.apidefs.metadata import ContainerStatus from conu.backend.docker.client import get_client @@ -42,6 +42,7 @@ from conu.backend.docker.skopeo import SkopeoTransport from six import string_types +import re @pytest.mark.parametrize("reference,result", [ ("registry.fedoraproject.org/fedora:27", ("registry.fedoraproject.org/fedora", "27")), @@ -135,8 +136,8 @@ def test_image(): image = backend.ImageClass(FEDORA_MINIMAL_REPOSITORY, tag=FEDORA_MINIMAL_REPOSITORY_TAG) assert "Config" in image.inspect() assert "Config" in image.inspect() - assert "fedora-minimal:26" in image.get_full_name() - assert "registry.fedoraproject.org/fedora-minimal:26" == str(image) + assert re.match(FEDORA_MINIMAL_NAME_REGEX, image.get_full_name()) + assert re.match(FEDORA_MINIMAL_IMAGE_REGEX, str(image)) assert "DockerImage(repository=%s, tag=%s)" % (FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG) == repr(image) assert isinstance(image.get_id(), string_types) diff --git a/tests/integration/test_podman.py b/tests/integration/test_podman.py index d6d50015..ab1b8f15 100644 --- a/tests/integration/test_podman.py +++ b/tests/integration/test_podman.py @@ -1,7 +1,7 @@ from __future__ import print_function, unicode_literals from ..constants import FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG, \ - FEDORA_REPOSITORY + FEDORA_REPOSITORY, FEDORA_MINIMAL_IMAGE_REGEX, FEDORA_MINIMAL_NAME_REGEX import subprocess import time @@ -18,6 +18,7 @@ from six import string_types import pytest +import re @pytest.fixture() @@ -51,8 +52,8 @@ def test_podman_image(podman_backend): assert "%s:%s" % (FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG) == image.get_full_name() assert "%s:%s" % (FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG) in image.inspect()['RepoTags'] assert "Config" in image.inspect() - assert "fedora-minimal:26" in image.get_full_name() - assert "registry.fedoraproject.org/fedora-minimal:26" == str(image) + assert re.match(FEDORA_MINIMAL_NAME_REGEX, image.get_full_name()) + assert re.match(FEDORA_MINIMAL_IMAGE_REGEX, str(image)) assert "PodmanImage(repository=%s, tag=%s)" % (FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG) == repr(image) assert isinstance(image.get_id(), string_types) From 55003816d8fd9d171011bfb2f3ed0972be7e06e8 Mon Sep 17 00:00:00 2001 From: K mehant Date: Tue, 7 Jan 2020 19:14:08 +0530 Subject: [PATCH 3/5] Update to version 31 --- tests/constants.py | 2 +- tests/integration/test_buildah.py | 10 +++++----- tests/integration/test_docker.py | 2 +- tests/integration/test_filesystem.py | 12 ++++++------ tests/integration/test_podman.py | 2 +- tests/release/test_release.py | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/constants.py b/tests/constants.py index 7b786e15..1b800a7d 100644 --- a/tests/constants.py +++ b/tests/constants.py @@ -17,7 +17,7 @@ FEDORA_REPOSITORY = "registry.fedoraproject.org/fedora" FEDORA_MINIMAL_REPOSITORY = "registry.fedoraproject.org/fedora-minimal" -FEDORA_MINIMAL_REPOSITORY_TAG = "26" +FEDORA_MINIMAL_REPOSITORY_TAG = "31" FEDORA_MINIMAL_REPOSITORY_DIGEST = "registry.fedoraproject.org/fedora-minimal@" \ "sha256:3b5147b65bf7d124b9ded3959b5e44bf392b405be219853dbcc346f8b9c06e88" FEDORA_MINIMAL_IMAGE = "{}:{}".format(FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG) diff --git a/tests/integration/test_buildah.py b/tests/integration/test_buildah.py index e0ba6b8e..2d258a91 100644 --- a/tests/integration/test_buildah.py +++ b/tests/integration/test_buildah.py @@ -138,7 +138,7 @@ def test_list_containers(buildah_backend): def test_list_images(buildah_backend): image_list = buildah_backend.list_images() assert len(image_list) > 0 - # id of registry.fedoraproject.org/fedora-minimal:26 + # id of registry.fedoraproject.org/fedora-minimal:31 assert isinstance(image_list[0], BuildahImage) assert image_list[0].get_id() assert image_list[0].get_full_name() @@ -151,8 +151,8 @@ def test_image_metadata(buildah_backend): assert im_metadata.command == ["/bin/bash"] assert im_metadata.name == FEDORA_MINIMAL_IMAGE - assert im_metadata.env_variables["FGC"] == "f26" - assert im_metadata.env_variables["DISTTAG"] == "f26container" + assert im_metadata.env_variables["FGC"] == "f31" + assert im_metadata.env_variables["DISTTAG"] == "f31container" assert im_metadata.labels == {} @@ -170,8 +170,8 @@ def test_container_metadata(buildah_backend): assert container_metadata.command == ["/bin/bash"] assert container_metadata.name == "mycontainer" - assert container_metadata.env_variables["FGC"] == "f26" - assert container_metadata.env_variables["DISTTAG"] == "f26container" + assert container_metadata.env_variables["FGC"] == "f31" + assert container_metadata.env_variables["DISTTAG"] == "f31container" assert container_metadata.labels == {} finally: c.delete(force=True) diff --git a/tests/integration/test_docker.py b/tests/integration/test_docker.py index f7689e6f..9fda2481 100644 --- a/tests/integration/test_docker.py +++ b/tests/integration/test_docker.py @@ -197,7 +197,7 @@ def test_copy_from(tmpdir): try: c.copy_from("/etc/fedora-release", str(tmpdir)) with open(os.path.join(str(tmpdir), "fedora-release")) as fd: - assert fd.read() == "Fedora release 26 (Twenty Six)\n" + assert fd.read() == "Fedora release 31 (Thirty One)\n" c.copy_from("/etc", str(tmpdir)) os.path.exists(os.path.join(str(tmpdir), "passwd")) diff --git a/tests/integration/test_filesystem.py b/tests/integration/test_filesystem.py index 49b1e2fb..90372288 100644 --- a/tests/integration/test_filesystem.py +++ b/tests/integration/test_filesystem.py @@ -53,14 +53,14 @@ def test_container_read_file(docker_container): with pytest.raises(ConuException): fs.read_file("/i/lost/my/banana") content = fs.read_file("/etc/system-release") - assert content == "Fedora release 26 (Twenty Six)\n" + assert content == "Fedora release 31 (Thirty One)\n" def test_container_copy_from(docker_container, tmpdir): with docker_container.mount() as fs: fs.copy_from("/etc/system-release", str(tmpdir)) with open(os.path.join(str(tmpdir), "system-release")) as fd: - assert fd.read() == "Fedora release 26 (Twenty Six)\n" + assert fd.read() == "Fedora release 31 (Thirty One)\n" tmpdir.mkdir("etc") if six.PY2: @@ -76,7 +76,7 @@ def test_container_get_file(docker_container): f = fs.get_file("/etc/system-release") assert f.fileno() assert "/etc/system-release" in f.name - assert f.read() == "Fedora release 26 (Twenty Six)\n" + assert f.read() == "Fedora release 31 (Thirty One)\n" f.close() @@ -119,14 +119,14 @@ def test_image_read_file(docker_image): with pytest.raises(ConuException): fs.read_file("/i/lost/my/banana") content = fs.read_file("/etc/system-release") - assert content == "Fedora release 26 (Twenty Six)\n" + assert content == "Fedora release 31 (Thirty One)\n" def test_image_copy_from(docker_image, tmpdir): with docker_image.mount() as fs: fs.copy_from("/etc/system-release", str(tmpdir)) with open(os.path.join(str(tmpdir), "system-release")) as fd: - assert fd.read() == "Fedora release 26 (Twenty Six)\n" + assert fd.read() == "Fedora release 31 (Thirty One)\n" tmpdir.mkdir("etc") if six.PY2: @@ -142,7 +142,7 @@ def test_image_get_file(docker_image): f = fs.get_file("/etc/system-release") assert f.fileno() assert "/etc/system-release" in f.name - assert f.read() == "Fedora release 26 (Twenty Six)\n" + assert f.read() == "Fedora release 31 (Thirty One)\n" f.close() diff --git a/tests/integration/test_podman.py b/tests/integration/test_podman.py index ab1b8f15..0a0b9a0e 100644 --- a/tests/integration/test_podman.py +++ b/tests/integration/test_podman.py @@ -322,7 +322,7 @@ def test_list_containers(podman_backend): def test_list_images(podman_backend): image_list = podman_backend.list_images() assert len(image_list) > 0 - # id of registry.fedoraproject.org/fedora-minimal:26 + # id of registry.fedoraproject.org/fedora-minimal:31 the_id = subprocess.check_output(["podman", "inspect", "-f", "{{.Id}}", FEDORA_MINIMAL_REPOSITORY + ":" + FEDORA_MINIMAL_REPOSITORY_TAG]).decode("utf-8").strip() diff --git a/tests/release/test_release.py b/tests/release/test_release.py index 9d866e8a..f2b617cd 100644 --- a/tests/release/test_release.py +++ b/tests/release/test_release.py @@ -109,7 +109,7 @@ def test_pypi(c): }, { "container_image": "registry.fedoraproject.org/fedora", - "container_image_tag": "26", + "container_image_tag": "31", "script": [ ["dnf", "install", "-y", "dnf-plugins-core"], ["dnf", "copr", "enable", "-y", "ttomecek/conu"], From f3c9d81510faa7ec4c109118a0aa27d0e3d96106 Mon Sep 17 00:00:00 2001 From: kmehant <411843@student.nitandhra.ac.in> Date: Wed, 8 Jan 2020 18:14:39 +0530 Subject: [PATCH 4/5] Update tests/constants.py Co-Authored-By: Tomas Tomecek --- tests/constants.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/constants.py b/tests/constants.py index 1b800a7d..0b173fb4 100644 --- a/tests/constants.py +++ b/tests/constants.py @@ -35,5 +35,5 @@ DJANGO_POSTGRES_TEMPLATE = "django-psql-example" INTERNAL_REGISTRY_URL = "172.30.1.1:5000" -FEDORA_MINIMAL_IMAGE_REGEX = "registry\.fedoraproject\.org\/fedora-minimal\:+([0-9])+" -FEDORA_MINIMAL_NAME_REGEX = "fedora-minimal:([0-9])+" \ No newline at end of file +FEDORA_MINIMAL_IMAGE_REGEX = r"registry\.fedoraproject\.org\/fedora-minimal\:+([0-9])+" +FEDORA_MINIMAL_NAME_REGEX = "fedora-minimal:([0-9])+" From 84ead44edc58bf216bbc41690907a63c629f4a8a Mon Sep 17 00:00:00 2001 From: K mehant Date: Tue, 14 Jan 2020 10:47:40 +0530 Subject: [PATCH 5/5] Fix conu tests --- conu/utils/__init__.py | 4 ++-- tests/integration/test_buildah.py | 1 + tests/integration/test_docker.py | 4 ++-- tests/integration/test_podman.py | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/conu/utils/__init__.py b/conu/utils/__init__.py index ccd9c0b1..e48428d6 100644 --- a/conu/utils/__init__.py +++ b/conu/utils/__init__.py @@ -451,8 +451,8 @@ def parse_reference(reference): """ parse provided image reference into : - :param reference: str, e.g. (registry.fedoraproject.org/fedora:27) - :return: collection (tuple or list), ("registry.fedoraproject.org/fedora", "27") + :param reference: str, e.g. (registry.fedoraproject.org/fedora:31) + :return: collection (tuple or list), ("registry.fedoraproject.org/fedora", "31") """ if ":" in reference: im, tag = reference.rsplit(":", 1) diff --git a/tests/integration/test_buildah.py b/tests/integration/test_buildah.py index 2d258a91..3ab6e403 100644 --- a/tests/integration/test_buildah.py +++ b/tests/integration/test_buildah.py @@ -14,6 +14,7 @@ from ..constants import FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG, \ FEDORA_MINIMAL_IMAGE_REGEX +import re def test_buildah_command(): assert check_buildah_command_works() diff --git a/tests/integration/test_docker.py b/tests/integration/test_docker.py index 9fda2481..815f6843 100644 --- a/tests/integration/test_docker.py +++ b/tests/integration/test_docker.py @@ -45,7 +45,7 @@ import re @pytest.mark.parametrize("reference,result", [ - ("registry.fedoraproject.org/fedora:27", ("registry.fedoraproject.org/fedora", "27")), + ("registry.fedoraproject.org/fedora:31", ("registry.fedoraproject.org/fedora", "31")), ("registry.fedoraproject.org/fedora", ("registry.fedoraproject.org/fedora", "latest")), ("registry.fedoraproject.org:7890/fedora", ("registry.fedoraproject.org:7890/fedora", "latest")), @@ -136,7 +136,7 @@ def test_image(): image = backend.ImageClass(FEDORA_MINIMAL_REPOSITORY, tag=FEDORA_MINIMAL_REPOSITORY_TAG) assert "Config" in image.inspect() assert "Config" in image.inspect() - assert re.match(FEDORA_MINIMAL_NAME_REGEX, image.get_full_name()) + assert re.match(FEDORA_MINIMAL_IMAGE_REGEX, image.get_full_name()) assert re.match(FEDORA_MINIMAL_IMAGE_REGEX, str(image)) assert "DockerImage(repository=%s, tag=%s)" % (FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG) == repr(image) diff --git a/tests/integration/test_podman.py b/tests/integration/test_podman.py index 0a0b9a0e..fb71e423 100644 --- a/tests/integration/test_podman.py +++ b/tests/integration/test_podman.py @@ -52,7 +52,7 @@ def test_podman_image(podman_backend): assert "%s:%s" % (FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG) == image.get_full_name() assert "%s:%s" % (FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG) in image.inspect()['RepoTags'] assert "Config" in image.inspect() - assert re.match(FEDORA_MINIMAL_NAME_REGEX, image.get_full_name()) + assert re.match(FEDORA_MINIMAL_IMAGE_REGEX, image.get_full_name()) assert re.match(FEDORA_MINIMAL_IMAGE_REGEX, str(image)) assert "PodmanImage(repository=%s, tag=%s)" % (FEDORA_MINIMAL_REPOSITORY, FEDORA_MINIMAL_REPOSITORY_TAG) == repr(image)