Merge pull request #115 from openSUSE/coolo_new_openqa
fix for openqa V3 API
This commit is contained in:
commit
6522f0cc09
@ -11,6 +11,7 @@ import yaml
|
|||||||
import re
|
import re
|
||||||
import urllib2
|
import urllib2
|
||||||
import time
|
import time
|
||||||
|
import json
|
||||||
|
|
||||||
from osc import oscerr
|
from osc import oscerr
|
||||||
from osc.core import change_review_state
|
from osc.core import change_review_state
|
||||||
@ -569,12 +570,7 @@ class StagingAPI(object):
|
|||||||
return (time.time() - float(entry.get('mtime')))/3600/24
|
return (time.time() - float(entry.get('mtime')))/3600/24
|
||||||
return 100000 # quite some!
|
return 100000 # quite some!
|
||||||
|
|
||||||
def find_openqa_state(self, project):
|
def find_openqa_id(self, project):
|
||||||
"""
|
|
||||||
Checks the openqa state of the project
|
|
||||||
:param project: project to check
|
|
||||||
:return None or list with issue informations
|
|
||||||
"""
|
|
||||||
u = self.makeurl(['build', project, 'images', 'x86_64', 'Test-DVD-x86_64'])
|
u = self.makeurl(['build', project, 'images', 'x86_64', 'Test-DVD-x86_64'])
|
||||||
f = http_GET(u)
|
f = http_GET(u)
|
||||||
root = ET.parse(f).getroot()
|
root = ET.parse(f).getroot()
|
||||||
@ -584,26 +580,50 @@ class StagingAPI(object):
|
|||||||
filename = binary.get('filename', '')
|
filename = binary.get('filename', '')
|
||||||
if filename.endswith('.iso'):
|
if filename.endswith('.iso'):
|
||||||
break
|
break
|
||||||
|
|
||||||
if not filename:
|
if not filename:
|
||||||
return 'No ISO built in {}'.format(u)
|
return 'No ISO built in {}'.format(u)
|
||||||
|
|
||||||
# don't look here - we will replace that once we have OBS<->openQA sync
|
try:
|
||||||
baseurl = 'http://opensuseqa.suse.de/openqa/testresults/openSUSE-Factory-staging'
|
f = urllib2.urlopen("http://opensuseqa.suse.de/api/v1/jobs")
|
||||||
url = baseurl + '_' + project.split(':')[-1].lower() + '-x86_64-Build'
|
except urllib2.HTTPError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
jobs = json.load(f)['jobs']
|
||||||
|
|
||||||
|
jobname = 'opensuse-Factory-staging'
|
||||||
|
jobname += '_' + project.split(':')[-1].lower() + '-x86_64-Build'
|
||||||
result = re.match('Test-([\d\.]+)-Build(\d+)\.(\d+)-Media.iso',
|
result = re.match('Test-([\d\.]+)-Build(\d+)\.(\d+)-Media.iso',
|
||||||
filename)
|
filename)
|
||||||
url += result.group(1)
|
jobname += result.group(1)
|
||||||
bn = int(result.group(2)) * 100 + int(result.group(3))
|
bn = int(result.group(2)) * 100 + int(result.group(3))
|
||||||
url += '.{}'.format(bn)
|
jobname += '.{}'.format(bn)
|
||||||
url += "-minimalx/results.json"
|
jobname += "-minimalx"
|
||||||
|
|
||||||
|
job_id = None
|
||||||
|
for job in jobs:
|
||||||
|
if job['name'] == jobname and job['result'] != 'incomplete':
|
||||||
|
job_id = job['id']
|
||||||
|
return job_id
|
||||||
|
|
||||||
|
def find_openqa_state(self, project):
|
||||||
|
"""
|
||||||
|
Checks the openqa state of the project
|
||||||
|
:param project: project to check
|
||||||
|
:return None or list with issue informations
|
||||||
|
"""
|
||||||
|
|
||||||
|
job = self.find_openqa_id(project)
|
||||||
|
if not job:
|
||||||
|
return 'No openQA result yet'
|
||||||
|
return
|
||||||
|
|
||||||
|
url = "http://opensuseqa.suse.de/tests/{}/file/results.json".format(job)
|
||||||
try:
|
try:
|
||||||
f = urllib2.urlopen(url)
|
f = urllib2.urlopen(url)
|
||||||
except urllib2.HTTPError:
|
except urllib2.HTTPError:
|
||||||
return 'No openQA result (yet) for {}'.format(url)
|
return "Can't open {}".format(url)
|
||||||
|
|
||||||
import json
|
|
||||||
openqa = json.load(f)
|
openqa = json.load(f)
|
||||||
overall = openqa.get('overall', 'inprogress')
|
overall = openqa.get('overall', 'inprogress')
|
||||||
if overall != 'ok':
|
if overall != 'ok':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user