Author: gnichols
Date: 2010-06-07 09:48:44 +0000 (Mon, 07 Jun 2010)
New Revision: 520
Modified:
trunk/v7/hardwaretest.py
Log:
599108 - FEAT: v7 should provide a way to continue a test run
Modified: trunk/v7/hardwaretest.py
===================================================================
--- trunk/v7/hardwaretest.py 2010-06-02 00:11:21 UTC (rev 519)
+++ trunk/v7/hardwaretest.py 2010-06-07 09:48:44 UTC (rev 520)
@@ -43,7 +43,7 @@
from v7.command import Command, V7CommandException
from v7.resultsengine import ResultsEngine
from v7.redhatrelease import RedHatRelease
-
+from v7.daemon import V7Daemon
class HardwareTestHarness(Controller):
@@ -58,7 +58,18 @@
self.debugLevel = self.options.debug # "off", "low", "medium", or 'high'
self.certification = None
self.runMode = self.options.mode
- self.commands = "plan", "run", "print", "submit", "certify", "server", "test", "version", "clean", "save"
+
+ self.commands = {'plan': self.doPlan,
+ 'certify': self.doCertify,
+ 'run': self.doRun,
+ 'continue': self.doContinue,
+ 'print': self.doPrint,
+ 'save': self.doSave,
+ 'submit': self.doSubmit ,
+ 'clean': self.doClean,
+ 'server': self.doServer,
+ 'version': self.doVersion,
+ }
def getOptions(self):
usage = "usage: %prog <command> [options]\n\ncommand:\n"\
@@ -68,6 +79,7 @@
"\tsubmit \t- submit certification test results\n"\
"\tclean \t- remove all results and temporary files\n"\
"\trun \t- run specific certification tests\n"\
+ "\tcontinue \t- continue a test run\n"\
"\tversion\t- prints the version of v7\n"\
"\tserver (start | stop | status | daemon) - run v7 as a test server\n"
@@ -161,28 +173,18 @@
self.makeDirectoryPath(self.environment.getDataDirectory())
result = False
- if (command == 'plan'):
- result = self.doPlan()
- elif (command == 'certify'):
- result = self.doCertify()
- elif (command == 'run'):
- result = self.doRun()
- elif (command == 'print'):
- result = self.doPrint()
- elif (command == 'save'):
- result = self.doSave()
- elif (command == 'submit'):
- result = self.doSubmit()
- elif (command == 'clean'):
- result = self.doClean()
- elif (command == 'version'):
- print "V7 version %s, release %s" % (v7.version.version, v7.version.release)
- result = True
- else:
+ # do the command
+ try:
+ self.commands[command]()
+ except KeyError:
print "unknown command: " + command
self.releaseLock()
return result
+ def doVersion(self):
+ print "V7 version %s, release %s" % (v7.version.version, v7.version.release)
+ return True
+
def doWeb(self):
# note - web server does not observe locks
command = "print"
@@ -578,7 +580,16 @@
self._doRun(tests)
- def _doRun(self, tests):
+ def doContinue(self):
+ self.load()
+ tests = self.certification.getIncompleteTestsFromLastRun()
+ if len(tests) is 0:
+ print "All tests in the last test run are complete"
+ return False
+
+ return self._doRun(tests, continueRun=True)
+
+ def _doRun(self, tests, continueRun=False):
self.addMandatoryTests(tests)
@@ -605,18 +616,27 @@
# Make a log dir for this testrun
runDirectory=self.makeTestRunDirectory()
+ # create the new run, mark incomplete
+ if continueRun:
+ runNumber = self.certification.getNumberOfTestRuns()
+ else:
+ runNumber = None
+ for test in tests:
+ if not test.isDisabled():
+ if not runNumber:
+ runNumber = self.certification.addTestRun()
+ run = test.newTestRun()
+ run.setNumber(runNumber)
+ self.certification.save(self.environment.getResultsPath())
+
# Start testin'!
- noTestsHaveRun = True
for test in tests:
if test.isDisabled():
print "skipping %s - disabled" % test.getName()
continue
print ("running %s on %s") % (test.getName(),test.getUDI())
- run = test.newTestRun()
- if noTestsHaveRun:
- noTestsHaveRun = False
- self.certification.addTestRun()
+ run = test.getRun(runNumber)
run.setRunTime(self.getCurrentUTCTime())
if not run.getMode():
@@ -647,9 +667,12 @@
try:
returnValue = self.runTest(directory, test, run, outputFilePath)
run.getResults(self.environment, directory+"/test-result.xml")
+ self.certification.save(self.environment.getResultsPath())
+ print "saved to " + self.environment.getResultsPath()
+
if self.options.rhts:
self.reportToRHTS(test, run.getSummary(), outputFilePath)
-
+
except OSError, e:
print "Test error: %s" % e
syslog.syslog("Test error: %s" % e)
@@ -1040,8 +1063,8 @@
print "Warning: unknown device: %s " % key
# create one from scratch
device = HalDevice(dict())
- if self.options.udi:
- device.setUDI(self.options.udi)
+ if self.options.udi and len(self.options.udi) > 0:
+ device.setUDI(self.options.udi[0])
test.setDevice(device)
if self.options.device: