Merge ~sylvain-pineau/checkbox-ng:no_resource_no_templates into checkbox-ng:master

Proposed by Sylvain Pineau
Status: Merged
Approved by: Sylvain Pineau
Approved revision: 49f6aa4c42948470322bf32bcb5e5168ba6d2721
Merge reported by: Sylvain Pineau
Merged at revision: 49f6aa4c42948470322bf32bcb5e5168ba6d2721
Proposed branch: ~sylvain-pineau/checkbox-ng:no_resource_no_templates
Merge into: checkbox-ng:master
Diff against target: 97 lines (+39/-35)
2 files modified
checkbox_ng/launcher/subcommands.py (+36/-33)
plainbox/impl/ctrl.py (+3/-2)
Reviewer Review Type Date Requested Status
Jonathan Cave (community) Approve
Sylvain Pineau (community) Approve
Review via email: mp+355777@code.launchpad.net

Description of the change

Fix the crash observed while running the sru test plan on pi2 where the graphics_card resource job returns nothing. Templates were still checked as checkbox then creates an empty record (to avoid another kind of crash ; IIRC "package.name == foo" checks on UC).

The proposed fix is to simply bypass instantiate all when such fake record is the only resource object known for this resource job.

Bonus a commit to handle KeyboardInterrrupt with the Run command.

To post a comment you must log in.
Revision history for this message
Jonathan Cave (jocave) wrote :

On the other MR that triggered this you say:

> The proposed solution fixes the crash and removes all those warnings about missing parameters.

So does this actually only remove the warnings when the fake record is the only resource object? i.e. there are still warnings if there is a real resource object but the key the job is using is missing? I think we want to keep those warnings as it helps debug job creation.

review: Needs Information
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Tested by adding a typo (s/name/foo)in the following job def:

unit: template
template-resource: fwts
plugin: shell
category_id: com.canonical.plainbox::firmware
id: firmware/fwts_{name}
estimated_duration: 1.2
requires: executable.name == 'fwts'
user: root
command: checkbox-support-fwts_test -t {foo} -l $PLAINBOX_SESSION_SHARE/fwts_{name}.log
_description: Run {name} test from Firmware Test Suite.
_summary: Run {name} test from Firmware Test Suite.

Checkbox still complains and issues the following warnings:

$ checkbox-cli run com.canonical.certification::client-cert-18-04
Ignoring firmware/fwts_{name} with missing template parameter foo
Ignoring firmware/fwts_{name} with missing template parameter foo
Ignoring firmware/fwts_{name} with missing template parameter foo
Ignoring firmware/fwts_{name} with missing template parameter foo
Ignoring firmware/fwts_{name} with missing template parameter foo
Ignoring firmware/fwts_{name} with missing template parameter foo
Ignoring firmware/fwts_{name} with missing template parameter foo
Ignoring firmware/fwts_{name} with missing template parameter foo
Ignoring firmware/fwts_{name} with missing template parameter foo
Ignoring firmware/fwts_{name} with missing template parameter foo
Ignoring firmware/fwts_{name} with missing template parameter foo
Ignoring firmware/fwts_{name} with missing template parameter foo
Ignoring firmware/fwts_{name} with missing template parameter foo
Ignoring firmware/fwts_{name} with missing template parameter foo
Ignoring firmware/fwts_{name} with missing template parameter foo
Ignoring firmware/fwts_{name} with missing template parameter foo
Ignoring firmware/fwts_{name} with missing template parameter foo
Ignoring firmware/fwts_{name} with missing template parameter foo
Ignoring firmware/fwts_{name} with missing template parameter foo
=========================[ Running Selected Test Plan ]=========================
-------------[ Running job 1 / 347. Estimated time left: unknown ]--------------
---------------[ Collect the hardware manifest (interactively) ]----------------
ID: com.canonical.plainbox::collect-manifest
Category: com.canonical.plainbox::uncategorised

Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Landing this one to avoid failing SRU tests

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

