tests: remove check_port

It's not portable and currently the detection scheme use really easy to
break and report false positive. Try to rather launch services on
different ports.

Change-Id: I0739bea2f8fe42e1bba1c04e6ce5be14237dfbcb
This commit is contained in:
Julien Danjou 2014-12-01 14:29:57 +01:00
parent 910188e2f8
commit e153202ca0
6 changed files with 10 additions and 34 deletions

View File

@ -1,4 +0,0 @@
function check_port(){
netstat -an 2>/dev/null | grep -q "$1"
return $?
}

View File

@ -1,8 +1,6 @@
#!/bin/bash
set -x -e
. functions.sh
function clean_exit(){
local error_code="$?"
local spawned=$(jobs -p)
@ -14,16 +12,11 @@ function clean_exit(){
trap "clean_exit" EXIT
if ! check_port 11211; then
memcached_bin=$(which memcached || true)
if [ -n "$memcached_bin" ]; then
$memcached_bin &
else
echo "Memcached server not available"
exit 1
fi
memcached_bin=$(which memcached || true)
if [ -n "$memcached_bin" ]; then
$memcached_bin -p 11212 &
fi
export TOOZ_TEST_MEMCACHED_URL="memcached://?timeout=5"
export TOOZ_TEST_MEMCACHED_URL="memcached://localhost:11212?timeout=5"
# Yield execution to venv command
$*

View File

@ -1,8 +1,6 @@
#!/bin/bash
set -x -e
. functions.sh
clean_exit () {
local error_code="$?"
kill $(jobs -p)

View File

@ -1,8 +1,6 @@
#!/bin/bash
set -x -e
. functions.sh
function clean_exit() {
local error_code="$?"
${PGSQL_PATH}/pg_ctl -w -D ${PGSQL_DATA} -o "-p $PGSQL_PORT" stop

View File

@ -1,8 +1,6 @@
#!/bin/bash
set -x -e
. functions.sh
function clean_exit(){
local error_code="$?"
local spawned=$(jobs -p)
@ -14,16 +12,11 @@ function clean_exit(){
trap "clean_exit" EXIT
if ! check_port 6379; then
redis_bin=$(which redis-server || true)
if [ -n "$redis_bin" ]; then
$redis_bin --port 6379 &
else
echo "Redis server not available"
exit 1
fi
redis_bin=$(which redis-server || true)
if [ -n "$redis_bin" ]; then
$redis_bin --port 6380 &
fi
export TOOZ_TEST_REDIS_URL="redis://localhost:6379?timeout=5"
export TOOZ_TEST_REDIS_URL="redis://localhost:6380?timeout=5"
# Yield execution to venv command
$*

View File

@ -1,8 +1,6 @@
#!/bin/bash
set -x -e
. functions.sh
ZOO_CONF=/etc/zookeeper
ZOO_BIN=/usr/share/zookeeper/bin
ZOO_TMP_DIR=$(mktemp -d /tmp/ZOO-TMP-XXXXX)
@ -33,7 +31,7 @@ function start_zookeeper_server(){
sed -i -r "s@(ZOOCFGDIR *= *).*@\1$ZOO_TMP_DIR@" $ZOO_TMP_DIR/bin/zkEnv.sh
mkdir $ZOO_TMP_DIR/log
sed -i -r "s@(ZOO_LOG_DIR *= *).*@\1$ZOO_TMP_DIR/log@" $ZOO_TMP_DIR/bin/vzkEnv.sh
sed -i -r "s@(ZOO_LOG_DIR *= *).*@\1$ZOO_TMP_DIR/log@" $ZOO_TMP_DIR/bin/zkEnv.sh
$ZOO_TMP_DIR/bin/zkServer.sh start
}
@ -45,7 +43,7 @@ function stop_zookeeper_server(){
trap "clean_exit" EXIT
if ! check_port 2181 && [ -d $ZOO_CONF ]; then
if [ -d $ZOO_CONF ]; then
start_zookeeper_server
if [ $? -eq 0 ]; then
ZOOKEEPER_STARTED=1