mariadb/mysql-test/t/wait_for_socket.sh
unknown 52fc261bca Added option --mtr-build-thread to mysql-test-run.pl
Load shared libraries from zlib (fixed that mysql-test-run.pl didn't work on some Solaris boxes)
Added connect timeout to test to make im_daemon_life_cycle more predictable


mysql-test/mysql-test-run.pl:
  Added option --mtr-build-thread
  Load shared libraries from zlib (fixed that mysql-test-run.pl didn't work on some Solaris boxes)
mysql-test/t/wait_for_socket.sh:
  Added connect timeout (to make test predictable)
2006-11-23 18:39:10 +02:00

62 lines
1.4 KiB
Bash
Executable file

#!/bin/sh
###########################################################################
if [ $# -ne 6 ]; then
echo "Usage: wait_for_socket.sh <executable path> <socket path> <username> <password> <db> <timeout>"
exit 0
fi
client_exe="$1"
socket_path="$2"
username="$3"
password="$4"
db="$5"
total_timeout="$6"
###########################################################################
if [ -z "$client_exe" ]; then
echo "Error: invalid path to client executable ($client_exe)."
exit 0;
fi
if [ ! -x "$client_exe" ]; then
echo "Error: client by path '$client_exe' is not available."
exit 0;
fi
if [ -z "$socket_path" ]; then
echo "Error: invalid socket patch."
exit 0
fi
###########################################################################
client_args="--silent --socket=$socket_path --connect_timeout=1 "
[ -n "$username" ] && client_args="$client_args --user=$username "
[ -n "$password" ] && client_args="$client_args --password=$password "
[ -n "$db" ] && client_args="$client_args $db"
###########################################################################
cur_attempt=1
while true; do
if ( echo 'quit' | "$client_exe" $client_args >/dev/null 2>&1 ); then
echo "Success: server is ready to accept connection on socket."
exit 0
fi
[ $cur_attempt -ge $total_timeout ] && break
sleep 1
cur_attempt=`expr $cur_attempt + 1`
done
echo "Error: server does not accept connections after $total_timeout seconds."
exit 0