Provides a wrapper around LXC via the lxd-client tools to automate test execution
lxctest provides a wrapper around lxd-client tools to automate test execution, while leaving the test creation and analysis to the user. It uses LXC to launch Ubuntu containers with specific customizations, run a series of commands, and items to gather as output all set by the user. By using LXC the user has a much faster way of running tests compared to VMs.
sudo apt install lxd distro-info python3-pip python3-yaml
pip3 install lxctest lxctest <filename>
git clone https://github.com/powersj/lxctest cd lxctest pip3 install -r requirements.txt python3 -m lxctest <filename>
A single YAML test case file is used to define the following items for each test:
The syntax for each of the above is defined below.
The image specification defines what LXC image will be used for the test. This includes the store and release. If no options are received, then by default the release LTS image will be used. Specifically:
lxc: store: release releases: lts
Defines which store of Ubuntu images to use. Two options:
lxc: store: images # Default store: ubuntu store: ubuntu-daily
Defines the targeted releases from the following options:
lxc: releases: lts # Default releases: supported releases: - xenial - yakkety - fedora/22
Architecture to test is defined by the system’s architecture.
There are two possible ways to customize an image: 1) push specific files to a container 2) use cloud-init’s user-data to inject data.
Files can be pushed over using lxc file push to customize the container. This is done via a list of lists specifying the source and then destination.
push: - - my_local_script.sh - /usr/bin/ - - examples/scripts/test.py - /root/
If the image used contains cloud-init, then user-data can be passed to the container. This is done using a file containing the cloud data. This data is passed in via --config=user.user-data= option on container launch.
Runs lxc exec on a list of commands to execute once the container is up and running.
execute: - python my_script.py execute: - whoami - date - uname -a
Files can be pulled using lxc file pull to collect information or results from the container. Only the source is required as all files will be put in the log directory.
pull: - file pull: - file1 - file2