~pieq/checkbox/fix-1484872-env-variables-forced-to-non-international

« back to all changes in this revision

Viewing changes to test-in-vagrant.sh

  • Committer: Daniel Manrique
  • Date: 2014-05-05 17:32:21 UTC
  • mto: This revision was merged to the branch mainline in revision 2974.
  • Revision ID: roadmr@ubuntu.com-20140505173221-2yze5mtgonh8h0ii
test-in-vagrant: Use per-component mini-scripts for testing.

This updates test-in-vagrant to look for, and use, the
previously-converted mini-scripts for testing each component.

This reduces duplication significantly and paves the way for running the
per-component tests under VM/container systems other than Vagrant, as
it'll be easier to rewrite the "run loop" once and just adapt the
startup, provisioning and shutdown parts for each container system.

Also, the test running line was updated to run commands on the vm in
$HOME.

Instead of assuming ssh into the virtual machine places me into my home
directory, explicitly reference $HOME in the commands, to make this an
absolute path. This still works because the $HOME parameter is expanded
once we are *inside* the VM so things will reference the correct
location, while being more compatible with what test-in-lxc (which will
expand $HOME to the invoking user's home, rather than that of the
container's user) will do.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
    fi
55
55
    # Display something before the first test output
56
56
    echo "[$target] Starting tests..."
57
 
 
58
 
    # Build checkbox-gui
59
 
    if time -o $TIMING vagrant ssh $target -c 'cd src/checkbox-gui; make distclean; qmake && make' >vagrant-logs/$target.checkbox-gui.log 2>vagrant-logs/$target.checkbox-gui.err; then
60
 
        echo "[$target] Checkbox GUI build: $PASS"
61
 
    else
62
 
        outcome=1
63
 
        echo "[$target] Checkbox GUI build: $FAIL"
64
 
        echo "[$target] stdout: $(pastebinit vagrant-logs/$target.checkbox-gui.log)"
65
 
        echo "[$target] stderr: $(pastebinit vagrant-logs/$target.checkbox-gui.err)"
66
 
    fi
67
 
    cat $TIMING | sed -e "s/^/[$target] (timing) /"
68
 
 
69
 
    # Refresh plainbox installation. This is needed if .egg-info (which is
70
 
    # essential for 'develop' to work) was removed in the meantime, for
71
 
    # example, by tarmac.
72
 
    if ! time -o $TIMING vagrant ssh $target -c 'cd src/plainbox && python3 setup.py egg_info' >vagrant-logs/$target.egginfo.log 2>vagrant-logs/$target.egginfo.err; then
73
 
        outcome=1
74
 
        echo "[$target] Running 'plainbox/setup.py egg_info' failed"
75
 
        echo "[$target] stdout: $(pastebinit vagrant-logs/$target.egginfo.log)"
76
 
        echo "[$target] stderr: $(pastebinit vagrant-logs/$target.egginfo.err)"
77
 
        echo "[$target] NOTE: unable to execute tests, marked as failed"
78
 
    fi
79
 
    cat $TIMING | sed -e "s/^/[$target] (timing) /"
80
 
 
81
 
    # Run plainbox unit tests
82
 
    # TODO: It would be nice to support fast failing here
83
 
    if time -o $TIMING vagrant ssh $target -c 'cd src/plainbox && python3 setup.py test' >vagrant-logs/$target.plainbox.log 2>vagrant-logs/$target.plainbox.err; then
84
 
        echo "[$target] PlainBox test suite: $PASS"
85
 
    else
86
 
        outcome=1
87
 
        echo "[$target] PlainBox test suite: $FAIL"
88
 
        echo "[$target] stdout: $(pastebinit vagrant-logs/$target.plainbox.log)"
89
 
        echo "[$target] stderr: $(pastebinit vagrant-logs/$target.plainbox.err)"
90
 
    fi
91
 
    cat $TIMING | sed -e "s/^/[$target] (timing) /"
92
 
 
93
 
    # Build plainbox documentation
94
 
    if time -o $TIMING vagrant ssh $target -c 'cd src/plainbox && python3 setup.py build_sphinx' >vagrant-logs/$target.sphinx.log 2>vagrant-logs/$target.sphinx.err; then
95
 
        echo "[$target] PlainBox documentation build: $PASS"
96
 
    else
97
 
        outcome=1
98
 
        echo "[$target] PlainBox documentation build: $FAIL"
99
 
        echo "[$target] stdout: $(pastebinit vagrant-logs/$target.sphinx.log)"
100
 
        echo "[$target] stderr: $(pastebinit vagrant-logs/$target.sphinx.err)"
101
 
    fi
102
 
    cat $TIMING | sed -e "s/^/[$target] (timing) /"
103
 
 
104
 
    # Run checkbox-ng unit tests
105
 
    if time -o $TIMING vagrant ssh $target -c 'cd src/checkbox-ng && python3 setup.py test' >vagrant-logs/$target.checkbox-ng.log 2>vagrant-logs/$target.checkbox-ng.err; then
106
 
        echo "[$target] CheckBoxNG test suite: $PASS"
107
 
    else
108
 
        outcome=1
109
 
        echo "[$target] CheckBoxNG test suite: $FAIL"
110
 
        echo "[$target] stdout: $(pastebinit vagrant-logs/$target.checkbox-ng.log)"
111
 
        echo "[$target] stderr: $(pastebinit vagrant-logs/$target.checkbox-ng.err)"
112
 
    fi
113
 
    cat $TIMING | sed -e "s/^/[$target] (timing) /"
114
 
 
115
 
    # Run plainbox integration test suite (that tests checkbox scripts)
116
 
    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
117
 
        echo "[$target] Integration tests: $PASS"
118
 
    else
119
 
        outcome=1
120
 
        echo "[$target] Integration tests: $FAIL"
121
 
        echo "[$target] stdout: $(pastebinit vagrant-logs/$target.self-test.log)"
122
 
        echo "[$target] stderr: $(pastebinit vagrant-logs/$target.self-test.err)"
123
 
    fi
124
 
    cat $TIMING | sed -e "s/^/[$target] (timing) /"
125
 
 
126
 
    # Validate the resource provider
127
 
    if time -o $TIMING vagrant ssh $target -c 'cd src/providers/plainbox-provider-resource-generic && ./manage.py validate' >vagrant-logs/$target.resource.log 2>vagrant-logs/$target.resource.err; then
128
 
        echo "[$target] Resource provider: $PASS"
129
 
    else
130
 
        outcome=1
131
 
        echo "[$target] Resource provider: $FAIL"
132
 
        echo "[$target] stdout: $(pastebinit vagrant-logs/$target.resource.log)"
133
 
        echo "[$target] stderr: $(pastebinit vagrant-logs/$target.resource.err)"
134
 
    fi
135
 
    cat $TIMING | sed -e "s/^/[$target] (timing) /"
136
 
 
137
 
    # Validate the checkbox provider
138
 
    if time -o $TIMING vagrant ssh $target -c 'cd src/providers/plainbox-provider-checkbox && ./manage.py validate' >vagrant-logs/$target.checkbox-provider.log 2>vagrant-logs/$target.checkbox-provider.err; then
139
 
        echo "[$target] Checkbox provider: $PASS"
140
 
    else
141
 
        outcome=1
142
 
        echo "[$target] Checkbox provider: $FAIL"
143
 
        echo "[$target] stdout: $(pastebinit vagrant-logs/$target.checkbox-provider.log)"
144
 
        echo "[$target] stderr: $(pastebinit vagrant-logs/$target.checkbox-provider.err)"
145
 
    fi
146
 
    cat $TIMING | sed -e "s/^/[$target] (timing) /"
 
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
147
91
 
148
92
    # Decide what to do with the VM
149
93
    case $VAGRANT_DONE_ACTION in