Merge lp:~rodsmith/checkbox/intro-docs into lp:checkbox

Proposed by Rod Smith
Status: Superseded
Proposed branch: lp:~rodsmith/checkbox/intro-docs
Merge into: lp:checkbox
Diff against target: 416 lines (+379/-1)
3 files modified
plainbox/docs/author/index.rst (+1/-0)
plainbox/docs/author/intro.rst (+359/-0)
plainbox/docs/glossary.rst (+19/-1)
To merge this branch: bzr merge lp:~rodsmith/checkbox/intro-docs
Reviewer Review Type Date Requested Status
Checkbox Developers Pending
Review via email: mp+232633@code.launchpad.net

This proposal has been superseded by a proposal from 2014-08-29.

Description of the change

Adds the notes from the training session with the server certification team as a part of the official Checkbox/PlainBox documentation. Note that I left the screen shots as such because this preserves reverse video formatting, which would be lost in a text-only conversion; however, I did crop the first two screen shots to reduce the amount of empty space.

To post a comment you must log in.
Revision history for this message
Daniel Manrique (roadmr) wrote :

Fantastic, thanks!

Some suggestions.

This document was meant to be stand-alone, so it includes a mini-glossary, but the plainbox documentation already has one here:

http://plainbox.readthedocs.org/en/latest/glossary.html

I'd suggest linking to that instead, you should be able to use :ref:`glossary` for that. Also, if my glossary has something different or missing in the global one, perhaps adding that to the global glossary to enrich it would be a good idea.

Next, see this section:

One way to deliver tests via PlainBox is to start your own provider. We have a very good document for Tutorial that:

http://plainbox.readthedocs.org/en/latest/author/tutorial.html

Since this lives in the same sphinx tree as the tutorial, you can use an internal reference to make this tidier. I'd change the above to:

One way to deliver tests via PlainBox is to start your own provider. To learn how to do that, see the :ref:`tutorial`.

Finally, maybe some gardening of the links at the end (so the ones referring to plainbox docs are turned into internal :ref: or :doc: links) would tidy things up a bit.

