@ -19,18 +19,24 @@ from __future__ import print_function
from collections import defaultdict
from collections import defaultdict
from contextlib import closing
from contextlib import closing
import logging
import os
import os
import subprocess
import subprocess
import tempfile
import tempfile
from textwrap import dedent
from textwrap import dedent
import time
import time
import apt_pkg
import apt_pkg
adt_britney = os . path . expanduser ( " ~/auto-package-testing/jenkins/adt-britney " )
adt_britney = os . path . expanduser ( " ~/auto-package-testing/jenkins/adt-britney " )
ADT_PASS = [ " PASS " , " ALWAYSFAIL " ]
ADT_EXCUSES_LABELS = {
" PASS " : ' <span style= " background:#87d96c " >Pass</span> ' ,
" ALWAYSFAIL " : ' <span style= " background:#e5c545 " >Always failed</span> ' ,
" REGRESSION " : ' <span style= " background:#ff6666 " >Regression</span> ' ,
" RUNNING " : ' <span style= " background:#99ddff " >Test in progress</span> ' ,
}
class AutoPackageTest ( object ) :
class AutoPackageTest ( object ) :
""" autopkgtest integration
""" autopkgtest integration
@ -62,7 +68,7 @@ class AutoPackageTest(object):
components : main restricted universe multiverse
components : main restricted universe multiverse
rsync_host : rsync : / / tachash . ubuntu - ci / adt /
rsync_host : rsync : / / tachash . ubuntu - ci / adt /
datadir : ~ / proposed - migration / autopkgtest / data """ %
datadir : ~ / proposed - migration / autopkgtest / data """ %
( self . series , self . series , home ) ) , file = rc_file )
( self . series , self . series , home ) ) , file = rc_file )
@property
@property
def _request_path ( self ) :
def _request_path ( self ) :
@ -85,8 +91,7 @@ class AutoPackageTest(object):
continue
continue
linebits = line . split ( )
linebits = line . split ( )
if len ( linebits ) < 2 :
if len ( linebits ) < 2 :
logging . warning (
print ( " W: Invalid line format: ' %s ' , skipped " % line )
" Invalid line format: ' %s ' , skipped " % line )
continue
continue
yield linebits
yield linebits
@ -94,29 +99,21 @@ class AutoPackageTest(object):
self . pkglist = defaultdict ( dict )
self . pkglist = defaultdict ( dict )
self . pkgcauses = defaultdict ( lambda : defaultdict ( list ) )
self . pkgcauses = defaultdict ( lambda : defaultdict ( list ) )
for linebits in self . _parse ( self . _result_path ) :
for linebits in self . _parse ( self . _result_path ) :
src = linebits . pop ( 0 )
( src , ver , status ) = linebits [ : 3 ]
ver = linebits . pop ( 0 )
self . pkglist [ src ] [ ver ] = {
if not ( src in self . pkglist and ver in self . pkglist [ src ] ) :
" status " : " NEW " ,
self . pkglist [ src ] [ ver ] = {
" causes " : { } ,
" status " : status ,
" causes " : { }
}
}
try :
status = linebits . pop ( 0 ) . upper ( )
i = iter ( linebits [ 3 : ] )
self . pkglist [ src ] [ ver ] [ " status " ] = status
for trigsrc , trigver in zip ( i , i ) :
while True :
if not trigsrc in self . pkglist [ src ] [ ver ] [ ' causes ' ] :
trigsrc = linebits . pop ( 0 )
self . pkglist [ src ] [ ver ] [ ' causes ' ] [ trigsrc ] = [ ]
trigver = linebits . pop ( 0 )
self . pkglist [ src ] [ ver ] [ ' causes ' ] [ trigsrc ] . append ( ( trigver ,
self . pkglist [ src ] [ ver ] [ " causes " ] [ trigsrc ] = trigver
status ) )
except IndexError :
self . pkgcauses [ trigsrc ] [ trigver ] . append ( ( status , src , ver ) )
# End of the list
pass
for src in self . pkglist :
all_vers = sorted ( self . pkglist [ src ] , cmp = apt_pkg . version_compare )
for ver in self . pkglist [ src ] :
status = self . pkglist [ src ] [ ver ] [ " status " ]
for trigsrc , trigver in \
self . pkglist [ src ] [ ver ] [ " causes " ] . items ( ) :
self . pkgcauses [ trigsrc ] [ trigver ] . append ( ( status , src , ver ) )
def _adt_britney ( self , * args ) :
def _adt_britney ( self , * args ) :
command = [
command = [
@ -197,12 +194,29 @@ class AutoPackageTest(object):
self . read ( )
self . read ( )
if self . britney . options . verbose :
if self . britney . options . verbose :
for src in sorted ( self . pkglist ) :
for src in sorted ( self . pkglist ) :
for ver in self . pkglist [ src ] :
for ver in sorted ( self . pkglist [ src ] ,
print ( " I: [ %s ] - Collected autopkgtest status for %s _ %s : "
cmp = apt_pkg . version_compare ) :
" %s " %
for trigsrc in sorted ( self . pkglist [ src ] [ ver ] [ ' causes ' ] ) :
( time . asctime ( ) , src , ver ,
for trigver , status \
self . pkglist [ src ] [ ver ] [ " status " ] ) )
in self . pkglist [ src ] [ ver ] [ ' causes ' ] [ trigsrc ] :
print ( " I: [ %s ] - Collected autopkgtest status "
" for %s _ %s / %s _ %s : " " %s " % (
time . asctime ( ) , src , ver , trigsrc ,
trigver , status ) )
def results ( self , trigsrc , trigver ) :
def results ( self , trigsrc , trigver ) :
for status , src , ver in self . pkgcauses [ trigsrc ] [ trigver ] :
for status , src , ver in self . pkgcauses [ trigsrc ] [ trigver ] :
# Check for regresssion
if status == ' FAIL ' :
passed_once = False
for ver in self . pkglist [ src ] :
for trigsrc in self . pkglist [ src ] [ ver ] [ ' causes ' ] :
for trigver , status \
in self . pkglist [ src ] [ ver ] [ ' causes ' ] [ trigsrc ] :
if status == ' PASS ' :
passed_once = True
if not passed_once :
status = ' ALWAYSFAIL '
else :
status = ' REGRESSION '
yield status , src , ver
yield status , src , ver