Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed docs/_images/checkbox-snappy-1-test-plan.png
Binary file not shown.
Binary file removed docs/_images/checkbox-snappy-2-resume-session.png
Binary file not shown.
Binary file removed docs/_images/checkbox-snappy-3-select-jobs.png
Binary file not shown.
Binary file removed docs/_images/checkbox-snappy-4-user-interact-job.png
Binary file not shown.
Binary file removed docs/_images/checkbox-snappy-5-rerun-jobs.png
Binary file not shown.
Binary file removed docs/_images/checkbox-snappy-6-test-results.png
Binary file not shown.
1 change: 0 additions & 1 deletion docs/how-to/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ These how-to guides cover key operations and processes in Checkbox.
:maxdepth: 1
:glob:

testing-ubuntu-core
custom-app
nested-test-plan
side-loading
Expand Down
115 changes: 0 additions & 115 deletions docs/how-to/testing-ubuntu-core.rst

This file was deleted.

2 changes: 2 additions & 0 deletions docs/reference/units/category.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _category_unit:

=============
Category Unit
=============
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Once you have completed the core tutorial, the extended optional tutorial
sections can be followed in any order - they don’t depend on each other.

.. toctree::
:maxdepth: 1
:maxdepth: 1

writing-tests/test-case
writing-tests/test-plan
15 changes: 15 additions & 0 deletions docs/tutorial/using-checkbox/installing-checkbox.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,27 @@ run the following::
[...]
checkbox (22.04/stable) X.Y.Z from Canonical Certification Team (ce-certification-qa) installed

If you are on Ubuntu Core, then you can't install the classic frontend.
You should use the following strict frontend instead::

$ sudo snap install checkbox --channel=uc22/stable --devmode
[...]
checkbox (22.04/stable) X.Y.Z from Canonical Certification Team (ce-certification-qa) installed

.. note::
There are multiple frontends as you may discover by typing ``snap info checkbox``.
If you are unsure about what ``frontend`` you should use, consider
reading this page: :ref:`ref_which_snap`, but for the scope of this tutorial the one
installed in this snipped is enough.

.. warning::
Checkbox will automatically start a agent service on your device when you
install it. To follow this tutorial you will need this service but you
should consider stopping it whenever you don't need it as it allows full
unauthenticated root level remote control of your machine! To disable it run
``snap stop --disable checkbox``. To start it once you need it run
``snap start checkbox``.

Now that we have installed both we can launch Checkbox running:

.. code-block:: none
Expand Down
30 changes: 13 additions & 17 deletions docs/tutorial/using-checkbox/remote.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,29 @@ Run the following command:

.. code-block:: none

systemctl status snap.checkbox.agent.service
snap services checkbox

You should see something like this:

.. code-block:: none

