Merge ~sylvain-pineau/checkbox-ng:fix-1805580 into checkbox-ng:master

Proposed by Sylvain Pineau
Status: Merged
Approved by: Sylvain Pineau
Approved revision: 0e9778fe5d5dec4461239db5d30d487c9032e766
Merged at revision: dc95de3c030a548827f2dc5e2eef74285b340085
Proposed branch: ~sylvain-pineau/checkbox-ng:fix-1805580
Merge into: checkbox-ng:master
Diff against target: 123 lines (+16/-13)
3 files modified
checkbox_ng/launcher/master.py (+12/-9)
checkbox_ng/urwid_ui.py (+2/-2)
plainbox/impl/session/remote_assistant.py (+2/-2)
Reviewer Review Type Date Requested Status
Jonathan Cave (community) Approve
Maciej Kisielewski (community) Approve
Review via email: mp+382548@code.launchpad.net

Description of the change

Fixes the linked bug (warning remote api bump inside)

Tested using a master & slave on the same network.

Selected test plan was forced, test selection not. Test plan was loading data for 60 jobs.

Before: 70s to get the test selection screen
After: 3.5s

To post a comment you must log in.
Revision history for this message
Maciej Kisielewski (kissiel) wrote :

Great optimization.
+1!

review: Approve
Revision history for this message
Jonathan Cave (jocave) wrote :

Tried this on a classic system using checkbox-snappy-classic installed a slow device. Time to the job selection screen was very short. Looks good to me, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/checkbox_ng/launcher/master.py b/checkbox_ng/launcher/master.py
2index f110860..99bdbba 100644
3--- a/checkbox_ng/launcher/master.py
4+++ b/checkbox_ng/launcher/master.py
5@@ -23,6 +23,7 @@ import contextlib
6 import getpass
7 import gettext
8 import ipaddress
9+import json
10 import logging
11 import os
12 import select
13@@ -264,8 +265,6 @@ class RemoteMaster(ReportsStage, MainLoopStage):
14 configuration['normal_user'] = self._normal_user
15
16 tps = self.sa.start_session(configuration)
17- _logger.debug("master: Session started. Available TPs:\n%s",
18- '\n'.join([' ' + tp[0] for tp in tps]))
19 if self.launcher.test_plan_forced:
20 self.select_tp(self.launcher.test_plan_default_selection)
21 self.select_jobs(self.jobs)
22@@ -330,7 +329,7 @@ class RemoteMaster(ReportsStage, MainLoopStage):
23 )
24 else:
25 _logger.info("master: Selecting jobs.")
26- reprs = self.sa.get_jobs_repr(all_jobs)
27+ reprs = json.loads(self.sa.get_jobs_repr(all_jobs))
28 wanted_set = CategoryBrowser(
29 "Choose tests to run on your system:", reprs).run()
30 # no need to set an alternate selection if the job list not changed
31@@ -403,7 +402,8 @@ class RemoteMaster(ReportsStage, MainLoopStage):
32 time.sleep(20)
33 else:
34 resume_dialog(10)
35- jobs_repr = self.sa.get_jobs_repr([resumed_session_info['last_job']])
36+ jobs_repr = json.loads(
37+ self.sa.get_jobs_repr([resumed_session_info['last_job']]))
38 job = jobs_repr[-1]
39 SimpleUI.header(job['name'])
40 print(_("ID: {0}").format(job['id']))
41@@ -422,7 +422,8 @@ class RemoteMaster(ReportsStage, MainLoopStage):
42 '\n'.join([' ' + job for job in jobs]))
43 total_num = len(jobs['done']) + len(jobs['todo'])
44
45- jobs_repr = self.sa.get_jobs_repr(jobs['todo'], len(jobs['done']))
46+ jobs_repr = json.loads(
47+ self.sa.get_jobs_repr(jobs['todo'], len(jobs['done'])))
48 if any([x['user'] is not None for x in jobs_repr]):
49 self.password_query()
50
51@@ -524,22 +525,24 @@ class RemoteMaster(ReportsStage, MainLoopStage):
52 # include resource jobs that jobs to retry depend on
53
54 candidates = self.sa.prepare_rerun_candidates(rerun_candidates)
55- self._run_jobs(self.sa.get_jobs_repr(candidates), len(candidates))
56+ self._run_jobs(
57+ json.loads(self.sa.get_jobs_repr(candidates)), len(candidates))
58 return True
59
60 def _maybe_manual_rerun_jobs(self):
61 rerun_candidates = self.sa.get_rerun_candidates('manual')
62 if not rerun_candidates:
63 return False
64- test_info_list = self.sa.get_jobs_repr(
65- [j.id for j in rerun_candidates])
66+ test_info_list = json.loads(
67+ self.sa.get_jobs_repr([j.id for j in rerun_candidates]))
68 wanted_set = ReRunBrowser(
69 _("Select jobs to re-run"), test_info_list, rerun_candidates).run()
70 if not wanted_set:
71 return False
72 candidates = self.sa.prepare_rerun_candidates([
73 job for job in rerun_candidates if job.id in wanted_set])
74- self._run_jobs(self.sa.get_jobs_repr(candidates), len(candidates))
75+ self._run_jobs(
76+ json.loads(self.sa.get_jobs_repr(candidates)), len(candidates))
77 return True
78
79 def _run_jobs(self, jobs_repr, total_num=0):
80diff --git a/checkbox_ng/urwid_ui.py b/checkbox_ng/urwid_ui.py
81index 2d5b579..572cba8 100644
82--- a/checkbox_ng/urwid_ui.py
83+++ b/checkbox_ng/urwid_ui.py
84@@ -250,7 +250,7 @@ class CategoryNode(urwid.ParentNode):
85 else:
86 value = next(
87 (job['partial_id'], job['name']) for job in test_info_list
88- if job.get("id") == key)
89+ if job["id"] == key)
90 return JobNode(
91 value, parent=self, key=key, depth=self.get_depth() + 1)
92
93@@ -457,7 +457,7 @@ class RerunNode(CategoryNode):
94 else:
95 value = next(
96 (job['partial_id'], job['name']) for job in test_info_list
97- if job.get("id") == key)
98+ if job["id"] == key)
99 return JobNode(
100 value, parent=self, key=key, depth=self.get_depth() + 1)
101
102diff --git a/plainbox/impl/session/remote_assistant.py b/plainbox/impl/session/remote_assistant.py
103index 4c0a379..2e679a7 100644
104--- a/plainbox/impl/session/remote_assistant.py
105+++ b/plainbox/impl/session/remote_assistant.py
106@@ -139,7 +139,7 @@ class BackgroundExecutor(Thread):
107 class RemoteSessionAssistant():
108 """Remote execution enabling wrapper for the SessionAssistant"""
109
110- REMOTE_API_VERSION = 10
111+ REMOTE_API_VERSION = 11
112
113 def __init__(self, cmd_callback):
114 _logger.debug("__init__()")
115@@ -595,7 +595,7 @@ class RemoteSessionAssistant():
116 "plugin": job.plugin,
117 }
118 test_info_list = test_info_list + ((test_info, ))
119- return test_info_list
120+ return json.dumps(test_info_list)
121
122 def resume_by_id(self, session_id=None):
123 _logger.info("resume_by_id: %r", session_id)

Subscribers

People subscribed via source and target branches