From b6cf53eaee155c96a3a9637cd7135bf7d0533fb4 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Feb 20 2019 20:49:13 +0000 Subject: Rename updates-testing images on download to avoid name clash I noticed yesterday that the filenames of images in updates and updates-testing composes are identical. For instance, both the updates and updates-testing composes for Fedora 29 for 20190220 contain a 'Fedora-AtomicHost-ostree-x86_64-29-20190220.0.iso'. This is a problem, because openQA assets are all stored together in one directory, there's no subdirectory per BUILD or anything like that. So all the time we've been testing these composes, we've actually been inadvertently just testing the same images twice - each day we'll have only actually tested one of the composes and not tested the other one at all. To try and deal with this, we'll rename the image files for the updates-testing composes on download. The openQA asset download code has a mechanism for doing this: if you pass for e.g. both ISO_URL and ISO, the file found at the URL will be downloaded under the name give as 'ISO'. Then, when we report results to resultsdb, we'll reverse that munging, so the 'item' name we report is the *original* file name, not the altered one. Signed-off-by: Adam Williamson --- diff --git a/fedora_openqa/report.py b/fedora_openqa/report.py index f4a7562..fff4354 100644 --- a/fedora_openqa/report.py +++ b/fedora_openqa/report.py @@ -398,6 +398,10 @@ def resultsdb_report(resultsdb_url=None, jobs=None, build=None, do_report=True, # special case for images decompressed for testing if job['settings']['IMAGETYPE'] == 'raw-xz' and imagename.endswith('.raw'): imagename += '.xz' + # reverse the hack we use in schedule.py to stuff 'testing-' on + # the front of image names in updates-testing composes + if imagename.startswith('testing-'): + imagename = imagename[8:] rdbpartial = partial(FedoraImageResult, imagename, build, tc_name='compose.' + tc_name) elif ttarget == 'COMPOSE': diff --git a/fedora_openqa/schedule.py b/fedora_openqa/schedule.py index cdaaf8a..34b6302 100644 --- a/fedora_openqa/schedule.py +++ b/fedora_openqa/schedule.py @@ -94,6 +94,13 @@ def _get_images(rel, wanted=None): param_urls = { FORMAT_TO_PARAM[foundimg['format']]: url } + if 'updates-testing' in rel.cid: + # image names in 'updates-testing' and 'updates' composes + # are the same. we need to set a custom filename for the + # image for updates-testing composes to avoid a clash + fileparam = FORMAT_TO_PARAM[foundimg['format']].split('_URL')[0] + filename = os.path.basename(foundimg['path']) + param_urls[fileparam] = 'testing-' + filename # if direct kernel boot is specified, we need to download kernel and initrd if wantimg.get('dkboot', False): (kernel_url, initrd_url) = _get_dkboot_urls(rel.https_url_generic, arch) diff --git a/tests/test_report.py b/tests/test_report.py index f5fbafb..898f70c 100644 --- a/tests/test_report.py +++ b/tests/test_report.py @@ -488,6 +488,14 @@ class TestResultsDBReport: fosreport.resultsdb_report(jobs=[1]) assert fakeres.call_count == 0 + def test_updates_testing(self, fakeres, oqaclientmock): + """Check we strip the 'testing-' that we add to the asset file + name for updates-testing images before reporting results. + """ + jobdict = oqaclientmock[2] + with mock.patch.dict(jobdict['settings'], {'ISO': 'testing-Fedora-Server-dvd-x86_64-Rawhide-20170207.n.0.iso'}): + fosreport.resultsdb_report(jobs=[1]) + assert fakeres.call_args[1]['item'] == 'Fedora-Server-dvd-x86_64-Rawhide-20170207.n.0.iso' def test_note(self, fakeres, oqaclientmock): """Check resultsdb_report adds a note for failed modules.""" diff --git a/tests/test_schedule.py b/tests/test_schedule.py index cb1c7da..0b9248b 100644 --- a/tests/test_schedule.py +++ b/tests/test_schedule.py @@ -215,6 +215,28 @@ class TestGetImages: ), ] + @mock.patch.object(fedfind.release.BranchedNightly, 'cid', 'Fedora-25-updates-testing-20161115.n.0') + def test_update_testing(self): + """Test that the image file name munging for updates-testing + composes works. Image file names for updates-testing and + updates composes with the same date, version and respin are + identical; we need to rename the images from one of the + composes so they don't overwrite each other in the openQA + asset directories. + """ + # we don't use cid here to avoid the sanity check failing + rel = fedfind.release.get_release(25, 'Branched', '20161115.n.0') + # let's just check the mocking is working as expected... + assert rel.cid == 'Fedora-25-updates-testing-20161115.n.0' + # this is to ensure we actually check *something* + count = 0 + ret = schedule._get_images(rel) + for (_, _, _, param_urls, _, _) in ret: + if 'ISO_URL' in param_urls: + assert param_urls.get('ISO', '').startswith('testing-') + count += 1 + assert count > 0 + def test_find_duplicate_jobs(): """Tests for _find_duplicate_jobs."""