Merge "Add gate hooks for Castellan functional tests"
Jenkins authored 8 years ago
Gerrit Code Review committed 8 years ago
0 | #!/bin/bash | |
1 | ||
2 | set -xe | |
3 | ||
4 | CASTELLAN_DIR="$BASE/new/castellan" | |
5 | ||
6 | ||
7 | function generate_testr_results { | |
8 | if [ -f .testrepository/0 ]; then | |
9 | sudo .tox/functional/bin/testr last --subunit > $WORKSPACE/testrepository.subunit | |
10 | sudo mv $WORKSPACE/testrepository.subunit $BASE/logs/testrepository.subunit | |
11 | sudo /usr/os-testr-env/bin/subunit2html $BASE/logs/testrepository.subunit $BASE/logs/testr_results.html | |
12 | sudo gzip -9 $BASE/logs/testrepository.subunit | |
13 | sudo gzip -9 $BASE/logs/testr_results.html | |
14 | sudo chown jenkins:jenkins $BASE/logs/testrepository.subunit.gz $BASE/logs/testr_results.html.gz | |
15 | sudo chmod a+r $BASE/logs/testrepository.subunit.gz $BASE/logs/testr_results.html.gz | |
16 | fi | |
17 | } | |
18 | ||
19 | owner=tempest | |
20 | ||
21 | # Set owner permissions according to job's requirements. | |
22 | cd $CASTELLAN_DIR | |
23 | sudo chown -R $owner:stack $CASTELLAN_DIR | |
24 | ||
25 | testenv=functional | |
26 | ||
27 | sudo -H -u $owner tox -e genconfig | |
28 | ||
29 | if [ ! -d /etc/castellan ]; then | |
30 | sudo mkdir /etc/castellan | |
31 | fi | |
32 | ||
33 | sudo cp $CASTELLAN_DIR/etc/castellan/castellan-functional.conf.sample /etc/castellan/castellan-functional.conf | |
34 | ||
35 | # Run tests | |
36 | echo "Running Castellan $testenv test suite" | |
37 | set +e | |
38 | ||
39 | sudo -H -u $owner tox -e $testenv | |
40 | ||
41 | testr_exit_code=$? | |
42 | set -e | |
43 | ||
44 | # Collect and parse results | |
45 | generate_testr_results | |
46 | exit $testr_exit_code |