nodepool/TESTING.rst
Jeremy Stanley d23662e50f Update unit test container setup and instructions
Update the TESTING.rst file to reflect that just installing and
starting zookeeperd is no longer sufficient now that we require TLS
and auth for the connection. Suggest the container-based setup
script instead. Also improve that script to allow it to be invoked
as a normal user, with root command escalation tool choice (e.g.
"sudo") supplied through a ROOTCMD environment variable, so that
things created inside the git worktree like the CA don't end up
root-owned.

Change-Id: Ia00f5514ba0bd97b2ef17fb798b7c2dc68d9a55e
2022-08-05 18:27:46 +00:00

2.3 KiB

Testing Nodepool

A Quickstart

This is designed to be enough information for you to run your first tests on an Ubuntu 16.04 (or later) host.

Install pip:

sudo apt-get install python3-pip

More information on pip here: http://www.pip-installer.org/en/latest/

Use pip to install tox:

sudo pip3 install tox

A running zookeeper is required to execute tests, but it also needs to be configured for TLS and a certificate authority set up to handle socket authentication. Because of these complexities, it's recommended to use a helper script to set up these dependencies:

sudo apt-get install docker-compose  # or podman-compose if preferred
ROOTCMD=sudo tools/test-setup-docker.sh

Run The Tests

Navigate to the project's root directory and execute:

tox

Note: completing this command may take a long time (depends on system resources) also, you might not see any output until tox is complete.

Information about tox can be found here: http://testrun.org/tox/latest/

Run The Tests in One Environment

Tox will run your entire test suite in the environments specified in the project tox.ini:

[tox]

envlist = <list of available environments>

To run the test suite in just one of the environments in envlist execute:

tox -e <env>

so for example, run the test suite in py35:

tox -e py35

Run One Test

To run individual tests with tox:

tox -e <env> -- path.to.module.Class.test

For example, to run a single Nodepool test:

tox -e py35 -- nodepool.tests.unit.test_launcher.TestLauncher.test_node_assignment

To run one test in the foreground (after previously having run tox to set up the virtualenv):

.tox/py35/bin/stestr run nodepool.tests.unit.test_launcher.TestLauncher.test_node_assignment

List Failing Tests

.tox/py35/bin/activate stestr failing --list

Hanging Tests

The following will run each test in turn and print the name of the test as it is run:

. .tox/py35/bin/activate
stestr run

You can compare the output of that to:

python -m testtools.run discover --list

Need More Info?

More information about stestr: http://stestr.readthedocs.io/en/latest/