nova/nova/tests/live_migration/hooks/utils.sh
ghanshyam a83613946d
Use tempest tox with regex first
This commit add regex first while running tempest tox

There is changes in way tempest tox runs tests by using the tempest run
command directly instead of some bash script.

With tempest run you specify a regex with a '--regex' parameter and to
keep backwards compatibility this is added to the tempest tox
definitions.

But in Nova tests scripts it is being used after concurrency and ends up
having a call equivalent to:

  tempest run --regex --concurrency=2 $tempest_regex

which obviously is incorrect. Simply switching the arg order should work here.

Change-Id: If0064b9e8358332972ef4a1eee8f150e66f8c50f
Needed-by: I3684fce66a799579fa68af119652cafef25a9f03
2016-09-14 09:32:53 -04:00

74 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
function run_tempest {
local message=$1
local tempest_regex=$2
sudo -H -u tempest tox -eall -- $tempest_regex --concurrency=$TEMPEST_CONCURRENCY
exitcode=$?
if [[ $exitcode -ne 0 ]]; then
die $LINENO "$message failure"
fi
}
function populate_start_script {
SCREEN_NAME=${SCREEN_NAME:-stack}
DEST=${DEST:-/opt/stack}
SERVICE_DIR=${SERVICE_DIR:-${DEST}/status}
ENABLED_SERVICES=${ENABLED_SERVICES:-n-cpu,g-api,c-vol}
LIBVIRT_GROUP=${LIBVIRT_GROUP:-libvirtd}
TIMESTAMP_FORMAT=${TIMESTAMP_FORMAT:-"%F-%H%M%S"}
LOGDAYS=${LOGDAYS:-7}
CURRENT_LOG_TIME=$(date "+$TIMESTAMP_FORMAT")
#creates script for starting process without screen and copies it to all
# nodes
#
# args:
# $1 - service name to start
# $2 - command to execute
# $3 - group to run under
cat > /tmp/start_process.sh <<EOF
set -x
service=\$1
command=\$2
sg=\$3
ENABLED_SERVICES=$ENABLED_SERVICES
SCREEN_NAME=$SCREEN_NAME
DEST=$DEST
SERVICE_DIR=$SERVICE_DIR
LOGDIR=$DEST/logs
TIMESTAMP_FORMAT=$TIMESTAMP_FORMAT
LOGDAYS=$LOGDAYS
CURRENT_LOG_TIME=\$(date "+$TIMESTAMP_FORMAT")
REAL_LOG_FILE="\$LOGDIR/\$service.log.\$CURRENT_LOG_TIME"
if [[ -n "\$LOGDIR" ]]; then
exec 1>&"\$REAL_LOG_FILE" 2>&1
ln -sf "\$REAL_LOG_FILE" \$LOGDIR/\$service.log
export PYTHONUNBUFFERED=1
fi
if [[ -n "\$sg" ]]; then
setsid sg \$sg -c "\$command" & echo \$! >\$SERVICE_DIR/\$SCREEN_NAME/\$service.pid
else
setsid \$command & echo \$! >\$SERVICE_DIR/\$SCREEN_NAME/\$service.pid
fi
exit 0
EOF
chmod +x /tmp/start_process.sh
$ANSIBLE subnodes --sudo -f 5 -i "$WORKSPACE/inventory" -m copy -a "src=/tmp/start_process.sh dest=/tmp/start_process.sh owner=$STACK_USER group=$STACK_USER mode=0777"
$ANSIBLE subnodes --sudo -f 5 -i "$WORKSPACE/inventory" -m shell -a "ls -la /tmp/start_process.sh"
}
function stop {
local target=$1
local service=$2
$ANSIBLE $target --sudo -f 5 -i "$WORKSPACE/inventory" -m shell -a "
executable=/bin/bash
BASE\=$BASE
source $BASE/new/devstack/functions-common
ENABLED_SERVICES\=$ENABLED_SERVICES
SCREEN_NAME\=$SCREEN_NAME
SERVICE_DIR\=$SERVICE_DIR
stop_process $service
"
}