| 1 |
#!/usr/bin/env bash |
| 2 |
|
| 3 |
set -xe |
| 4 |
|
| 5 |
NETWORKING_L2GW_DIR="$BASE/new/networking-l2gw" |
| 6 |
TEMPEST_DIR="$BASE/new/tempest" |
| 7 |
SCRIPTS_DIR="/usr/os-testr-env/bin/" |
| 8 |
|
| 9 |
venv=${1:-"fullstack"} |
| 10 |
|
| 11 |
function generate_test_logs { |
| 12 |
local path="$1" |
| 13 |
# Compress all $path/*.txt files and move the directories holding those |
| 14 |
# files to /opt/stack/logs. Files with .log suffix have their |
| 15 |
# suffix changed to .txt (so browsers will know to open the compressed |
| 16 |
# files and not download them). |
| 17 |
if [[ -d "$path" ]] ; then |
| 18 |
sudo find "$path" -iname "*.log" -type f -exec mv {} {}.txt \; -exec gzip -9 {}.txt \; |
| 19 |
sudo mv "$path/*" /opt/stack/logs/ |
| 20 |
fi |
| 21 |
} |
| 22 |
|
| 23 |
function generate_testr_results { |
| 24 |
# Give job user rights to access tox logs |
| 25 |
sudo -H -u "$owner" chmod o+rw . |
| 26 |
sudo -H -u "$owner" chmod o+rw -R .testrepository |
| 27 |
if [[ -f ".testrepository/0" ]] ; then |
| 28 |
".tox/$venv/bin/subunit-1to2" < .testrepository/0 > ./testrepository.subunit |
| 29 |
$SCRIPTS_DIR/subunit2html ./testrepository.subunit testr_results.html |
| 30 |
gzip -9 ./testrepository.subunit |
| 31 |
gzip -9 ./testr_results.html |
| 32 |
sudo mv ./*.gz /opt/stack/logs/ |
| 33 |
fi |
| 34 |
|
| 35 |
if [[ "$venv" == fullstack* ]] ; then |
| 36 |
generate_test_logs "/tmp/${venv}-logs" |
| 37 |
fi |
| 38 |
} |
| 39 |
|
| 40 |
owner=stack |
| 41 |
sudo_env= |
| 42 |
|
| 43 |
# virtuelenv 14.0.6 gives a strange error which appears solved in version 15. |
| 44 |
# Therefore, we force the newer version. |
| 45 |
sudo pip uninstall -y virtualenv |
| 46 |
sudo pip install "virtualenv>=15.0.1" |
| 47 |
|
| 48 |
# Set owner permissions according to job's requirements. |
| 49 |
cd "$NETWORKING_L2GW_DIR" |
| 50 |
sudo chown -R $owner:stack "$NETWORKING_L2GW_DIR" |
| 51 |
|
| 52 |
# Run tests |
| 53 |
echo "Running networking-l2gw $venv tests" |
| 54 |
set +e |
| 55 |
sudo -H -u "$owner" tox -e "$venv" |
| 56 |
testr_exit_code=$? |
| 57 |
set -e |
| 58 |
|
| 59 |
# Collect and parse results |
| 60 |
generate_testr_results |
| 61 |
exit $testr_exit_code |