1
==========================
2
Juju GUI Charm Development
3
==========================
9
There are two types of tests for the charm: unit tests and functional tests.
15
The unit tests do not require a functional Juju environment, and can be run
18
python tests/unit.test
20
Unit tests should be created in the "tests" subdirectory and be named in the
21
customary way (i.e., "test_*.py").
27
Running the functional tests requires a Juju testing environment as provided
28
by the Jitsu test command. All files in the tests directory which end with
29
".test" will be run in a Juju Jitsu test environment.
35
At the time of this writing the Jitsu test command is not yet released. To run
36
it you must first install it locally. The files may be installed globally, or
37
into your home directory (as here)::
39
sudo apt-get install autoconf libtool python-charmhelpers
40
bzr branch lp:~jimbaker/juju-jitsu/unit-test jitsu-unit-test
43
./configure --prefix=$HOME
47
The current incarnation of the Jitsu test command requires that the current
48
directory name match the charm name, so you must check out the charm into a
49
directory named "juju-gui"::
51
bzr branch lp:~juju-gui/charms/precise/juju-gui/trunk juju-gui
53
The branch directory must be placed (or linked from) within a local charm
54
repository. It consists of a directory, itself containing a number of
55
directories, one for each distribution codename, e.g. ``precise``. In turn, the
56
codename directories will contain the charm repositories.
58
Now you are ready to run the functional tests (see the next section).
61
Running the functional tests
62
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64
Jitsu requires the charm directory be named the same as the charm and it be the
65
current working directory when the tests are run::
67
JUJU_REPOSITORY=/path/to/charm/repo ~/bin/jitsu test juju-gui \
68
--logdir /tmp --timeout 40m
70
This command will bootstrap the default Juju environment specified in your
71
``~/.juju/environments.yaml``.
73
If you are going to run the tests often, you probably want to set up LXC and
74
run the tests locally by setting your default environment to a "local" one.
75
Among other things you will need to install apt-cacher-ng and LXC to do so.
77
Unfortunately, currently running tests on a local environment is quite slow
78
(with quantal host and precise container at least), so you may want to further
79
increase the ``jitsu test`` command timeout.
81
If Jitsu generates errors about not being able bootstrap::
83
CalledProcessError: Command '['juju', 'bootstrap']'...
85
...or it hangs, then you may need to bootstrap the environment yourself and
86
pass the --no-bootstrap switch to Jitsu.
88
If you do not yet have an environment defined, the Jitsu command
89
"setup-environment" is an easy way to get started.