lorax/test
Jacob Kozol 38f1edd2aa Add test for VALID_BLUEPRINT_NAME check
Blueprint names can only contain alphanumeric characters and the characters: ._-. This test checks that an api request to create a blueprint with invalid characters in its name will return an InvalidChars error.
2019-07-09 22:53:51 +02:00
..
check-api Add test for VALID_BLUEPRINT_NAME check 2019-07-09 22:53:51 +02:00
check-cli Revert "test: Disable test_live_iso test" 2019-06-25 10:24:51 +02:00
check-cloud Use Cockpit's test images and infrastructure 2019-05-20 20:24:01 +02:00
composertest.py test: Output results for cockpit's log.html 2019-06-25 23:50:16 +02:00
README.md test/README.md: Add section explaining GitHub integration 2019-07-03 16:51:37 +02:00
run Add API integration test 2019-06-04 11:50:25 +03:00
vm.install test: Install beakerlib on non-RHEL images 2019-05-23 12:00:30 +02:00

Integration Tests

lorax uses Cockpit's integration test framework and infrastructure. To do this, we're checking out Cockpit's bots/ subdirectory. It contains links to test images and tools to manipulate and start virtual machines from them.

Each test is run on a new instance of a virtual machine. Branch/test matrix is configured in bots/tests-scan inside the cockpit repository.

Dependencies

These dependencies are needed on Fedora to run tests locally:

$ sudo dnf install curl expect \
    libvirt libvirt-client libvirt-daemon libvirt-python \
    python python-libguestfs python-lxml libguestfs-xfs \
    python3 libvirt-python3 \
    libguestfs-tools qemu qemu-kvm rpm-build rsync xz

Building a test VM

To build a test VM, run

$ make vm

This downloads a base image from Cockpit's infrastructure. You can control which image is downloaded with the TEST_OS environment variable. Cockpit's documentation lists accepted values. It then creates a new image based on that (a qemu snapshot) in tests/images, which contain the current tests/ directory and have newly built rpms from the current checkout installed.

To delete the generated image, run

$ make vm-reset

Base images are stored in bots/images. Set TEST_DATA to override this directory.

Running tests

After building a test image, run

$ ./test/check-cli [TESTNAME]

or any of the other check-* scripts. To debug a test failure, pass --sit. This will keep the test machine running after the first failure and print an ssh line to connect to it.

Run make vm after changing tests or lorax source to recreate the test machine. It is usually not necessary to reset the VM.

Updating images

The bots/ directory is checked out from Cockpit when make vm is first run. To get the latest images you need to update it manually (in order not to poll GitHub every time):

$ make -B bots

GitHub integration

Tests are automatically triggered for every pull request. To disable tests for a pull request, add the no-test label when opening it.

To interact with GitHub from scripts in bots/, generate a token with at least repo:status, public_repo, and read:org permissions, and put it into ~/.config/github-token.

You can retry a failed test with:

$ bots/tests-trigger --repo weldr/lorax <PR> <test>

If no test is given, all failed tests will be retried. Pass --allow to trigger tests on a pull request by an outside contributor.