adopting mysql-test-run to new ndb config

+ added option to ndb_waiter to wait for NO CONTACT
parent 1860613c
......@@ -1450,7 +1450,7 @@ then
then
echo "Starting ndbcluster"
./ndb/ndbcluster --port-base=$NDBCLUSTER_PORT --small --discless --initial --data-dir=$MYSQL_TEST_DIR/var || exit 1
export NDB_CONNECTSTRING=`cat Ndb.cfg`
export NDB_CONNECTSTRING="host=localhost:$NDBCLUSTER_PORT"
else
export NDB_CONNECTSTRING="$USE_RUNNING_NDBCLUSTER"
echo "Using ndbcluster at $NDB_CONNECTSTRING"
......
......@@ -81,9 +81,9 @@ while test $# -gt 0; do
shift
done
fs_ndb=$fsdir/ndbcluster
fs_name_1=$fs_ndb/node-1-fs-$port_base
fs_name_2=$fs_ndb/node-2-fs-$port_base
fs_ndb=$fsdir/ndbcluster-$port_base
fs_name_1=$fs_ndb/node-1-fs
fs_name_2=$fs_ndb/node-2-fs
NDB_HOME=
export NDB_CONNECTSTRING
......@@ -100,12 +100,14 @@ if [ ! -x $exec_mgmtsrv ]; then
exit 1
fi
ndb_host="localhost"
ndb_mgmd_port=$port_base
export NDB_CONNECTSTRING="host=$ndb_host:$ndb_mgmd_port"
start_default_ndbcluster() {
# do some checks
NDB_CONNECTSTRING=
if [ $initial_ndb ] ; then
[ -d $fs_ndb ] || mkdir $fs_ndb
[ -d $fs_name_1 ] || mkdir $fs_name_1
......@@ -118,11 +120,7 @@ fi
# set som help variables
ndb_host="localhost"
ndb_mgmd_port=$port_base
port_transporter=`expr $ndb_mgmd_port + 2`
export NDB_CONNECTSTRING="host=$ndb_host:$ndb_mgmd_port"
# Start management server as deamon
......@@ -143,29 +141,29 @@ sed \
> "$fs_ndb/config.ini"
fi
rm -f Ndb.cfg
rm -f $fs_ndb/Ndb.cfg
rm -f $cfgfile 2>&1 | cat > /dev/null
rm -f $fs_ndb/$cfgfile 2>&1 | cat > /dev/null
if ( cd $fs_ndb ; $exec_mgmtsrvr -d -c config.ini ) ; then :; else
echo "Unable to start $exec_mgmtsrvr from `pwd`"
exit 1
fi
cat `find $fs_ndb -name 'ndb_*.pid'` > $pidfile
cat `find $fs_ndb -name 'ndb_*.pid'` > $fs_ndb/$pidfile
# Start database node
echo "Starting ndbd"
( cd $fs_ndb ; $exec_ndb -d $flags_ndb & )
cat `find $fs_ndb -name 'ndb_*.pid'` > $pidfile
cat `find $fs_ndb -name 'ndb_*.pid'` > $fs_ndb/$pidfile
# Start database node
echo "Starting ndbd"
( cd $fs_ndb ; $exec_ndb -d $flags_ndb & )
cat `find $fs_ndb -name 'ndb_*.pid'` > $pidfile
cat `find $fs_ndb -name 'ndb_*.pid'` > $fs_ndb/$pidfile
# test if Ndb Cluster starts properly
......@@ -175,14 +173,14 @@ if ( $exec_waiter ) | grep "NDBT_ProgramExit: 0 - OK"; then :; else
exit 1
fi
cat `find $fs_ndb -name 'ndb_*.pid'` > $pidfile
cat `find $fs_ndb -name 'ndb_*.pid'` > $fs_ndb/$pidfile
status_ndbcluster
}
status_ndbcluster() {
# Start management client
echo "show" | $exec_mgmtclient $ndb_host $ndb_mgmd_port
echo "show" | $exec_mgmtclient
}
stop_default_ndbcluster() {
......@@ -191,26 +189,20 @@ stop_default_ndbcluster() {
# exit 0
#fi
if [ ! -f $cfgfile ] ; then
echo "$cfgfile missing"
exit 1
fi
ndb_host=`cat $cfgfile | sed -e "s,.*host=\(.*\)\:.*,\1,1"`
ndb_mgmd_port=`cat $cfgfile | sed -e "s,.*host=$ndb_host\:\([0-9]*\).*,\1,1"`
#if [ ! -f $cfgfile ] ; then
# echo "$cfgfile missing"
# exit 1
#fi
# Start management client
exec_mgmtclient="$exec_mgmtclient --try-reconnect=1 $ndb_host $ndb_mgmd_port"
echo "$exec_mgmtclient"
echo "all stop" | $exec_mgmtclient
exec_mgmtclient="$exec_mgmtclient --try-reconnect=1"
sleep 5
echo "all stop" | $exec_mgmtclient 2>&1 | cat > /dev/null
if [ -f $pidfile ] ; then
kill `cat $pidfile` 2> /dev/null
rm $pidfile
if [ -f $fs_ndb/$pidfile ] ; then
kill -9 `cat $fs_ndb/$pidfile` 2> /dev/null
rm $fs_ndb/$pidfile
fi
}
......
......@@ -27,16 +27,21 @@
#include <NDBT.hpp>
int
waitClusterStarted(const char* _addr, unsigned int _timeout= 120);
waitClusterStatus(const char* _addr,
ndb_mgm_node_status _status= NDB_MGM_NODE_STATUS_STARTED,
unsigned int _timeout= 120);
int main(int argc, const char** argv){
const char* _hostName = NULL;
int _no_contact = 0;
int _help = 0;
struct getargs args[] = {
{ "no-contact", 0, arg_flag, &_no_contact, "Wait for cluster no contact", "" },
{ "usage", '?', arg_flag, &_help, "Print help", "" }
};
int num_args = sizeof(args) / sizeof(args[0]);
int optind = 0;
char desc[] =
......@@ -86,7 +91,10 @@ int main(int argc, const char** argv){
}
}
if (waitClusterStarted(_hostName) != 0)
if (_no_contact) {
if (waitClusterStatus(_hostName, NDB_MGM_NODE_STATUS_NO_CONTACT) != 0)
return NDBT_ProgramExit(NDBT_FAILED);
} else if (waitClusterStatus(_hostName) != 0)
return NDBT_ProgramExit(NDBT_FAILED);
return NDBT_ProgramExit(NDBT_OK);
......@@ -164,9 +172,10 @@ getStatus(){
}
int
waitClusterStarted(const char* _addr, unsigned int _timeout)
waitClusterStatus(const char* _addr,
ndb_mgm_node_status _status,
unsigned int _timeout)
{
ndb_mgm_node_status _status = NDB_MGM_NODE_STATUS_STARTED;
int _startphase = -1;
int _nodes[MAX_NDB_NODES];
......@@ -290,7 +299,7 @@ waitClusterStarted(const char* _addr, unsigned int _timeout)
allInState = false;
}
}
g_info << "Waiting for cluster enter state"
g_info << "Waiting for cluster enter state "
<< ndb_mgm_get_node_status_string(_status)<< endl;
NdbSleep_SecSleep(1);
attempts++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment