[LNT] r239468 - Add filter-machine-regex functionality to daily report.
Kristof Beyls
kristof.beyls at arm.com
Wed Jun 10 05:13:57 PDT 2015
Author: kbeyls
Date: Wed Jun 10 07:13:57 2015
New Revision: 239468
URL: http://llvm.org/viewvc/llvm-project?rev=239468&view=rev
Log:
Add filter-machine-regex functionality to daily report.
For the email report, this is added by the new command line option
--filter_machine_regex for the "lnt send-daily-report" command. For the daily
report webui, this is added by URL query parameter "?filter-machine-regex=".
Only machines with the specified regular expression in their name are
displayed.
Modified:
lnt/trunk/lnt/lnttool/main.py
lnt/trunk/lnt/server/reporting/dailyreport.py
lnt/trunk/lnt/server/ui/templates/layout.html
lnt/trunk/lnt/server/ui/templates/reporting/daily_report.html
lnt/trunk/lnt/server/ui/views.py
lnt/trunk/tests/lnttool/email_tools.py
lnt/trunk/tests/server/ui/Inputs/V4Pages_extra_records.sql
lnt/trunk/tests/server/ui/V4Pages.py
Modified: lnt/trunk/lnt/lnttool/main.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/lnttool/main.py?rev=239468&r1=239467&r2=239468&view=diff
==============================================================================
--- lnt/trunk/lnt/lnttool/main.py (original)
+++ lnt/trunk/lnt/lnttool/main.py Wed Jun 10 07:13:57 2015
@@ -264,6 +264,9 @@ def action_send_daily_report(name, args)
" Used for testing.")
parser.add_option("", "--days", dest="days", default=3, type="int",
help="Number of days to show in report.")
+ parser.add_option("", "--filter-machine-regex", dest="filter_machine_regex",
+ default=None,
+ help="only show machines that contain the regex.")
(opts, args) = parser.parse_args(args)
@@ -304,7 +307,8 @@ def action_send_daily_report(name, args)
report = lnt.server.reporting.dailyreport.DailyReport(
ts, year=date.year, month=date.month, day=date.day,
day_start_offset_hours=date.hour, for_mail=True,
- num_prior_days_to_include=opts.days)
+ num_prior_days_to_include=opts.days,
+ filter_machine_regex=opts.filter_machine_regex)
report.build()
note("generating HTML report...")
Modified: lnt/trunk/lnt/server/reporting/dailyreport.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/reporting/dailyreport.py?rev=239468&r1=239467&r2=239468&view=diff
==============================================================================
--- lnt/trunk/lnt/server/reporting/dailyreport.py (original)
+++ lnt/trunk/lnt/server/reporting/dailyreport.py Wed Jun 10 07:13:57 2015
@@ -1,4 +1,5 @@
import datetime
+import re
import sqlalchemy.sql
@@ -16,7 +17,8 @@ OrderAndHistory = namedtuple('OrderAndHi
class DailyReport(object):
def __init__(self, ts, year, month, day, num_prior_days_to_include=3,
- day_start_offset_hours=16, for_mail=False):
+ day_start_offset_hours=16, for_mail=False,
+ filter_machine_regex=None):
self.ts = ts
self.num_prior_days_to_include = num_prior_days_to_include
self.year = year
@@ -26,6 +28,12 @@ class DailyReport(object):
self.day_start_offset = datetime.timedelta(
hours=day_start_offset_hours)
self.for_mail = for_mail
+ self.filter_machine_re = None
+ if filter_machine_regex:
+ try:
+ self.filter_machine_re = re.compile(filter_machine_regex)
+ except re.error:
+ pass
# Computed values.
self.error = None
@@ -83,6 +91,11 @@ class DailyReport(object):
filter(ts.Run.start_time <= day).all()
for day, prior_day in util.pairs(self.prior_days)]
+ if self.filter_machine_re is not None:
+ prior_runs = [[run for run in runs
+ if self.filter_machine_re.search(run.machine.name)]
+ for runs in prior_runs]
+
# For every machine, we only want to report on the last run order that
# was reported for that machine for the particular day range.
#
Modified: lnt/trunk/lnt/server/ui/templates/layout.html
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/templates/layout.html?rev=239468&r1=239467&r2=239468&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/templates/layout.html (original)
+++ lnt/trunk/lnt/server/ui/templates/layout.html Wed Jun 10 07:13:57 2015
@@ -2,13 +2,13 @@
<html lang="en">
<head>
<link href="{{ url_for('.static', filename='bootstrap/css/bootstrap.min.css')
- }}" rel="stylesheet" media="screen">
+ }}" rel="stylesheet" media="screen"/>
<link href="{{ url_for('.static', filename='bootstrap/css/bootstrap-responsive.min.css')
- }}" rel="stylesheet">
+ }}" rel="stylesheet"/>
<link href="{{ url_for('.static', filename='narrow.css')
- }}" rel="stylesheet" media='screen and (max-width: 750px)' >
+ }}" rel="stylesheet" media='screen and (max-width: 750px)'/>
<link href="{{ url_for('.static', filename='wide.css')
- }}" rel="stylesheet" media='screen and (min-width: 750px)'>
+ }}" rel="stylesheet" media='screen and (min-width: 750px)'/>
<script src="{{ url_for('.static', filename='jquery/1.7.2/jquery-1.7.2.min.js')
}}"> </script>
<script src="{{ url_for('.static', filename='jquery/jquery.dateFormat/jquery-dateFormat.min.js')
@@ -16,11 +16,11 @@
<script src="{{ url_for('.static', filename='bootstrap/js/bootstrap.min.js')
}}"></script>
- <script src="{{ url_for('.static', filename='timedate.js')
- }}"></script>
+ <script src="{{ url_for('.static', filename='timedate.js')
+ }}"></script>
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<style type="text/css">
/* Sticky footer styles ------------------------------------------------- */
@@ -65,7 +65,7 @@
}
</style>
- <link rel="icon" type="image/png" href="{{ url_for('.static', filename='favicon.ico') }}">
+ <link rel="icon" type="image/png" href="{{ url_for('.static', filename='favicon.ico') }}"/>
<title>
{{old_config.name}}{% for short_name,_ in components %} : {{short_name}}{% endfor %} - {{ self.title() }}
@@ -115,7 +115,7 @@
<li><a href="{{ v4_url_for('v4_daily_report_overview') }}">Daily Report</a></li>
<li><a href="{{ v4_url_for('v4_machines') }}">All Machines</a></li>
<li class="divider"></li>
- <li class="disabled"><a href=#>Summary Report</a></li>
+ <li class="disabled"><a href="#">Summary Report</a></li>
{#"{{ v4_url_for('v4_summary_report') }}"#}
</ul>
</li>
Modified: lnt/trunk/lnt/server/ui/templates/reporting/daily_report.html
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/templates/reporting/daily_report.html?rev=239468&r1=239467&r2=239468&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/templates/reporting/daily_report.html (original)
+++ lnt/trunk/lnt/server/ui/templates/reporting/daily_report.html Wed Jun 10 07:13:57 2015
@@ -46,7 +46,7 @@
{# Generate the table showing which run orders we are reporting on, for each
machine. #}
-<h3 style={{ "styles.h3" }}>Reported Machine Order</h3>
+<h3 style="{{ styles.h3 }}">Reported Machine Order</h3>
<table border="1" style="{{ styles.table }}">
<thead>
<tr>
@@ -124,6 +124,7 @@
{% for i in range(report.num_prior_days_to_include)|reverse %}
<th style="{{ styles.th }}">Day - {{i}}</th>
{% endfor %}
+ </tr>
</thead>
{% endmacro %}
@@ -148,6 +149,7 @@
{% for day_result in day_results[:-1]|reverse %}
{{ get_cell_value(day_result) }}
{% endfor %}
+ <td>{{test.name}}</td>
</tr>
{% endfor %}
{{ "</table><p>" if report.for_mail }}
Modified: lnt/trunk/lnt/server/ui/views.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/views.py?rev=239468&r1=239467&r2=239468&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/views.py (original)
+++ lnt/trunk/lnt/server/ui/views.py Wed Jun 10 07:13:57 2015
@@ -1036,11 +1036,14 @@ def v4_daily_report(year, month, day):
else:
day_start = 16
+ filter_machine_regex = request.args.get('filter-machine-regex')
+
ts = request.get_testsuite()
# Create the report object.
report = lnt.server.reporting.dailyreport.DailyReport(
- ts, year, month, day, num_days, day_start)
+ ts, year, month, day, num_days, day_start,
+ filter_machine_regex=filter_machine_regex)
# Build the report.
report.build()
Modified: lnt/trunk/tests/lnttool/email_tools.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/lnttool/email_tools.py?rev=239468&r1=239467&r2=239468&view=diff
==============================================================================
--- lnt/trunk/tests/lnttool/email_tools.py (original)
+++ lnt/trunk/tests/lnttool/email_tools.py Wed Jun 10 07:13:57 2015
@@ -9,6 +9,5 @@
# RUN: --from some.other at address.com \
# RUN: --host localhost %t.instance 1 2
# RUN: lnt send-daily-report --dry-run --from some.other at address.com \
-# RUN: --host localhost --testsuite nts \
+# RUN: --host localhost --testsuite nts --filter-machine-regex=machine.? \
# RUN: %t.instance some at address.com
-#
Modified: lnt/trunk/tests/server/ui/Inputs/V4Pages_extra_records.sql
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/ui/Inputs/V4Pages_extra_records.sql?rev=239468&r1=239467&r2=239468&view=diff
==============================================================================
--- lnt/trunk/tests/server/ui/Inputs/V4Pages_extra_records.sql (original)
+++ lnt/trunk/tests/server/ui/Inputs/V4Pages_extra_records.sql Wed Jun 10 07:13:57 2015
@@ -1,4 +1,14 @@
BEGIN TRANSACTION;
INSERT INTO "NT_Test" VALUES(87,'SingleSource/UnitTests/ObjC/block-byref-aggr');
INSERT INTO "compile_Test" VALUES(38,'compile/403.gcc/combine.c/init/(-O0)');
+-- make sure there are 3 machines - to test ?filter-machine-regex= on daily_report page
+INSERT INTO "NT_Machine" VALUES(2,'machine2','[]','AArch64','linux');
+UPDATE "NT_Order" SET "NextOrder" = 5 WHERE "ID" = 4;
+INSERT INTO "NT_Order" VALUES(5,4,6,'152290');
+INSERT INTO "NT_Run" VALUES(3,2,5,'run3.json','2012-04-11 16:28:23.000000','2012-04-11 16:28:58.000000',NULL,'[]');
+INSERT INTO "NT_Sample" VALUES(3,3,1,NULL,NULL,0.001,0.0001,NULL);
+INSERT INTO "NT_Machine" VALUES(3,'machine3','[]','AArch64','linux');
+INSERT INTO "NT_Order" VALUES(6,5,NULL,'152291');
+INSERT INTO "NT_Run" VALUES(4,3,6,'run4.json','2012-04-11 16:28:24.000000','2012-04-11 16:28:59.000000',NULL,'[]');
+INSERT INTO "NT_Sample" VALUES(4,4,1,NULL,NULL,0.001,0.0001,NULL);
COMMIT;
Modified: lnt/trunk/tests/server/ui/V4Pages.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/ui/V4Pages.py?rev=239468&r1=239467&r2=239468&view=diff
==============================================================================
--- lnt/trunk/tests/server/ui/V4Pages.py (original)
+++ lnt/trunk/tests/server/ui/V4Pages.py Wed Jun 10 07:13:57 2015
@@ -10,6 +10,8 @@
import logging
import sys
+import xml.etree.ElementTree as ET
+from htmlentitydefs import name2codepoint
import lnt.server.db.migrate
import lnt.server.ui.app
@@ -21,6 +23,48 @@ def check_code(client, url, expected_cod
resp = client.get(url, follow_redirects=False)
assert resp.status_code == expected_code, \
"Call to %s returned: %d, not the expected %d"%(url, resp.status_code, expected_code)
+ return resp
+
+def dump_html(html_string):
+ for linenr, line in enumerate(html_string.split('\n')):
+ print "%4d:%s" % (linenr+1, line)
+
+def get_xml_tree(html_string):
+ try:
+ parser = ET.XMLParser()
+ parser.parser.UseForeignDTD(True)
+ parser.entity.update((x, unichr(i)) for x, i in name2codepoint.iteritems())
+ tree = ET.fromstring(html_string, parser=parser)
+ except:
+ dump_html(html_string)
+ raise
+ return tree
+
+def check_nr_machines_reported(client, url, expected_nr_machines):
+ resp = check_code(client, url)
+ html = resp.data
+ tree = get_xml_tree(html)
+ # look for the table containing the machines on the page.
+ # do this by looking for the title containing "Reported Machine Order"
+ # and assuming that the first <table> at the same level after it is the
+ # one we're looking for.
+ reported_machine_order_table = None
+ table_parent_elements = tree.findall(".//table/..")
+ found_header = False
+ for parent in table_parent_elements:
+ for child in parent.findall('*'):
+ if found_header:
+ if child.tag == "table":
+ reported_machine_order_table = child
+ found_header = False
+ elif child.tag.startswith('h') and \
+ child.text == 'Reported Machine Order':
+ found_header = True
+ if reported_machine_order_table is None:
+ nr_machines = 0
+ else:
+ nr_machines = len(reported_machine_order_table.findall("./tr"))
+ assert expected_nr_machines == nr_machines
def main():
_,instance_path = sys.argv
@@ -80,6 +124,15 @@ def main():
check_code(client, '/v4/nts/daily_report/2012/4/10')
check_code(client, '/v4/nts/daily_report/2012/4/14')
+ # check ?filter-machine-regex= filter
+ check_nr_machines_reported(client, '/v4/nts/daily_report/2012/4/12', 3)
+ check_nr_machines_reported(client, '/v4/nts/daily_report/2012/4/12?filter-machine-regex=machine2', 1)
+ check_nr_machines_reported(client, '/v4/nts/daily_report/2012/4/12?filter-machine-regex=machine', 2)
+ check_nr_machines_reported(client, '/v4/nts/daily_report/2012/4/12?filter-machine-regex=ma.*[34]$', 1)
+ check_nr_machines_reported(client, '/v4/nts/daily_report/2012/4/12?filter-machine-regex=ma.*4', 0)
+ # Don't crash on an invalid regular expression:
+ check_nr_machines_reported(client, '/v4/nts/daily_report/2012/4/12?filter-machine-regex=?', 3)
+
# Now check the compile report
# Get the V4 overview page.
check_code(client, '/v4/compile/')
More information about the llvm-commits
mailing list