Browse Source

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
changes/62/138062/2
Julien Danjou 8 years ago
parent
commit
e153202ca0
  1. 4
      functions.sh
  2. 15
      setup-memcached-env.sh
  3. 2
      setup-mysql-env.sh
  4. 2
      setup-postgresql-env.sh
  5. 15
      setup-redis-env.sh
  6. 6
      setup-zookeeper-env.sh

4
functions.sh

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

15
setup-memcached-env.sh

@ -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
$*

2
setup-mysql-env.sh

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

2
setup-postgresql-env.sh

@ -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

15
setup-redis-env.sh

@ -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
$*

6
setup-zookeeper-env.sh

@ -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

Loading…
Cancel
Save