125d950dd4
Currently, unittests at real HBase are not usually used. Jenkins jobs and a predominant amount of developers use HBase mock. One of the reasons for this is that unittests at real HBase are too slow. It's due to processing of "disable_table" and "delete_table" commands. In HBase these command take up to 1-2 seconds. Now we create all table-set for each test that's why at real HBase unit tests may be executed several hours. So, at real HBase backend unit tests may be executed several hours. My CR speeds up this case. To solve this problem it was decided to keep all test data in one table. To provide a distinguishability of data from different tests unique row-prefix is used for each one. Creating and deleting required table are implements at setup-test-env.sh. Separating data is implemented with mock.patchs which transforms row value in happybase.Table methods. Change-Id: I1883d6e0619b0b2f223a4e58bdc0fc0656636e1f Closes-bug: #1372912
43 lines
1.3 KiB
Bash
Executable File
43 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
function clean_exit(){
|
|
local error_code="$?"
|
|
rm -rf ${MONGO_DATA}
|
|
if test -n "$CEILOMETER_TEST_HBASE_URL"
|
|
then
|
|
python tools/test_hbase_table_utils.py --clear
|
|
fi
|
|
kill $(jobs -p)
|
|
return $error_code
|
|
}
|
|
|
|
# Setup MongoDB test server
|
|
MONGO_DATA=`mktemp -d CEILO-MONGODB-XXXXX`
|
|
MONGO_PORT=29000
|
|
trap "clean_exit" EXIT
|
|
mkfifo ${MONGO_DATA}/out
|
|
export PATH=${PATH:+$PATH:}/sbin:/usr/sbin
|
|
if ! which mongod >/dev/null 2>&1
|
|
then
|
|
echo "Could not find mongod command" 1>&2
|
|
exit 1
|
|
fi
|
|
mongod --maxConns 32 --nojournal --noprealloc --smallfiles --quiet --noauth --port ${MONGO_PORT} --dbpath "${MONGO_DATA}" --bind_ip localhost --config /dev/null &>${MONGO_DATA}/out &
|
|
# Wait for Mongo to start listening to connections
|
|
while read line
|
|
do
|
|
echo "$line" | grep -q "waiting for connections on port ${MONGO_PORT}" && break
|
|
done < ${MONGO_DATA}/out
|
|
# Read the fifo for ever otherwise mongod would block
|
|
cat ${MONGO_DATA}/out > /dev/null &
|
|
export CEILOMETER_TEST_MONGODB_URL="mongodb://localhost:${MONGO_PORT}/ceilometer"
|
|
if test -n "$CEILOMETER_TEST_HBASE_URL"
|
|
then
|
|
export CEILOMETER_TEST_HBASE_TABLE_PREFIX=$(hexdump -n 16 -v -e '/1 "%02X"' /dev/urandom)
|
|
python tools/test_hbase_table_utils.py --upgrade
|
|
fi
|
|
|
|
# Yield execution to venv command
|
|
$*
|