46
31
echo "[$target] stdout: $(pastebinit vagrant-logs/$target.startup.log)"
47
32
echo "[$target] stderr: $(pastebinit vagrant-logs/$target.startup.err)"
48
33
echo "[$target] NOTE: unable to execute tests, marked as failed"
49
echo "[$target] Destroying failed VM to reclaim resources"
50
vagrant destroy -f $target;
53
cat $TIMING | sed -e "s/^/[$target] (timing) /"
36
echo "Timing for $step"
55
39
# Display something before the first test output
56
40
echo "[$target] Starting tests..."
57
# Run test suite commands here.
58
# Tests are found in each component's requirements/ dir and are named *container-tests-*
59
# Numbers can be used at the beginning to control running order within each component.
60
# Tests scripts are expected to:
61
# - Be run from the *component's* top-level directory. This is a convenience to avoid
62
# a boilerplate "cd .." on every test script. So for 'plainbox' we do the equivalent of
65
# - Exit 0 for success, other codes for failure
66
# - Write logs/debugging data to stdout and stderr.
67
for test_script in $(find ./ -path '*/requirements/*container-tests-*' | sort); do
68
echo "Found a test script: $test_script"
69
test_name=$(basename $test_script)
70
# Two dirnames strips the requirements/ component
71
component_dir=$(dirname $(dirname $test_script))
72
# Inside the VM, tests are relative to $HOME/src.
73
# Note that for vagrant, we want $HOME to expand *inside* the VM, so
74
# that part of the command is in *single* quotes, otherwise we get the
75
# $HOME from the host. However, $component_dir and $test_name should
76
# come from the host, so we use double quotes.
77
script_md5sum=$(echo $test_script | md5sum |cut -d " " -f 1)
78
logfile=vagrant-logs/${target}.${test_name}.${script_md5sum}.log
79
errfile=vagrant-logs/${target}.${test_name}.${script_md5sum}.err
80
if /usr/bin/time -o $TIMING vagrant ssh $target -c 'cd $HOME/src/'"$component_dir && ./requirements/$test_name" >$logfile 2>$errfile
82
echo "[$target] ${test_name}: $PASS"
85
echo "[$target] ${test_name}: $FAIL"
86
echo "[$target] stdout: $(pastebinit $logfile)"
87
echo "[$target] stderr: $(pastebinit $errfile)"
89
cat $TIMING | sed -e "s/^/[$target] (timing) /"
92
# Decide what to do with the VM
41
# Run checkbox unit tests
42
if time -o $TIMING vagrant ssh $target -c 'cd checkbox && ./test' >vagrant-logs/$target.checkbox.log 2>vagrant-logs/$target.checkbox.err; then
43
echo "[$target] CheckBox test suite: pass"
46
echo "[$target] CheckBox test suite: fail"
47
echo "[$target] stdout: $(pastebinit vagrant-logs/$target.checkbox.log)"
48
echo "[$target] stderr: $(pastebinit vagrant-logs/$target.checkbox.err)"
50
echo "Timing for Checkbox test suite"
52
# Refresh plainbox installation. This is needed if .egg-info (which is
53
# essential for 'develop' to work) was removed in the meantime, for
55
if ! time -o $TIMING vagrant ssh $target -c 'cd checkbox/plainbox && python3 setup.py egg_info' >vagrant-logs/$target.egginfo.log 2>vagrant-logs/$target.egginfo.err; then
57
echo "[$target] Running 'plainbox/setup.py egg_info' failed"
58
echo "[$target] stdout: $(pastebinit vagrant-logs/$target.egginfo.log)"
59
echo "[$target] stderr: $(pastebinit vagrant-logs/$target.egginfo.err)"
60
echo "[$target] NOTE: unable to execute tests, marked as failed"
62
echo "Timing for refreshing plainbox installation"
64
# Run plainbox unit tests
65
# TODO: It would be nice to support fast failing here
66
if time -o $TIMING vagrant ssh $target -c 'cd checkbox/plainbox && python3 setup.py test' >vagrant-logs/$target.plainbox.log 2>vagrant-logs/$target.plainbox.err; then
67
echo "[$target] PlainBox test suite: pass"
70
echo "[$target] PlainBox test suite: fail"
71
echo "[$target] stdout: $(pastebinit vagrant-logs/$target.plainbox.log)"
72
echo "[$target] stderr: $(pastebinit vagrant-logs/$target.plainbox.err)"
74
echo "Timing for plainbox test suite"
76
# Build plainbox documentation
77
if time -o $TIMING vagrant ssh $target -c 'cd checkbox/plainbox && python3 setup.py build_sphinx' >vagrant-logs/$target.sphinx.log 2>vagrant-logs/$target.sphinx.err; then
78
echo "[$target] PlainBox documentation build: pass"
81
echo "[$target] PlainBox documentation build: fail"
82
echo "[$target] stdout: $(pastebinit vagrant-logs/$target.sphinx.log)"
83
echo "[$target] stderr: $(pastebinit vagrant-logs/$target.sphinx.err)"
85
echo "Timing for plainbox documentation build"
87
# Run plainbox integration test suite (that tests checkbox scripts)
88
if time -o $TIMING vagrant ssh $target -c 'sudo plainbox self-test --verbose --fail-fast --integration-tests' >vagrant-logs/$target.self-test.log 2>vagrant-logs/$target.self-test.err; then
89
echo "[$target] Integration tests: pass"
92
echo "[$target] Integration tests: fail"
93
echo "[$target] stdout: $(pastebinit vagrant-logs/$target.self-test.log)"
94
echo "[$target] stderr: $(pastebinit vagrant-logs/$target.self-test.err)"
96
echo "Timing for integration tests"
93
98
case $VAGRANT_DONE_ACTION in
95
100
# Suspend the target to conserve resources