Last active
December 20, 2015 11:49
-
-
Save dfarrell07/6126029 to your computer and use it in GitHub Desktop.
Script for loading OpenStack plugin code from SVN repo and executing tests.
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
#!/usr/bin/env bash | |
# Copy code to controllers and execute tests | |
# Author: Daniel Farrell | |
EX_USAGE=64 | |
EX_CONFIG=78 | |
EX_OK=0 | |
buildmaster="10.66.9.5" | |
os1="10.66.66.9" | |
os2="10.66.66.12" | |
bm_plugin="/data/openstack/Release_v1.1/source_code/Extreme_OpenStack_v1.1\ | |
/extreme/" | |
plugins_dir="/opt/stack/quantum/quantum/plugins/" | |
ex_plugin_dir="/opt/stack/quantum/quantum/plugins/extreme/" | |
# Confirm that required jars are in place | |
if [ ! -d ../lib-jar ] | |
then | |
echo "lib-jar directory not found." | |
exit $EX_CONFIG | |
fi | |
# Print usage message | |
usage() | |
{ | |
cat << EOF | |
Usage: $0 [options] | |
Run nightly or regression OpenStack tests. | |
OPTIONS: | |
-h Show this message. | |
-t Tests to run ([r]egression/[n]ightly). | |
-c Copy fresh code from SVN to test machnes. | |
-d Delete old code on test machines (ensures clean test, implies copy). | |
-D Delete without confirmation (WARNING: Not suggested). | |
-n Number of times to run the given tests (defaults to 1). | |
-v Verbose output | |
EOF | |
} | |
del() | |
{ | |
# Remove old code | |
echo "Deleting plugin code from $os1." | |
ssh stack@$os1 rm -rf $ex_plugin_dir | |
echo "Deleting plugin code from $os2." | |
ssh stack@$os2 rm -rf $ex_plugin_dir | |
} | |
copy() | |
{ | |
# Copy fresh code from SVN to test servers | |
echo "Copying code to $os1." | |
if [ $verbose ] | |
then | |
scp -r $buildmaster:$bm_plugin stack@$os1:$plugins_dir | |
else | |
scp -r $buildmaster:$bm_plugin stack@$os1:$plugins_dir > /dev/null | |
fi | |
echo "Copying code to $os2." | |
if [ $verbose ] | |
then | |
scp -r $buildmaster:$bm_plugin stack@$os2:$plugins_dir | |
else | |
scp -r $buildmaster:$bm_plugin stack@$os2:$plugins_dir > /dev/null | |
fi | |
} | |
run_reg() | |
{ | |
if [ ! -f ./regression ] | |
then | |
echo "Buildfile \"./regression\" not found." >&2 | |
exit $EX_CONFIG | |
fi | |
echo "This will take about 15-25 minutes." | |
echo "You can monitor ./logs/OpenStackTest.log." | |
sleep 3 | |
if [ $verbose ] | |
then | |
ant -buildfile regression clean build | |
ant -buildfile regression OpenStackSolutionTest | |
else | |
ant -buildfile regression clean build > /dev/null | |
ant -buildfile regression OpenStackSolutionTest > /dev/null | |
fi | |
} | |
run_nightly() | |
{ | |
if [ ! -f ./nightly ] | |
then | |
echo "Buildfile \"./nightly\" not found." >&2 | |
exit $EX_CONFIG | |
fi | |
echo "This will take about 75 minutes." | |
echo "You can monitor ./logs/OpenStackTest.log." | |
sleep 3 | |
if [ $verbose ] | |
then | |
ant -buildfile nightly clean build | |
ant -buildfile nightly OpenStackSolutionTest | |
else | |
ant -buildfile nightly clean build > /dev/null | |
ant -buildfile nightly OpenStackSolutionTest > /dev/null | |
fi | |
} | |
# Default number of tests to run | |
n=1 | |
# Read arguments | |
while getopts ":hcdDt:n:v" opt; do | |
case "$opt" in | |
h) | |
# Help message | |
usage | |
exit $EX_OK | |
;; | |
c) | |
# [c]opy code to servers from SVN | |
copy=1 | |
;; | |
d) | |
# [d]elete existing code | |
copy=1 # Delete implies copy | |
# Confirm delete option | |
tput setaf 1 | |
tput bold | |
echo "To delete: $os1:$ex_plugin_dir" | |
echo "To delete: $os2:$ex_plugin_dir" | |
echo -n "Confirm deletion? [y/N] " | |
tput sgr0 | |
read confirm | |
if [ "$confirm" == "y" ] | |
then | |
delete=1 | |
elif [ "$clobber" == "n" -o "$clobber" == "" ] | |
then | |
echo "Not removing old code." | |
else | |
echo "Expected: \"y\", \"n\" or [return]." >&2 | |
exit $EX_USAGE | |
fi | |
;; | |
D) | |
# Delete without confirmation | |
copy=1 | |
delete=1 | |
tput setaf 1 | |
tput bold | |
echo "WARNING: Deleting old code without confirmation!" | |
tput sgr0 | |
;; | |
t) | |
# [t]ests to run (regression or nightly) | |
if [ "$OPTARG" == "r" ] | |
then | |
regression=1 | |
elif [ "$OPTARG" == "n" ] | |
then | |
nightly=1 | |
else | |
echo "Invalid test argument: $OPTARG" >&2 | |
usage | |
exit $EX_USAGE | |
fi | |
;; | |
n) | |
# Number of times to run the tests | |
n=$OPTARG | |
;; | |
v) | |
# Verbose output | |
verbose=1 | |
;; | |
?) | |
usage | |
exit $EX_USAGE | |
esac | |
done | |
i=0 | |
while [ $i -lt $n ]; do | |
# Copy new code to servers, maybe delete old code | |
if [ "$copy" ] | |
then | |
if [ "$delete" ] | |
then | |
# Delete old code on servers (assures clean test) | |
del | |
fi | |
# Copy code to servers from SVN | |
copy | |
else | |
echo "Not copying code." | |
fi | |
if [ $regression ] | |
then | |
# Run regression tests | |
run_reg | |
elif [ "$nightly" ] | |
then | |
# Run nightly tests | |
run_nightly | |
else | |
echo "No test specified." >&2 | |
exit $EX_USAGE | |
fi | |
let i=i+1 | |
done | |
exit $EX_OK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment