Now run also the benches. Added a "local" mode run.

This commit is contained in:
Jean-Paul Chaput 2015-06-14 16:23:11 +02:00
parent e9369ab905
commit fa1081275d
1 changed files with 126 additions and 43 deletions

View File

@ -32,6 +32,7 @@ try:
import traceback import traceback
import distutils.sysconfig import distutils.sysconfig
import subprocess import subprocess
import socket
import re import re
import smtplib import smtplib
from email.mime.text import MIMEText from email.mime.text import MIMEText
@ -193,14 +194,14 @@ class GitRepository ( object ):
return return
def openLog ( logDir ): def openLog ( logDir, stem ):
if not os.path.isdir(logDir): if not os.path.isdir(logDir):
os.makedirs( logDir ) os.makedirs( logDir )
index = 0 index = 0
timeTag = time.strftime( "%Y.%m.%d" ) timeTag = time.strftime( "%Y.%m.%d" )
while True: while True:
logFile = os.path.join(logDir,"install-%s-%02d.log" % (timeTag,index)) logFile = os.path.join(logDir,"%s-%s-%02d.log" % (stem,timeTag,index))
if not os.path.isfile(logFile): if not os.path.isfile(logFile):
print "Report log: <%s>" % logFile print "Report log: <%s>" % logFile
break break
@ -209,23 +210,28 @@ def openLog ( logDir ):
return (fd,logFile) return (fd,logFile)
def sendReport ( state, installLog ): def sendReport ( state, buildLog, benchsLog, nightlyBuild ):
sender = 'Jean-Paul.Chaput@soc.lip6.fr' sender = 'Jean-Paul.Chaput@soc.lip6.fr'
receiver = 'Jean-Paul.Chaput@lip6.fr' receiver = 'Jean-Paul.Chaput@lip6.fr'
date = time.strftime( "%A %d %B %Y" ) date = time.strftime( "%A %d %B %Y" )
stateText = 'FAILED' stateText = 'FAILED'
if state: stateText = 'SUCCESS' buildText = 'SoC installation'
if state: stateText = 'SUCCESS'
if nightlyBuild: buildText = 'Nightly build'
message = MIMEMultipart() message = MIMEMultipart()
message['Subject'] = '[%s] Coriolis & Chams Nightly build %s' % (stateText,date) message['Subject'] = '[%s] Coriolis & Chams %s %s' % (stateText,buildText,date)
message['From' ] = sender message['From' ] = sender
message['To' ] = receiver message['To' ] = receiver
mainText = '\n' mainText = '\n'
mainText += 'Salut le Crevard,\n' mainText += 'Salut le Crevard,\n'
mainText += '\n' mainText += '\n'
mainText += 'This is the nightly build report of Coriolis & Chams.\n' if nightlyBuild:
mainText += 'This is the nightly build report of Coriolis & Chams.\n'
else:
mainText += 'SoC installer report of Coriolis & Chams.\n'
mainText += '%s\n' % date mainText += '%s\n' % date
mainText += '\n' mainText += '\n'
if state: if state:
@ -234,11 +240,13 @@ def sendReport ( state, installLog ):
mainText += 'Build has FAILED, please have a look to the attached log file.\n' mainText += 'Build has FAILED, please have a look to the attached log file.\n'
mainText += '\n' mainText += '\n'
mainText += 'Complete log file can be found here:\n' mainText += 'Complete log file can be found here:\n'
mainText += ' <%s>\n' % installLog mainText += ' <%s>\n' % buildLog
if benchsLog:
mainText += ' <%s>\n' % benchsLog
mainText += '\n' mainText += '\n'
message.attach( MIMEText(mainText) ) message.attach( MIMEText(mainText) )
fd = open( installLog, 'rb' ) fd = open( buildLog, 'rb' )
fd.seek( -1024*100, os.SEEK_END ) fd.seek( -1024*100, os.SEEK_END )
tailLines = '' tailLines = ''
for line in fd.readlines()[1:]: for line in fd.readlines()[1:]:
@ -246,58 +254,114 @@ def sendReport ( state, installLog ):
message.attach( MIMEApplication(tailLines) ) message.attach( MIMEApplication(tailLines) )
fd.close() fd.close()
if benchsLog:
fd = open( benchsLog, 'rb' )
fd.seek( -1024*100, os.SEEK_END )
tailLines = ''
for line in fd.readlines()[1:]:
tailLines += line
message.attach( MIMEApplication(tailLines) )
fd.close()
session = smtplib.SMTP( 'localhost' ) session = smtplib.SMTP( 'localhost' )
session.sendmail( sender, receiver, message.as_string() ) session.sendmail( sender, receiver, message.as_string() )
session.quit() session.quit()
return return
def detectRunningHost ():
runningHost = 'unknown'
hostname = socket.gethostname()
hostAddr = socket.gethostbyname(hostname)
if hostname == 'lepka' and hostAddr == '127.0.0.1':
print 'Running on <lepka>, watchout mode enabled.'
runningHost = 'lepka'
else:
runningHost = hostname.split('.')[0]
return runningHost
# ------------------------------------------------------------------- # -------------------------------------------------------------------
# <socInstaller> Main Part. # <socInstaller> Main Part.
parser = optparse.OptionParser () parser = optparse.OptionParser ()
parser.add_option ( "--debug" , action="store_true" , dest="debug" , help="Build a <Debug> aka (-g) version." ) parser.add_option ( "--debug" , action="store_true" , dest="debug" , help="Build a <Debug> aka (-g) version." )
parser.add_option ( "--no-git" , action="store_true" , dest="noGit" , help="Do not pull/update Git repositories before building." )
parser.add_option ( "--no-report" , action="store_true" , dest="noReport" , help="Do not send a final report." )
parser.add_option ( "--nightly" , action="store_true" , dest="nightly" , help="Perform a nighly build." ) parser.add_option ( "--nightly" , action="store_true" , dest="nightly" , help="Perform a nighly build." )
parser.add_option ( "--benchs" , action="store_true" , dest="benchs" , help="Run the <alliance-checker-toolkit> sanity benchs." )
parser.add_option ( "--rm-build" , action="store_true" , dest="rmBuild" , help="Remove the build/install directories." ) parser.add_option ( "--rm-build" , action="store_true" , dest="rmBuild" , help="Remove the build/install directories." )
parser.add_option ( "--rm-source" , action="store_true" , dest="rmSource" , help="Remove the Git source repositories." ) parser.add_option ( "--rm-source" , action="store_true" , dest="rmSource" , help="Remove the Git source repositories." )
parser.add_option ( "--rm-all" , action="store_true" , dest="rmAll" , help="Remove everything (source+build+install)." ) parser.add_option ( "--rm-all" , action="store_true" , dest="rmAll" , help="Remove everything (source+build+install)." )
parser.add_option ( "--root" , action="store" , type="string", dest="rootDir" , help="The root directory (default: <~/coriolis-2.x/>)." ) parser.add_option ( "--root" , action="store" , type="string", dest="rootDir" , help="The root directory (default: <~/coriolis-2.x/>)." )
(options, args) = parser.parse_args () (options, args) = parser.parse_args ()
fdLog = None nightlyBuild = False
logFile = None fdBuildLog = None
fdBenchsLog = None
buildLogFile = None
benchsLogFile = None
try: try:
nightlyBuild = False
rmSource = False rmSource = False
rmBuild = False rmBuild = False
doGit = True
doBench = False
doSendReport = True
debugArg = '' debugArg = ''
runningHost = detectRunningHost()
targetSL6 = 'rock'
targetSL6_64 = 'bip'
targetSL7_64 = None
if options.debug: debugArg = '--debug' if options.debug: debugArg = '--debug'
if options.nightly: nightlyBuild = True if options.nightly: nightlyBuild = True
if options.noGit: doGit = False
if options.benchs: doBenchs = True
if options.noReport: doSendReport = False
if options.rmSource or options.rmAll: rmSource = True if options.rmSource or options.rmAll: rmSource = True
if options.rmBuild or options.rmAll: rmBuild = True if options.rmBuild or options.rmAll: rmBuild = True
coriolisRepo = 'https://www-soc.lip6.fr/git/coriolis.git' if runningHost == 'lepka':
chamsRepo = 'file:///users/outil/chams/chams.git' print 'Never touch the Git tree when running on <lepka>.'
homeDir = os.environ['HOME'] doGit = False
rootDir = homeDir + '/coriolis-2.x' rmSource = False
rmBuild = False
targetSL7_64 = 'lepka'
targetSL6 = None
targetSL6_64 = None
if nightlyBuild: if nightlyBuild:
rootDir = homeDir + '/nightly/coriolis-2.x' targetSL6 = None
srcDir = rootDir + '/src'
logDir = rootDir + '/log'
allianceCheckRepo = 'https://www-soc.lip6.fr/git/alliance-check-toolkit.git'
coriolisRepo = 'https://www-soc.lip6.fr/git/coriolis.git'
chamsRepo = 'file:///users/outil/chams/chams.git'
homeDir = os.environ['HOME']
rootDir = homeDir + '/coriolis-2.x'
if nightlyBuild:
rootDir = homeDir + '/nightly/coriolis-2.x'
srcDir = rootDir + '/src'
logDir = srcDir + '/logs'
gitCoriolis = GitRepository( coriolisRepo, srcDir ) gitCoriolis = GitRepository( coriolisRepo , srcDir )
if rmSource: gitCoriolis.removeLocalRepo() gitChams = GitRepository( chamsRepo , srcDir )
gitCoriolis.clone () gitAllianceCheck = GitRepository( allianceCheckRepo, srcDir )
gitCoriolis.checkout( 'devel' )
gitChams = GitRepository( chamsRepo, srcDir ) if doGit:
if rmSource: gitChams.removeLocalRepo() if rmSource: gitCoriolis.removeLocalRepo()
gitChams.clone () gitCoriolis.clone ()
gitChams.checkout( 'devel' ) gitCoriolis.checkout( 'devel' )
if rmSource: gitChams.removeLocalRepo()
gitChams.clone ()
gitChams.checkout( 'devel' )
if rmSource: AllianceCheck.removeLocalRepo()
AllianceCheck.clone ()
if rmBuild: if rmBuild:
for entry in os.listdir(rootDir): for entry in os.listdir(rootDir):
@ -312,32 +376,51 @@ try:
, ' <%s>' % ccbBin , ' <%s>' % ccbBin
] ) ] )
commandFormat = '%s --root=%s --project=coriolis --project=chams --devtoolset-2 --make="-j%%d install" %%s' \ fdBuildLog,buildLogFile = openLog( logDir, 'build' )
% (ccbBin,rootDir) if doBenchs:
fdBenchsLog,benchsLogFile = openLog( logDir, 'benchs' )
commands = [ ( 'bip', commandFormat % (6,debugArg) ) buildCommand = '%s --root=%s --project=coriolis --project=chams --make="-j%%d install" %%s' \
, ( 'bip', commandFormat % (1,debugArg+' --doc') ) % (ccbBin,rootDir)
] benchsCommand = 'cd %s/benchs && ./bin/go.sh clean && ./bin/go.sh lvx' \
if not nightlyBuild: % (gitAllianceCheck.localRepoDir)
commands = [ ( 'rock', commandFormat % (2,debugArg) )
, ( 'rock', commandFormat % (1,debugArg+' --doc') ) if targetSL7_64:
commands = [ ( targetSL7_64, buildCommand % (3,debugArg) , fdBuildLog )
, ( targetSL7_64, buildCommand % (1,debugArg+' --doc'), fdBuildLog )
] ]
if doBenchs:
commands += [ ( targetSL7_64, benchsCommand, fdBenchsLog ) ]
if targetSL6_64:
commands = [ ( targetSL6_64, buildCommand % (6,debugArg+' --devtoolset-2') , fdBuildLog )
, ( targetSL6_64, buildCommand % (1,debugArg+' --devtoolset-2 --doc'), fdBuildLog )
]
if doBenchs:
commands += [ ( targetSL6_64, benchsCommand, fdBenchsLog ) ]
if targetSL6:
commands = [ ( targetSL6, buildCommand % (2,debugArg+' --devtoolset-2') , fdBuildLog )
, ( targetSL6, buildCommand % (1,debugArg+' --devtoolset-2 --doc'), fdBuildLog )
]
if doBenchs:
commands += [ ( targetSL6, benchsCommand, fdBenchsLog ) ]
fdLog,logFile = openLog( logDir ) for host,command,fd in commands:
Command( [ 'ssh', host, command ], fd ).execute()
for host,command in commands: fdBuildLog.close()
Command( [ 'ssh', host, command ], fdLog ).execute() if doBenchs: fdBenchsLog.close()
fdLog.close() if doSendReport:
sendReport( True, logFile ) sendReport( True, buildLogFile, benchsLogFile, nightlyBuild )
except ErrorMessage, e: except ErrorMessage, e:
print e print e
if fdLog: fdLog.close() if fdBuildLog: fdBuildLog.close()
if fdBenchsLog: fdBenchsLog.close()
if showTrace: if showTrace:
print '\nPython stack trace:' print '\nPython stack trace:'
traceback.print_tb( sys.exc_info()[2] ) traceback.print_tb( sys.exc_info()[2] )
sendReport( False, logFile ) sendReport( False, buildLogFile, benchsLogFile, nightlyBuild )
sys.exit( e.code ) sys.exit( e.code )
sys.exit( 0 ) sys.exit( 0 )