--HG--
branch : 1.0
This commit is contained in:
Robert Helmer 2011-01-05 15:11:31 -08:00
Родитель 9610920526 3c3b2e19c0
Коммит ce1b62ecb7
4 изменённых файлов: 163 добавлений и 8 удалений

Просмотреть файл

@ -1,5 +1,3 @@
import csv, datetime, time, os
def analyze(data):
n = len(data)
if n > 1:
@ -20,6 +18,7 @@ def analyze(data):
variance = 0.0
return {"avg": avg, "n": n, "variance": variance}
def calc_t(w1, w2):
if len(w1) == 0 or len(w2) == 0:
return 0
@ -56,7 +55,7 @@ class PerfDatum(object):
def __cmp__(self, o):
return cmp(
(self.time, self.timestamp),
(o.time, o.timestamp)
(o.time, o.timestamp),
)
def __eq__(self, o):
@ -74,6 +73,7 @@ class PerfDatum(object):
def __str__(self):
return "Build %s on %s %s %s %s" % (self.buildid, self.timestamp, self.time, self.value, self.machine_id)
class TalosAnalyzer:
def __init__(self):
# List of PerfDatum instances
@ -146,4 +146,3 @@ class TalosAnalyzer:
# adjust to the new baseline.
good_data.append(di)
yield di, "regression"

Просмотреть файл

@ -1,4 +1,3 @@
import sys
import sqlalchemy as sa
from sqlalchemy.ext.sqlsoup import SqlSoup
@ -26,6 +25,9 @@ class TestSeries:
return "%s %s %s" % (self.branch_name, self.os_name, self.test_shortname)
db = None
goodNameClause = None
def connect(url):
global db
db = SqlSoup(url)
@ -33,6 +35,7 @@ def connect(url):
global goodNameClause
goodNameClause = db.machines.is_active == 1
def getTestData(series, start_time):
q = sa.select(
[db.test_runs.id, db.test_runs.machine_id, db.builds.ref_build_id,
@ -79,7 +82,7 @@ def getTestSeries(branches, start_date, test_names, last_run=None):
sa.not_(db.machines.name.like('%stage%')),
sa.not_(db.tests.pretty_name.like("%NoChrome%")),
sa.not_(db.tests.pretty_name.like("%Fast Cycle%")),
test_clause
test_clause,
))
if last_run:
@ -91,7 +94,10 @@ def getTestSeries(branches, start_date, test_names, last_run=None):
retval.append(TestSeries(*row))
return retval
_machines_cache = {}
def getMachinesForTest(series):
key = (series.os_id, series.branch_id, series.test_id)
if key in _machines_cache:
@ -112,7 +118,10 @@ def getMachinesForTest(series):
_machines_cache[key] = [row[0] for row in result.fetchall()]
return _machines_cache[key]
_name_cache = {}
def getMachineName(machine_id):
if machine_id in _name_cache:
return _name_cache[machine_id]

Просмотреть файл

@ -0,0 +1,137 @@
import logging as log
try:
import simplejson as json
except ImportError:
import json
import urllib
from analyze import PerfDatum
class TestSeries:
def __init__(self, branch_id, branch_name, os_id, os_name, test_id, test_name):
self.branch_id = branch_id
self.branch_name = branch_name
self.os_id = os_id
self.os_name = os_name
self.test_id = test_id
self.test_name = test_name
def __eq__(self, o):
return (self.branch_id, self.os_id, self.test_id) == (o.branch_id, o.os_id, o.test_id)
def __hash__(self):
return hash((self.branch_id, self.os_id, self.test_id))
class GraphAPISource:
def __init__(self, baseurl):
self.baseurl = baseurl
def getTestSeries(self, branches, start_date, test_names):
url = "%s/%s" % (self.baseurl, "test")
try:
log.debug("Getting %s", url)
req = urllib.urlopen(url)
tests = json.load(req)
except KeyboardInterrupt:
raise
except:
log.exception("Couldn't load or parse %s", url)
return []
if tests['stat'] != "ok":
log.warn("Test status not ok: %s", tests['stat'])
return []
retval = []
machines_by_branch = {}
machine_names = {}
for test in tests['tests']:
machine_info = test['machine']
machine_id = machine_info['id']
machine_name = machine_info['name']
os_info = test['os']
os_id = os_info['id']
branch_info = test['branch']
branch_id = branch_info['id']
if branch_info['name'] not in branches:
continue
test_id = test['id']
test_name = test['name']
if test_names and test_name not in test_names:
continue
# Skip NoChrome tests
if "NoChrome" in test_name:
continue
# Skip Fast Cycle tests
if "Fast Cycle" in test_name:
continue
series = TestSeries(branch_id, branch_info['name'],
os_id, os_info['name'],
test_id, test_name)
if series not in retval:
retval.append(series)
if series not in machines_by_branch:
machines_by_branch[series] = []
if machine_id not in machines_by_branch[series]:
machines_by_branch[series].append(machine_id)
if machine_id not in machine_names:
machine_names[machine_id] = machine_info['name']
self.machines_by_branch = machines_by_branch
self.machine_names = machine_names
return retval
def getTestData(self, series, start_time):
base = self.baseurl
retval = []
seen = {}
for machine_id in self.machines_by_branch[series]:
test_id = series.test_id
branch_id = series.branch_id
machine_id = machine_id
url = "%(base)s/test/runs?id=%(test_id)s&branchid=%(branch_id)s&machineid=%(machine_id)s" % locals()
try:
log.debug("Getting %s", url)
req = urllib.urlopen(url)
results = json.load(req)
except KeyboardInterrupt:
raise
except:
log.exception("Couldn't load or parse %s", url)
continue
if 'test_runs' not in results:
log.debug("No data from %s", url)
continue
for item in results['test_runs']:
testrunid, build, date, average, run_number, annotations = item
if average is None:
continue
d = PerfDatum(machine_id, date, average, build[1], date, build[2])
d.run_number = run_number
retval.append(d)
t = (d.buildid, date, average, machine_id)
#if t in seen:
#if seen[t].run_number == run_number:
#continue
#log.error("%s %s %s", seen[t], seen[t].machine_id, seen[t].run_number)
#log.error("%s %s %s", d, d.machine_id, d.run_number)
#log.error(url)
#else:
#seen[t] = d
return retval
def getMachinesForTest(self, series):
return self.machines_by_branch[series]
def getMachineName(self, machine_id):
return self.machine_names[machine_id]

Просмотреть файл

@ -1100,9 +1100,19 @@ if __name__ == "__main__":
config.read([options.config])
if options.addresses:
config.set('main', 'regression_emails', ",".join(option.addresses))
config.set('main', 'regression_emails', ",".join(options.addresses))
if options.machine_addresses:
config.set('main', 'machine_emails', ",".join(option.machine_addresses))
config.set('main', 'machine_emails', ",".join(options.machine_addresses))
vars = os.environ.copy()
vars['sys_prefix'] = sys.prefix
vars['here'] = os.path.dirname(__file__)
for section in config.sections():
for option in config.options(section):
value = config.get(section, option)
if '$' in value:
value = Template(value).substitute(vars)
config.set(section, option, value)
runner = AnalysisRunner(options, config)
try: