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
|
|
|
|
2016-05-09 17:12:13 +02:00
|
|
|
logger = logging.getLogger()
|
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"""
|
|
|
|
|
2016-05-09 17:12:13 +02:00
|
|
|
def __init__(self, project, dryrun = False):
|
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):
|
2015-10-20 06:51:40 +02:00
|
|
|
return 70
|
2015-04-07 14:11:57 +02:00
|
|
|
|
2015-05-03 16:08:22 +02:00
|
|
|
def current_version(self):
|
2015-05-14 08:34:45 +02:00
|
|
|
return self.release_version()
|
2015-05-03 16:08:22 +02:00
|
|
|
|
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
|
|
|
|
|
2015-05-03 16:08:22 +02:00
|
|
|
|
|
|
|
def ftp_build_version(self, tree):
|
|
|
|
for binary in self.binaries_of_product('openSUSE:%s' % self.project, tree):
|
|
|
|
result = re.match(r'openSUSE.*Build(.*)-Media1.report', binary)
|
|
|
|
|
|
|
|
if result:
|
|
|
|
return result.group(1)
|
|
|
|
raise Exception("can't find %s version" % self.project)
|
|
|
|
|
|
|
|
def release_version(self):
|
2015-05-14 08:42:05 +02:00
|
|
|
url = self.api.makeurl(['build', 'openSUSE:%s' % self.project, 'standard', self.arch(),
|
2015-05-03 16:08:22 +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)
|
|
|
|
|
2015-05-14 08:42:05 +02:00
|
|
|
raise Exception("can't find %s version" % self.project)
|
2015-05-03 16:08:22 +02:00
|
|
|
|
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']:
|
2016-03-22 17:40:56 +01:00
|
|
|
if job['clone_id'] or job['result'] == 'obsoleted':
|
2014-09-12 11:42:42 +02:00
|
|
|
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
|
2016-05-09 17:12:13 +02:00
|
|
|
logger.info('%s %s %s'%(module['name'], module['result'], module['flags']))
|
2014-09-12 11:42:42 +02:00
|
|
|
|
|
|
|
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
|
2016-05-09 17:12:13 +02:00
|
|
|
logger.warning('we have only %s jobs' % len(jobs))
|
2014-09-12 11:42:42 +02:00
|
|
|
return QA_INPROGRESS
|
|
|
|
|
|
|
|
number_of_fails = 0
|
|
|
|
in_progress = False
|
2015-05-19 14:13:08 +02:00
|
|
|
machines = []
|
2014-09-12 11:42:42 +02:00
|
|
|
for job in jobs:
|
2016-01-06 17:44:03 +01:00
|
|
|
machines.append(job['settings']['MACHINE'])
|
2014-09-12 11:42:42 +02:00
|
|
|
# print json.dumps(job, sort_keys=True, indent=4)
|
2015-06-22 09:25:28 +02:00
|
|
|
if job['result'] in ('failed', 'incomplete', 'skipped', 'user_cancelled', 'obsoleted'):
|
2014-09-12 11:42:42 +02:00
|
|
|
jobname = job['name'] + '@' + job['settings']['MACHINE']
|
2015-05-19 14:13:08 +02:00
|
|
|
# Record machines we have tests for
|
2014-09-12 11:42:42 +02:00
|
|
|
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']
|
2016-07-15 14:07:13 +02:00
|
|
|
print (jobname, url, failedmodule, job['retry_avbl'])
|
2014-09-12 11:42:42 +02:00
|
|
|
# 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
|
|
|
|
|
2015-05-19 14:13:08 +02:00
|
|
|
machines = list(set(machines))
|
|
|
|
for item in machines:
|
|
|
|
for item2 in self.known_failures:
|
|
|
|
if item2.split('@')[1] == item:
|
2016-05-09 17:12:13 +02:00
|
|
|
logger.info('now passing %s'%item2)
|
2014-09-12 11:42:42 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
2016-02-11 11:52:45 +01:00
|
|
|
# coolo's experience says that 'finished' won't be
|
|
|
|
# sufficient here, so don't try to add it :-)
|
2014-09-12 11:42:42 +02:00
|
|
|
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.
|
2016-02-11 11:52:45 +01:00
|
|
|
if repo.get('repository') in ('ports', 'factory', 'images_staging'):
|
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':
|
2016-05-09 17:12:13 +02:00
|
|
|
logger.info('%s %s %s -> %s'%(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:
|
2016-05-09 17:12:13 +02:00
|
|
|
logger.info('%s %s %s -> %s'%(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':
|
2016-05-09 17:12:13 +02:00
|
|
|
logger.info('%s %s %s %s -> %s'%(project, package, repository, arch, status.get('code')))
|
2014-09-12 11:42:42 +02:00
|
|
|
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:
|
2016-05-09 17:12:13 +02:00
|
|
|
logger.error('%s %s %s %s: %s'%(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
|
|
|
|
|
2016-05-09 17:14:13 +02:00
|
|
|
# FIXME: make configurable. openSUSE:Factory:ARM currently has multiple
|
|
|
|
# repos with release targets, so obs needs to know which one to release
|
|
|
|
if project == 'openSUSE:Factory:ARM':
|
|
|
|
query['repository'] = 'images'
|
|
|
|
|
2014-09-12 11:42:42 +02:00
|
|
|
baseurl = ['source', project, package]
|
|
|
|
|
|
|
|
url = self.api.makeurl(baseurl, query=query)
|
2015-04-14 13:39:48 +02:00
|
|
|
if self.dryrun:
|
2016-05-09 17:12:13 +02:00
|
|
|
logger.info("release %s/%s (%s)"%(project, package, set_release))
|
2015-04-14 13:39:48 +02:00
|
|
|
else:
|
|
|
|
self.api.retried_POST(url)
|
2014-09-12 11:42:42 +02:00
|
|
|
|
|
|
|
def update_totest(self, snapshot):
|
2016-05-09 17:12:13 +02:00
|
|
|
logger.info('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):
|
2016-05-09 17:12:13 +02:00
|
|
|
logger.info('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)
|
2016-03-23 16:09:27 +01:00
|
|
|
current_qa_version = self.api.load_file_content("%s:Staging" % self.api.project, "dashboard", "version_totest")
|
2014-09-12 15:05:57 +02:00
|
|
|
|
2016-05-09 17:12:13 +02:00
|
|
|
logger.info('current_snapshot %s: %s'%(current_snapshot, self._result2str(current_result)))
|
|
|
|
logger.debug('new_snapshot %s', new_snapshot)
|
2016-06-03 14:39:56 +02:00
|
|
|
logger.debug('current_qa_version %s', current_qa_version)
|
2014-09-12 15:05:57 +02:00
|
|
|
|
2015-07-01 11:48:23 +02:00
|
|
|
snapshotable = self.factory_snapshottable()
|
2016-05-09 17:12:13 +02:00
|
|
|
logger.debug("snapshotable: %s", snapshotable)
|
2015-07-01 11:48:23 +02:00
|
|
|
can_release = (current_result != QA_INPROGRESS and snapshotable)
|
2015-02-20 13:18:09 +01:00
|
|
|
|
2014-09-12 11:42:42 +02:00
|
|
|
# not overwriting
|
|
|
|
if new_snapshot == current_snapshot:
|
2016-05-09 17:12:13 +02:00
|
|
|
logger.debug("no change in snapshot version")
|
2014-09-12 11:42:42 +02:00
|
|
|
can_release = False
|
|
|
|
elif not self.all_repos_done('openSUSE:%s:ToTest' % self.project):
|
2016-05-09 17:12:13 +02:00
|
|
|
logger.debug("not all repos done, can't release")
|
2014-09-12 11:42:42 +02:00
|
|
|
# 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():
|
2016-05-09 17:12:13 +02:00
|
|
|
logger.debug("totest already publishing")
|
2014-09-12 11:42:42 +02:00
|
|
|
can_publish = False
|
|
|
|
|
2015-04-14 13:39:48 +02:00
|
|
|
if can_publish:
|
2016-03-23 16:09:27 +01:00
|
|
|
if current_qa_version == current_snapshot:
|
|
|
|
self.publish_factory_totest()
|
|
|
|
self.write_version_to_dashboard("snapshot", current_snapshot)
|
|
|
|
can_release = False # we have to wait
|
|
|
|
else:
|
|
|
|
# We reached a very bad status: openQA testing is 'done', but not of the same version
|
|
|
|
# currently in :ToTest. This can happen when 'releasing' the product failed
|
|
|
|
raise Exception("Publishing stopped: tested version (%s) does not match :ToTest version (%s)"
|
|
|
|
% (current_qa_version, current_snapshot))
|
2014-09-12 11:42:42 +02:00
|
|
|
|
2015-04-14 13:39:48 +02:00
|
|
|
if can_release:
|
2014-09-16 09:12:08 +02:00
|
|
|
self.update_totest(new_snapshot)
|
2015-11-20 07:05:49 +01:00
|
|
|
self.write_version_to_dashboard("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 = []
|
2016-02-19 09:25:29 +01:00
|
|
|
if self.project == "Factory:PowerPC":
|
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-11-19 16:09:44 +01:00
|
|
|
def write_version_to_dashboard(self, target, version):
|
2015-11-20 07:05:49 +01:00
|
|
|
if not self.dryrun:
|
|
|
|
url = self.api.makeurl(['source', 'openSUSE:%s:Staging' % self.project, 'dashboard', 'version_%s' % target])
|
|
|
|
osc.core.http_PUT(url + '?comment=Update+version', data=version)
|
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']
|
|
|
|
|
2015-07-01 11:48:23 +02:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
ToTestBase.__init__(self, *args, **kwargs)
|
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-05-27 13:26:29 +02:00
|
|
|
|
2015-03-19 09:58:46 +01:00
|
|
|
class ToTestFactoryPowerPC(ToTestBase):
|
2015-06-08 17:41:30 +02:00
|
|
|
main_products = ['_product:openSUSE-dvd5-dvd-ppc64',
|
|
|
|
'_product:openSUSE-dvd5-dvd-ppc64le',
|
2015-03-19 09:58:46 +01:00
|
|
|
'_product:openSUSE-cd-mini-ppc64',
|
|
|
|
'_product:openSUSE-cd-mini-ppc64le']
|
|
|
|
|
2016-02-11 18:54:12 +01:00
|
|
|
ftp_products = [ '_product:openSUSE-ftp-ftp-ppc64_ppc64le' ]
|
2015-03-19 09:58:46 +01:00
|
|
|
|
2015-03-21 16:06:18 +01:00
|
|
|
livecd_products = []
|
|
|
|
|
2015-07-01 11:48:23 +02:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
ToTestBase.__init__(self, *args, **kwargs)
|
2015-03-19 09:58:46 +01:00
|
|
|
|
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-04-08 15:24:36 +02:00
|
|
|
class ToTestFactoryARM(ToTestFactory):
|
2015-10-12 18:05:14 +02:00
|
|
|
main_products = [ '_product:openSUSE-cd-mini-aarch64',
|
|
|
|
'_product:openSUSE-dvd5-dvd-aarch64' ]
|
2015-04-08 15:24:36 +02:00
|
|
|
|
|
|
|
ftp_products = [ '_product:openSUSE-ftp-ftp-aarch64' ]
|
|
|
|
|
|
|
|
livecd_products = []
|
|
|
|
|
2015-07-01 11:48:23 +02:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
ToTestFactory.__init__(self, *args, **kwargs)
|
2015-04-08 15:24:36 +02:00
|
|
|
|
|
|
|
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
|
|
|
def current_version(self):
|
2015-05-03 16:08:22 +02:00
|
|
|
return self.ftp_tree_version('_product:openSUSE-ftp-ftp-i586_x86_64')
|
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):
|
2015-07-01 11:48:23 +02:00
|
|
|
level = None
|
2015-04-14 13:39:48 +02:00
|
|
|
if (self.options.debug):
|
2015-07-01 11:48:23 +02:00
|
|
|
level = logging.DEBUG
|
2015-04-14 13:39:48 +02:00
|
|
|
elif (self.options.verbose):
|
2015-07-01 11:48:23 +02:00
|
|
|
level = logging.INFO
|
2016-05-09 17:12:13 +02:00
|
|
|
logging.basicConfig(level=level, format='%(asctime)s - %(module)s:%(lineno)d - %(levelname)s - %(message)s')
|
2015-04-14 13:39:48 +02:00
|
|
|
|
|
|
|
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))
|
2015-06-26 09:09:39 +02:00
|
|
|
raise cmdln.CmdlnUserError(msg)
|
2015-04-14 13:39:48 +02:00
|
|
|
|
2016-05-09 17:12:13 +02:00
|
|
|
return self.totest_class[project](project, self.options.dry)
|
2015-04-14 13:39:48 +02:00
|
|
|
|
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:
|
2016-05-09 17:12:13 +02:00
|
|
|
logger.error(e)
|
2015-04-20 15:00:02 +02:00
|
|
|
|
|
|
|
if opts.interval:
|
2016-05-09 17:12:13 +02:00
|
|
|
logger.info("sleeping %d minutes. Press enter to check now ..."%opts.interval)
|
2015-04-20 15:00:02 +02:00
|
|
|
signal.alarm(opts.interval*60)
|
|
|
|
try:
|
|
|
|
raw_input()
|
|
|
|
except ExTimeout:
|
|
|
|
pass
|
|
|
|
signal.alarm(0)
|
2016-05-09 17:12:13 +02:00
|
|
|
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
|