● snap.checkbox.agent.service - Service for snap application checkbox.service
Loaded: loaded (/etc/systemd/system/snap.checkbox.service.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2023-07-21 13:38:48 CST; 1h 29min ago
Main PID: 1411 (python3)
Tasks: 1 (limit: 19014)
Memory: 69.7M
CPU: 2.537s
CGroup: /system.slice/snap.checkbox.agent.service
└─1411 python3 /snap/checkbox22/current/bin/checkbox-cli run-agent

Jul 21 13:38:48 coltrane systemd[1]: Started Service for snap application checkbox.service.
(...)
Service Startup Current Notes
checkbox.agent disabled inactive -

When you install Checkbox on a device, a Systemd service is started to turn
this device into a Checkbox agent.

For the sake of this tutorial, let's stop this service for the moment:
the device into a Checkbox agent. We have instructed you to disable this
service in :ref:`installing_checkbox` but in case you didn't do so, run the
following:

.. code-block:: none

sudo systemctl stop snap.checkbox.agent.service
snap stop --disable checkbox

.. warning::
Remember that while the agent is running, the device is fully controllable
via the network at a root level without any authentication! This is the
purpose of Checkbox, but a bit too scary to keep this enabled on your
personal device.

Now, open two terminal windows using ``Ctrl+Alt+T``. In the first one,
start the Checkbox agent:
Expand Down
69 changes: 59 additions & 10 deletions docs/tutorial/writing-tests/test-case.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. _test_case:
.. _adv_test_case:

=================
Writing Test Jobs
Expand All @@ -15,7 +15,7 @@ ideal for prototyping. To provision Checkbox from source do the following:
.. code-block:: shell

# first install python3 and python3-venv
$ sudo apt install python3 python3-venv python3-pip
$ sudo apt install python3 python3-virtualenv python3-pip
# clone the Checkbox repository
$ git clone https://github.com/canonical/checkbox.git
# call the mk-venv script with the location of your virtualenv
Expand All @@ -37,6 +37,12 @@ ideal for prototyping. To provision Checkbox from source do the following:
Remember to activate the virtual environment! You can also create an alias
in your ``~/.bashrc`` to enable it when you need it.

.. note::
All of the commands in this tutorial are using the
``com.canonical.certification`` namespace. If you want to continue the one you
have started before, remember to change the namespace
(i.e. ``2024.com.tutorial::tutorial``) in the commands as well!

Creating a new provider
=======================

Expand All @@ -45,7 +51,7 @@ Checkbox organizes and manages all jobs, test plans and other test units in vari
Let's create a new Checkbox provider by using the Checkbox sub-command
``startprovider``.

.. code-block:: shell
.. code-block:: none

(checkbox_venv) $ checkbox-cli startprovider 2024.com.tutorial:tutorial

Expand Down Expand Up @@ -105,6 +111,13 @@ Now to run our test we can use the ``run`` sub-command. Try the following:
☑ : A job that always passes


.. important::
You should always run ``python3 manage.py validate`` before running your
tests. This ensures that your unit is valid and Checkbox will interpret it
correctly. When you don't do it, Checkbox may ignore some errors in your
unit and, for example, fail to load some jobs leaving you wondering why the
``run`` command doesn't work!

First concrete test example
===========================

Expand Down Expand Up @@ -151,12 +164,44 @@ like this:
==================================[ Results ]===================================
☑ : Test that the internet is reachable

Similarly to ``summary`` and ``id``, consider also providing a ``category`` for
your tests. It makes the output easier to read and clearer (you can see that we
are getting an ``uncategorised`` category right now). Additionally it is used
in the Test Selection screen to group your tests, so when you have many of
them, it makes sifting through them that much easier. You can create your own
category (See: :ref:`category_unit`), but consider using the built-in ones.

To get a list of them, try the following:

.. code-block:: none

(checkbox_venv) $ checkbox-cli list "category" | grep "com.canonical.plainbox"

.. note::
Similarly to ``summary`` and ``id``, consider also providing a ``category``
for your tests. It makes the output easier to read and clearer (you can see
that we are getting an ``uncategorised`` category right now). Additionally
it is used in the Test Selection screen to group your tests, so when you
have many of them, it makes sifting through them that much easier.
We grep for ``com.canonical.plainbox`` categories because those are part of
Checkbox. If you use a category id that is not builtin, remember that doing
so adds a new dependency between your provider and the one that defines the
category unit you are using!

We can use the ``com.canonical.plainbox::networking`` category for our tests by
modifying the unit as follows:

.. code-block:: none

id: network_available
flags: simple
_summary: Test that the internet is reachable
category_id: com.canonical.plainbox::networking
command:
ping -c 1 1.1.1.1

As any other unit that is not defined in the same namespace you are using, when
referring to it you have to use the full name, including the namespace!

.. note::
We will omit the ``category_id`` from all units in this tutorial to make the
snippets shorter but you should always use it for your production unit.


Dependencies
============
Expand Down Expand Up @@ -337,7 +382,8 @@ Create a new job with the following content:
"\nlink_info_kind: " + .linkinfo.info_kind +
"\nlink_type: " + .link_type + "\n"'

We are using ``jq`` to parse the output of the ``ip`` command, which means we need to make sure ``jq`` is available. We need to declare this in
We are using ``jq`` to parse the output of the ``ip`` command, which means we
need to make sure ``jq`` is available. We need to declare this in
the correct spot, otherwise this will not work in a reproducible manner. Let's add
a packaging meta-data unit to our ``units/extended_tutorial.pxu`` file:

Expand All @@ -349,7 +395,10 @@ a packaging meta-data unit to our ``units/extended_tutorial.pxu`` file:
Depends:
jq

If you now run the following command you will notice a validation error.
If you have ``developed`` the other providers that Checkbox comes with, by
running the following command you will notice a validation error. If you don't
see this error, don't worry, it means you don't have the base provider
``installed`` or ``developed`` yet.

.. code-block:: none

Expand Down
Loading
Loading