[LNT] r299399 - Interface for comparing the most recent run from two machines

Chris Matthews via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 3 16:16:38 PDT 2017


Author: cmatthews
Date: Mon Apr  3 18:16:37 2017
New Revision: 299399

URL: http://llvm.org/viewvc/llvm-project?rev=299399&view=rev
Log:
Interface for comparing the most recent run from two machines

Sometimes it is nice to be able to compare two machines. Sometimes
machines can codify an interesting change, for example with and without
a flag, or two branches.  Add a form diaglog to the machine page to
allow the user to compare the most recent (in time) results from two
machines.

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

Modified: lnt/trunk/lnt/server/ui/templates/v4_machine.html
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/templates/v4_machine.html?rev=299399&r1=299398&r2=299399&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/templates/v4_machine.html (original)
+++ lnt/trunk/lnt/server/ui/templates/v4_machine.html Mon Apr  3 18:16:37 2017
@@ -61,6 +61,26 @@
   </table>
   </section>
 
+    <section id="compare">
+        <h3>Compare</h3>
+            <p>Compare the latest run on this machine with the latest run on another.</p>
+
+            <form action="{{ v4_url_for("v4_machine_compare", machine_id=machine.id)}}" method="get">
+                <p>
+                Compare {{ machine.name }} to
+                <select name="compare_to_id">
+                    {%  for machine in machines %}
+                        <option value="{{ machine.id }}">{{ machine.name }}:{{ machine.id }}</option>
+                    {% endfor %}
+                </select>
+                </p>
+                <p>
+                    <input class="btn" type="submit" value="Compare">
+                </p>
+
+            </form>
+    </section>
+
   <section id="submissions">
   <h3>Submissions</h3>
   <table class="table table-striped table-hover table-condensed">

Modified: lnt/trunk/lnt/server/ui/views.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/views.py?rev=299399&r1=299398&r2=299399&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/views.py (original)
+++ lnt/trunk/lnt/server/ui/views.py Mon Apr  3 18:16:37 2017
@@ -220,6 +220,24 @@ def v4_machine_latest(machine_id):
     return redirect(v4_url_for('v4_run', id=run.id))
 
 
+ at v4_route("/machine/<int:machine_id>/compare")
+def v4_machine_compare(machine_id):
+    """Return the most recent run on this machine."""
+    ts = request.get_testsuite()
+    machine_compare_to_id = int(request.args['compare_to_id'])
+    machine_1_run = ts.query(ts.Run) \
+        .filter(ts.Run.machine_id == machine_id) \
+        .order_by(ts.Run.start_time.desc()) \
+        .first()
+
+    machine_2_run = ts.query(ts.Run) \
+        .filter(ts.Run.machine_id == machine_compare_to_id) \
+        .order_by(ts.Run.start_time.desc()) \
+        .first()
+
+    return redirect(v4_url_for('v4_run', id=machine_1_run.id, compare_to=machine_2_run.id))
+
+
 @v4_route("/machine/<int:id>")
 def v4_machine(id):
 
@@ -238,6 +256,8 @@ def v4_machine(id):
     associated_runs = associated_runs.items()
     associated_runs.sort()
 
+    machines = ts.query(ts.Machine).all()
+
     if request.args.get('json'):
         json_obj = dict()
         machine_obj = ts.query(ts.Machine).filter(ts.Machine.id == id).one()
@@ -252,9 +272,11 @@ def v4_machine(id):
         return flask.jsonify(**json_obj)
     try:
         return render_template("v4_machine.html",
-                           testsuite_name=g.testsuite_name, id=id,
-                           associated_runs=associated_runs)
-    except NoResultFound as e:
+                               testsuite_name=g.testsuite_name,
+                               id=id,
+                               associated_runs=associated_runs,
+                               machines=machines)
+    except NoResultFound:
         abort(404)
 
 class V4RequestInfo(object):

Modified: lnt/trunk/tests/server/ui/V4Pages.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/ui/V4Pages.py?rev=299399&r1=299398&r2=299399&view=diff
==============================================================================
--- lnt/trunk/tests/server/ui/V4Pages.py (original)
+++ lnt/trunk/tests/server/ui/V4Pages.py Mon Apr  3 18:16:37 2017
@@ -440,6 +440,12 @@ def main():
     check_code(client, '/v4/compile/machine/-1', expected_code=HTTP_NOT_FOUND)
     check_code(client, '/v4/compile/machine/a', expected_code=HTTP_NOT_FOUND)
 
+    # Check the compare machine form gives correct redirects.
+    resp = check_code(client, '/v4/nts/machine/2/compare?compare_to_id=3', expected_code=HTTP_REDIRECT)
+    assert resp.headers['Location'] == "http://localhost/db_default/v4/nts/9?compare_to=4"
+    resp = check_code(client, '/v4/nts/machine/3/compare?compare_to_id=2', expected_code=HTTP_REDIRECT)
+    assert resp.headers['Location'] == "http://localhost/db_default/v4/nts/4?compare_to=9"
+    
     # Get the order summary page.
     check_code(client, '/v4/compile/all_orders')
 




More information about the llvm-commits mailing list