Correctly kills mongodb processes (Closes: #835177)

Change-Id: Id3f717fb708c99ff808601a5c73f9911afa069a0
This commit is contained in:
Thomas Goirand 2016-10-10 13:56:37 +02:00
parent 0703b548f5
commit 90452fec47
3 changed files with 21 additions and 34 deletions

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
aodh (3.0.0-2) unstable; urgency=medium
* Correctly kills mongodb processes (Closes: #835177).
-- Thomas Goirand <zigo@debian.org> Mon, 10 Oct 2016 13:55:42 +0200
aodh (3.0.0-1) unstable; urgency=medium
* New upstream release.

24
debian/functions.sh vendored
View File

@ -1,24 +0,0 @@
function clean_exit(){
local error_code="$?"
rm -rf "$1"
kill $(jobs -p)
return $error_code
}
check_for_cmd () {
if ! which "$1" >/dev/null 2>&1
then
echo "Could not find $1 command" 1>&2
exit 1
fi
}
wait_for_line () {
while read line
do
echo "$line" | grep -q "$1" && break
done < "$2"
# Read the fifo for ever otherwise process would block
cat "$2" >/dev/null &
}

View File

@ -1,27 +1,32 @@
#!/bin/bash
set -e
source debian/functions.sh
if [ "$1" = "--coverage" ]; then
COVERAGE_ARG="$1"
shift
fi
export PATH=${PATH:+$PATH:}/sbin:/usr/sbin
check_for_cmd mongod
wait_for_line () {
while read line ; do
echo "$line" | grep -q "$1" && break
done < "$2"
# Read the fifo for ever otherwise process would block
cat "$2" >/dev/null &
WAIT_FOR_LINE_PID=$!
}
# Start MongoDB process for tests
MONGO_DATA=`mktemp -d /tmp/AODH-MONGODB-XXXXX`
MONGO_PORT=29000
trap "clean_exit ${MONGO_DATA}" EXIT
mkfifo ${MONGO_DATA}/out
mongod --maxConns 32 --nojournal --noprealloc --smallfiles --quiet --noauth --port ${MONGO_PORT} --dbpath "${MONGO_DATA}" --bind_ip localhost --config /dev/null &>${MONGO_DATA}/out &
MONGO_PID=$!
# Wait for Mongo to start listening to connections
wait_for_line "waiting for connections on port ${MONGO_PORT}" ${MONGO_DATA}/out
# Read the fifo for ever otherwise mongod would block
cat ${MONGO_DATA}/out > /dev/null &
MONGO_DATA_PID=$!
export AODH_TEST_STORAGE_URL="mongodb://localhost:${MONGO_PORT}/AODH"
# Yield execution to venv command
OS_TEST_PATH=./aodh/tests/unit $*
# Kill all processes
kill ${WAIT_FOR_LINE_PID}
kill ${MONGO_PID}
kill ${MONGO_DATA_PID}