[LNT] r239557 - Retain URL query string parameters when redirecting from daily report page.

Kristof Beyls kristof.beyls at arm.com
Thu Jun 11 13:12:16 PDT 2015


Author: kbeyls
Date: Thu Jun 11 15:12:16 2015
New Revision: 239557

URL: http://llvm.org/viewvc/llvm-project?rev=239557&view=rev
Log:
Retain URL query string parameters when redirecting from daily report page.

Modified:
    lnt/trunk/lnt/server/ui/views.py
    lnt/trunk/tests/server/ui/V4Pages.py

Modified: lnt/trunk/lnt/server/ui/views.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/views.py?rev=239557&r1=239556&r2=239557&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/views.py (original)
+++ lnt/trunk/lnt/server/ui/views.py Thu Jun 11 15:12:16 2015
@@ -3,6 +3,7 @@ import os
 import re
 import tempfile
 import time
+import copy
 
 import flask
 from flask import abort
@@ -1019,8 +1020,14 @@ def v4_daily_report_overview():
         # Otherwise, just use today.
         date = datetime.date.today()
 
+    extra_args = request.args.copy()
+    extra_args.pop("year", None)
+    extra_args.pop("month", None)
+    extra_args.pop("day", None)
+
     return redirect(v4_url_for("v4_daily_report",
-                               year=date.year, month=date.month, day=date.day))
+                               year=date.year, month=date.month, day=date.day,
+                               **extra_args))
 
 @v4_route("/daily_report/<int:year>/<int:month>/<int:day>")
 def v4_daily_report(year, month, day):

Modified: lnt/trunk/tests/server/ui/V4Pages.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/ui/V4Pages.py?rev=239557&r1=239556&r2=239557&view=diff
==============================================================================
--- lnt/trunk/tests/server/ui/V4Pages.py (original)
+++ lnt/trunk/tests/server/ui/V4Pages.py Thu Jun 11 15:12:16 2015
@@ -9,6 +9,7 @@
 # RUN: python %s %t.instance
 
 import logging
+import re
 import sys
 import xml.etree.ElementTree as ET
 from htmlentitydefs import name2codepoint
@@ -25,6 +26,17 @@ def check_code(client, url, expected_cod
         "Call to %s returned: %d, not the expected %d"%(url, resp.status_code, expected_code)
     return resp
 
+def check_redirect(client, url, expected_redirect_regex):
+    resp = client.get(url, follow_redirects=False)
+    assert resp.status_code == 302, \
+        "Call to %s returned: %d, not the expected %d"%(url, resp.status_code, 302)
+    regex = re.compile(expected_redirect_regex)
+    assert regex.search(resp.location), \
+        "Call to %s redirects to: %s, not matching the expected regex %s" \
+        % (url, resp.location, expected_redirect_regex)
+    return resp
+
+
 def dump_html(html_string):
    for linenr, line in enumerate(html_string.split('\n')):
       print "%4d:%s" % (linenr+1, line)
@@ -109,7 +121,8 @@ def main():
 
 
     # Get a graph page. This has been changed to redirect.
-    check_code(client, '/v4/nts/1/graph?test.87=2', expected_code=302)
+    check_redirect(client, '/v4/nts/1/graph?test.87=2',
+                   'v4/nts/graph\?plot\.0=1\.87\.2&highlight_run=1$')
 
     # Get the new graph page.
     check_code(client, '/v4/nts/graph?plot.0=1.87.2')
@@ -123,6 +136,14 @@ def main():
     check_code(client, '/v4/nts/daily_report/2012/4/13')
     check_code(client, '/v4/nts/daily_report/2012/4/10')
     check_code(client, '/v4/nts/daily_report/2012/4/14')
+    check_redirect(client, '/v4/nts/daily_report',
+                   '/v4/nts/daily_report/\d+/\d+/\d+$')
+    check_redirect(client, '/v4/nts/daily_report?num_days=7',
+                   '/v4/nts/daily_report/\d+/\d+/\d+\?num_days=7$')
+    # Don't crash when using a parameter that happens to have the same name as
+    # a flask URL variable.
+    check_redirect(client, '/v4/nts/daily_report?day=15',
+                   '/v4/nts/daily_report/\d+/\d+/\d+$')
 
     # check ?filter-machine-regex= filter
     check_nr_machines_reported(client, '/v4/nts/daily_report/2012/4/12', 3)





More information about the llvm-commits mailing list