~jocave/checkbox/hybrid-amd-gpu-mods

« back to all changes in this revision

Viewing changes to test-in-vagrant.sh

  • Committer: Zygmunt Krynicki
  • Date: 2013-05-17 13:54:25 UTC
  • mto: This revision was merged to the branch mainline in revision 2130.
  • Revision ID: zygmunt.krynicki@canonical.com-20130517135425-cxcenxx5t0qrtbxd
checkbox-ng: add CheckBoxNG sub-project

CheckBoxNG (or lowercase as checkbox-ng, pypi:checkbox-ng) is a clean
implementation of CheckBox on top of PlainBox. It provides a new
executable, 'checkbox' that has some of the same commands that were
previously implemented in the plainbox package.

In particular CheckBoxNG comes with the 'checkbox sru' command
(the same one as in plainbox). Later on this sub-command will be removed
from plainbox.

CheckBoxNG depends on plainbox >= 0.3

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
mkdir -p vagrant-logs
5
5
TIMING=vagrant-logs/timing.dat
6
 
VAGRANT_DONE_ACTION=${VAGRANT_DONE_ACTION:-destroy}
7
 
 
8
 
 
9
 
pastebinit() {
10
 
    /usr/bin/python /usr/bin/pastebinit "$@";
11
 
}
12
6
 
13
7
test -z $(which vagrant) && echo "You need to install vagrant first" && exit
14
8
 
23
17
    ln -fs "$VAGRANT_STATE_FILE" .vagrant
24
18
fi
25
19
 
26
 
if [ "$1" = "" ]; then
27
 
    # Vagrantfile defines several ubuntu target releases, the ones
28
 
    # we actually want to test in should be included in target_list below.
29
 
    target_list="precise trusty"
30
 
else
31
 
    target_list="$1"
32
 
fi
33
 
 
34
 
PASS="$(printf "\33[32;1mPASS\33[39;0m")"
35
 
FAIL="$(printf "\33[31;1mFAIL\33[39;0m")"
36
 
 
37
20
outcome=0
 
21
# XXX: this list needs to be in sync with Vagrantfile
 
22
target_list="precise quantal raring"
38
23
for target in $target_list; do
39
24
    # Bring up target if needed
40
25
    if ! vagrant status $target | grep -q running; then
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;
51
34
            continue
52
35
        fi
53
 
        cat $TIMING | sed -e "s/^/[$target] (timing) /"
 
36
        echo "Timing for $step"
 
37
        cat $TIMING
54
38
    fi
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
63
 
    #   $ cd $BLAH/plainbox
64
 
    #   $
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
81
 
        then
82
 
            echo "[$target] ${test_name}: $PASS"
83
 
        else
84
 
            outcome=1
85
 
            echo "[$target] ${test_name}: $FAIL"
86
 
            echo "[$target] stdout: $(pastebinit $logfile)"
87
 
            echo "[$target] stderr: $(pastebinit $errfile)"
88
 
        fi
89
 
        cat $TIMING | sed -e "s/^/[$target] (timing) /"
90
 
    done
91
 
 
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"
 
44
    else
 
45
        outcome=1
 
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)"
 
49
    fi
 
50
    echo "Timing for Checkbox test suite"
 
51
    cat $TIMING
 
52
    # Refresh plainbox installation. This is needed if .egg-info (which is
 
53
    # essential for 'develop' to work) was removed in the meantime, for
 
54
    # example, by tarmac.
 
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
 
56
        outcome=1
 
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"
 
61
    fi
 
62
    echo "Timing for refreshing plainbox installation"
 
63
    cat $TIMING
 
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"
 
68
    else
 
69
        outcome=1
 
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)"
 
73
    fi
 
74
    echo "Timing for plainbox test suite"
 
75
    cat $TIMING
 
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"
 
79
    else
 
80
        outcome=1
 
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)"
 
84
    fi
 
85
    echo "Timing for plainbox documentation build"
 
86
    cat $TIMING
 
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"
 
90
    else
 
91
        outcome=1
 
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)"
 
95
    fi
 
96
    echo "Timing for integration tests"
 
97
    cat $TIMING
93
98
    case $VAGRANT_DONE_ACTION in
94
99
        suspend)
95
100
            # Suspend the target to conserve resources