tests: test_urls: Make fedora distro checking a bit smarter

Rather than constantly require updating distro values for latest
Fedora when osinfo-db catches up, build some smarts into the
test suite
This commit is contained in:
Cole Robinson 2018-03-28 14:56:52 -04:00
parent 74f2fb73fd
commit 35df66c1ed
2 changed files with 35 additions and 7 deletions

View File

@ -19,7 +19,7 @@ distro = fedora14
# Latest GA release # Latest GA release
[fedora27] [fedora27]
url = http://dl.fedoraproject.org/pub/fedora/linux/releases/27/Server/x86_64/os/ url = http://dl.fedoraproject.org/pub/fedora/linux/releases/27/Server/x86_64/os/
distro = fedora26 distro = fedora27
# Fedora dev release can be enabled during alpha/beta cycle # Fedora dev release can be enabled during alpha/beta cycle
#[fedora-dev] #[fedora-dev]
@ -30,7 +30,7 @@ distro = fedora26
# Test for xen and boot iso for full fedora coverage # Test for xen and boot iso for full fedora coverage
[fedora-rawhide] [fedora-rawhide]
url = http://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Server/x86_64/os/ url = http://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Server/x86_64/os/
distro = fedora26 distro = testsuite-fedora-rawhide
testxen = 1 testxen = 1
testbootiso = 1 testbootiso = 1

View File

@ -5,6 +5,7 @@
import logging import logging
import os import os
import re
import sys import sys
import time import time
import traceback import traceback
@ -13,6 +14,7 @@ import unittest
from tests import utils from tests import utils
from virtinst import Guest from virtinst import Guest
from virtinst import OSDB
from virtinst import urlfetcher from virtinst import urlfetcher
from virtinst import util from virtinst import util
from virtinst.urlfetcher import ALTLinuxDistro from virtinst.urlfetcher import ALTLinuxDistro
@ -118,6 +120,30 @@ def _storeForDistro(fetcher, guest):
raise # pylint: disable=misplaced-bare-raise raise # pylint: disable=misplaced-bare-raise
def _sanitize_osdict_name(detectdistro):
"""
Try to handle working with out of date osinfo-db data. Like if
checking distro FedoraXX but osinfo-db latest Fedora is
FedoraXX-1, convert to use that
"""
if not detectdistro:
return detectdistro
if detectdistro == "testsuite-fedora-rawhide":
# Special value we use in the test suite to always return the latest
# fedora when checking rawhide URL
return OSDB.latest_fedora_version()
if re.match("fedora[0-9]+", detectdistro):
if not OSDB.lookup_os(detectdistro):
ret = OSDB.latest_fedora_version()
print("\nConverting detectdistro=%s to latest value=%s" %
(detectdistro, ret))
return ret
return detectdistro
def _testURL(fetcher, testdata): def _testURL(fetcher, testdata):
""" """
Test that our URL detection logic works for grabbing kernel, xen Test that our URL detection logic works for grabbing kernel, xen
@ -125,11 +151,13 @@ def _testURL(fetcher, testdata):
""" """
distname = testdata.name distname = testdata.name
arch = testdata.arch arch = testdata.arch
detectdistro = _sanitize_osdict_name(testdata.detectdistro)
hvmguest.os.arch = arch hvmguest.os.arch = arch
xenguest.os.arch = arch xenguest.os.arch = arch
if testdata.testshortcircuit: if testdata.testshortcircuit:
hvmguest.os_variant = testdata.detectdistro hvmguest.os_variant = detectdistro
xenguest.os_variant = testdata.detectdistro xenguest.os_variant = detectdistro
else: else:
hvmguest.os_variant = None hvmguest.os_variant = None
xenguest.os_variant = None xenguest.os_variant = None
@ -157,8 +185,8 @@ def _testURL(fetcher, testdata):
fetcher.location)) fetcher.location))
# Make sure the stores are reporting correct distro name/variant # Make sure the stores are reporting correct distro name/variant
if (s and testdata.detectdistro and if (s and detectdistro and
testdata.detectdistro != s.get_osdict_info()): detectdistro != s.get_osdict_info()):
raise AssertionError( raise AssertionError(
"Detected OS did not match expected values:\n" "Detected OS did not match expected values:\n"
"found = %s\n" "found = %s\n"
@ -166,7 +194,7 @@ def _testURL(fetcher, testdata):
"name = %s\n" "name = %s\n"
"url = %s\n" "url = %s\n"
"store = %s" % "store = %s" %
(s.os_variant, testdata.detectdistro, (s.os_variant, detectdistro,
distname, fetcher.location, testdata.distroclass)) distname, fetcher.location, testdata.distroclass))
# Do this only after the distro detection, since we actually need # Do this only after the distro detection, since we actually need