Merge lp:~sylvain-pineau/checkbox/nested_tp_doc into lp:checkbox

Proposed by Sylvain Pineau
Status: Merged
Approved by: Paul Larson
Approved revision: 4481
Merged at revision: 4482
Proposed branch: lp:~sylvain-pineau/checkbox/nested_tp_doc
Merge into: lp:checkbox
Diff against target: 395 lines (+380/-0)
2 files modified
checkbox-ng/docs/index.rst (+1/-0)
checkbox-ng/docs/nested-test-plan.rst (+379/-0)
To merge this branch: bzr merge lp:~sylvain-pineau/checkbox/nested_tp_doc
Reviewer Review Type Date Requested Status
Paul Larson Approve
Sylvain Pineau (community) Needs Resubmitting
Review via email: mp+304993@code.launchpad.net

Description of the change

Finally, the doc about nested test plans and all their possible usages.

To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) wrote :

A question and a small fix below. Otherwise it looks pretty good. Also, after we have a lot of these in place, do we think it would be useful to go back and do some editing for consistency of titles, format, etc?

review: Needs Information
4481. By Sylvain Pineau

checkbox-ng:doc: Added a tutorial to start with nested test plans

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

Fixed and repushed (debian->Debian + a link to the overrides section in the test plan man page)

review: Needs Resubmitting
Revision history for this message
Paul Larson (pwlars) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'checkbox-ng/docs/index.rst'
2--- checkbox-ng/docs/index.rst 2016-08-25 08:56:43 +0000
3+++ checkbox-ng/docs/index.rst 2016-09-06 15:48:18 +0000
4@@ -58,6 +58,7 @@
5 stack.rst
6 launcher-tutorial.rst
7 configs.rst
8+ nested-test-plan.rst
9 snappy.rst
10 testing-snappy.rst
11
12
13=== added file 'checkbox-ng/docs/nested-test-plan.rst'
14--- checkbox-ng/docs/nested-test-plan.rst 1970-01-01 00:00:00 +0000
15+++ checkbox-ng/docs/nested-test-plan.rst 2016-09-06 15:48:18 +0000
16@@ -0,0 +1,379 @@
17+Checkbox/plainbox nested test plans tutorial
18+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19+
20+We designed checkbox to consume test providers. Hence the test harness and the
21+tests are completely separated. Checkbox can load tests from multiple providers.
22+They can be installed as Debian packages or loaded from source to build a snap.
23+
24+To load the tests and run them we need a test plan. Test plans for checkbox are
25+a collection of job (test) ids meant to be run one by one.
26+
27+Most of the time when we create a new test plan, there's a need to include a
28+generic section, common to several other test plans. But the test plan unit was
29+not allowing such feature and we ended up having a lot of duplication across
30+our projects. And duplication means duplicated efforts to maintain all those
31+test plan sections in sync and up-to-date.
32+
33+What if it could be possible now to have nested test plans. One being built by
34+aggregating sections from one or more "base test plans"?
35+
36+Let's review in detail this new feature available in checkbox since plainbox 0.29
37+
38+Quick start
39+===========
40+
41+The only thing to add to your test plan is the identifier of the test plan you
42+want to include, as follow:
43+
44+::
45+
46+ nested_part:
47+ 2013.com.canonical.certification::my_base_test_plan
48+
49+The test plan order will then be test plan ``include`` + all nested test plan
50+``include``, in that order.
51+
52+Loading nested parts will load the ``include``, ``mandatory_include`` and
53+``bootstrap_include`` sections and all the overrides (``category``,
54+``certification status``).
55+
56+Note: All mandatory includes will always be run first.
57+
58+Note: Job and test plan ids can be listed in their abbreviated form (without
59+the namespace prefix) if the job definitions reside in the same namespace as
60+the provider that is defining the test plan.
61+
62+Use cases
63+=========
64+
65+All the following examples are available here:
66+https://github.com/yphus/nested_testplan_demo To test them locally you just
67+need to develop the 3 providers and run one of the demo launchers:
68+
69+::
70+
71+ git clone https://github.com/yphus/nested_testplan_demo.git
72+ cd nested_testplan_demo/
73+ find . -name manage.py -exec {} develop \;
74+ ./demo1 # or demo2, 3, 4, 5, 6.
75+
76+How to use a base test plan?
77+----------------------------
78+
79+Let's use two providers, both belonging to the same namespace, ``2016.com.ubuntu``:
80+
81+``2016.com.ubuntu:foo`` and ``2016.com.ubuntu:baz``
82+
83+Baz provider contains the following units, 4 jobs and a test plan (our base
84+test plan):
85+
86+::
87+
88+ id: hello
89+ command: echo hello
90+ flags: simple
91+
92+ id: bye
93+ command: echo bye
94+ flags: simple
95+
96+ id: mandatory
97+ command: true
98+ flags: simple
99+
100+ id: bootstrap
101+ command: echo os: ubuntu
102+ plugin: resource
103+ flags: simple
104+
105+ unit: test plan
106+ id: baz_tp
107+ _name: Generic baz test plan
108+ _description: This test plan contains generic test cases
109+ estimated_duration: 1m
110+ include:
111+ hello certification-status=blocker
112+ bye certification-status=non-blocker
113+ mandatory_include:
114+ mandatory certification-status=blocker
115+ bootstrap_include:
116+ bootstrap
117+
118+Foo provider contains two new tests:
119+
120+::
121+
122+ id: always-pass
123+ command: true
124+ flags: simple
125+
126+ id: always-fail
127+ command: true
128+ flags: simple
129+
130+We want to reuse the ``baz_tp`` in a new test plan (in the Foo provider) with
131+the two new tests. Such test plan will look like this:
132+
133+
134+::
135+
136+ unit: test plan
137+ id: foo_tp_1
138+ _name: Foo test plan 1
139+ _description: This test plan contains generic tests + 2 new tests
140+ include:
141+ always-pass certification-status=blocker
142+ always-fail
143+ nested_part:
144+ baz_tp
145+
146+The jobs execution order is:
147+
148+- ``bootstrap``
149+- ``mandatory``
150+- ``always-pass``
151+- ``always-fail``
152+- ``hello``
153+- ``bye``
154+
155+How to use a base test plan, but without running them last?
156+-----------------------------------------------------------
157+
158+Let's keep the previous providers, Foo and Baz. This time we want to run the
159+base test plan between ``always-pass`` and ``always-fail``. In order to change
160+the job execution order, the new test plan will be made of several nested
161+parts, since they will follow the list order. Let's create in the Foo provider
162+2 new test plans that we'll use as nested parts to fine tune the job ordering:
163+
164+::
165+
166+ unit: test plan
167+ id: foo_tp_part1
168+ _name: Foo test plan part 1
169+ _description: This test plan contains part 1
170+ estimated_duration: 1m
171+ include:
172+ always-pass certification-status=blocker
173+
174+ unit: test plan
175+ id: foo_tp_part2
176+ _name: Foo test plan part 2
177+ _description: This test plan contains part 2
178+ estimated_duration: 1m
179+ include:
180+ always-fail
181+
182+The final test plan will only contain nested parts:
183+
184+::
185+
186+ unit: test plan
187+ id: foo_tp_2
188+ _name: Foo test plan 2
189+ _description:
190+ This test plan contains generic tests + 2 new tests (but ordered differently)
191+ include:
192+ nested_part:
193+ foo_tp_part1
194+ baz_tp
195+ foo_tp_part2
196+
197+Note: Always keep the ``include`` section (even empty) as this field is
198+mandatory and validation would failed otherwise (and the test plan never loaded
199+by checkbox)
200+
201+The jobs execution order is:
202+
203+- ``bootstrap``
204+- ``mandatory``
205+- ``always-pass``
206+- ``hello``
207+- ``bye``
208+- ``always-fail``
209+
210+How to change category or certification status of jobs coming from nested parts?
211+--------------------------------------------------------------------------------
212+
213+The `test plan override mechanism
214+<http://plainbox.readthedocs.io/en/latest/manpages/plainbox-test-plan-units.html?highlight=category-overrides>`_
215+still works with nested parts. For example the ``hello`` job from the Baz
216+provider was defined as a blocker and did not have a category.
217+
218+Let's update the previous use case:
219+
220+::
221+
222+ unit: test plan
223+ id: foo_tp_3
224+ _name: Foo test plan 3
225+ _description: This test plan contains generic tests + 2 new tests + overrides
226+ include:
227+ always-pass certification-status=blocker
228+ always-fail
229+ nested_part:
230+ baz_tp
231+ certification_status_overrides:
232+ apply non-blocker to hello
233+ category_overrides:
234+ apply 2013.com.canonical.plainbox::audio to hello
235+
236+To check that overrides worked as expected, you can open the json exporter
237+report:
238+
239+::
240+
241+ "result_map": {
242+ "2016.com.ubuntu::hello": {
243+ "summary": "hello",
244+ "category_id": "2013.com.canonical.plainbox::audio",
245+ "certification_status": "non-blocker"
246+ [...]
247+
248+How to include a nested part from another namespace?
249+----------------------------------------------------
250+
251+You can include a nested part from another namespace, just prefix the test plan
252+identifier with the provider namespace.
253+
254+Let's use a third provider (Bar, under the ``2013.com.ubuntu`` namespace) as an
255+example:
256+
257+::
258+
259+ id: sleep
260+ command: sleep 1
261+ flags: simple
262+
263+ id: uname
264+ command: uname -a
265+ flags: simple
266+
267+ unit: test plan
268+ id: bar_tp
269+ _name: bar test plan
270+ _description: This test plan contains bar test cases
271+ estimated_duration: 1m
272+ include:
273+ sleep
274+ uname
275+
276+Now in provider Foo, a test plan including a part from provider Bar will look
277+like this:
278+
279+::
280+
281+ unit: test plan
282+ id: foo_tp_4
283+ _name: Foo test plan 4
284+ _description:
285+ This test plan contains generic tests + 2 new tests + 2 tests from a
286+ different namespace provider
287+ include:
288+ always-pass certification-status=blocker
289+ always-fail
290+ nested_part:
291+ baz_tp
292+ 2013.com.ubuntu::bar_tp
293+
294+The jobs execution order is:
295+
296+- ``bootstrap``
297+- ``mandatory``
298+- ``always-pass``
299+- ``always-fail``
300+- ``hello``
301+- ``bye``
302+- ``sleep``
303+- ``uname``
304+
305+Is it possible to have multiple levels of nesting?
306+--------------------------------------------------
307+
308+Yes, it's possible to have multiple levels of nesting, a nested part being
309+built from another nested parts, each level bringing its own set of new tests.
310+
311+Let's add a new test plan to provider Baz:
312+
313+::
314+
315+ unit: test plan
316+ id: baz_tp_2
317+ _name: Generic baz test plan 2
318+ _description: This test plan contains generic test cases + a nested part
319+ include:
320+ hello certification-status=blocker
321+ bye certification-status=non-blocker
322+ mandatory_include:
323+ mandatory certification-status=blocker
324+ bootstrap_include:
325+ bootstrap
326+ nested_part:
327+ 2013.com.ubuntu::bar_tp
328+
329+As you can see this test plan includes a part from provider Bar (the same used
330+in the previous example). In provider Foo, we can create a new test plan
331+including `baz_tp_2`:
332+
333+::
334+
335+ unit: test plan
336+ id: foo_tp_5
337+ _name: Foo test plan 5
338+ _description: This test plan is built from multiple level of nested test plans
339+ include:
340+ always-pass certification-status=blocker
341+ always-fail
342+ nested_part:
343+ baz_tp_2
344+
345+The jobs execution order is still:
346+
347+- ``bootstrap``
348+- ``mandatory``
349+- ``always-pass``
350+- ``always-fail``
351+- ``hello``
352+- ``bye``
353+- ``sleep``
354+- ``uname``
355+
356+How to use a base test plan except a few jobs?
357+----------------------------------------------
358+
359+The test plan units support an optional field - ``exclude`` - that we can use
360+to remove jobs from a nested part ``include`` section.
361+
362+Note: The ``exclude`` ids cannot remove jobs that are parts of the
363+``mandatory_include`` sections (nested or not).
364+
365+The test plan below (from provider Foo) won't run the ``hello`` job of provider
366+Baz:
367+
368+::
369+
370+ unit: test plan
371+ id: foo_tp_6
372+ _name: Foo test plan 6
373+ _description: This test plan contains generic tests + 2 new tests - hello job
374+ include:
375+ always-pass certification-status=blocker
376+ always-fail
377+ exclude:
378+ hello
379+ nested_part:
380+ baz_tp
381+
382+The jobs execution order is:
383+
384+- ``bootstrap``
385+- ``mandatory``
386+- ``always-pass``
387+- ``always-fail``
388+- ``bye``
389+
390+Known limitations
391+=================
392+
393+You can create infinite loops if a nested part is calling itself or if
394+somewhere in the nested chain such a loop exists. Checkbox won't like that and
395+so far there's no validation to prevent it, be warned!

Subscribers

People subscribed via source and target branches