1
0
mirror of https://pagure.io/fedora-qa/createhdds.git synced 2024-11-22 07:13:09 +00:00

some changes in openqa_trigger.py

This commit is contained in:
Garret Raziel 2015-01-29 10:08:05 +01:00 committed by Josef Skladanka
parent 64e70b8957
commit 76ce5be7a6

View File

@ -8,13 +8,14 @@ import os.path
import sys import sys
import subprocess import subprocess
import jozuv_bomba_script #from evaluate_jobs import evaluate_jobs
PERSISTENT="/var/tmp/openqa_watcher.json" PERSISTENT = "/var/tmp/openqa_watcher.json"
CURRENT_TEST="https://fedoraproject.org/wiki/Test_Results:Current_Installation_Test" CURRENT_TEST = "https://fedoraproject.org/wiki/Test_Results:Current_Installation_Test"
ISO_REGEX=re.compile(r'https://kojipkgs\.fedoraproject\.org/mash/(?P<name>rawhide-(?P<build>\d+))/rawhide/(?P<arch>x86_64|i386)/os/images/boot\.iso') ISO_URL = "https://kojipkgs.fedoraproject.org/mash/rawhide-%s/rawhide/%s/os/images/boot.iso"
ISO_PATH="/var/lib/openqa/factory/iso/" ISO_REGEX = re.compile(r'https://kojipkgs\.fedoraproject\.org/mash/(?P<name>rawhide-(?P<build>\d+))/rawhide/(?P<arch>x86_64|i386)/os/images/boot\.iso')
RUN_COMMAND="/var/lib/openqa/script/client isos post ISO=%s DISTRI=fedora VERSION=rawhide FLAVOR=server ARCH=%s BUILD=%s" ISO_PATH = "/var/lib/openqa/factory/iso/"
RUN_COMMAND = "/var/lib/openqa/script/client isos post ISO=%s DISTRI=fedora VERSION=rawhide FLAVOR=server ARCH=%s BUILD=%s"
VERSIONS = ['i386', 'x86_64'] VERSIONS = ['i386', 'x86_64']
# read last tested version from file # read last tested version from file
@ -38,37 +39,73 @@ def read_currents():
for match in ISO_REGEX.finditer(page): for match in ISO_REGEX.finditer(page):
yield match.group("build"), match.group(0), match.group("name"), match.group("arch") yield match.group("build"), match.group(0), match.group("name"), match.group("arch")
last_versions, json_parsed = read_last() # download rawhide iso from koji
jobs = [] def download_rawhide_iso(link, name, arch):
# for every architecture
for current_version, link, name, arch in read_currents():
# don't run when there is newer version
last_version = last_versions.get(arch, None)
if last_version is not None and (last_version == current_version):
continue
json_parsed[arch] = current_version
isoname = "%s_%s.iso" % (name, arch) isoname = "%s_%s.iso" % (name, arch)
filename = os.path.join(ISO_PATH, isoname) filename = os.path.join(ISO_PATH, isoname)
link = "http://" + link[len("https://"):]
urlgrabber.urlgrab(link, filename) urlgrabber.urlgrab(link, filename)
return isoname
command = RUN_COMMAND % (isoname, arch, current_version) # run OpenQA 'isos' job on selected isoname, with given arch and build
# returns list of job IDs
def run_openqa_jobs(isoname, arch, build):
command = RUN_COMMAND % (isoname, arch, build)
# starts OpenQA jobs
output = subprocess.check_output(command.split()) output = subprocess.check_output(command.split())
# read ids from OpenQA to wait for # read ids from OpenQA to wait for
r = re.compile(r'ids => \[(?P<from>\d+)( \.\. (?P<to>\d+))?\]') r = re.compile(r'ids => \[(?P<from>\d+)( \.\. (?P<to>\d+))?\]')
match = r.search(output) match = r.search(output)
if match: if match and match.group('to'):
from_i = int(match.group('from')) from_i = int(match.group('from'))
to_i = int(match.group('to')) + 1 to_i = int(match.group('to')) + 1
jobs.extend(range(from_i, to_i)) return range(from_i, to_i)
elif match:
return [int(match.group('from'))]
else:
return []
# write info about latest versions # run OpenQA on rawhide if there is newer version since last run
f = open(PERSISTENT, "w") def run_if_newer():
f.write(json.dumps(json_parsed)) last_versions, json_parsed = read_last()
f.close() jobs = []
jozuv_bomba_script.vyres_problemy(jobs) # for every architecture
for current_version, link, name, arch in read_currents():
# don't run when there is newer version
last_version = last_versions.get(arch, None)
if last_version is not None and (last_version == current_version):
continue
json_parsed[arch] = current_version
isoname = download_rawhide_iso(link, name, arch)
job_ids = run_openqa_jobs(isoname, arch, current_version)
jobs.extend(job_ids)
# write info about latest versions
f = open(PERSISTENT, "w")
f.write(json.dumps(json_parsed))
f.close()
# wait for jobs to finish and display results
#evaluate_jobs(jobs)
print jobs
if __name__ == "__main__":
if len(sys.argv) == 1:
run_if_newer()
elif len(sys.argv) == 3:
version = sys.argv[1]
arch = sys.argv[2]
name = "rawhide-%s" % version
link = ISO_URL % (sys.argv[1], sys.argv[2])
isoname = download_rawhide_iso(link, name, arch)
job_ids = run_openqa_jobs(isoname, arch, version)
print job_ids
else:
print "%s [rawhide_version arch]" % sys.arv[0]