2014-05-27 11:14:35 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
# (C) 2014 mhrusecky@suse.cz, openSUSE.org
|
|
|
|
# (C) 2014 tchvatal@suse.cz, openSUSE.org
|
|
|
|
# (C) 2014 aplanas@suse.de, openSUSE.org
|
|
|
|
# (C) 2014 coolo@suse.de, openSUSE.org
|
|
|
|
# Distribute under GPLv2 or GPLv3
|
|
|
|
|
2015-04-14 13:39:48 +02:00
|
|
|
import cmdln
|
2015-04-29 13:32:04 +02:00
|
|
|
import datetime
|
2014-09-12 11:42:42 +02:00
|
|
|
import json
|
2014-05-27 11:14:35 +02:00
|
|
|
import os
|
2014-09-12 11:42:42 +02:00
|
|
|
import re
|
2014-05-27 11:14:35 +02:00
|
|
|
import sys
|
2014-09-12 15:05:57 +02:00
|
|
|
import urllib2
|
2015-04-14 13:39:48 +02:00
|
|
|
import logging
|
2015-04-20 15:00:02 +02:00
|
|
|
import signal
|
2014-09-12 15:05:57 +02:00
|
|
|
|
2014-09-12 11:42:42 +02:00
|
|
|
from xml.etree import cElementTree as ET
|
2014-05-27 11:14:35 +02:00
|
|
|
|
2014-09-12 11:42:42 +02:00
|
|
|
import osc
|
2014-05-28 15:14:58 +02:00
|
|
|
|
2014-05-27 11:14:35 +02:00
|
|
|
|
|
|
|
# Expand sys.path to search modules inside the pluging directory
|
2014-09-01 14:17:23 +02:00
|
|
|
PLUGINDIR = os.path.expanduser(os.path.dirname(os.path.realpath(__file__)))
|
|
|
|
sys.path.append(PLUGINDIR)
|
2015-02-20 13:18:09 +01:00
|
|
|
from osclib.conf import Config
|
2014-05-27 11:14:35 +02:00
|
|
|
from osclib.stagingapi import StagingAPI
|
2015-04-08 10:06:02 +02:00
|
|
|
from osc.core import makeurl
|
2014-05-27 11:14:35 +02:00
|
|
|
|
2014-09-12 11:42:42 +02:00
|
|
|
|
|
|
|
# QA Results
|
|
|
|
QA_INPROGRESS = 1
|
|
|
|
QA_FAILED = 2
|
|
|
|
QA_PASSED = 3
|
|
|
|
|
|
|
|
|
|
|
|
class ToTestBase(object):
|
|
|
|
"""Base class to store the basic interface"""
|
|
|
|
|
2014-12-09 16:01:42 +01:00
|
|
|
def __init__(self, project, dryrun):
|
2014-09-12 11:42:42 +02:00
|
|
|
self.project = project
|
2014-12-09 16:01:42 +01:00
|
|
|
self.dryrun = dryrun
|
2015-02-20 12:54:50 +01:00
|
|
|
self.api = StagingAPI(osc.conf.config['apiurl'], project='openSUSE:%s' % project)
|
2014-12-08 11:40:44 +01:00
|
|
|
self.known_failures = self.known_failures_from_dashboard(project)
|
2014-09-12 11:42:42 +02:00
|
|
|
|
2015-04-08 10:06:02 +02:00
|
|
|
def openqa_group(self):
|
2014-09-12 15:05:57 +02:00
|
|
|
return self.project
|
|
|
|
|
2014-11-11 12:57:10 +01:00
|
|
|
def iso_prefix(self):
|
|
|
|
return self.project
|
|
|
|
|
2015-04-07 14:11:57 +02:00
|
|
|
def jobs_num(self):
|
|
|
|
return 90
|
|
|
|
|
2014-09-12 15:05:57 +02:00
|
|
|
def binaries_of_product(self, project, product):
|
|
|
|
url = self.api.makeurl(['build', project, 'images', 'local', product])
|
|
|
|
try:
|
|
|
|
f = self.api.retried_GET(url)
|
|
|
|
except urllib2.HTTPError:
|
|
|
|
return []
|
|
|
|
|
|
|
|
ret = []
|
|
|
|
root = ET.parse(f).getroot()
|
|
|
|
for binary in root.findall('binary'):
|
|
|
|
ret.append(binary.get('filename'))
|
|
|
|
|
|
|
|
return ret
|
|
|
|
|
2014-09-12 11:42:42 +02:00
|
|
|
def get_current_snapshot(self):
|
|
|
|
"""Return the current snapshot in :ToTest"""
|
|
|
|
|
|
|
|
# for now we hardcode all kind of things
|
2015-03-21 16:06:18 +01:00
|
|
|
for binary in self.binaries_of_product('openSUSE:%s:ToTest' % self.project, '_product:openSUSE-cd-mini-%s' % self.arch()):
|
2015-03-19 09:58:46 +01:00
|
|
|
result = re.match(r'openSUSE-%s-NET-.*-Snapshot(.*)-Media.iso' % self.iso_prefix(),
|
2014-09-12 15:05:57 +02:00
|
|
|
binary)
|
2014-09-12 11:42:42 +02:00
|
|
|
if result:
|
|
|
|
return result.group(1)
|
|
|
|
|
2014-09-12 15:05:57 +02:00
|
|
|
return None
|
|
|
|
|
2014-09-12 11:42:42 +02:00
|
|
|
def find_openqa_results(self, snapshot):
|
|
|
|
"""Return the openqa jobs of a given snapshot and filter out the
|
|
|
|
cloned jobs
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
2015-04-08 10:06:02 +02:00
|
|
|
url = makeurl('https://openqa.opensuse.org', ['api', 'v1', 'jobs'], { 'group': self.openqa_group(), 'build': snapshot } )
|
2014-09-12 11:42:42 +02:00
|
|
|
f = self.api.retried_GET(url)
|
|
|
|
jobs = []
|
|
|
|
for job in json.load(f)['jobs']:
|
|
|
|
if job['clone_id']:
|
|
|
|
continue
|
|
|
|
job['name'] = job['name'].replace(snapshot, '')
|
|
|
|
jobs.append(job)
|
|
|
|
return jobs
|
|
|
|
|
|
|
|
def _result2str(self, result):
|
|
|
|
if result == QA_INPROGRESS:
|
|
|
|
return 'inprogress'
|
|
|
|
elif result == QA_FAILED:
|
|
|
|
return 'failed'
|
|
|
|
else:
|
|
|
|
return 'passed'
|
|
|
|
|
2015-03-12 13:05:43 +01:00
|
|
|
def find_failed_module(self, testmodules):
|
|
|
|
# print json.dumps(testmodules, sort_keys=True, indent=4)
|
|
|
|
for module in testmodules:
|
|
|
|
if module['result'] != 'failed':
|
2014-09-12 11:42:42 +02:00
|
|
|
continue
|
|
|
|
flags = module['flags']
|
|
|
|
if 'fatal' in flags or 'important' in flags:
|
|
|
|
return module['name']
|
|
|
|
break
|
|
|
|
print module['name'], module['result'], module['flags']
|
|
|
|
|
|
|
|
def overall_result(self, snapshot):
|
|
|
|
"""Analyze the openQA jobs of a given snapshot Returns a QAResult"""
|
|
|
|
|
2015-02-20 13:35:34 +01:00
|
|
|
if snapshot is None:
|
2014-09-12 15:05:57 +02:00
|
|
|
return QA_FAILED
|
|
|
|
|
2014-09-12 11:42:42 +02:00
|
|
|
jobs = self.find_openqa_results(snapshot)
|
|
|
|
|
2015-04-07 14:11:57 +02:00
|
|
|
if len(jobs) < self.jobs_num(): # not yet scheduled
|
2014-09-12 11:42:42 +02:00
|
|
|
print 'we have only %s jobs' % len(jobs)
|
|
|
|
return QA_INPROGRESS
|
|
|
|
|
|
|
|
number_of_fails = 0
|
|
|
|
in_progress = False
|
|
|
|
for job in jobs:
|
|
|
|
# print json.dumps(job, sort_keys=True, indent=4)
|
2015-04-15 12:20:31 +02:00
|
|
|
if job['result'] in ('failed', 'incomplete', 'skipped'):
|
2014-09-12 11:42:42 +02:00
|
|
|
jobname = job['name'] + '@' + job['settings']['MACHINE']
|
|
|
|
if jobname in self.known_failures:
|
|
|
|
self.known_failures.remove(jobname)
|
|
|
|
continue
|
|
|
|
number_of_fails += 1
|
|
|
|
# print json.dumps(job, sort_keys=True, indent=4), jobname
|
2015-03-12 13:05:43 +01:00
|
|
|
failedmodule = self.find_failed_module(job['modules'])
|
2014-09-12 11:42:42 +02:00
|
|
|
url = 'https://openqa.opensuse.org/tests/%s' % job['id']
|
|
|
|
print jobname, url, failedmodule, job['retry_avbl']
|
|
|
|
# if number_of_fails < 3: continue
|
|
|
|
elif job['result'] == 'passed':
|
|
|
|
continue
|
|
|
|
elif job['result'] == 'none':
|
|
|
|
if job['state'] != 'cancelled':
|
|
|
|
in_progress = True
|
|
|
|
else:
|
|
|
|
raise Exception(job['result'])
|
|
|
|
|
|
|
|
if number_of_fails > 0:
|
|
|
|
return QA_FAILED
|
|
|
|
|
|
|
|
if in_progress:
|
|
|
|
return QA_INPROGRESS
|
|
|
|
|
|
|
|
if self.known_failures:
|
|
|
|
print 'Some are now passing', self.known_failures
|
|
|
|
return QA_PASSED
|
|
|
|
|
|
|
|
def all_repos_done(self, project, codes=None):
|
|
|
|
"""Check the build result of the project and only return True if all
|
|
|
|
repos of that project are either published or unpublished
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
codes = ['published', 'unpublished'] if not codes else codes
|
|
|
|
|
|
|
|
url = self.api.makeurl(['build', project, '_result'], {'code': 'failed'})
|
|
|
|
f = self.api.retried_GET(url)
|
|
|
|
root = ET.parse(f).getroot()
|
2015-04-29 13:31:52 +02:00
|
|
|
ready = True
|
2014-09-12 11:42:42 +02:00
|
|
|
for repo in root.findall('result'):
|
2015-04-29 13:31:30 +02:00
|
|
|
# ignore ports. 'factory' is used by arm for repos that are not
|
|
|
|
# meant to use the totest manager.
|
|
|
|
if repo.get('repository') in ('ports', 'factory'):
|
2014-10-31 11:11:52 +01:00
|
|
|
continue
|
2015-04-14 09:57:55 +02:00
|
|
|
# ignore 32bit for now. We're only interesed in aarch64 here
|
|
|
|
if repo.get('arch') in ('armv6l', 'armv7l'):
|
|
|
|
continue
|
2014-09-12 11:42:42 +02:00
|
|
|
if repo.get('dirty', '') == 'true':
|
|
|
|
print repo.get('project'), repo.get('repository'), repo.get('arch'), 'dirty'
|
2015-04-29 13:31:52 +02:00
|
|
|
ready = False
|
2014-09-12 11:42:42 +02:00
|
|
|
if repo.get('code') not in codes:
|
|
|
|
print repo.get('project'), repo.get('repository'), repo.get('arch'), repo.get('code')
|
2015-04-29 13:31:52 +02:00
|
|
|
ready = False
|
|
|
|
return ready
|
2014-09-12 11:42:42 +02:00
|
|
|
|
|
|
|
def maxsize_for_package(self, package):
|
|
|
|
if re.match(r'.*-mini-.*', package):
|
|
|
|
return 737280000 # a CD needs to match
|
|
|
|
|
|
|
|
if re.match(r'.*-dvd5-.*', package):
|
|
|
|
return 4700372992 # a DVD needs to match
|
|
|
|
|
|
|
|
if re.match(r'.*-image-livecd-x11.*', package):
|
|
|
|
return 681574400 # not a full CD
|
|
|
|
|
|
|
|
if re.match(r'.*-image-livecd.*', package):
|
|
|
|
return 999999999 # a GB stick
|
|
|
|
|
2014-10-14 14:44:27 +02:00
|
|
|
if re.match(r'.*-dvd9-dvd-.*', package):
|
|
|
|
return 8539996159
|
|
|
|
|
2015-04-14 09:58:19 +02:00
|
|
|
if package.startswith('_product:openSUSE-ftp-ftp-'):
|
2014-09-12 11:42:42 +02:00
|
|
|
return None
|
|
|
|
|
|
|
|
if package == '_product:openSUSE-Addon-NonOss-ftp-ftp-i586_x86_64':
|
|
|
|
return None
|
|
|
|
|
|
|
|
raise Exception('No maxsize for {}'.format(package))
|
|
|
|
|
|
|
|
def package_ok(self, project, package, repository, arch):
|
|
|
|
"""Checks one package in a project and returns True if it's succeeded
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
query = {'package': package, 'repository': repository, 'arch': arch}
|
|
|
|
|
|
|
|
url = self.api.makeurl(['build', project, '_result'], query)
|
|
|
|
f = self.api.retried_GET(url)
|
|
|
|
root = ET.parse(f).getroot()
|
|
|
|
for repo in root.findall('result'):
|
|
|
|
status = repo.find('status')
|
|
|
|
if status.get('code') != 'succeeded':
|
|
|
|
print project, package, repository, arch, status.get('code')
|
|
|
|
return False
|
|
|
|
|
2014-09-12 15:05:57 +02:00
|
|
|
maxsize = self.maxsize_for_package(package)
|
2014-09-12 11:42:42 +02:00
|
|
|
if not maxsize:
|
|
|
|
return True
|
|
|
|
|
|
|
|
url = self.api.makeurl(['build', project, repository, arch, package])
|
|
|
|
f = self.api.retried_GET(url)
|
|
|
|
root = ET.parse(f).getroot()
|
|
|
|
for binary in root.findall('binary'):
|
|
|
|
if not binary.get('filename', '').endswith('.iso'):
|
|
|
|
continue
|
|
|
|
isosize = int(binary.get('size', 0))
|
|
|
|
if isosize > maxsize:
|
2014-10-02 13:27:40 +02:00
|
|
|
print project, package, repository, arch, 'too large by %s bytes' % (isosize-maxsize)
|
2014-09-12 11:42:42 +02:00
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
def factory_snapshottable(self):
|
|
|
|
"""Check various conditions required for factory to be snapshotable
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
if not self.all_repos_done('openSUSE:%s' % self.project):
|
|
|
|
return False
|
|
|
|
|
2015-03-19 09:58:46 +01:00
|
|
|
for product in self.ftp_products + self.main_products:
|
2014-09-12 11:42:42 +02:00
|
|
|
if not self.package_ok('openSUSE:%s' % self.project, product, 'images', 'local'):
|
|
|
|
return False
|
|
|
|
|
2015-03-21 16:06:18 +01:00
|
|
|
if len(self.livecd_products):
|
2014-09-12 11:42:42 +02:00
|
|
|
|
2015-03-19 09:58:46 +01:00
|
|
|
if not self.all_repos_done('openSUSE:%s:Live' % self.project):
|
|
|
|
return False
|
2014-09-12 11:42:42 +02:00
|
|
|
|
2015-03-19 09:58:46 +01:00
|
|
|
for arch in ['i586', 'x86_64' ]:
|
|
|
|
for product in self.livecd_products:
|
2015-03-21 16:06:18 +01:00
|
|
|
if not self.package_ok('openSUSE:%s:Live' % self.project, product, 'standard', arch):
|
2015-03-19 09:58:46 +01:00
|
|
|
return False
|
2014-09-12 11:42:42 +02:00
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
def release_package(self, project, package, set_release=None):
|
|
|
|
query = {'cmd': 'release'}
|
|
|
|
|
|
|
|
if set_release:
|
|
|
|
query['setrelease'] = set_release
|
|
|
|
|
|
|
|
baseurl = ['source', project, package]
|
|
|
|
|
|
|
|
url = self.api.makeurl(baseurl, query=query)
|
2015-04-14 13:39:48 +02:00
|
|
|
if self.dryrun:
|
|
|
|
print "release %s/%s (%s)"%(project, package, set_release)
|
|
|
|
else:
|
|
|
|
self.api.retried_POST(url)
|
2014-09-12 11:42:42 +02:00
|
|
|
|
|
|
|
def update_totest(self, snapshot):
|
|
|
|
print 'Updating snapshot %s' % snapshot
|
2015-04-14 13:39:48 +02:00
|
|
|
if not self.dryrun:
|
|
|
|
self.api.switch_flag_in_prj('openSUSE:%s:ToTest' % self.project, flag='publish', state='disable')
|
2014-09-12 11:42:42 +02:00
|
|
|
|
2015-03-19 09:58:46 +01:00
|
|
|
for product in self.ftp_products:
|
2015-03-21 16:06:18 +01:00
|
|
|
self.release_package('openSUSE:%s' % self.project, product)
|
2015-03-19 09:58:46 +01:00
|
|
|
|
2015-03-21 16:06:18 +01:00
|
|
|
for cd in self.livecd_products:
|
|
|
|
self.release_package('openSUSE:%s:Live' % self.project, cd, set_release='Snapshot%s' % snapshot)
|
2014-09-12 11:42:42 +02:00
|
|
|
|
2014-10-17 10:09:35 +02:00
|
|
|
for cd in self.main_products:
|
2014-09-12 11:42:42 +02:00
|
|
|
self.release_package('openSUSE:%s' % self.project, cd, set_release='Snapshot%s' % snapshot)
|
|
|
|
|
|
|
|
def publish_factory_totest(self):
|
|
|
|
print 'Publish ToTest'
|
2015-04-14 13:39:48 +02:00
|
|
|
if not self.dryrun:
|
|
|
|
self.api.switch_flag_in_prj('openSUSE:%s:ToTest' % self.project, flag='publish', state='enable')
|
2014-09-12 11:42:42 +02:00
|
|
|
|
|
|
|
def totest_is_publishing(self):
|
|
|
|
"""Find out if the publishing flag is set in totest's _meta"""
|
|
|
|
|
|
|
|
url = self.api.makeurl(['source', 'openSUSE:%s:ToTest' % self.project, '_meta'])
|
|
|
|
f = self.api.retried_GET(url)
|
|
|
|
root = ET.parse(f).getroot()
|
|
|
|
if not root.find('publish'): # default true
|
|
|
|
return True
|
|
|
|
|
|
|
|
for flag in root.find('publish'):
|
|
|
|
if flag.get('repository', None) or flag.get('arch', None):
|
|
|
|
continue
|
|
|
|
if flag.tag == 'enable':
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
def totest(self):
|
|
|
|
current_snapshot = self.get_current_snapshot()
|
2014-09-12 15:05:57 +02:00
|
|
|
new_snapshot = self.current_version()
|
2014-09-12 11:42:42 +02:00
|
|
|
|
|
|
|
current_result = self.overall_result(current_snapshot)
|
2014-09-12 15:05:57 +02:00
|
|
|
|
2014-09-12 11:42:42 +02:00
|
|
|
print 'current_snapshot', current_snapshot, self._result2str(current_result)
|
2014-09-12 15:05:57 +02:00
|
|
|
|
2014-09-12 11:42:42 +02:00
|
|
|
can_release = (current_result != QA_INPROGRESS and self.factory_snapshottable())
|
2015-02-20 13:18:09 +01:00
|
|
|
|
2014-09-12 11:42:42 +02:00
|
|
|
# not overwriting
|
|
|
|
if new_snapshot == current_snapshot:
|
|
|
|
can_release = False
|
|
|
|
elif not self.all_repos_done('openSUSE:%s:ToTest' % self.project):
|
|
|
|
# the repos have to be done, otherwise we better not touch them with a new release
|
|
|
|
can_release = False
|
|
|
|
|
|
|
|
can_publish = (current_result == QA_PASSED)
|
|
|
|
|
|
|
|
# already published
|
|
|
|
if self.totest_is_publishing():
|
|
|
|
can_publish = False
|
|
|
|
|
2015-04-14 13:39:48 +02:00
|
|
|
if can_publish:
|
2014-09-12 11:42:42 +02:00
|
|
|
self.publish_factory_totest()
|
|
|
|
can_release = False # we have to wait
|
|
|
|
|
2015-04-14 13:39:48 +02:00
|
|
|
if can_release:
|
2014-09-16 09:12:08 +02:00
|
|
|
self.update_totest(new_snapshot)
|
2014-09-12 11:42:42 +02:00
|
|
|
|
2015-04-14 09:58:53 +02:00
|
|
|
def release(self):
|
|
|
|
new_snapshot = self.current_version()
|
|
|
|
self.update_totest(new_snapshot)
|
|
|
|
|
2014-12-08 11:40:44 +01:00
|
|
|
def known_failures_from_dashboard(self, project):
|
|
|
|
known_failures = []
|
2015-04-08 15:24:36 +02:00
|
|
|
if self.project in ("Factory:PowerPC", "Factory:ARM"):
|
2015-03-19 09:58:46 +01:00
|
|
|
project = "Factory"
|
|
|
|
else:
|
|
|
|
project = self.project
|
|
|
|
|
|
|
|
url = self.api.makeurl(['source', 'openSUSE:%s:Staging' % project, 'dashboard', 'known_failures'])
|
2014-12-08 11:40:44 +01:00
|
|
|
f = self.api.retried_GET(url)
|
|
|
|
for line in f:
|
|
|
|
if not line[0] == '#':
|
|
|
|
known_failures.append(line.strip())
|
|
|
|
return known_failures
|
2014-09-12 11:42:42 +02:00
|
|
|
|
2015-02-20 13:18:09 +01:00
|
|
|
|
2014-09-12 11:42:42 +02:00
|
|
|
class ToTestFactory(ToTestBase):
|
2014-10-13 17:07:24 +02:00
|
|
|
main_products = ['_product:openSUSE-dvd5-dvd-i586',
|
|
|
|
'_product:openSUSE-dvd5-dvd-x86_64',
|
|
|
|
'_product:openSUSE-cd-mini-i586',
|
|
|
|
'_product:openSUSE-cd-mini-x86_64']
|
2014-05-27 11:14:35 +02:00
|
|
|
|
2015-03-19 09:58:46 +01:00
|
|
|
ftp_products = ['_product:openSUSE-ftp-ftp-i586_x86_64',
|
|
|
|
'_product:openSUSE-Addon-NonOss-ftp-ftp-i586_x86_64']
|
|
|
|
|
|
|
|
livecd_products = ['kiwi-image-livecd-kde',
|
|
|
|
'kiwi-image-livecd-gnome',
|
|
|
|
'kiwi-image-livecd-x11']
|
|
|
|
|
2014-12-09 16:01:42 +01:00
|
|
|
def __init__(self, project, dryrun):
|
|
|
|
ToTestBase.__init__(self, project, dryrun)
|
2014-09-12 15:05:57 +02:00
|
|
|
|
2015-03-31 15:35:30 +02:00
|
|
|
def openqa_group(self):
|
2015-04-08 10:06:02 +02:00
|
|
|
return 'openSUSE Tumbleweed'
|
2015-03-31 15:35:30 +02:00
|
|
|
|
2014-11-11 12:57:10 +01:00
|
|
|
def iso_prefix(self):
|
|
|
|
return 'Tumbleweed'
|
|
|
|
|
2015-03-19 09:58:46 +01:00
|
|
|
def arch(self):
|
|
|
|
return 'x86_64'
|
|
|
|
|
2014-09-12 15:05:57 +02:00
|
|
|
# for Factory we check the version of the release package
|
|
|
|
def current_version(self):
|
2015-03-25 01:22:15 +01:00
|
|
|
url = self.api.makeurl(['build', 'openSUSE:%s' % self.project, 'standard', self.arch(),
|
2014-09-12 15:05:57 +02:00
|
|
|
'_product:openSUSE-release'])
|
|
|
|
f = self.api.retried_GET(url)
|
|
|
|
root = ET.parse(f).getroot()
|
|
|
|
for binary in root.findall('binary'):
|
|
|
|
binary = binary.get('filename', '')
|
|
|
|
result = re.match(r'.*-([^-]*)-[^-]*.src.rpm', binary)
|
|
|
|
if result:
|
|
|
|
return result.group(1)
|
|
|
|
raise Exception("can't find factory version")
|
2014-05-27 13:26:29 +02:00
|
|
|
|
2015-03-19 09:58:46 +01:00
|
|
|
class ToTestFactoryPowerPC(ToTestBase):
|
|
|
|
main_products = ['_product:openSUSE-dvd5-BE-ppc64',
|
|
|
|
'_product:openSUSE-dvd5-LE-ppc64le',
|
|
|
|
'_product:openSUSE-cd-mini-ppc64',
|
|
|
|
'_product:openSUSE-cd-mini-ppc64le']
|
|
|
|
|
|
|
|
ftp_products = [ '_product:openSUSE-ftp-ftp-ppc_ppc64_ppc64le' ]
|
|
|
|
|
2015-03-21 16:06:18 +01:00
|
|
|
livecd_products = []
|
|
|
|
|
2015-03-19 09:58:46 +01:00
|
|
|
def __init__(self, project, dryrun):
|
|
|
|
ToTestBase.__init__(self, project, dryrun)
|
|
|
|
|
2015-03-31 15:35:30 +02:00
|
|
|
def openqa_group(self):
|
2015-04-08 10:06:02 +02:00
|
|
|
return 'openSUSE Tumbleweed PowerPC'
|
2015-03-31 15:35:30 +02:00
|
|
|
|
2015-03-19 09:58:46 +01:00
|
|
|
def arch(self):
|
|
|
|
return 'ppc64le'
|
|
|
|
|
|
|
|
def iso_prefix(self):
|
|
|
|
return 'Tumbleweed'
|
|
|
|
|
2015-04-07 14:11:57 +02:00
|
|
|
def jobs_num(self):
|
|
|
|
return 4
|
|
|
|
|
2015-03-19 09:58:46 +01:00
|
|
|
# for Factory we check the version of the release package
|
|
|
|
def current_version(self):
|
2015-03-25 01:22:15 +01:00
|
|
|
url = self.api.makeurl(['build', 'openSUSE:%s' % self.project, 'standard', self.arch(),
|
2015-03-19 09:58:46 +01:00
|
|
|
'_product:openSUSE-release'])
|
|
|
|
f = self.api.retried_GET(url)
|
|
|
|
root = ET.parse(f).getroot()
|
|
|
|
for binary in root.findall('binary'):
|
|
|
|
binary = binary.get('filename', '')
|
|
|
|
result = re.match(r'.*-([^-]*)-[^-]*.src.rpm', binary)
|
|
|
|
if result:
|
|
|
|
return result.group(1)
|
|
|
|
raise Exception("can't find factory powerpc version")
|
|
|
|
|
2015-04-08 15:24:36 +02:00
|
|
|
class ToTestFactoryARM(ToTestFactory):
|
|
|
|
main_products = [ '_product:openSUSE-cd-mini-aarch64']
|
|
|
|
|
|
|
|
ftp_products = [ '_product:openSUSE-ftp-ftp-aarch64' ]
|
|
|
|
|
|
|
|
livecd_products = []
|
|
|
|
|
|
|
|
def __init__(self, project, dryrun):
|
|
|
|
ToTestFactory.__init__(self, project, dryrun)
|
|
|
|
|
|
|
|
def openqa_group(self):
|
2015-04-23 13:09:49 +02:00
|
|
|
return 'openSUSE Tumbleweed AArch64'
|
2015-04-08 15:24:36 +02:00
|
|
|
|
|
|
|
def arch(self):
|
|
|
|
return 'aarch64'
|
|
|
|
|
|
|
|
def jobs_num(self):
|
2015-04-23 13:09:49 +02:00
|
|
|
return 2
|
2015-02-20 13:18:09 +01:00
|
|
|
|
2014-09-12 11:42:42 +02:00
|
|
|
class ToTest132(ToTestBase):
|
2015-02-20 13:35:34 +01:00
|
|
|
main_products = [
|
|
|
|
'_product:openSUSE-dvd5-dvd-i586',
|
|
|
|
'_product:openSUSE-dvd5-dvd-x86_64',
|
|
|
|
'_product:openSUSE-cd-mini-i586',
|
|
|
|
'_product:openSUSE-cd-mini-x86_64',
|
|
|
|
'_product:openSUSE-dvd5-dvd-promo-i586',
|
|
|
|
'_product:openSUSE-dvd5-dvd-promo-x86_64',
|
|
|
|
'_product:openSUSE-dvd9-dvd-biarch-i586_x86_64'
|
2014-10-13 17:07:24 +02:00
|
|
|
]
|
2015-02-20 13:35:34 +01:00
|
|
|
|
2014-09-12 15:05:57 +02:00
|
|
|
# for 13.2 we take the build number of the FTP tree
|
|
|
|
def current_version(self):
|
|
|
|
for binary in self.binaries_of_product('openSUSE:%s' % self.project, '_product:openSUSE-ftp-ftp-i586_x86_64'):
|
|
|
|
result = re.match(r'openSUSE.*Build(.*)-Media1.report', binary)
|
|
|
|
if result:
|
|
|
|
return result.group(1)
|
|
|
|
|
|
|
|
raise Exception("can't find 13.2 version")
|
2014-05-27 13:26:29 +02:00
|
|
|
|
2015-04-14 13:39:48 +02:00
|
|
|
|
|
|
|
class CommandlineInterface(cmdln.Cmdln):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
cmdln.Cmdln.__init__(self, args, kwargs)
|
|
|
|
|
|
|
|
self.totest_class = {
|
|
|
|
'Factory': ToTestFactory,
|
|
|
|
'Factory:PowerPC': ToTestFactoryPowerPC,
|
|
|
|
'Factory:ARM': ToTestFactoryARM,
|
|
|
|
'13.2': ToTest132,
|
|
|
|
}
|
|
|
|
|
|
|
|
def get_optparser(self):
|
|
|
|
parser = cmdln.CmdlnOptionParser(self)
|
|
|
|
parser.add_option("--dry", action="store_true", help="dry run")
|
|
|
|
parser.add_option("--debug", action="store_true", help="debug output")
|
|
|
|
parser.add_option("--verbose", action="store_true", help="verbose")
|
|
|
|
parser.add_option("--osc-debug", action="store_true", help="osc debug output")
|
|
|
|
return parser
|
|
|
|
|
|
|
|
def postoptparse(self):
|
|
|
|
logging.basicConfig()
|
|
|
|
self.logger = logging.getLogger(self.optparser.prog)
|
|
|
|
if (self.options.debug):
|
|
|
|
self.logger.setLevel(logging.DEBUG)
|
|
|
|
elif (self.options.verbose):
|
|
|
|
self.logger.setLevel(logging.INFO)
|
|
|
|
|
|
|
|
osc.conf.get_config()
|
|
|
|
if (self.options.osc_debug):
|
|
|
|
osc.conf.config['debug'] = True
|
|
|
|
|
|
|
|
def _setup_totest(self, project):
|
|
|
|
Config('openSUSE:%s' % project)
|
|
|
|
|
|
|
|
if project not in self.totest_class:
|
|
|
|
msg = 'Project %s not recognized. Possible values [%s]' % (project, ', '.join(self.totest_class))
|
|
|
|
raise CmdlnUserError()
|
|
|
|
|
|
|
|
return self.totest_class[project](project, self.options.dry)
|
|
|
|
|
2015-04-20 15:00:02 +02:00
|
|
|
@cmdln.option('-n', '--interval', metavar="minutes", type="int", help="periodic interval in minutes")
|
2015-04-14 13:39:48 +02:00
|
|
|
def do_run(self, subcmd, opts, project = 'Factory'):
|
|
|
|
"""${cmd_name}: run the ToTest Manager
|
|
|
|
|
|
|
|
${cmd_usage}
|
|
|
|
${cmd_option_list}
|
|
|
|
"""
|
|
|
|
|
2015-04-20 15:00:02 +02:00
|
|
|
class ExTimeout(Exception):
|
|
|
|
"""raised on timeout"""
|
|
|
|
|
|
|
|
if opts.interval:
|
|
|
|
def alarm_called(nr, frame):
|
|
|
|
raise ExTimeout()
|
|
|
|
signal.signal(signal.SIGALRM, alarm_called)
|
|
|
|
|
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
totest = self._setup_totest(project)
|
|
|
|
totest.totest()
|
|
|
|
except Exception, e:
|
|
|
|
self.logger.error(e)
|
|
|
|
|
|
|
|
if opts.interval:
|
|
|
|
self.logger.info("sleeping %d minutes. Press enter to check now ..."%opts.interval)
|
|
|
|
signal.alarm(opts.interval*60)
|
|
|
|
try:
|
|
|
|
raw_input()
|
|
|
|
except ExTimeout:
|
|
|
|
pass
|
|
|
|
signal.alarm(0)
|
2015-04-29 13:32:04 +02:00
|
|
|
self.logger.info("recheck at %s"%datetime.datetime.now().isoformat())
|
2015-04-20 15:00:02 +02:00
|
|
|
continue
|
|
|
|
break
|
2015-04-14 13:39:48 +02:00
|
|
|
|
|
|
|
def do_release(self, subcmd, opts, project = 'Factory'):
|
|
|
|
"""${cmd_name}: manually release all media. Use with caution!
|
|
|
|
|
|
|
|
${cmd_usage}
|
|
|
|
${cmd_option_list}
|
|
|
|
"""
|
|
|
|
|
|
|
|
totest = self._setup_totest(project)
|
|
|
|
|
|
|
|
totest.release()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
app = CommandlineInterface()
|
|
|
|
sys.exit( app.main() )
|
|
|
|
|
|
|
|
# vim: sw=4 et
|