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 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't use devstack to setup our functional env
This adds a setup script for each tox functional target to start a rabbitmq-server, qpidd or redis daemon dedicated for the functional testing. This script is responsible to spawn a preconfigured daemon needed for the functional tests. This also changes the gate script to just install the required packages instead of setup a devstack. This also fixes the zmq config options loading in tests Closes-bug: #1442612 Change-Id: I27eb2c1d3d0ca67aa361c83e41372138e03d9bdd
- Loading branch information
1 parent
5b15364
commit 15764fe
Showing
9 changed files
with
202 additions
and
53 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
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 |
---|---|---|
|
@@ -16,14 +16,54 @@ | |
|
||
RPC_BACKEND=$1 | ||
|
||
function generate_testr_results { | ||
if [ -f .testrepository/0 ]; then | ||
sudo .tox/py27-func-${RPC_BACKEND}/bin/testr last --subunit > $WORKSPACE/testrepository.subunit | ||
sudo mv $WORKSPACE/testrepository.subunit $BASE/logs/testrepository.subunit | ||
sudo .tox/py27-func-${RPC_BACKEND}/bin/python /usr/local/jenkins/slave_scripts/subunit2html.py $BASE/logs/testrepository.subunit $BASE/logs/testr_results.html | ||
sudo gzip -9 $BASE/logs/testrepository.subunit | ||
sudo gzip -9 $BASE/logs/testr_results.html | ||
sudo chown jenkins:jenkins $BASE/logs/testrepository.subunit.gz $BASE/logs/testr_results.html.gz | ||
sudo chmod a+r $BASE/logs/testrepository.subunit.gz $BASE/logs/testr_results.html.gz | ||
fi | ||
} | ||
|
||
# Allow jenkins to retrieve reports | ||
sudo chown -R jenkins:stack $BASE/new/oslo.messaging | ||
|
||
set +e | ||
|
||
# Install required packages | ||
case $RPC_BACKEND in | ||
amqp1|qpid) | ||
# Ensure authentification works before continuing, otherwise tests | ||
# will retries forever | ||
sudo yum install -y qpid-tools | ||
qpid-config --sasl-mechanism=PLAIN -a stackqpid/[email protected] | ||
zeromq) | ||
sudo apt-get update -y | ||
sudo apt-get install -y redis-server python-redis | ||
;; | ||
qpid) | ||
sudo apt-get update -y | ||
sudo apt-get install -y qpidd sasl2-bin | ||
;; | ||
amqp1) | ||
# qpid-tools is needed to ensure authentification works before | ||
# starting tests, otherwise tests will retries forever | ||
sudo yum install -y qpid-cpp-server qpid-proton-c-devel python-qpid-proton cyrus-sasl-lib cyrus-sasl-plain | ||
;; | ||
rabbit) | ||
sudo apt-get update -y | ||
sudo apt-get install -y rabbitmq-server | ||
;; | ||
esac | ||
|
||
# Got to the oslo.messaging dir | ||
cd $BASE/new/oslo.messaging | ||
sudo -H -u stack tox -e py27-func-$RPC_BACKEND | ||
|
||
# Run tests | ||
echo "Running oslo.messaging functional test suite" | ||
# Preserve env for OS_ credentials | ||
sudo -E -H -u jenkins tox -e py27-func-$RPC_BACKEND | ||
EXIT_CODE=$? | ||
set -e | ||
|
||
# Collect and parse result | ||
generate_testr_results | ||
exit $EXIT_CODE |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# require qpidd, qpid-tools sasl2-bin/cyrus-sasl-plain+cyrus-sasl-lib | ||
|
||
. tools/functions.sh | ||
|
||
DATADIR=$(mktemp -d /tmp/OSLOMSG-QPID.XXXXX) | ||
trap "clean_exit $DATADIR" EXIT | ||
|
||
[ -f "/usr/lib/qpid/daemon/acl.so" ] && LIBACL="load-module=/usr/lib/qpid/daemon/acl.so" | ||
|
||
cat > ${DATADIR}/qpidd.conf <<EOF | ||
port=65123 | ||
acl-file=${DATADIR}/qpidd.acl | ||
sasl-config=${DATADIR}/sasl2 | ||
log-to-file=${DATADIR}/log | ||
${LIBACL} | ||
mgmt-enable=yes | ||
auth=yes | ||
# Used by AMQP1.0 only | ||
queue-patterns=exclusive | ||
queue-patterns=unicast | ||
topic-patterns=broadcast | ||
EOF | ||
|
||
cat > ${DATADIR}/qpidd.acl <<EOF | ||
group admin stackqpid@QPID | ||
acl allow admin all | ||
acl deny all all | ||
EOF | ||
|
||
mkdir -p ${DATADIR}/sasl2 | ||
cat > ${DATADIR}/sasl2/qpidd.conf <<EOF | ||
pwcheck_method: auxprop | ||
auxprop_plugin: sasldb | ||
sasldb_path: ${DATADIR}/qpidd.sasldb | ||
mech_list: PLAIN | ||
EOF | ||
|
||
echo secretqpid | saslpasswd2 -c -p -f ${DATADIR}/qpidd.sasldb -u QPID stackqpid | ||
|
||
QPIDD=$(which qpidd 2>/dev/null) | ||
[ ! -x $QPIDD ] && /usr/sbin/qpidd | ||
|
||
mkfifo ${DATADIR}/out | ||
$QPIDD --config ${DATADIR}/qpidd.conf &> ${DATADIR}/out & | ||
wait_for_line "Broker .*running" "error" ${DATADIR}/out | ||
|
||
# Earlier failure if qpid-config is avialable | ||
[ -x "$(which qpid-config)" ] && qpid-config -b stackqpid/secretqpid@localhost:65123 | ||
|
||
$* |
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,32 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
. tools/functions.sh | ||
|
||
DATADIR=$(mktemp -d /tmp/OSLOMSG-RABBIT.XXXXX) | ||
trap "clean_exit $DATADIR" EXIT | ||
|
||
export RABBITMQ_NODE_IP_ADDRESS=127.0.0.1 | ||
export RABBITMQ_NODE_PORT=65123 | ||
export RABBITMQ_NODENAME=oslomsg-test@localhost | ||
export RABBITMQ_LOG_BASE=$DATADIR | ||
export RABBITMQ_MNESIA_BASE=$DATADIR | ||
export RABBITMQ_PID_FILE=$DATADIR/pid | ||
export HOME=$DATADIR | ||
|
||
# NOTE(sileht): We directly use the rabbitmq scripts | ||
# to avoid distribution check, like running as root/rabbitmq | ||
# enforcing. | ||
export PATH=/usr/lib/rabbitmq/bin/:$PATH | ||
|
||
|
||
mkfifo ${DATADIR}/out | ||
rabbitmq-server &> ${DATADIR}/out & | ||
wait_for_line "Starting broker... completed" "ERROR:" ${DATADIR}/out | ||
|
||
rabbitmqctl add_user oslomsg oslosecret | ||
rabbitmqctl set_permissions "oslomsg" ".*" ".*" ".*" | ||
|
||
|
||
export TRANSPORT_URL=rabbit://oslomsg:[email protected]:65123// | ||
$* |
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,30 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
. tools/functions.sh | ||
|
||
DATADIR=$(mktemp -d /tmp/OSLOMSG-ZEROMQ.XXXXX) | ||
trap "clean_exit $DATADIR" EXIT | ||
|
||
export TRANSPORT_URL=zmq:// | ||
export ZMQ_MATCHMAKER=redis | ||
export ZMQ_REDIS_PORT=65123 | ||
export ZMQ_IPC_DIR=${DATADIR} | ||
|
||
cat > ${DATADIR}/zmq.conf <<EOF | ||
[DEFAULT] | ||
transport_url=${TRANSPORT_URL} | ||
rpc_zmq_matchmaker=${ZMQ_MATCHMAKER} | ||
rpc_zmq_ipc_dir=${ZMQ_IPC_DIR} | ||
[matchmaker_redis] | ||
port=${ZMQ_REDIS_PORT} | ||
EOF | ||
|
||
redis-server --port $ZMQ_REDIS_PORT & | ||
|
||
oslo-messaging-zmq-receiver --config-file ${DATADIR}/zmq.conf > ${DATADIR}/receiver.log 2>&1 & | ||
|
||
# FIXME(sileht): This does the same kind of setup that devstack does | ||
# But this doesn't work yet, a zeromq maintener should take a look on that | ||
|
||
$* |
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,19 @@ | ||
|
||
wait_for_line () { | ||
while read line | ||
do | ||
echo "$line" | grep -q "$1" && break | ||
echo "$line" | grep "$2" && exit 1 | ||
done < "$3" | ||
# Read the fifo for ever otherwise process would block | ||
cat "$3" >/dev/null & | ||
} | ||
|
||
function clean_exit(){ | ||
local error_code="$?" | ||
kill -9 $(jobs -p) | ||
rm -rf "$1" | ||
return $error_code | ||
} | ||
|
||
|
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 |
---|---|---|
|
@@ -28,25 +28,22 @@ deps = -r{toxinidir}/requirements-py3.txt | |
-r{toxinidir}/test-requirements-py3.txt | ||
|
||
[testenv:py27-func-qpid] | ||
setenv = TRANSPORT_URL=qpid://stackqpid:[email protected]// | ||
commands = python setup.py testr --slowest --testr-args='oslo_messaging.tests.functional' | ||
setenv = TRANSPORT_URL=qpid://stackqpid:[email protected]:65123// | ||
commands = {toxinidir}/setup-test-env-qpid.sh python setup.py testr --slowest --testr-args='oslo_messaging.tests.functional' | ||
|
||
[testenv:py27-func-rabbit] | ||
setenv = TRANSPORT_URL=rabbit://stackrabbit:[email protected]// | ||
commands = python setup.py testr --slowest --testr-args='oslo_messaging.tests.functional' | ||
commands = {toxinidir}/setup-test-env-rabbit.sh python setup.py testr --slowest --testr-args='oslo_messaging.tests.functional' | ||
|
||
[testenv:py27-func-amqp1] | ||
setenv = TRANSPORT_URL=amqp://stackqpid:[email protected]// | ||
setenv = TRANSPORT_URL=amqp://stackqpid:[email protected]:65123// | ||
deps = -r{toxinidir}/amqp1-requirements.txt | ||
{[testenv]deps} | ||
# NOTE(sileht): This gate job run in fedora21 because proton libs are not | ||
# available on ubuntu yet, | ||
commands = python setup.py testr --slowest --testr-args='oslo_messaging.tests.(functional|test_amqp_driver)' | ||
commands = {toxinidir}/setup-test-env-qpid.sh python setup.py testr --slowest --testr-args='oslo_messaging.tests.(functional|test_amqp_driver)' | ||
|
||
[testenv:py27-func-zeromq] | ||
setenv = TRANSPORT_URL=zmq:// | ||
ZMQ_MATCHMAKER=oslo_messaging._drivers.matchmaker_redis.MatchMakerRedis | ||
commands = python setup.py testr --slowest --testr-args='oslo_messaging.tests.functional' | ||
commands = {toxinidir}/setup-test-env-zmq.sh python setup.py testr --slowest --testr-args='oslo_messaging.tests.functional' | ||
|
||
[flake8] | ||
show-source = True | ||
|