* Fixed unit test runner (upstream script ./setup-test-env-mongodb.sh isn't
[openstack-build/ceilometer-build.git] / xenial / debian / setup-test-env-mongodb.sh
1 #!/bin/bash
2 set -e
3
4 source functions.sh
5
6 if [ "$1" = "--coverage" ]; then
7         COVERAGE_ARG="$1"
8         shift
9 fi
10
11 export PATH=${PATH:+$PATH:}/sbin:/usr/sbin
12 check_for_cmd mongod
13
14 # Start MongoDB process for tests
15 MONGO_DATA=`mktemp -d /tmp/CEILO-MONGODB-XXXXX`
16 MONGO_PORT=29000
17 trap "clean_exit ${MONGO_DATA}" EXIT
18 mkfifo ${MONGO_DATA}/out
19 mongod --maxConns 32 --nojournal --noprealloc --smallfiles --quiet --noauth --port ${MONGO_PORT} --dbpath "${MONGO_DATA}" --bind_ip localhost --config /dev/null &>${MONGO_DATA}/out &
20 # Wait for Mongo to start listening to connections
21 wait_for_line "waiting for connections on port ${MONGO_PORT}" ${MONGO_DATA}/out
22 # Read the fifo for ever otherwise mongod would block
23 cat ${MONGO_DATA}/out > /dev/null &
24 export CEILOMETER_TEST_STORAGE_URL="mongodb://localhost:${MONGO_PORT}/ceilometer"
25
26 # Yield execution to venv command
27 OS_TEST_PATH=./ceilometer/tests/unit $*