This repository has been archived by the owner on Sep 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring integration job to archive logs on error
Currently if the stack.sh fails, the openstack project logs are not archived. Change-Id: If48f27bc6e5e0ee2eacecbf5358a8d4884e7f267 Closes-bug: #1466224
- Loading branch information
Showing
3 changed files
with
42 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env bash | ||
|
||
TOP_DIR="$BASE/new/devstack" | ||
NEW_BASE="$BASE/new" | ||
GBP_DIR="$NEW_BASE/group-based-policy" | ||
SCRIPTS_DIR="/usr/local/jenkins/slave_scripts" | ||
LOGS_DIR="$NEW_BASE/logs" | ||
ARCHIVE_LOGS_DIR="$BASE/logs" | ||
|
||
# Prepare the log files for Jenkins to upload | ||
function prepare_logs { | ||
cd $LOGS_DIR | ||
for f in $(find . -name "*.log.2*"); do | ||
sudo mv $f ${f/.log.*/.txt} | ||
done | ||
sudo gzip -9fk `find . -maxdepth 1 \! -type l -name "*.txt" | xargs ls -d` | ||
mv *.gz $ARCHIVE_LOGS_DIR/ | ||
} | ||
|
||
function generate_testr_results { | ||
# Give job user rights to access tox logs | ||
sudo -H chmod o+rw . | ||
sudo -H chmod o+rw -R .testrepository | ||
if [ -f ".testrepository/0" ] ; then | ||
.tox/dsvm-functional/bin/subunit-1to2 < .testrepository/0 > ./testrepository.subunit | ||
.tox/dsvm-functional/bin/python $SCRIPTS_DIR/subunit2html.py ./testrepository.subunit testr_results.html | ||
gzip -9 ./testrepository.subunit | ||
gzip -9 ./testr_results.html | ||
sudo mv ./*.gz $ARCHIVE_LOGS_DIR/ | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,35 @@ | ||
#!/bin/bash | ||
|
||
set -xe | ||
source functions-gbp | ||
|
||
NEW_BASE="$BASE/new" | ||
GBP_DIR="$NEW_BASE/group-based-policy" | ||
SCRIPTS_DIR="/usr/local/jenkins/slave_scripts" | ||
LOGS_DIR="$NEW_BASE/logs" | ||
|
||
function generate_testr_results { | ||
# Give job user rights to access tox logs | ||
sudo -H chmod o+rw . | ||
sudo -H chmod o+rw -R .testrepository | ||
if [ -f ".testrepository/0" ] ; then | ||
.tox/dsvm-functional/bin/subunit-1to2 < .testrepository/0 > ./testrepository.subunit | ||
.tox/dsvm-functional/bin/python $SCRIPTS_DIR/subunit2html.py ./testrepository.subunit testr_results.html | ||
gzip -9 ./testrepository.subunit | ||
gzip -9 ./testr_results.html | ||
sudo mv ./*.gz /opt/stack/logs/ | ||
fi | ||
} | ||
|
||
|
||
function dsvm_functional_prep_func { | ||
: | ||
} | ||
set -x | ||
|
||
# Check if any gbp exercises failed | ||
set +e | ||
exercises_exit_code=0 | ||
if grep -qs "FAILED gbp*" $LOGS_DIR/*; then | ||
exercises_exit_code=1 | ||
fi | ||
set -e | ||
|
||
prep_func="dsvm_functional_prep_func" | ||
|
||
# Run tests | ||
# Run integration tests | ||
echo "Running gbpfunc test suite" | ||
set +e | ||
cd $NEW_BASE/devstack | ||
source openrc demo demo | ||
cd $NEW_BASE | ||
sudo git clone https://github.com/noironetworks/devstack -b jishnub/testsuites gbpfunctests | ||
cd gbpfunctests/testcases/testcases_func | ||
python suite_run.py -s func | ||
gbpfunc_exit_code=$? | ||
set -e | ||
|
||
# Set owner permissions according to job's requirements. | ||
# Run functional tests | ||
cd $GBP_DIR | ||
# Prep the environment according to job's requirements. | ||
$prep_func | ||
|
||
# Run tests | ||
echo "Running group-based-policy dsvm-functional test suite" | ||
set +e | ||
# Temporary workaround for subunit not getting installed in tox environment | ||
sudo -H tox -e dsvm-functional | ||
testr_exit_code=$? | ||
set -e | ||
|
||
# Collect and parse results | ||
generate_testr_results | ||
|
||
# Prepare the log files for Jenkins to upload | ||
set +e | ||
cd $LOGS_DIR | ||
for f in $(find . -name "*.log.2*"); do | ||
sudo mv $f ${f/.log.*/.txt} | ||
done | ||
sudo gzip -9fk `find . -maxdepth 1 \! -type l -name "*.txt" | xargs ls -d` | ||
mv *.gz /opt/stack/logs/ | ||
set -e | ||
prepare_logs | ||
|
||
exit $(($exercises_exit_code+$gbpfunc_exit_code+$testr_exit_code)) |