Fix incorrect reporting of failed exercise scripts

Also fixes the name of the VM image. Now points to the env var
DEFAULT_IMAGE_NAME used by devstack.

Change-Id: I627be09e275e02af1dba41d6b19426f3552719da
This commit is contained in:
Sumit Naiksatam
2015-09-18 13:12:35 -07:00
parent c1ba8e97d6
commit 9743fad625
5 changed files with 32 additions and 31 deletions

View File

@@ -8,18 +8,13 @@ echo "*********************************************************************"
echo "Begin DevStack Exercise: $0"
echo "*********************************************************************"
# Settings
# ========
# This script exits on an error so that errors don't compound and you see
# only the first error that occurred.
set -o errexit
# Print the commands being run so that we can see the command that triggers
# an error. It is also useful for following allowing as the install occurs.
set -o xtrace
# Settings
# ========
# Keep track of the current directory
EXERCISE_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
@@ -35,6 +30,10 @@ source $TOP_DIR/exerciserc
source $TOP_DIR/openrc demo demo
# Print the commands being run so that we can see the command that triggers
# an error. It is also useful for following allowing as the install occurs.
set -o xtrace
function confirm_server_active {
local VM_UUID=$1
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova show $VM_UUID | grep status | grep -q ACTIVE; do sleep 1; done"; then
@@ -79,15 +78,15 @@ WEB_PORT=$(gbp policy-target-create web-pt-1 --policy-target-group web | awk "/p
CLIENT1_PORT=$(gbp policy-target-create client-pt-1 --policy-target-group client-1 | awk "/port_id/ {print \$4}")
CLIENT2_PORT=$(gbp policy-target-create client-pt-2 --policy-target-group client-2 | awk "/port_id/ {print \$4}")
WEB_VM_1_UUID=`nova boot --flavor m1.tiny --image cirros-0.3.2-x86_64-uec --nic port-id=$WEB_PORT web-vm-1 | grep ' id ' | cut -d"|" -f3 | sed 's/ //g'`
WEB_VM_1_UUID=`nova boot --flavor m1.tiny --image $DEFAULT_IMAGE_NAME --nic port-id=$WEB_PORT web-vm-1 | grep ' id ' | cut -d"|" -f3 | sed 's/ //g'`
die_if_not_set $LINENO WEB_VM_1_UUID "Failure launching web-vm-1"
confirm_server_active $WEB_VM_1_UUID
CLIENT_VM_1_UUID=`nova boot --flavor m1.tiny --image cirros-0.3.2-x86_64-uec --nic port-id=$CLIENT1_PORT client-vm-1 | grep ' id ' | cut -d"|" -f3 | sed 's/ //g'`
CLIENT_VM_1_UUID=`nova boot --flavor m1.tiny --image $DEFAULT_IMAGE_NAME --nic port-id=$CLIENT1_PORT client-vm-1 | grep ' id ' | cut -d"|" -f3 | sed 's/ //g'`
die_if_not_set $LINENO CLIENT_VM_1_UUID "Failure launching client-vm-1"
confirm_server_active $CLIENT_VM_1_UUID
CLIENT_VM_2_UUID=`nova boot --flavor m1.tiny --image cirros-0.3.2-x86_64-uec --nic port-id=$CLIENT2_PORT client-vm-2 | grep ' id ' | cut -d"|" -f3 | sed 's/ //g'`
CLIENT_VM_2_UUID=`nova boot --flavor m1.tiny --image $DEFAULT_IMAGE_NAME --nic port-id=$CLIENT2_PORT client-vm-2 | grep ' id ' | cut -d"|" -f3 | sed 's/ //g'`
die_if_not_set $LINENO CLIENT_VM_2_UUID "Failure launching client-vm-2"
confirm_server_active $CLIENT_VM_2_UUID

View File

@@ -12,11 +12,6 @@ echo "*********************************************************************"
# only the first error that occurred.
set -o errexit
# Print the commands being run so that we can see the command that triggers
# an error. It is also useful for following allowing as the install occurs.
set -o xtrace
# Settings
# ========
@@ -35,6 +30,10 @@ source $TOP_DIR/exerciserc
source $TOP_DIR/openrc admin admin
# Print the commands being run so that we can see the command that triggers
# an error. It is also useful for following allowing as the install occurs.
set -o xtrace
function confirm_server_active {
local VM_UUID=$1
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova show $VM_UUID | grep status | grep -q ACTIVE; do sleep 1; done"; then

View File

@@ -12,11 +12,6 @@ echo "*********************************************************************"
# only the first error that occurred.
set -o errexit
# Print the commands being run so that we can see the command that triggers
# an error. It is also useful for following redirecting as the install occurs.
set -o xtrace
# Settings
# ========
@@ -35,6 +30,10 @@ source $TOP_DIR/exerciserc
source $TOP_DIR/openrc demo demo
# Print the commands being run so that we can see the command that triggers
# an error. It is also useful for following redirecting as the install occurs.
set -o xtrace
function confirm_server_active {
local VM_UUID=$1
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova show $VM_UUID | grep status | grep -q ACTIVE; do sleep 1; done"; then
@@ -91,11 +90,11 @@ WEB_PORT=$(gbp policy-target-create web-pt-1 --policy-target-group web | awk "/p
CLIENT1_PORT=$(gbp policy-target-create client-pt-1 --policy-target-group client-1 | awk "/port_id/ {print \$4}")
##TODO(Magesh): Add traffic testing and use namespace ports instead of launching VMs
WEB_VM_1_UUID=`nova boot --flavor m1.tiny --image cirros-0.3.2-x86_64-uec --nic port-id=$WEB_PORT web-vm-1 | grep ' id ' | cut -d"|" -f3 | sed 's/ //g'`
WEB_VM_1_UUID=`nova boot --flavor m1.tiny --image $DEFAULT_IMAGE_NAME --nic port-id=$WEB_PORT web-vm-1 | grep ' id ' | cut -d"|" -f3 | sed 's/ //g'`
die_if_not_set $LINENO WEB_VM_1_UUID "Failure launching web-vm-1"
confirm_server_active $WEB_VM_1_UUID
CLIENT_VM_1_UUID=`nova boot --flavor m1.tiny --image cirros-0.3.2-x86_64-uec --nic port-id=$CLIENT1_PORT client-vm-1 | grep ' id ' | cut -d"|" -f3 | sed 's/ //g'`
CLIENT_VM_1_UUID=`nova boot --flavor m1.tiny --image $DEFAULT_IMAGE_NAME --nic port-id=$CLIENT1_PORT client-vm-1 | grep ' id ' | cut -d"|" -f3 | sed 's/ //g'`
die_if_not_set $LINENO CLIENT_VM_1_UUID "Failure launching client-vm-1"
confirm_server_active $CLIENT_VM_1_UUID

View File

@@ -6,6 +6,7 @@ GBP_DIR="$NEW_BASE/group-based-policy"
SCRIPTS_DIR="/usr/os-testr-env/bin"
LOGS_DIR="$NEW_BASE/logs"
ARCHIVE_LOGS_DIR="$BASE/logs"
XTRACE=$(set +o | grep xtrace)
function prepare_gbp_devstack {
cd $TOP_DIR
@@ -15,7 +16,6 @@ function prepare_gbp_devstack {
sudo cp $CONTRIB_DIR/devstack/lib/* $TOP_DIR/lib/
sudo cp -r $CONTRIB_DIR/devstack/gbp-templates $TOP_DIR
sudo sed -i 's/DEST=\/opt\/stack/DEST=\/opt\/stack\/new/g' $TOP_DIR/stackrc
sudo sed -i 's/exit 1/echo/g' $TOP_DIR/exercise.sh
sudo sed -i 's/source $TOP_DIR\/lib\/neutron-legacy/source $TOP_DIR\/lib\/neutron-legacy\nsource $TOP_DIR\/lib\/gbp/g' $TOP_DIR/stack.sh
sudo sed -i 's/# Extras Configuration/install_gbpclient\ninit_gbpservice\n# Extras Configuration/g' $TOP_DIR/stack.sh
sudo sed -i 's/echo_summary "Creating initial neutron network elements"//g' $TOP_DIR/stack.sh
@@ -25,6 +25,14 @@ function prepare_gbp_devstack {
pip_install -e $GBP_DIR
}
function source_creds {
local xtrace=$(set +o | grep xtrace)
set +o xtrace
source $1 $2 $3
$xtrace
}
function run_gbp_rally {
cd $NEW_BASE
git clone http://github.com/group-policy/rally.git -b dev
@@ -33,7 +41,7 @@ function run_gbp_rally {
sed -i 's/\"concurrency\"\: 1/\"concurrency\"\: 10,/g' samples/tasks/scenarios/gbp/gbp.json
./install_rally.sh -f
. /home/jenkins/rally/bin/activate
source $TOP_DIR/openrc admin admin
source_creds $TOP_DIR/openrc admin admin
rally deployment create --fromenv --name=gbp
rally -v task start samples/tasks/scenarios/gbp/gbp.json
rally task results > $LOGS_DIR/rally-task-results.log.20
@@ -64,7 +72,7 @@ function generate_testr_results {
}
function check_residual_resources {
source $NEW_BASE/devstack/openrc $1 $2
source_creds $NEW_BASE/devstack/openrc $1 $2
gbp l3policy-list
gbp l2policy-list
gbp group-list

View File

@@ -8,11 +8,7 @@ trap prepare_logs ERR
# Run exercise scripts
$TOP_DIR/exercise.sh
# Check if any gbp exercises failed
exercises_exit_code=0
if grep -qs "FAILED gbp*" $LOGS_DIR/*; then
exercises_exit_code=1
fi
exercises_exit_code=$?
# Check if exercises left any resources undeleted
check_residual_resources admin admin