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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/sh
# Run all tests in various versions of Ubuntu via vagrant

mkdir -p vagrant-logs
TIMING=vagrant-logs/timing.dat

test -z $(which vagrant) && echo "You need to install vagrant first" && exit

# When running in tarmac, the state file .vagrant, will be removed when the
# tree is re-pristinized. To work around that, check for present
# VAGRANT_STATE_FILE (custom variable, not set by tarmac or respected by
# vagrant) and symlink the .vagrant state file from there.
if [ "x$VAGRANT_STATE_FILE" != "x" ]; then
    if [ ! -e "$VAGRANT_STATE_FILE" ]; then
        touch "$VAGRANT_STATE_FILE"
    fi
    ln -fs "$VAGRANT_STATE_FILE" .vagrant
fi

outcome=0
# XXX: this list needs to be in sync with Vagrantfile
target_list="precise quantal raring"
for target in $target_list; do
    # Bring up target if needed
    if ! vagrant status $target | grep -q running; then
        step="[$target] Bringing VM 'up'"
        echo $step
        if ! time -o $TIMING vagrant up $target >vagrant-logs/$target.startup.log 2>vagrant-logs/$target.startup.err; then
            outcome=1
            echo "[$target] Unable to 'up' VM!"
            echo "[$target] stdout: $(pastebinit vagrant-logs/$target.startup.log)"
            echo "[$target] stderr: $(pastebinit vagrant-logs/$target.startup.err)"
            echo "[$target] NOTE: unable to execute tests, marked as failed"
            continue
        fi
        echo "Timing for $step"
        cat $TIMING
    fi
    # Display something before the first test output
    echo "[$target] Starting tests..."
    # Run checkbox unit tests
    if time -o $TIMING vagrant ssh $target -c 'cd checkbox && ./test' >vagrant-logs/$target.checkbox.log 2>vagrant-logs/$target.checkbox.err; then
        echo "[$target] CheckBox test suite: pass"
    else
        outcome=1
        echo "[$target] CheckBox test suite: fail"
        echo "[$target] stdout: $(pastebinit vagrant-logs/$target.checkbox.log)"
        echo "[$target] stderr: $(pastebinit vagrant-logs/$target.checkbox.err)"
    fi
    echo "Timing for Checkbox test suite"
    cat $TIMING
    # Refresh plainbox installation. This is needed if .egg-info (which is
    # essential for 'develop' to work) was removed in the meantime, for
    # example, by tarmac.
    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
        outcome=1
        echo "[$target] Running 'plainbox/setup.py egg_info' failed"
        echo "[$target] stdout: $(pastebinit vagrant-logs/$target.egginfo.log)"
        echo "[$target] stderr: $(pastebinit vagrant-logs/$target.egginfo.err)"
        echo "[$target] NOTE: unable to execute tests, marked as failed"
    fi
    echo "Timing for refreshing plainbox installation"
    cat $TIMING
    # Run plainbox unit tests
    # TODO: It would be nice to support fast failing here
    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
        echo "[$target] PlainBox test suite: pass"
    else
        outcome=1
        echo "[$target] PlainBox test suite: fail"
        echo "[$target] stdout: $(pastebinit vagrant-logs/$target.plainbox.log)"
        echo "[$target] stderr: $(pastebinit vagrant-logs/$target.plainbox.err)"
    fi
    echo "Timing for plainbox test suite"
    cat $TIMING
    # Build plainbox documentation
    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
        echo "[$target] PlainBox documentation build: pass"
    else
        outcome=1
        echo "[$target] PlainBox documentation build: fail"
        echo "[$target] stdout: $(pastebinit vagrant-logs/$target.sphinx.log)"
        echo "[$target] stderr: $(pastebinit vagrant-logs/$target.sphinx.err)"
    fi
    echo "Timing for plainbox documentation build"
    cat $TIMING
    # Run plainbox integration test suite (that tests checkbox scripts)
    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
        echo "[$target] Integration tests: pass"
    else
        outcome=1
        echo "[$target] Integration tests: fail"
        echo "[$target] stdout: $(pastebinit vagrant-logs/$target.self-test.log)"
        echo "[$target] stderr: $(pastebinit vagrant-logs/$target.self-test.err)"
    fi
    echo "Timing for integration tests"
    cat $TIMING
    case $VAGRANT_DONE_ACTION in
        suspend)
            # Suspend the target to conserve resources
            echo "[$target] Suspending VM"
            if ! vagrant suspend $target >vagrant-logs/$target.suspend.log 2>vagrant-logs/$target.suspend.err; then
                echo "[$target] Unable to suspend VM!"
                echo "[$target] stdout: $(pastebinit vagrant-logs/$target.suspend.log)"
                echo "[$target] stderr: $(pastebinit vagrant-logs/$target.suspend.err)"
                echo "[$target] You may need to manually 'vagrant destroy $target' to fix this"
            fi
            ;;
        destroy)
            # Destroy the target to work around virtualbox hostsf bug
            echo "[$target] Destroying VM"
            if ! vagrant destroy --force $target >vagrant-logs/$target.destroy.log 2>vagrant-logs/$target.destroy.err; then
                echo "[$target] Unable to destroy VM!"
                echo "[$target] stdout: $(pastebinit vagrant-logs/$target.suspend.log)"
                echo "[$target] stderr: $(pastebinit vagrant-logs/$target.suspend.err)"
                echo "[$target] You may need to manually 'vagrant destroy $target' to fix this"
            fi
            ;;
    esac
done
# Propagate failure code outside
exit $outcome