Skip to content

Commit

Permalink
Add possibility to select sanity checks individually
Browse files Browse the repository at this point in the history
  • Loading branch information
pratid authored and jesuspg committed May 13, 2016
1 parent 558fbd0 commit 555ee13
Showing 1 changed file with 33 additions and 21 deletions.
54 changes: 33 additions & 21 deletions fiware-region-sanity-tests/sanity_checks
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright 2013-2015 Telefónica I+D
# Copyright 2013-2016 Telefónica I+D
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
Expand All @@ -20,7 +20,7 @@
# Launch testcase execution and generate reports
#
# Usage:
# $0 [options] [region ...]
# $0 [options] [REGION|TESTS_SPEC ...]
# $0 --help|--version
#
# Options:
Expand All @@ -38,6 +38,9 @@
# -d, --os-user-domain-name=NAME optional OpenStack user_domain_name (to
# replace the former if Identity API v3)
#
# Tests specification examples:
# tests.regions.test_<region>:TestSuite.test_<name>
#
# Environment:
# TEST_PHONEHOME_ENDPOINT default value for --phonehome-endpoint
# OS_AUTH_URL default value for --os-auth-url
Expand All @@ -51,14 +54,14 @@
# python2.7 Python 2.7 interpreter (found in path)
#
# OpenStack credentials and PhoneHome service endpoint:
# Override values defined in 'settings.json' configuration file.
# Given values override those defined in 'settings.json' configuration file
#
# Regions:
# Valid regions are those included in 'settings.json':
# $REGIONS
# Valid regions included in 'settings.json':
# $REGIONS_AVAILABLE
#

VERSION=1.7.0
VERSION=1.7.1
NAME=$(basename $0)
OPTS=`tr -d '\n ' <<END
h(help)
Expand All @@ -75,6 +78,9 @@ OPTS=`tr -d '\n ' <<END
d(os-user-domain-name):
END`
# Settings file
SETTINGS=resources/settings.json
# Command line options (default values)
OUTPUT_NAME=test_results
TEMPLATE_NAME=test_report_template.html
Expand All @@ -87,19 +93,19 @@ export OS_TENANT_ID OS_TENANT_NAME OS_USER_DOMAIN_NAME
# Options for nosetests
TESTS=
REGIONS=
NOSEOPTS="--config=nose.cfg"
# Available regions
REGIONS=$(sed -n '/"external_network_name"/,/}/ p' resources/settings.json \
REGIONS_AVAILABLE=$(sed -n '/"external_network_name"/,/}/ p' $SETTINGS \
| awk -F\" 'NF==5 {print $2}')
REGIONS_PATTERN='^\('$(echo $REGIONS | sed 's/ /\\|/g')'\)$'
REGIONS_PATTERN='^\('$(echo $REGIONS_AVAILABLE | sed 's/ /\\|/g')'\)$'
# Process command line
REGION_NAME_LIST=
OPTERR=
OPTSTR=$(echo :-:$OPTS | sed 's/([a-zA-Z0-9]*)//g')
OPTHLP=$(sed -n '20,/^$/ { s/$0/'$NAME'/; s/^#[ ]\?//p }' $0 | head -n -2;
for i in $REGIONS; do printf " \"%s\"\n" $i; done)
for i in $REGIONS_AVAILABLE; do printf " - %s\n" $i; done)
while getopts $OPTSTR OPT; do while [ -z "$OPTERR" ]; do
case $OPT in
'v') NOSEOPTS="$NOSEOPTS --logging-level=DEBUG";;
Expand Down Expand Up @@ -130,9 +136,11 @@ esac; break; done; done
shift $(expr $OPTIND - 1)
while [ -z "$OPTERR" -a -n "$1" ]; do
REGION=$(expr "$1" : "$REGIONS_PATTERN" | sed 's/.*/\L&/')
[ -z "$REGION" ] && OPTERR="Invalid region '$1'"
TESTS="$TESTS tests.regions.test_$REGION"
REGION_NAME_LIST="$REGION_NAME_LIST $REGION"
TESTS_SPEC=$(expr "$1" : "^\(tests\.regions\.test.*\)")
TESTS_REGION=$(expr "$1" : "^tests\.regions\.test_\(.*\):.*")
[ -z "$REGION" -a -z "$TESTS_SPEC" ] && OPTERR="Invalid argument '$1'"
TESTS="$TESTS ${TESTS_SPEC:-tests.regions.test_$REGION}"
REGIONS="$REGIONS ${REGION:-$TESTS_REGION}"
shift
done
[ -n "$OPTERR" ] && {
Expand All @@ -142,21 +150,25 @@ done
printf "$OPTERR" | tr -s '\t' | expand -t$TABSTOPS | fmt -$WIDTH -s 1>&2
exit 1
}
TESTS=${TESTS:-tests/regions}
# Delete all generated Nova Console-Log files for the given regions before each sanity check execution.
echo "Deleting Nova Console-Log files from previous executions for the given regions ($REGION_NAME_LIST)"
for region in $REGION_NAME_LIST; do
rm -f ${OUTPUT_NOVA_CONSOLE_NAME}_${region}_*.log
# Unless otherwise specified, run all tests in all regions
TESTS="${TESTS:-tests/regions}"
REGIONS="${REGIONS:-$(echo $REGIONS_AVAILABLE | sed 's/.*/\L&/')}"
# First delete all previously generated Nova Console-Log files for given regions
echo "Deleting all previous Nova Console-Log files for: $REGIONS..."
for REGION in $REGIONS; do
rm -f ${OUTPUT_NOVA_CONSOLE_NAME}_${REGION}_*.log
done
# Sanity Checks execution
echo "Running Sanity Checks"
# Run 'nose' to execute the Sanity Checks
echo "Running Sanity Checks..."
nosetests $TESTS $NOSEOPTS -v --exe \
--with-xunit --xunit-file=$OUTPUT_NAME.xml \
--with-html --html-report=$OUTPUT_NAME.html \
--html-report-template=resources/templates/$TEMPLATE_NAME
printf "Generating summary report ... "
# Summary report
printf "Generating summary report... "
commons/results_analyzer.py $OUTPUT_NAME.xml > $OUTPUT_NAME.txt
printf "%s\n" $OUTPUT_NAME.txt

0 comments on commit 555ee13

Please sign in to comment.