From 41ee1f170804dcce39db80aeb57f44bf37b1021c Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Wed, 16 Sep 2020 15:24:50 +0200 Subject: [PATCH] test/integration: build image for current distro Add a separate unit test to do a compose for a RHEL based image, but then restrict the execution of test_compose_{disto} to the distribution the test is running on, since currently cross- distribution builds can be problematic. --- test/integration/test_koji.py | 52 +++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/test/integration/test_koji.py b/test/integration/test_koji.py index fc2c071..4a798a2 100644 --- a/test/integration/test_koji.py +++ b/test/integration/test_koji.py @@ -10,6 +10,10 @@ import subprocess F32_REPO = "http://download.fedoraproject.org/pub/fedora/linux/releases/32/Everything/$arch/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()] @@ -23,6 +27,30 @@ def koji_command(*args, _input=None, _globals=None, **kwargs): check=False) +def parse_os_release(): + info = {} + with open("/etc/os-release") as f: + for line in f: + line = line.strip() + if not line: + continue + if line[0] == "#": + continue + k, v = line.split("=", 1) + info[k] = v.strip('"') + 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): @@ -49,10 +77,12 @@ class TestIntegration(unittest.TestCase): "\n error: " + res.stdout) self.fail(msg) - def test_compose(self): - """Successful compose""" + @unittest.skipUnless(is_fedora(), "no cross builds") + def test_compose_fedora(self): + """Successful Fedora compose""" # Simple test of a successful compose of F32 # Needs the f32-candidate tag be setup properly + res = self.koji("Fedora-Cloud", "32", "fedora-32", @@ -62,6 +92,24 @@ class TestIntegration(unittest.TestCase): repo=F32_REPO) self.check_res(res) + @unittest.skipUnless(is_rhel(), "no cross builds") + def test_compose_rhel(self): + """Successful RHEL compose""" + # Simple test of a successful compose of RHEL + + repos = [] + for repo in RHEL_REPOS: + repos += ["--repo", repo] + + res = self.koji("RHEL-Cloud", + "8", + "rhel-8", + "f32-candidate", + "x86_64", + "--wait", + *repos) + self.check_res(res) + def test_unknown_tag_check(self): """Unknown Tag check""" # Check building an unknown tag fails