diskimage-builder/tests/run_output_format_test.sh

78 lines
2.0 KiB
Bash
Raw Normal View History

Rework functional test runner This simplifies and enhances the functional-test runner script for much better interactive behaviour and to give us the ability to better choose what is running in CI. Firstly, I have split the image-output testing into a separate script. This is not actually part of the functional testing of elements and is both logically and functionally different. It currently does not run in upstream CI because we don't have docker in the images. I have nothing against it, but it can be it's own thing. run_functests.sh is overhauled to have a useful interactive interface, e.g. --- $ ./run_functests.sh -h run_functests.sh [-h] [-l] <test> <test> ... -h : show this help -l : list available tests <test> : functional test to run Special test 'all' will run all tests $ ./run_functests.sh -l The available functional tests are: apt-sources/test-sources debian/build-succeeds fedora/build-succeeds fedora/build-succeeds-f21 ironic-agent/build-succeeds-fedora --- As described there, you can run a single test, a number of tests, the default tests (as CI will do) or all tests. Running all tests is too much for regular CI, but currently the only way to stop a low priority test running, or temporarily pause is to remove it completely -- clearly sub-optimal (see I93c2990472e88ab3e5ff14db56b4ff1b4dd965ef). There is nothing complicated about this, and to further simplify I have merged the runner functions back into run_functests.sh which remains a very modest ~150 lines, with most of that being argument sanity. With that and the image-format cleanup, we can remove the indirection of the 3 small library files. For consistency, I have renamed the "dib_functions_test" (that tests things from the dib functions library) with a run_* prefix. Because the default list is the same as the current functional tests run, this does not modify the status-quo. I plan to modify this, however, to run fedora-minimal & centos-minimal tests in a future change, as these are required to be stable for openstack ci. Documentation is updated, and a README.rst is added in the tests directory for discoverability. Change-Id: I86d208bd34ff09a29fdb916a4e7ef740c7f65af8
2016-02-05 03:54:50 +00:00
#!/bin/bash
set -eu
set -o pipefail
#
# run_output_format_test.sh
#
# Use docker to test generation of various output formats.
#
BASE_DIR=$(cd $(dirname "$0")/.. && pwd)
export DIB_ELEMENTS=$BASE_DIR/elements
export TEST_ELEMENTS=$BASE_DIR/tests/elements
export DIB_CMD=$BASE_DIR/bin/disk-image-create
function build_test_image() {
format=${1:-}
if [ -n "$format" ]; then
type_arg="-t $format"
else
type_arg=
format="qcow2"
fi
dest_dir=$(mktemp -d)
base_dest=$(basename $dest_dir)
trap "rm -rf $dest_dir; sudo docker rmi $base_dest/image" EXIT
Rework functional test runner This simplifies and enhances the functional-test runner script for much better interactive behaviour and to give us the ability to better choose what is running in CI. Firstly, I have split the image-output testing into a separate script. This is not actually part of the functional testing of elements and is both logically and functionally different. It currently does not run in upstream CI because we don't have docker in the images. I have nothing against it, but it can be it's own thing. run_functests.sh is overhauled to have a useful interactive interface, e.g. --- $ ./run_functests.sh -h run_functests.sh [-h] [-l] <test> <test> ... -h : show this help -l : list available tests <test> : functional test to run Special test 'all' will run all tests $ ./run_functests.sh -l The available functional tests are: apt-sources/test-sources debian/build-succeeds fedora/build-succeeds fedora/build-succeeds-f21 ironic-agent/build-succeeds-fedora --- As described there, you can run a single test, a number of tests, the default tests (as CI will do) or all tests. Running all tests is too much for regular CI, but currently the only way to stop a low priority test running, or temporarily pause is to remove it completely -- clearly sub-optimal (see I93c2990472e88ab3e5ff14db56b4ff1b4dd965ef). There is nothing complicated about this, and to further simplify I have merged the runner functions back into run_functests.sh which remains a very modest ~150 lines, with most of that being argument sanity. With that and the image-format cleanup, we can remove the indirection of the 3 small library files. For consistency, I have renamed the "dib_functions_test" (that tests things from the dib functions library) with a run_* prefix. Because the default list is the same as the current functional tests run, this does not modify the status-quo. I plan to modify this, however, to run fedora-minimal & centos-minimal tests in a future change, as these are required to be stable for openstack ci. Documentation is updated, and a README.rst is added in the tests directory for discoverability. Change-Id: I86d208bd34ff09a29fdb916a4e7ef740c7f65af8
2016-02-05 03:54:50 +00:00
ELEMENTS_PATH=$DIB_ELEMENTS:$TEST_ELEMENTS \
$DIB_CMD -x $type_arg --docker-target=$base_dest/image \
-o $dest_dir/image -n fake-os
format=$(echo $format | tr ',' ' ')
for format in $format; do
if [ $format != 'docker' ]; then
img_path="$dest_dir/image.$format"
if ! [ -f "$img_path" ]; then
echo "Error: No image with name $img_path found!"
exit 1
else
echo "Found image $img_path."
fi
else
if ! sudo docker images | grep $base_dest/image ; then
Rework functional test runner This simplifies and enhances the functional-test runner script for much better interactive behaviour and to give us the ability to better choose what is running in CI. Firstly, I have split the image-output testing into a separate script. This is not actually part of the functional testing of elements and is both logically and functionally different. It currently does not run in upstream CI because we don't have docker in the images. I have nothing against it, but it can be it's own thing. run_functests.sh is overhauled to have a useful interactive interface, e.g. --- $ ./run_functests.sh -h run_functests.sh [-h] [-l] <test> <test> ... -h : show this help -l : list available tests <test> : functional test to run Special test 'all' will run all tests $ ./run_functests.sh -l The available functional tests are: apt-sources/test-sources debian/build-succeeds fedora/build-succeeds fedora/build-succeeds-f21 ironic-agent/build-succeeds-fedora --- As described there, you can run a single test, a number of tests, the default tests (as CI will do) or all tests. Running all tests is too much for regular CI, but currently the only way to stop a low priority test running, or temporarily pause is to remove it completely -- clearly sub-optimal (see I93c2990472e88ab3e5ff14db56b4ff1b4dd965ef). There is nothing complicated about this, and to further simplify I have merged the runner functions back into run_functests.sh which remains a very modest ~150 lines, with most of that being argument sanity. With that and the image-format cleanup, we can remove the indirection of the 3 small library files. For consistency, I have renamed the "dib_functions_test" (that tests things from the dib functions library) with a run_* prefix. Because the default list is the same as the current functional tests run, this does not modify the status-quo. I plan to modify this, however, to run fedora-minimal & centos-minimal tests in a future change, as these are required to be stable for openstack ci. Documentation is updated, and a README.rst is added in the tests directory for discoverability. Change-Id: I86d208bd34ff09a29fdb916a4e7ef740c7f65af8
2016-02-05 03:54:50 +00:00
echo "Error: No docker image with name $base_dest/image found!"
exit 1
else
echo "Found docker image $base_dest/image"
fi
fi
done
trap EXIT
rm -rf $dest_dir
if sudo docker images | grep $base_dest/image ; then
sudo docker rmi $base_dest/image
Rework functional test runner This simplifies and enhances the functional-test runner script for much better interactive behaviour and to give us the ability to better choose what is running in CI. Firstly, I have split the image-output testing into a separate script. This is not actually part of the functional testing of elements and is both logically and functionally different. It currently does not run in upstream CI because we don't have docker in the images. I have nothing against it, but it can be it's own thing. run_functests.sh is overhauled to have a useful interactive interface, e.g. --- $ ./run_functests.sh -h run_functests.sh [-h] [-l] <test> <test> ... -h : show this help -l : list available tests <test> : functional test to run Special test 'all' will run all tests $ ./run_functests.sh -l The available functional tests are: apt-sources/test-sources debian/build-succeeds fedora/build-succeeds fedora/build-succeeds-f21 ironic-agent/build-succeeds-fedora --- As described there, you can run a single test, a number of tests, the default tests (as CI will do) or all tests. Running all tests is too much for regular CI, but currently the only way to stop a low priority test running, or temporarily pause is to remove it completely -- clearly sub-optimal (see I93c2990472e88ab3e5ff14db56b4ff1b4dd965ef). There is nothing complicated about this, and to further simplify I have merged the runner functions back into run_functests.sh which remains a very modest ~150 lines, with most of that being argument sanity. With that and the image-format cleanup, we can remove the indirection of the 3 small library files. For consistency, I have renamed the "dib_functions_test" (that tests things from the dib functions library) with a run_* prefix. Because the default list is the same as the current functional tests run, this does not modify the status-quo. I plan to modify this, however, to run fedora-minimal & centos-minimal tests in a future change, as these are required to be stable for openstack ci. Documentation is updated, and a README.rst is added in the tests directory for discoverability. Change-Id: I86d208bd34ff09a29fdb916a4e7ef740c7f65af8
2016-02-05 03:54:50 +00:00
fi
}
test_formats="tar tgz squashfs raw qcow2 docker aci"
for binary in qemu-img docker mksquashfs; do
if [ -z "$(type $binary)" ]; then
Rework functional test runner This simplifies and enhances the functional-test runner script for much better interactive behaviour and to give us the ability to better choose what is running in CI. Firstly, I have split the image-output testing into a separate script. This is not actually part of the functional testing of elements and is both logically and functionally different. It currently does not run in upstream CI because we don't have docker in the images. I have nothing against it, but it can be it's own thing. run_functests.sh is overhauled to have a useful interactive interface, e.g. --- $ ./run_functests.sh -h run_functests.sh [-h] [-l] <test> <test> ... -h : show this help -l : list available tests <test> : functional test to run Special test 'all' will run all tests $ ./run_functests.sh -l The available functional tests are: apt-sources/test-sources debian/build-succeeds fedora/build-succeeds fedora/build-succeeds-f21 ironic-agent/build-succeeds-fedora --- As described there, you can run a single test, a number of tests, the default tests (as CI will do) or all tests. Running all tests is too much for regular CI, but currently the only way to stop a low priority test running, or temporarily pause is to remove it completely -- clearly sub-optimal (see I93c2990472e88ab3e5ff14db56b4ff1b4dd965ef). There is nothing complicated about this, and to further simplify I have merged the runner functions back into run_functests.sh which remains a very modest ~150 lines, with most of that being argument sanity. With that and the image-format cleanup, we can remove the indirection of the 3 small library files. For consistency, I have renamed the "dib_functions_test" (that tests things from the dib functions library) with a run_* prefix. Because the default list is the same as the current functional tests run, this does not modify the status-quo. I plan to modify this, however, to run fedora-minimal & centos-minimal tests in a future change, as these are required to be stable for openstack ci. Documentation is updated, and a README.rst is added in the tests directory for discoverability. Change-Id: I86d208bd34ff09a29fdb916a4e7ef740c7f65af8
2016-02-05 03:54:50 +00:00
echo "Warning: No $binary binary found, cowardly refusing to run tests."
exit 1
Rework functional test runner This simplifies and enhances the functional-test runner script for much better interactive behaviour and to give us the ability to better choose what is running in CI. Firstly, I have split the image-output testing into a separate script. This is not actually part of the functional testing of elements and is both logically and functionally different. It currently does not run in upstream CI because we don't have docker in the images. I have nothing against it, but it can be it's own thing. run_functests.sh is overhauled to have a useful interactive interface, e.g. --- $ ./run_functests.sh -h run_functests.sh [-h] [-l] <test> <test> ... -h : show this help -l : list available tests <test> : functional test to run Special test 'all' will run all tests $ ./run_functests.sh -l The available functional tests are: apt-sources/test-sources debian/build-succeeds fedora/build-succeeds fedora/build-succeeds-f21 ironic-agent/build-succeeds-fedora --- As described there, you can run a single test, a number of tests, the default tests (as CI will do) or all tests. Running all tests is too much for regular CI, but currently the only way to stop a low priority test running, or temporarily pause is to remove it completely -- clearly sub-optimal (see I93c2990472e88ab3e5ff14db56b4ff1b4dd965ef). There is nothing complicated about this, and to further simplify I have merged the runner functions back into run_functests.sh which remains a very modest ~150 lines, with most of that being argument sanity. With that and the image-format cleanup, we can remove the indirection of the 3 small library files. For consistency, I have renamed the "dib_functions_test" (that tests things from the dib functions library) with a run_* prefix. Because the default list is the same as the current functional tests run, this does not modify the status-quo. I plan to modify this, however, to run fedora-minimal & centos-minimal tests in a future change, as these are required to be stable for openstack ci. Documentation is updated, and a README.rst is added in the tests directory for discoverability. Change-Id: I86d208bd34ff09a29fdb916a4e7ef740c7f65af8
2016-02-05 03:54:50 +00:00
fi
done
for format in '' $test_formats; do
build_test_image $format
echo "Test passed for output formats '$format'."
done
combined_format=$(echo $test_formats | tr ' ' ',')
build_test_image $combined_format
echo "Test passed for output format '$combined_format'."