diff --git a/test/integration/test_koji.py b/test/integration/test_koji.py index 2dba022..df548cb 100644 --- a/test/integration/test_koji.py +++ b/test/integration/test_koji.py @@ -4,22 +4,30 @@ import functools +import platform import unittest +import string import subprocess -F33_REPO = "http://download.fedoraproject.org/pub/fedora/linux/releases/33/Everything/$arch/os" +REPOS = { + "fedora": [ + "http://download.fedoraproject.org/pub/fedora/linux/releases/$release/Everything/$arch/os" + ], + "rhel": [ + "http://download.devel.redhat.com/released/RHEL-8/$release/BaseOS/x86_64/os/", + "http://download.devel.redhat.com/released/RHEL-8/$release/AppStream/x86_64/os/", + ] +} -RHEL_REPOS = [ - "http://download.devel.redhat.com/released/RHEL-8/8.2.0/BaseOS/x86_64/os/", - "http://download.devel.redhat.com/released/RHEL-8/8.2.0/AppStream/x86_64/os/", -] def koji_command(*args, _input=None, _globals=None, **kwargs): args = list(args) + [f'--{k}={v}' for k, v in kwargs.items()] if _globals: args = [f'--{k}={v}' for k, v in _globals.items()] + args - return subprocess.run(["koji"] + args, + cmd = ["koji"] + args + print(cmd) + return subprocess.run(cmd, encoding="utf-8", stdout=subprocess.PIPE, stderr=subprocess.STDOUT, @@ -41,16 +49,6 @@ def parse_os_release(): return info -def is_fedora(): - info = parse_os_release() - return info["ID"].lower() == "fedora" - - -def is_rhel(): - info = parse_os_release() - return info["ID"].lower() == "rhel" - - class TestIntegration(unittest.TestCase): def setUp(self): @@ -77,35 +75,37 @@ class TestIntegration(unittest.TestCase): "\n error: " + res.stdout) self.fail(msg) - @unittest.skipUnless(is_fedora(), "no cross builds") - def test_compose_fedora(self): - """Successful Fedora compose""" - # Simple test of a successful compose of F33 - # Needs the f33-candidate tag be setup properly - - res = self.koji("Fedora-Cloud", - "33", - "fedora-33", - "f33-candidate", - "x86_64", - "--wait", - repo=F33_REPO) - self.check_res(res) - - @unittest.skipUnless(is_rhel(), "no cross builds") - def test_compose_rhel(self): - """Successful RHEL compose""" + def test_compose(self): + """Successful compose""" # Simple test of a successful compose of RHEL - repos = [] - for repo in RHEL_REPOS: - repos += ["--repo", repo] + info = parse_os_release() - res = self.koji("RHEL-Cloud", - "8", - "rhel-8", - "f33-candidate", - "x86_64", + name = info["ID"] # 'fedora' or 'rhel' + version = info["VERSION_ID"] # or . + major = version.split(".")[0] + + distro = f"{name}-{major}" + tag = f"{name}{major}-candidate" # fedora or rhel + arch = platform.machine() + + release = version + if name.lower() == "rhel": + release += ".0" + + repos = [] + for repo in REPOS[name]: + tpl = string.Template(repo) + url = tpl.safe_substitute({"release": release}) + repos += ["--repo", url] + + package = f"{name.lower()}-guest" + + res = self.koji(package, + major, + distro, + tag, + arch, "--wait", *repos) self.check_res(res) @@ -113,9 +113,17 @@ class TestIntegration(unittest.TestCase): def test_unknown_tag_check(self): """Unknown Tag check""" # Check building an unknown tag fails - res = self.koji("Fedora-Cloud", - "33", - "fedora-33", + + info = parse_os_release() + + name = info["ID"] # 'fedora' or 'rhel' + version = info["VERSION_ID"] # or . + major = version.split(".")[0] + distro = f"{name}-{major}" + + res = self.koji("fedora-guest", + major, + distro, "UNKNOWNTAG", - "x86_64") + platform.machine()) self.check_fail(res) diff --git a/test/make-tags.sh b/test/make-tags.sh index 4c2e37e..2f6cc9b 100755 --- a/test/make-tags.sh +++ b/test/make-tags.sh @@ -1,18 +1,29 @@ #!/usr/bin/sh set -ux +. /etc/os-release + KOJI_SERVER=${KOJI_SERVER:-http://localhost:8080/kojihub} KOJI="koji --server=${KOJI_SERVER} --user=kojiadmin --password=kojipass --authtype=password" -$KOJI add-tag f33 -$KOJI add-tag --parent f33 f33-candidate -$KOJI add-tag --parent f33 --arches=x86_64 f33-build -$KOJI add-target f33-candidate f33-build f33-candidate +ARCHES=$(uname -m) +VERSION_MAJOR="${VERSION_ID%.*}" -$KOJI add-pkg --owner kojiadmin f33-candidate Fedora-Cloud -$KOJI add-pkg --owner kojiadmin f33-candidate RHEL-Cloud +TAG_NAME="${ID}${VERSION_MAJOR}" # fedora35 or rhel8 +TAG_BUILD="${TAG_NAME}-build" +TAG_CANDIDATE="${TAG_NAME}-candidate" -$KOJI add-pkg --owner kojiadmin f33-candidate Fedora-IoT +echo "Tag configuration: ${TAG_NAME}, ${TAG_BUILD}, ${TAG_CANDIDATE}, ${ARCHES}" -$KOJI regen-repo f33-build +$KOJI add-tag "${TAG_NAME}" +$KOJI add-tag --parent "${TAG_NAME}" "${TAG_CANDIDATE}" +$KOJI add-tag --parent "${TAG_NAME}" --arches="${ARCHES}" "${TAG_BUILD}" +$KOJI add-target "${TAG_CANDIDATE}" "${TAG_BUILD}" "${TAG_CANDIDATE}" + +$KOJI add-pkg --owner kojiadmin "${TAG_CANDIDATE}" fedora-guest +$KOJI add-pkg --owner kojiadmin "${TAG_CANDIDATE}" rhel-guest + +$KOJI add-pkg --owner kojiadmin "${TAG_CANDIDATE}" fedora-iot + +$KOJI regen-repo "${TAG_BUILD}"