Merge "Add a tox target to run functional tests locally"
This commit is contained in:
commit
45928ab5d1
@ -375,6 +375,18 @@ In order to create a test case, follow these steps:
|
|||||||
python
|
python
|
||||||
""""""
|
""""""
|
||||||
|
|
||||||
|
To run functional tests locally, install and start docker, then use
|
||||||
|
the following tox command::
|
||||||
|
|
||||||
|
tox -efunc
|
||||||
|
|
||||||
|
Note that running functional tests requires *sudo* rights, thus you may be
|
||||||
|
asked for your password.
|
||||||
|
|
||||||
|
To run functional tests for one element, append its name to the command::
|
||||||
|
|
||||||
|
tox -efunc ironic-agent
|
||||||
|
|
||||||
Additionally, elements can be tested using python unittests. To create a
|
Additionally, elements can be tested using python unittests. To create a
|
||||||
a python test:
|
a python test:
|
||||||
|
|
||||||
|
@ -3,7 +3,11 @@
|
|||||||
set -eux
|
set -eux
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
|
element=${1:-}
|
||||||
|
|
||||||
|
if [ -z $element ]; then
|
||||||
$(dirname $0)/image_output_formats.bash
|
$(dirname $0)/image_output_formats.bash
|
||||||
$(dirname $0)/test_elements.bash
|
fi
|
||||||
|
$(dirname $0)/test_elements.bash $element
|
||||||
|
|
||||||
echo "Tests passed!"
|
echo "Tests passed!"
|
||||||
|
@ -4,16 +4,30 @@ set -eux
|
|||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
basedir=$(dirname $0)
|
basedir=$(dirname $0)
|
||||||
|
requested_element=${1:-}
|
||||||
source $basedir/test_functions.bash
|
source $basedir/test_functions.bash
|
||||||
|
|
||||||
for test_element in $basedir/../elements/*/test-elements/*; do
|
function run_on_element {
|
||||||
if [ -d "$test_element" ]; then
|
test_element=$1
|
||||||
# our element name is two dirs up
|
# our element name is two dirs up
|
||||||
element_name=$(basename $(dirname $(dirname $test_element)))
|
local element_name=$(basename $(dirname $(dirname $test_element)))
|
||||||
element_type=disk
|
local element_type=disk
|
||||||
if [ -f "$test_element/element-type" ]; then
|
if [ -f "$test_element/element-type" ]; then
|
||||||
element_type=$(cat "$test_element/element-type")
|
element_type=$(cat "$test_element/element-type")
|
||||||
fi
|
fi
|
||||||
run_${element_type}_element_test "$(basename $test_element)" "$element_name"
|
run_${element_type}_element_test "$(basename $test_element)" "$element_name"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z $requested_element ]; then
|
||||||
|
for test_element in $basedir/../elements/*/test-elements/*; do
|
||||||
|
if [ -d "$test_element" ]; then
|
||||||
|
run_on_element "$test_element"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
else
|
||||||
|
for test_element in $basedir/../elements/$requested_element/test-elements/*; do
|
||||||
|
if [ -d "$test_element" ]; then
|
||||||
|
run_on_element "$test_element"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
4
tox.ini
4
tox.ini
@ -19,6 +19,10 @@ commands =
|
|||||||
[testenv:venv]
|
[testenv:venv]
|
||||||
commands = {posargs}
|
commands = {posargs}
|
||||||
|
|
||||||
|
[testenv:func]
|
||||||
|
envdir = {toxworkdir}/venv
|
||||||
|
commands = {toxinidir}/tests/run_functests.sh {posargs}
|
||||||
|
|
||||||
[testenv:cover]
|
[testenv:cover]
|
||||||
setenv = PYTHON=coverage run --source diskimage_builder
|
setenv = PYTHON=coverage run --source diskimage_builder
|
||||||
commands = bash -c 'if [ ! -d ./.testrepository ] ; then testr init ; fi'
|
commands = bash -c 'if [ ! -d ./.testrepository ] ; then testr init ; fi'
|
||||||
|
Loading…
Reference in New Issue
Block a user