From b48982c0f92cb0854cd81b9c5f0a778d666aff48 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Jul 23 2018 14:51:07 +0000 Subject: Fix duplicate detection for composes with identical ISO names The scheduling duplicate detection assumes that ISO names will always be unique. This is no longer the case, however, as now we have identical filenames in two-week Atomic nightly, updates and updates-testing composes: for these we wind up only running tests on whichever compose happens first, and the jobs for the others are incorrectly skipped by the duplicate detection. So, add a BUILD check to the duplicate detection to avoid this. Signed-off-by: Adam Williamson --- diff --git a/fedora_openqa/schedule.py b/fedora_openqa/schedule.py index dafd67b..db2432b 100644 --- a/fedora_openqa/schedule.py +++ b/fedora_openqa/schedule.py @@ -106,24 +106,24 @@ def _get_images(rel, wanted=None): return images -def _find_duplicate_jobs(client, param_urls, flavor): +def _find_duplicate_jobs(client, build, param_urls, flavor): """Check if we have any existing non-cancelled jobs for this - ISO/HDD and flavor (checking flavor is important otherwise we'd - bail on doing the per-ISO jobs for the ISO we use for the + build, ISO/HDD and flavor (checking flavor is important otherwise + we'd bail on doing the per-ISO jobs for the ISO we use for the 'universal' tests). ISO/HDD are taken from param_urls dict. """ if any([param in param_urls for param in ('ISO_URL', 'HDD_1_DECOMPRESS_URL', 'HDD_1')]): if 'ISO_URL' in param_urls: assetname = param_urls['ISO_URL'].split('/')[-1] - jobs = client.openqa_request('GET', 'jobs', params={'iso': assetname})['jobs'] + jobs = client.openqa_request('GET', 'jobs', params={'iso': assetname, 'build': build})['jobs'] elif 'HDD_1_DECOMPRESS_URL' in param_urls: # HDDs hddname = param_urls['HDD_1_DECOMPRESS_URL'].split('/')[-1] assetname = os.path.splitext(hddname)[0] - jobs = client.openqa_request('GET', 'jobs', params={'hdd_1': assetname})['jobs'] + jobs = client.openqa_request('GET', 'jobs', params={'hdd_1': assetname, 'build': build})['jobs'] else: assetname = param_urls['HDD_1'].split('/')[-1] - jobs = client.openqa_request('GET', 'jobs', params={'hdd_1': assetname})['jobs'] + jobs = client.openqa_request('GET', 'jobs', params={'hdd_1': assetname, 'build': build})['jobs'] jobs = [job for job in jobs if job['settings']['FLAVOR'] == flavor] jobs = [job for job in jobs if @@ -206,7 +206,7 @@ def run_openqa_jobs(param_urls, flavor, arch, subvariant, imagetype, build, vers client = OpenQA_Client(openqa_hostname) if not force: - duplicates = _find_duplicate_jobs(client, param_urls, flavor) + duplicates = _find_duplicate_jobs(client, build, param_urls, flavor) if duplicates: logger.debug("Existing jobs found: %s", ' '.join(str(dupe['id']) for dupe in duplicates)) return [] diff --git a/tests/test_schedule.py b/tests/test_schedule.py index 04a457e..06e6501 100644 --- a/tests/test_schedule.py +++ b/tests/test_schedule.py @@ -224,31 +224,31 @@ def test_find_duplicate_jobs(): client.openqa_request.return_value = {'jobs': [{'settings': {'FLAVOR': 'someflavor'}, 'state': 'done'}]} # check ISO case - ret = schedule._find_duplicate_jobs(client, {'ISO_URL': 'https://some.url/some.iso'}, 'someflavor') + ret = schedule._find_duplicate_jobs(client, 'build', {'ISO_URL': 'https://some.url/some.iso'}, 'someflavor') assert len(ret) == 1 - assert client.openqa_request.call_args[1]['params'] == {'iso': 'some.iso'} + assert client.openqa_request.call_args[1]['params'] == {'iso': 'some.iso', 'build': 'build'} # HDD_1 case - ret = schedule._find_duplicate_jobs(client, {'HDD_1': 'somefile.img'}, 'someflavor') + ret = schedule._find_duplicate_jobs(client, 'build', {'HDD_1': 'somefile.img'}, 'someflavor') assert len(ret) == 1 - assert client.openqa_request.call_args[1]['params'] == {'hdd_1': 'somefile.img'} + assert client.openqa_request.call_args[1]['params'] == {'hdd_1': 'somefile.img', 'build': 'build'} client.openqa_request.reset_mock() # HDD_1_DECOMPRESS_URL case ret = schedule._find_duplicate_jobs( - client, {'HDD_1_DECOMPRESS_URL': 'https://some.url/somefile.img.gz'}, 'someflavor') + client, 'build', {'HDD_1_DECOMPRESS_URL': 'https://some.url/somefile.img.gz'}, 'someflavor') assert len(ret) == 1 # shouldn't find any dupes if flavor differs - ret = schedule._find_duplicate_jobs(client, {'ISO_URL': 'https://some.url/some.iso'}, 'otherflavor') + ret = schedule._find_duplicate_jobs(client, 'build', {'ISO_URL': 'https://some.url/some.iso'}, 'otherflavor') assert len(ret) == 0 # job in 'cancelled' state isn't a dupe client.openqa_request.return_value = {'jobs': [{'settings': {'FLAVOR': 'someflavor'}, 'state': 'cancelled'}]} - ret = schedule._find_duplicate_jobs(client, {'ISO_URL': 'https://some.url/some.iso'}, 'someflavor') + ret = schedule._find_duplicate_jobs(client, 'build', {'ISO_URL': 'https://some.url/some.iso'}, 'someflavor') assert len(ret) == 0 # user-cancelled job (which is a result not a state?) isn't either client.openqa_request.return_value = {'jobs': [{'settings': {'FLAVOR': 'someflavor'}, 'result': 'user_cancelled'}]} - ret = schedule._find_duplicate_jobs(client, {'ISO_URL': 'https://some.url/some.iso'}, 'someflavor') + ret = schedule._find_duplicate_jobs(client, 'build', {'ISO_URL': 'https://some.url/some.iso'}, 'someflavor') assert len(ret) == 0