Still, this is good (thanks for cropping the screenshots, it's exactly what I was thinking about), so if you want to merge it as-is and iterate to improve it, I'd be fine with that.

lp:~rodsmith/checkbox/intro-docs updated
3229. By Rod Smith

Revisions as per Daniel's suggestions

3230. By Rod Smith

Reformatted and addressed some of Zygmunt's comments

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'plainbox/docs/author/cc1.png'
2Binary files plainbox/docs/author/cc1.png 1970-01-01 00:00:00 +0000 and plainbox/docs/author/cc1.png 2014-08-29 19:05:20 +0000 differ
3=== added file 'plainbox/docs/author/cc2.png'
4Binary files plainbox/docs/author/cc2.png 1970-01-01 00:00:00 +0000 and plainbox/docs/author/cc2.png 2014-08-29 19:05:20 +0000 differ
5=== added file 'plainbox/docs/author/cc3.png'
6Binary files plainbox/docs/author/cc3.png 1970-01-01 00:00:00 +0000 and plainbox/docs/author/cc3.png 2014-08-29 19:05:20 +0000 differ
7=== modified file 'plainbox/docs/author/index.rst'
8--- plainbox/docs/author/index.rst 2014-02-04 00:37:00 +0000
9+++ plainbox/docs/author/index.rst 2014-08-29 19:05:20 +0000
10@@ -7,6 +7,7 @@
11 core.
12
13 .. toctree::
14+ intro.rst
15 tutorial.rst
16 providers.rst
17 jobs.rst
18
19=== added file 'plainbox/docs/author/intro.rst'
20--- plainbox/docs/author/intro.rst 1970-01-01 00:00:00 +0000
21+++ plainbox/docs/author/intro.rst 2014-08-29 19:05:20 +0000
22@@ -0,0 +1,359 @@
23+Introduction to PlainBox
24+========================
25+
26+.. contents::
27+
28+What is PlainBox?
29+-----------------
30+
31+Many years ago, a dark sorcerer known only as CR3 created a testing tool
32+called ``hw-test`` with the vision of running tests against hardware to
33+bless the hardware and deem it as Ubuntu Certified. There was great
34+rejoicing. From the crowd that gathered around this tool came requests and
35+requirements for new features, new tests and new methods of doing things.
36+Over the subsequent years, a tool called CheckBox was created. It was the
37+product of the design by committee philosophy and soon grew ponderous and
38+difficult to understand except by a few known only as "The Developers."
39+CheckBox's goal was to function as a universal testing engine that could
40+drive several types of testing: end-users running tests on their systems,
41+certification testing with a larger set of tests, and even OEM-specific
42+testing with custom tests.
43+
44+A couple of years ago CheckBox started showing its age. The architecture
45+was difficult to understand and to extend and the core didn't really scale
46+to some things we wanted to do; however, the test suite itself was still
47+quite valuable.
48+
49+Thus PlainBox was created, as a "plain CheckBox" and again, there was much
50+rejoicing. It was originally meant to be a simpler library for creating
51+testing applications and as a requirement, it was designed to be compatible
52+with the CheckBox test/job definition format.
53+
54+Since then, PlainBox has become a large set of libraries and tools, but the
55+central aim is still to write testing applications. Note that the term
56+*CheckBox* is still used to refer to the test suite generically; *PlainBox*
57+is used to refer to the new tool set "under the hood."
58+
59+Goal
60+----
61+
62+The goal of these tools is of course to run tests. They use a test
63+description language that was inherited from CheckBox, so it has many
64+interesting quirks. Since CheckBox itself is now deprecated, we have been
65+adding new features and improving the test description language so this is
66+in some flux.
67+
68+Terminology
69+-----------
70+
71+In developing or using PlainBox, you'll run into several unfamiliar terms. Check the :doc:`../glossary` to learn what they mean. In fact, you should probably check it now. Pay particular attention to the terms *CheckBox*, *PlainBox*, *job*, *provier*, and *whitelist*.
72+
73+Getting Started
74+---------------
75+
76+To get started, we'll install PlainBox and ``checkbox-ng`` along with some
77+tests and look at how they are organized and packaged.
78+
79+The newest versions are in our PPAs. We'll use the development PPA at
80+``ppa:checkbox-dev/ppa``. From there we'll install ``plainbox``,
81+``checkbox-ng``, and ``plainbox-provider-checkbox``.
82+
83+As an end user this is all I need to run some tests. We can quickly run
84+``checkbox-cli``, which will show a series of screens to facilitate running tests. First up is a welcome screen:
85+
86+.. image:: cc1.png
87+ :height: 178
88+ :width: 800
89+ :scale: 100
90+ :alt: checkbox-cli presents an introductory message before enabling you to select tests.
91+
92+When you press the Enter key, ``checkbox-cli`` lets you select which whitelist to use:
93+
94+.. image:: cc2.png
95+ :height: 343
96+ :width: 300
97+ :scale: 100
98+ :alt: checkbox-cli enables you to select which test suite to run.
99+
100+With a whitelist selected, you can choose the individual tests to run:
101+
102+.. image:: cc3.png
103+ :height: 600
104+ :width: 800
105+ :scale: 100
106+ :alt: checkbox-cli enables you to select or de-select specific tests.
107+
108+When the tests are run, the results are saved to files and the program prompts to submit them to Launchpad.
109+
110+As mentioned, ``checkbox-cli`` is just a convenient front-end for some
111+PlainBox features but it lets us see some aspects of PlainBox.
112+
113+Looking Deeper
114+--------------
115+
116+Providers
117+`````````
118+
119+First, we installed some "provider" packages. Providers were designed to
120+encapsulate test descriptions and their related tools and data. Providers
121+are shipped in Debian packages, which allows us to express dependencies to
122+ensure required external packages are installed, and we can also separate
123+those dependencies; for instance, the provider used for server testing
124+doesn't actually contain the server-specific test definitions (we try to
125+keep all the test definitions in the CheckBox provider), but it does depend
126+on all the packages needed for server testing. Most users will want the
127+resource and CheckBox providers which contain many premade tests, but this
128+organization allows shipping the tiny core and a fully customized provider
129+without extraneous dependencies.
130+
131+A provider is described in a configuration file (stored in
132+``/usr/share/plainbox-providers-1``). This file describes where to find all
133+the files from the provider. This file is usually managed automatically
134+(more on this later) but to see how it's structured, consider the
135+``/usr/share/plainbox-providers-1/2013.com.canonical.certification.checkbox.provider``
136+file::
137+
138+ [PlainBox Provider]
139+ bin_dir = /usr/lib/2013.com.canonical.certification:checkbox/bin
140+ data_dir = /usr/share/2013.com.canonical.certification:checkbox/data
141+ description = Checkbox provider
142+ gettext_domain = 2013.com.canonical.certification.checkbox
143+ jobs_dir = /usr/share/2013.com.canonical.certification:checkbox/jobs
144+ locale_dir = /usr/share/locale
145+ name = 2013.com.canonical.certification:checkbox
146+ version = 0.5
147+ whitelists_dir = /usr/share/2013.com.canonical.certification:checkbox/whitelists
148+
149+You can see a provider can ship jobs, binaries, data and whitelists.
150+
151+A **job** or **test** is the smallest unit or description that PlainBox knows about. It describes a single test (historically they're called jobs).
152+The simplest possible job is::
153+
154+ id: a-job
155+ plugin: manual
156+ description: Ensure your computer is turned on. Is the computer turned on?
157+
158+Jobs are shipped in a provider's jobs directory. This ultra-simple example has three fields: ``id``, ``plugin``, and ``description``. The ``id`` identifies the job (of course) and the ``description`` provides a plain-text description of the job. In the case of this example, the description is shown to the user, who must respond because the ``plugin`` type is ``manual``. ``plugin`` types include (but are not limited to):
159+
160+ * ``manual`` -- A test that requires the user to perform some action and report the results.
161+ * ``shell`` -- An automated test that requires no user interaction; the test is passed or failed on the basis of the return value of the script or command.
162+ * ``local`` -- This type of job is similar to a ``shell`` test, but it supports creating multiple tests from a single definition (say, to test all the Ethernet ports on a computer). Jobs using the ``local`` plugin are run when PlainBox is initialized.
163+ * ``user-interact`` -- A test that asks the user to perform some action *before* the test is performed. The test then passes or fails automatically based on the output of the test. An example is ``keys/media-control``, which runs a tool to detect keypresses, asks the user to press volume keys, and then exits automatically once the last key has been pressed or the user clicks the skip button in the tool.
164+ * ``user-interact-verify`` -- This type of test is similar to the ``user-interact`` test, except that the test's output is displayed for the user, who must then decide whether it has passed or failed. An example of this would be the ``usb/disk_detect`` test, which asks the user to insert a USB key, click the ``test`` button, and then verify manually that the USB key was detected correctly.
165+ * ``user-verify`` -- A test that the user manually performs or runs automatically and requires the user to verify the result as passed or failed. An example of this is the graphics maximum resolution test which probes the system to determine the maximum supported resolution and then asks the user to confirm that the resolution is correct.
166+
167+A fairly complex example definition is::
168+
169+ plugin: local
170+ _summary: Automated test to walk multiple network cards and test each one in sequence.
171+ id: ethernet/multi_nic
172+ requires:
173+ device.category == 'NETWORK'
174+ _description: Automated test to walk multiple network cards and test each one in sequence.
175+ command:
176+ cat <<'EOF' | run_templates -s 'udev_resource | filter_templates -w "category=NETWORK" | awk "/path: / { print \$2 }" | xargs -n 1 sh -c "for i in \``ls /sys\$0/net 2>/dev/null\``; do echo \$0 \$i; done"'
177+ plugin: shell
178+ id: ethernet/multi_nic_$2
179+ requires:
180+ package.name == 'ethtool'
181+ package.name == 'nmap'
182+ device.path == "$1"
183+ user: root
184+ environ: TEST_TARGET_FTP TEST_TARGET_IPERF TEST_USER TEST_PASS
185+ command: network test -i $2 -t iperf --fail-threshold 80
186+ estimated_duration: 330.0
187+ description:
188+ Testing for NIC $2
189+ EOF
190+
191+Key points to note include:
192+
193+ * If a field name begins with an underscore, its value can be localized.
194+ * The values of fields can appear on the same line as their field names, as in ``plugin: local``; or they can appear on a subsequent line, which is indented, as in the preceding example's ``requires: device.category == 'NETWORK'``.
195+ * The ``requires`` field can be used to specify dependencies; if the specified condition is not met, the test does not run.
196+ * The ``command`` field specifies the command that's used to run the test. This can be a standard Linux command (or even a set of commands) or a CheckBox test script. In this example's ``local`` test definition, the first ``command`` line generates a list of network devices that is fed to an embedded test, which is defined beginning with the second ``plugin`` line immediately following the first ``command`` line.
197+ * In this example, the line that reads ``EOF`` ends the ``ethernet/ethtool_multi_nic_$2`` test's command; it's matched to the ``EOF`` that's part of ``cat << 'EOF'`` near the start of that command.
198+
199+Each provider has a ``bin`` directory and all binaries there are available in the
200+path.
201+
202+Whitelists
203+``````````
204+
205+In the job files we have a "universe" of known jobs. We don't normally want
206+to run them all; rather we want to select a subset depending on what we're
207+testing, and maybe give the user a way to fine-tune that selection. Also,
208+we need a way to determine the order in which they will run, beyond what
209+dependencies may provide. This is where the whitelist comes in; think of it
210+as a mask or selection filter from the universe of jobs. Whitelists support
211+regular expressions, and PlainBox will attempt to run tests in the order
212+shown in the whitelist. Again, providers ship whitelists in a specific
213+directory, and you can use ``plainbox`` to run a specific whitelist with
214+the ``-w`` option.
215+
216+You can also use ``plainbox`` to run a test with the ``-i`` syntax. This is
217+good for quickly running a job and ensuring it works well.
218+
219+Let's look at ``checkbox-cli`` for a moment. This is a "launcher"; it
220+specifies a set of configuration options for a specific testing purpose.
221+This enables us to create mini-clients for each testing purpose, without
222+changing the core utility (``checkbox-launcher``). For instance, let's look
223+at the launcher for ``canonical-certification-server``, which appears in
224+``./providers/plainbox-provider-certification-server/launcher/canonical-certification-server``
225+in the CheckBox source tree::
226+
227+ #!/usr/bin/env checkbox-launcher
228+ [welcome]
229+ text = Welcome to System Certification!
230+ This application will gather information from your system. Then you will be
231+ asked manual tests to confirm that the system is working properly. Finally,
232+ you will be asked for the Secure ID of the computer to submit the
233+ information to the certification.canonical.com database.
234+ To learn how to create or locate the Secure ID, please see here:
235+ https://certification.canonical.com/
236+
237+ [suite]
238+ # Whitelist(s) displayed in the suite selection screen
239+ whitelist_filter = ^((network|storage|usb|virtualization)-only)|(server-(full|functional)-14.04)$
240+ # Whitelist(s) pre-selected in the suite selection screen, default whitelist(s)
241+ whitelist_selection = ^server-full-14.04$
242+
243+ [transport]
244+ submit_to = certification
245+
246+ [config]
247+ config_filename = canonical-certification.conf
248+
249+A launcher such as this sets up an environment that includes introductory
250+text to be shown to users, a filter to determine what whitelists to present
251+as options, information on where to (optionally) submit results, and a
252+configuration filename. This allows each provider to ship a launcher or
253+binary with which to launch its relevant tests.
254+
255+Developing Tests
256+````````````````
257+
258+One way to deliver tests via PlainBox is to start your own provider. To learn how to do that, see the :ref:`tutorial`.
259+
260+In other cases you want to add tests to the main CheckBox repository (which
261+is also what we recommend to keep tests centralized, unless they're so
262+purpose-specific that this makes no sense).
263+
264+This is a bit easier because the provider in question already exists. So
265+let's get started by branching a copy of ``lp:checkbox``. In brief, you
266+should change to your software development directory and type ``bzr branch
267+lp:checkbox my-branch`` to create a copy of the ``checkbox`` Launchpad
268+project in the ``my-branch`` subdirectory. You can then edit the files in
269+that subdirectory, upload the results to your own Launchpad account, and
270+request a merge.
271+
272+To begin, consider the files and subdirectories in the main CheckBox
273+development directory (``my-branch`` if you used the preceding ``bzr``
274+command without change):
275+
276+ * ``checkbox-gui`` -- CheckBox GUI components, used in desktop/laptop testing
277+ * ``checkbox-ng`` -- The PlainBox-based version of CheckBox
278+ * ``checkbox-support`` -- Support code for many providers
279+ * ``checkbox-touch`` -- A CheckBox frontend optimized for touch/tablet devices
280+ * ``mk-venv`` -- A symbolic link to a script used to set up an environment for testing CheckBox
281+ * ``plainbox`` -- A Python3 library and development tools at the heart of PlainBox
282+ * ``plainbox-client`` -- Unfinished Python3 interface for CheckBox
283+ * ``providers`` -- Provider definitions, including test scripts
284+ * ``README.md`` -- A file describing the contents of the subdirectory in greater detail
285+ * ``setup.py`` -- A setup script
286+ * ``support`` -- Support code that's not released
287+ * ``tarmac-verify`` -- A support script
288+ * ``test-in-lxc.sh`` -- A support script for testing in an LXC
289+ * ``test-in-vagrant.sh`` -- A support script for testing with Vagrant
290+ * ``test-with-coverage`` -- A link to a support script for testing with coverage
291+ * ``Vagrantfile`` -- A Vagrant configuration file
292+
293+Let's say I want to write a test to ensure that the ubuntu user exists in
294+``/etc/passwd``. You need to remove any existing CheckBox provider
295+packages, lest they interfere with your new or modified tests. The
296+``setup.py`` script will set up a PlainBox development environment for you.
297+
298+We can write a simple job here, then add a requirement, perhaps a
299+dependency, then a script in the directory. Note that scripts can be
300+anything that's executable, we usually prefer either shell or Python but
301+anything goes.
302+
303+PlainBox will supply two environment variables, ``PLAINBOX_PROVIDER_DATA``
304+and ``SHARE``, we usually try to use them in the job description only, not
305+in the scripts, to keep the scripts PlainBox-agnostic if possible.
306+
307+Once the test is running correctly, we can create a whitelist with a few tests
308+and name it.
309+
310+Once we get everything running correctly we can prepare and propose a merge
311+request using ``bzr`` as usual.
312+
313+Other Questions
314+---------------
315+
316+ **What Python modules are useful?**
317+ I usually Google for the description of the problem I'm trying to solve, and/or peruse the Python documentation in my spare time. I recommend the *Dive Into Python* books if you have experience with another language, as they are very focused on how to translate what you know into Python. This applies also to Pythonisms like iterators, comprehensions, and dictionaries which are quite versatile, and others. Again, the *Dive* books will show you how these work.
318+
319+ **Are there other tools to use?**
320+ ``flake8`` or ``pyflakes``, it's always a good idea to run this if you
321+ wrote a Python script, to ensure consistent syntax. ``manage.py
322+ validate`` and ``plainbox dev analyze`` are also good tools to know
323+ about.
324+
325+ **Is there a preferred editor for Python programming?**
326+ I don't really know of a good editor/IDE that will provide a lot of help when developing Python, as I usually prefer a minimalistic editor. I'm partial to ``vim`` as it has syntax coloring, decent formatting assistance, can interface with ``git`` and ``pyflakes`` and is just really fast. We even have a plugin for PlainBox job files. Another good option if you're not married to an editor is sublime text, Zygmunt has been happy with it and it seems easy to extend, plus it's very nice-looking. A recent survey identified Kate as a good alterntive. The same survey identified ``gedit`` as *not* a good alternative so I'd avoid that one. Finally if you're into cloud, ``cloud9.io`` may be an option although we don't have a specific PlainBox development setup for it.
327+
328+References
329+----------
330+
331+ :doc:`Reference on PlainBox test authoring <index>`
332+
333+ :doc:`jobs`
334+
335+ :doc:`PlainBox provider template <provider-template>`
336+
337+ :doc:`Provider and job writing tutorial <tutorial>`
338+
339+ :doc:`../dev/intro`
340+
341+ :doc:`What resources are and how they work <../dev/resources>`
342+
343+ :doc:`Man pages on special variables available to jobs <../manpages/PLAINBOX_SESSION_SHARE>`
344+
345+ :doc:`All the manpages <../manpages/index>`
346+
347+ `The CheckBox stack diagram`_
348+
349+.. _The CheckBox stack diagram: http://checkbox.readthedocs.org/en/latest/stack.html
350+
351+ `Old CheckBox documentation for nostalgia`_
352+
353+.. _Old CheckBox documentation for nostalgia: https://wiki.ubuntu.com/Testing/Automation/CheckBox
354+
355+ `Usual Python modules`_
356+
357+.. _Usual Python modules: https://docs.python.org/3.3/
358+
359+ `Document on upcoming template units feature`_
360+
361+.. _Document on upcoming template units feature: http://bazaar.launchpad.net/~checkbox-dev/checkbox/trunk/view/head:/plainbox/docs/manpages/plainbox-template-units.rst
362+
363+ `A quick introduction to Bazaar and bzr`_
364+
365+.. _A quick introduction to Bazaar and bzr: http://doc.bazaar.canonical.com/bzr.dev/en/mini-tutorial/
366+
367+ `A tool to use git locally but be able to pull/push from Launchpad`_
368+
369+.. _A tool to use git locally but be able to pull/push from Launchpad: http://zyga.github.io/git-lp/
370+
371+ `A video on using git with Launchpad`_
372+
373+.. _A video on using git with Launchpad: https://plus.google.com/115602646184989903283/posts/RCepekrA5gu
374+
375+ `A video on how to set up Sublime Text for PlainBox development`_
376+
377+.. _A video on how to set up Sublime Text for PlainBox development: https://www.youtube.com/watch?v=mrfyAgDg4ME&list=UURGrmUhQo5P9hTbVskIIjoQ
378+
379+ `CheckBox(ng) documentation home`_
380+
381+.. _CheckBox(ng) documentation home: http://checkbox.readthedocs.org
382
383=== modified file 'plainbox/docs/glossary.rst'
384--- plainbox/docs/glossary.rst 2014-03-12 20:05:37 +0000
385+++ plainbox/docs/glossary.rst 2014-08-29 19:05:20 +0000
386@@ -21,12 +21,30 @@
387 available at http://launchpad.net/checkbox. The ``checkbox`` package is
388 pre-installed on all Ubuntu systems
389
390+ Checkbox-ng
391+
392+ This is the actual direct replacement for CheckBox. It provides a
393+ few binaries that can do end-user testing, and which leverage
394+ PlainBox as a library to do the heavy lifting. This lives in the
395+ ``checkbox-ng`` package for the binaries, and
396+ ``python3-checkbox-ng`` for the core functionality.
397+
398 PlainBox
399
400 PlainBox is a rewrite of CheckBox with the aim of improving internal
401 architecture, testability, robustness, quality and speed. It is
402 currently under active development. It is not pre-installed on Ubuntu.
403- It is developed inside CheckBox code repository.
404+ It is developed inside the CheckBox code repository. In common
405+ use, the term *PlainBox* can refer to either of two things:
406+
407+ * The core library (``python3-plainbox``). ``python3-plainbox`` is
408+ usually installed implicitly, as most of our tools depend on it.
409+
410+ * The ``plainbox`` utility/binary, which is essentially a
411+ command-line swiss-army frontend to all of the library's
412+ functionality. It's useful for develoment and diagnostics but not
413+ necessary for end-user work. ``plainbox`` is usually installed
414+ explicitly if needed.
415
416 whitelist
417

Subscribers

People subscribed via source and target branches