Thanks for the extra info, the warnings are still present when required by the looks of it.

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/subcommands.py b/checkbox_ng/launcher/subcommands.py
2index 8dd3873..87e4698 100644
3--- a/checkbox_ng/launcher/subcommands.py
4+++ b/checkbox_ng/launcher/subcommands.py
5@@ -756,40 +756,43 @@ class Run(Command, MainLoopStage):
6 self.ctx.args.non_interactive)
7
8 def invoked(self, ctx):
9- self._C = Colorizer()
10- self.ctx = ctx
11- ctx.sa = SessionAssistant(
12- "com.canonical:checkbox-cli",
13- self.get_cmd_version(),
14- "0.99",
15- ["restartable"],
16- )
17- self._configure_restart()
18- try_selecting_providers(self.sa, '*')
19- self.sa.start_new_session('checkbox-run')
20- tps = self.sa.get_test_plans()
21- self._configure_report()
22- selection = ctx.args.PATTERN
23- if len(selection) == 1 and selection[0] in tps:
24- self.ctx.sa.update_app_blob(json.dumps(
25- {'testplan_id': selection[0]}).encode("UTF-8"))
26- self.just_run_test_plan(selection[0])
27- else:
28- self.ctx.sa.update_app_blob(json.dumps(
29- {}).encode("UTF-8"))
30- self.sa.hand_pick_jobs(selection)
31- print(self.C.header(_("Running Selected Jobs")))
32- self._run_jobs(self.sa.get_dynamic_todo_list())
33- # there might have been new jobs instantiated
34- while True:
35- self.sa.hand_pick_jobs(ctx.args.PATTERN)
36- todos = self.sa.get_dynamic_todo_list()
37- if not todos:
38- break
39+ try:
40+ self._C = Colorizer()
41+ self.ctx = ctx
42+ ctx.sa = SessionAssistant(
43+ "com.canonical:checkbox-cli",
44+ self.get_cmd_version(),
45+ "0.99",
46+ ["restartable"],
47+ )
48+ self._configure_restart()
49+ try_selecting_providers(self.sa, '*')
50+ self.sa.start_new_session('checkbox-run')
51+ tps = self.sa.get_test_plans()
52+ self._configure_report()
53+ selection = ctx.args.PATTERN
54+ if len(selection) == 1 and selection[0] in tps:
55+ self.ctx.sa.update_app_blob(json.dumps(
56+ {'testplan_id': selection[0]}).encode("UTF-8"))
57+ self.just_run_test_plan(selection[0])
58+ else:
59+ self.ctx.sa.update_app_blob(json.dumps(
60+ {}).encode("UTF-8"))
61+ self.sa.hand_pick_jobs(selection)
62+ print(self.C.header(_("Running Selected Jobs")))
63 self._run_jobs(self.sa.get_dynamic_todo_list())
64- self.sa.finalize_session()
65- self._print_results()
66- return 0 if self.sa.get_summary()['fail'] == 0 else 1
67+ # there might have been new jobs instantiated
68+ while True:
69+ self.sa.hand_pick_jobs(ctx.args.PATTERN)
70+ todos = self.sa.get_dynamic_todo_list()
71+ if not todos:
72+ break
73+ self._run_jobs(self.sa.get_dynamic_todo_list())
74+ self.sa.finalize_session()
75+ self._print_results()
76+ return 0 if self.sa.get_summary()['fail'] == 0 else 1
77+ except KeyboardInterrupt:
78+ return 1
79
80 def just_run_test_plan(self, tp_id):
81 self.sa.select_test_plan(tp_id)
82diff --git a/plainbox/impl/ctrl.py b/plainbox/impl/ctrl.py
83index 471dd5f..4aefe11 100644
84--- a/plainbox/impl/ctrl.py
85+++ b/plainbox/impl/ctrl.py
86@@ -270,8 +270,9 @@ class CheckBoxSessionStateController(ISessionStateController):
87 or replace resource records.
88 """
89 self._parse_and_store_resource(session_state, job, result)
90- self._instantiate_templates(
91- session_state, job, result, fake_resources)
92+ if session_state.resource_map[job.id] != [Resource({})]:
93+ self._instantiate_templates(
94+ session_state, job, result, fake_resources)
95
96 def _parse_and_store_resource(self, session_state, job, result):
97 # NOTE: https://bugs.launchpad.net/checkbox/+bug/1297928

Subscribers

People subscribed via source and target branches