[llvm-commits] [zorg] r99165 - in /zorg/trunk/lnt/lnt: import/ImportData import/NTAuxSubmit import/NTEmailReport.py import/ServerUtil.py import/SubmitData lnttool/__init__.py util/ util/NTAuxSubmit util/NTEmailReport.py util/ServerUtil.py
Daniel Dunbar
daniel at zuster.org
Mon Mar 22 00:18:34 PDT 2010
Author: ddunbar
Date: Mon Mar 22 02:18:34 2010
New Revision: 99165
URL: http://llvm.org/viewvc/llvm-project?rev=99165&view=rev
Log:
LNT: Move some import tools to lnt.util, and move SubmitData to 'lnt submit'.
Added:
zorg/trunk/lnt/lnt/util/
zorg/trunk/lnt/lnt/util/NTAuxSubmit
- copied, changed from r99164, zorg/trunk/lnt/lnt/import/NTAuxSubmit
zorg/trunk/lnt/lnt/util/NTEmailReport.py
- copied, changed from r99164, zorg/trunk/lnt/lnt/import/NTEmailReport.py
zorg/trunk/lnt/lnt/util/ServerUtil.py
- copied, changed from r99164, zorg/trunk/lnt/lnt/import/ServerUtil.py
Removed:
zorg/trunk/lnt/lnt/import/NTAuxSubmit
zorg/trunk/lnt/lnt/import/NTEmailReport.py
zorg/trunk/lnt/lnt/import/ServerUtil.py
zorg/trunk/lnt/lnt/import/SubmitData
Modified:
zorg/trunk/lnt/lnt/import/ImportData
zorg/trunk/lnt/lnt/lnttool/__init__.py
Modified: zorg/trunk/lnt/lnt/import/ImportData
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/import/ImportData?rev=99165&r1=99164&r2=99165&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/import/ImportData (original)
+++ zorg/trunk/lnt/lnt/import/ImportData Mon Mar 22 02:18:34 2010
@@ -13,6 +13,7 @@
from lnt import formats, viewer
from lnt.viewer import Util, PerfDB
+from lnt.util import NTEmailReport
def main():
global opts
@@ -99,7 +100,6 @@
print " INFO : %r = %r" % (ri.key, ri.value)
if opts.emailOnImport and (success or opts.alwaysEmail):
- import NTEmailReport
print "\nMAILING RESULTS TO: %r\n" % opts.emailReportTo
NTEmailReport.emailReport(db, run,
opts.emailReportURL,
Removed: zorg/trunk/lnt/lnt/import/NTAuxSubmit
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/import/NTAuxSubmit?rev=99164&view=auto
==============================================================================
--- zorg/trunk/lnt/lnt/import/NTAuxSubmit (original)
+++ zorg/trunk/lnt/lnt/import/NTAuxSubmit (removed)
@@ -1,56 +0,0 @@
-#!/usr/bin/env python
-
-"""
-Command line tool for submitting to a LNT server.
-
-This script is explicitly designed to work with llvm/utils/NewNightlyTest.pl's
--submit-aux argument. It simply uploads the data to the server, and assumes the
-server will sort out any input conversion issues.
-
-This script should be totally free-standing; it is designed so users can svn
-export it directly from the LLVM repository as part of their submission scripts.
-"""
-
-import plistlib
-import sys
-import urllib
-import urllib2
-
-def main():
- global opts
- from optparse import OptionParser
- parser = OptionParser("usage: %prog {nightlytest sentdata.txt}*")
- parser.add_option("", "--commit", dest="commit", type=int,
- default=True)
-
- # FIXME: It would be nice to support an easy mechanism for localized
- # instances of the LNT infrastructure to default to the correct server for
- # their installation.
- parser.add_option("", "--server", dest="serverUrl", type=str,
- default="http://llvm.org/perf/db_default/submitRun")
-
- opts,args = parser.parse_args()
-
- if not args:
- parser.error("no input files")
-
- for inputFile in args:
- print '%s: note: submitting %s' % (sys.argv[0], inputFile)
-
- # Encode the form data.
- f = open(inputFile, 'rb')
- values = { 'input_data' : f.read(),
- 'commit' : ("0","1")[not not commit] }
- f.close()
- data = urllib.urlencode(values)
-
- # Send it off.
- response = urllib2.urlopen(urllib2.Request(url, data))
- the_page = response.read()
-
- # FIXME: Parse results and return proper error code.
- print the_page
-
-
-if __name__ == '__main__':
- main()
Removed: zorg/trunk/lnt/lnt/import/NTEmailReport.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/import/NTEmailReport.py?rev=99164&view=auto
==============================================================================
--- zorg/trunk/lnt/lnt/import/NTEmailReport.py (original)
+++ zorg/trunk/lnt/lnt/import/NTEmailReport.py (removed)
@@ -1,235 +0,0 @@
-#!/usr/bin/python
-
-"""
-Command line tool for sending an LNT email report.
-"""
-
-# FIXME: Roll into lnttool or just kill?
-
-import os
-import smtplib
-import sys
-
-import StringIO
-from lnt import viewer
-from lnt.viewer import PerfDB
-from lnt.viewer.NTUtil import *
-
-def main():
- global opts
- from optparse import OptionParser
- parser = OptionParser("usage: %prog database run-id baseurl sendmail-host from to")
- opts,args = parser.parse_args()
-
- if len(args) != 6:
- parser.error("incorrect number of argments")
-
- dbpath,runID,baseurl,host,from_,to = args
-
- db = PerfDB.PerfDB(dbpath)
- run = db.getRun(int(runID))
-
- emailReport(db, run, baseurl, host, from_, to)
-
-def emailReport(db, run, baseurl, host, from_, to, was_added=True,
- will_commit=True):
- import email.mime.text
-
- subject, report = getReport(db, run, baseurl, was_added, will_commit)
-
- msg = email.mime.text.MIMEText(report)
- msg['Subject'] = subject
- msg['From'] = from_
- msg['To'] = to
-
- s = smtplib.SMTP(host)
- s.sendmail(from_, [to], msg.as_string())
- s.quit()
-
-def findPreceedingRun(query, run):
- """findPreceedingRun - Find the most recent run in query which
- preceeds run."""
- best = None
- for r in query:
- # Restrict to nightlytest runs.
- if 'tag' in r.info and r.info['tag'].value != 'nightlytest':
- continue
-
- # Select most recent run prior to the one we are reporting on.
- if (r.start_time < run.start_time and
- (best is None or r.start_time > best.start_time)):
- best = r
- return best
-
-def getReport(db, run, baseurl, was_added, will_commit):
- report = StringIO.StringIO()
-
- machine = run.machine
- compareTo = None
-
- # Find comparison run.
- # FIXME: Share this code with similar stuff in the viewer.
- # FIXME: Scalability.
- compareCrossesMachine = False
- compareTo = findPreceedingRun(db.runs(machine=machine), run)
-
- # If we didn't find a comparison run against this machine, look
- # for a comparison run against the same machine name, and warn the
- # user we are crosses machines.
- if compareTo is None:
- compareCrossesMachine = True
- q = db.session.query(PerfDB.Run).join(PerfDB.Machine)
- q = q.filter_by(name=machine.name)
- compareTo = findPreceedingRun(q, run)
-
- summary = RunSummary()
- summary.addRun(db, run)
- if compareTo:
- summary.addRun(db, compareTo)
-
- def getTestValue(run, testname, keyname):
- fullname = 'nightlytest.' + testname + '.' + keyname
- t = summary.testMap.get(str(fullname))
- if t is None:
- return None
- samples = summary.getRunSamples(run).get(t.id)
- if not samples:
- return None
- return samples[0]
- def getTestSuccess(run, testname, keyname):
- res = getTestValue(run, testname, keyname + '.success')
- if res is None:
- return res
- return not not res
-
- newPasses = Util.multidict()
- newFailures = Util.multidict()
- addedTests = Util.multidict()
- removedTests = Util.multidict()
- allTests = set()
- allFailures = set()
- allFailuresByKey = Util.multidict()
- for keyname,title in kTSKeys.items():
- for testname in summary.testNames:
- curResult = getTestSuccess(run, testname, keyname)
- prevResult = getTestSuccess(compareTo, testname, keyname)
-
- if curResult is not None:
- allTests.add((testname,keyname))
- if curResult is False:
- allFailures.add((testname,keyname))
- allFailuresByKey[title] = testname
-
- # Count as new pass if it passed, and previous result was failure.
- if curResult and prevResult == False:
- newPasses[testname] = title
-
- # Count as new failure if it failed, and previous result was not
- # failure.
- if curResult == False and prevResult != False:
- newFailures[testname] = title
-
- if curResult is not None and prevResult is None:
- addedTests[testname] = title
- if curResult is None and prevResult is not None:
- removedTests[testname] = title
-
- changes = Util.multidict()
- for i,(name,key) in enumerate(kComparisonKinds):
- if not key:
- # FIXME: File Size
- continue
-
- for testname in summary.testNames:
- curValue = getTestValue(run, testname, key)
- prevValue = getTestValue(compareTo, testname, key)
-
- # Skip missing tests.
- if curValue is None or prevValue is None:
- continue
-
- pct = Util.safediv(curValue, prevValue)
- if pct is None:
- continue
- pctDelta = pct - 1.
- if abs(pctDelta) < .05:
- continue
- if min(prevValue, curValue) <= .2:
- continue
-
- changes[name] = (testname, curValue, prevValue, pctDelta)
-
- if will_commit:
- if not was_added:
- print >>report, ("*** NOTE ***: This was a duplicate submission, "
- "and did not modify the database.\n")
- else:
- if was_added:
- print >>report, ("*** NOTE ***: This is a test submission, "
- "it will not be committed to the database.\n")
- else:
- print >>report, ("*** NOTE ***: This is a test submission, "
- "and was a duplicate of an existing run.\n")
-
- if baseurl[-1] == '/':
- baseurl = baseurl[:-1]
- print >>report, """%s/%d/""" % (baseurl, run.id)
- print >>report, """Name: %s""" % (machine.info['name'].value,)
- print >>report, """Nickname: %s:%d""" % (machine.name, machine.number)
- print >>report
- print >>report, """Run: %d, Start Time: %s, End Time: %s""" % (
- run.id, run.start_time, run.end_time)
- if compareTo:
- print >>report, """Comparing To: %d, Start Time: %s, End Time: %s""" % (
- compareTo.id, compareTo.start_time, compareTo.end_time)
- if compareCrossesMachine:
- print >>report, """*** WARNING ***:""",
- print >>report, """comparison is against a different machine""",
- print >>report, """(%s:%d)""" % (compareTo.machine.name,
- compareTo.machine.number)
- else:
- print >>report, """Comparing To: (none)"""
- print >>report
-
- print >>report, """--- Changes Summary ---"""
- for title,elts in (('New Test Passes', newPasses),
- ('New Test Failures', newFailures),
- ('Added Tests', addedTests),
- ('Removed Tests', removedTests)):
- print >>report, """%s: %d""" % (title,
- sum([len(values)
- for key,values in elts.items()]))
- numSignificantChanges = sum([len(changelist)
- for name,changelist in changes.items()])
- print >>report, """Significant Changes: %d""" % (numSignificantChanges,)
- print >>report
- print >>report, """--- Tests Summary ---"""
- print >>report, """Total Tests: %d""" % (len(allTests),)
- print >>report, """Total Test Failures: %d""" % (len(allFailures),)
- print >>report
- print >>report, """Total Test Failures By Type:"""
- for name,items in Util.sorted(allFailuresByKey.items()):
- print >>report, """ %s: %d""" % (name, len(set(items)))
-
- print >>report
- print >>report, """--- Changes Detail ---"""
- for title,elts in (('New Test Passes', newPasses),
- ('New Test Failures', newFailures),
- ('Added Tests', addedTests),
- ('Removed Tests', removedTests)):
- print >>report, """%s:""" % (title,)
- print >>report, "".join("%s [%s]\n" % (key, ", ".join(values))
- for key,values in Util.sorted(elts.items()))
- print >>report, """Significant Changes in Test Results:"""
- for name,changelist in changes.items():
- print >>report, """%s:""" % name
- for name,curValue,prevValue,delta in Util.sorted(changelist):
- print >>report, """ %s: %.2f%% (%.4f => %.4f)""" % (
- name, delta*100, prevValue, curValue)
-
- # FIXME: Where is the old mailer getting the arch from?
- subject = """%s nightly tester results""" % machine.name
- return subject,report.getvalue()
-
-if __name__ == '__main__':
- main()
Removed: zorg/trunk/lnt/lnt/import/ServerUtil.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/import/ServerUtil.py?rev=99164&view=auto
==============================================================================
--- zorg/trunk/lnt/lnt/import/ServerUtil.py (original)
+++ zorg/trunk/lnt/lnt/import/ServerUtil.py (removed)
@@ -1,20 +0,0 @@
-"""
-Utility for submitting files to a web server over HTTP.
-"""
-
-import plistlib
-import urllib
-import urllib2
-
-def submitFiles(url, files, commit):
- for file in files:
- f = open(file, 'rb')
- values = { 'input_data' : f.read(),
- 'commit' : ("0","1")[not not commit] }
- f.close()
-
- data = urllib.urlencode(values)
- response = urllib2.urlopen(urllib2.Request(url, data))
- the_page = response.read()
-
- print the_page
Removed: zorg/trunk/lnt/lnt/import/SubmitData
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/import/SubmitData?rev=99164&view=auto
==============================================================================
--- zorg/trunk/lnt/lnt/import/SubmitData (original)
+++ zorg/trunk/lnt/lnt/import/SubmitData (removed)
@@ -1,25 +0,0 @@
-#!/usr/bin/python
-
-"""
-Command line utility for submitting an LNT plist file to a LNT server.
-"""
-
-# FIXME: Roll into lnttool and kill. See also refactor conversion code.
-
-import ServerUtil
-
-def main():
- global opts
- from optparse import OptionParser
- parser = OptionParser("usage: %prog serverUrl files+")
- parser.add_option("", "--commit", dest="commit", type=int,
- default=False)
- opts,args = parser.parse_args()
-
- if len(args) < 2:
- parser.error("incorrect number of argments")
-
- ServerUtil.submitFiles(args[0], args[1:], opts.commit)
-
-if __name__ == '__main__':
- main()
Modified: zorg/trunk/lnt/lnt/lnttool/__init__.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/lnttool/__init__.py?rev=99165&r1=99164&r2=99165&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/lnttool/__init__.py (original)
+++ zorg/trunk/lnt/lnt/lnttool/__init__.py Mon Mar 22 02:18:34 2010
@@ -47,6 +47,23 @@
from create import action_create
from convert import action_convert
+def action_submit(name, args):
+ """submit a test report to the server."""
+
+ from optparse import OptionParser, OptionGroup
+ parser = OptionParser("%%prog %s [options] url files+" % name)
+ parser.add_option("", "--commit", dest="commit", type=int,
+ default=False)
+
+ (opts, args) = parser.parse_args(args)
+ if len(args) < 2:
+ parser.error("incorrect number of argments")
+
+ from lnt.util import ServerUtil
+ ServerUtil.submitFiles(args[0], args[1:], opts.commit)
+
+###
+
commands = dict((name[7:], f) for name,f in locals().items()
if name.startswith('action_'))
Copied: zorg/trunk/lnt/lnt/util/NTAuxSubmit (from r99164, zorg/trunk/lnt/lnt/import/NTAuxSubmit)
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/NTAuxSubmit?p2=zorg/trunk/lnt/lnt/util/NTAuxSubmit&p1=zorg/trunk/lnt/lnt/import/NTAuxSubmit&r1=99164&r2=99165&rev=99165&view=diff
==============================================================================
(empty)
Copied: zorg/trunk/lnt/lnt/util/NTEmailReport.py (from r99164, zorg/trunk/lnt/lnt/import/NTEmailReport.py)
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/NTEmailReport.py?p2=zorg/trunk/lnt/lnt/util/NTEmailReport.py&p1=zorg/trunk/lnt/lnt/import/NTEmailReport.py&r1=99164&r2=99165&rev=99165&view=diff
==============================================================================
(empty)
Copied: zorg/trunk/lnt/lnt/util/ServerUtil.py (from r99164, zorg/trunk/lnt/lnt/import/ServerUtil.py)
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/ServerUtil.py?p2=zorg/trunk/lnt/lnt/util/ServerUtil.py&p1=zorg/trunk/lnt/lnt/import/ServerUtil.py&r1=99164&r2=99165&rev=99165&view=diff
==============================================================================
(empty)
More information about the llvm-commits
mailing list