- In a module’s root directory create a directory
testsand place there a module configuration file
config.yamldescribed in detail in section Configuration file. If you would like to use MTF without your own
config.yaml. It is possible. It uses default minimal config. Then you have to set
URLenvvar to set test subject, otherwise it causes traceback. It is usefull for example for module what does not provide any service (no own
start/stop/status/etcaction defined.) or for testing with modulelint.
- Optionally write multiline Bash snippet tests directly in the
tests/config.yamlfile as described in section Multiline Bash snippet tests.
- Check the list of Environment variables.
- Write your tests, for example see sanity tests and various tests examples in
/usr/share/moduleframework/examples/testing-module/. All tests methods are listed in section API Index and alphabetically in Index section.
In the directory
Mind to keep the
mtf-generatorline only if there are multiline Bash snippet tests in the
mtf-generatorcommand will convert those multiline Bash snippet tests from the
tests/config.yamlfile into Python tests and stores them in the
tests/generated.pyfile, which will be processed further by avocado.
MODULE_LINT=/usr/share/moduleframework/tests/generic/*.py TESTS=*.py CMD=avocado run $(MODULE_LINT) $(TESTS) # all: mtf-generator $(CMD)
- In a module’s root directory create a
Makefile, which contains a secton test. For example:
.PHONY: build run default IMAGE_NAME = debugging-tools MODULEMDURL=file://debugging-tools.yaml all: run default: run build: docker build --tag=$(IMAGE_NAME) . run: build docker run -it --name $(IMAGE_NAME) --privileged --ipc=host --net=host --pid=host -e HOST=/host -e NAME=$(IMAGE_NAME) -e IMAGE=$(IMAGE_NAME) -v /run:/run -v /var/log:/var/log -v /etc/machine-id:/etc/machine-id -v /etc/localtime:/etc/localtime -v /:/host $(IMAGE_NAME) test: build cd tests; MODULE=docker MODULEMD=$(MODULEMDURL) URL="docker=$(IMAGE_NAME)" make all cd tests; MODULE=nspawn MODULEMD=$(MODULEMDURL) make all cd tests; MODULE=openshift OPENSHIFT_IP="127.0.0.1" OPENSHIFT_USER="developer" OPENSHIFT_PASSWORD="developer" make all
- Prepare the environment to run tests in.
- Execute tests from the module root directory by running
#run tests from a module root directory $ make test
or from the
testsdirectory by running#run Python tests from the tests/ directory $ sudo MODULE=docker mtf ./*.py
or#run Bash tests from the tests/ directory $ sudo MODULE=docker mtf ./*.sh
- Clean up the environment after test execution.
- Configuration file
- Enviroment setup
- Environment variables
- Workflow integration