diskimage-builder/tests/run_dib_library_tests.sh
Ian Wienand b18f71f781 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-19 13:50:09 +11:00

51 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# unit testing for some of the common-functions
#
# This is fairly invasive and *may* leave behind mounts, etc, that
# need a human in the loop. Thus it's mostly useful for developers
# during testing, but not so great for CI
source ../lib/common-functions
#
# Directory mounting and unmounting
#
# make mount points
TMP_DIR=$(mktemp -d)
cd $TMP_DIR
mkdir mnt
mkdir mnt/proc mnt/dev mnt/dev/pts mnt/sysfs mnt/sys
# for extra complexity, simulate the path being behind a symlink
ln -s mnt mnt-symlink
TMP_MOUNT_PATH=$TMP_DIR/mnt-symlink
# mount devices
mount_proc_dev_sys
if [ $(grep "$TMP_DIR" /proc/mounts | wc -l) -ne 4 ]; then
echo "*** FAILED to mount all directories"
# we might be in an unclean state here, but something is broken...
# we don't want to delete mounted system directories
return 1
else
echo "*** PASS : mounted all directories"
fi
# umount devices
unmount_dir $TMP_MOUNT_PATH
if grep -q "$TMP_DIR" /proc/mounts; then
echo "*** FAILED due to mounts being left behind"
return 1
else
echo "*** PASS all directories unmounted"
fi
# cleanup
rm -rf $TMP_DIR
### TODO more tests here