[LNT] r308413 - api: Show number of total runs in machine removal progress

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 18 20:07:52 PDT 2017


Author: matze
Date: Tue Jul 18 20:07:52 2017
New Revision: 308413

URL: http://llvm.org/viewvc/llvm-project?rev=308413&view=rev
Log:
api: Show number of total runs in machine removal progress

Also try whether `Transfer-Encoding: chunked` improves the experience.

Modified:
    lnt/trunk/lnt/server/ui/api.py
    lnt/trunk/tests/server/ui/test_api_modify.py

Modified: lnt/trunk/lnt/server/ui/api.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/api.py?rev=308413&r1=308412&r2=308413&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/api.py (original)
+++ lnt/trunk/lnt/server/ui/api.py Tue Jul 18 20:07:52 2017
@@ -158,6 +158,9 @@ class Machine(Resource):
         # running into OOM or timeout situations for machines with a hundreds
         # of runs. So instead remove machine runs in chunks.
         def perform_delete(ts, machine):
+            count = ts.query(ts.Run) \
+                .filter(ts.Run.machine_id == machine.id).count()
+            at = 0
             while True:
                 runs = ts.query(ts.Run) \
                     .filter(ts.Run.machine_id == machine.id) \
@@ -165,8 +168,9 @@ class Machine(Resource):
                     .order_by(ts.Run.id).limit(10).all()
                 if len(runs) == 0:
                     break
-                yield "Deleting runs %s\n" % \
-                    " ".join([str(run.id) for run in runs])
+                at += len(runs)
+                yield "Deleting runs %s (%d/%d)\n" % \
+                    (" ".join([str(run.id) for run in runs]), at, count)
                 for run in runs:
                     ts.session.delete(run)
                 ts.commit()
@@ -176,7 +180,8 @@ class Machine(Resource):
             yield "Deleted machine %s\n" % machine_id
 
         stream = stream_with_context(perform_delete(ts, machine))
-        return Response(stream, mimetype="text/plain")
+        return Response(stream, mimetype="text/plain",
+                        headers={'Transfer-Encoding': 'chunked'})
 
 
     @staticmethod

Modified: lnt/trunk/tests/server/ui/test_api_modify.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/ui/test_api_modify.py?rev=308413&r1=308412&r2=308413&view=diff
==============================================================================
--- lnt/trunk/tests/server/ui/test_api_modify.py (original)
+++ lnt/trunk/tests/server/ui/test_api_modify.py Tue Jul 18 20:07:52 2017
@@ -111,7 +111,7 @@ class JSONAPIDeleteTester(unittest.TestC
                              headers={'AuthToken': 'test_token'})
         self.assertEqual(resp.status_code, 200)
         self.assertEqual(resp.get_data(),
-'''Deleting runs 3 5 6 7 8 9
+'''Deleting runs 3 5 6 7 8 9 (6/6)
 Deleted machine 2
 ''')
 




More information about the llvm-commits mailing list