aboutsummaryrefslogtreecommitdiffstats
path: root/distribution/cassandra_job
diff options
context:
space:
mode:
authorNelson,Thomas(tn1381)(arthurdent3) <tn1381@att.com>2018-10-16 15:59:48 -0400
committerNelson,Thomas(tn1381)(arthurdent3) <tn1381@att.com>2018-10-16 15:59:48 -0400
commit714f843dd2bda27b8375db26e1e2aa9af94d1c93 (patch)
treea628824526366e6b121eec3de1961149f8fab77f /distribution/cassandra_job
parent287bdcbb5482f94df091c3b7b766fed0007efa2e (diff)
Update runcql
Change-Id: I1ed72cbf2e29d1a1636eebd252fb184a6dee7555 Issue-ID: MUSIC-147 Signed-off-by: Nelson,Thomas(tn1381)(arthurdent3) <tn1381@att.com>
Diffstat (limited to 'distribution/cassandra_job')
-rw-r--r--distribution/cassandra_job/runcql.sh77
1 files changed, 47 insertions, 30 deletions
diff --git a/distribution/cassandra_job/runcql.sh b/distribution/cassandra_job/runcql.sh
index 687e93b3..078edf77 100644
--- a/distribution/cassandra_job/runcql.sh
+++ b/distribution/cassandra_job/runcql.sh
@@ -1,25 +1,38 @@
#! /bin/bash
+re='^[0-9]+$'
+if [[ $TIMEOUT =~ $re ]]; then
+ echo "TIMEOUT not set or error, defaulting to 10 seconds"
+ TIMEOUT=10
+fi
+TO="--request-timeout=$TIMEOUT"
+
if [ $CASS_HOSTNAME ]; then
- echo "#############################################"
- echo "############## Let run cql's ################"
- echo "#############################################"
- echo "Current Variales in play"
- echo "Default User"
- echo "DEF_USER="$DEF_USER
- echo "DEF_PASS=***********"
- echo "New User"
- echo "USERNAME="$USERNAME
- echo "PASSWORD=***********"
- if cqlsh -u cassandra -p cassandra -e "describe keyspaces;";
+ >&2 echo "#############################################"
+ >&2 echo "############## Let run cql's ################"
+ >&2 echo "#############################################"
+ >&2 echo "Current Variables in play"
+ >&2 echo "Default User"
+ >&2 echo "DEF_USER="$DEF_USER
+ >&2 echo "DEF_PASS=***********"
+ >&2 echo "New User"
+ >&2 echo "USERNAME="$USERNAME
+ >&2 echo "PASSWORD=***********"
+ >&2 echo "TIMEOUT="$TIMEOUT
+ >&2 echo "Running cqlsh $TO -u cassandra -p cassandra -e \"describe keyspaces;\" ${CASS_HOSTNAME} ${PORT};"
+ if cqlsh $TO -u cassandra -p cassandra -e "describe keyspaces;" ${CASS_HOSTNAME} ${PORT};
then
>&2 echo "Cassandra user still avalable, will continue as usual";
else
- if cqlsh -u $USERNAME -p $PASSWORD -e "describe keyspaces;";
+ CASSFAIL=true
+ >&2 echo "$DEF_USER failed, trying with $USERNAME"
+ if cqlsh $TO -u $USERNAME -p $PASSWORD -e "describe keyspaces;" ${CASS_HOSTNAME} ${PORT};
then
>&2 echo "Password $USERNAME in play, update Variables"
DEF_USER=$USERNAME
DEF_PASS=$PASSWORD
- if cqlsh -u $USERNAME -p $PASSWORD -e "describe keyspaces;" | grep admin1;
+ >&2 echo "DEF_USER="$DEF_USER
+ >&2 echo "DEF_PASS=***********"
+ if cqlsh $TO -u $USERNAME -p $PASSWORD -e "describe keyspaces;" ${CASS_HOSTNAME} ${PORT} | grep admin;
then
>&2 echo "Admin table exists, everything looks good"
exit 0;
@@ -28,25 +41,28 @@ if [ $CASS_HOSTNAME ]; then
>&2 echo "DEF_USER=" $DEF_USER
fi
else
- >&2 echo "Continue and as usual"
+ if [ $CASSFAIL ]; then
+ >&2 echo "$DEF_USER and $USERNAME fail. DB might need to be initialized again. This shouldn't have happend."
+ exit 1;
+ else
+ >&2 echo "Continue and as usual"
+ fi
fi
fi
- echo "admin.cql file:"
- cat /cql/admin.cql
+ >&2 echo "Running admin.cql file:"
>&2 echo "Running cqlsh -u $DEF_USER -p $DEF_PASS -f /cql/admin.cql ${CASS_HOSTNAME} ${PORT}"
sleep 1;
- if cqlsh -u $DEF_USER -p $DEF_PASS -f /cql/admin.cql ${CASS_HOSTNAME} ${PORT};
+ if cqlsh $TO -u $DEF_USER -p $DEF_PASS -f /cql/admin.cql ${CASS_HOSTNAME} ${PORT};
then
>&2 echo "Success - admin.cql - Admin keyspace created";
else
>&2 echo "Failure - admin.cql";
exit 0;
fi
- echo "admin_pw.cql file:"
- cat /cql/admin_pw.cql
+ >&2 echo "Running admin_pw.cql file:"
>&2 echo "Running cqlsh -u $DEF_USER -p $DEF_PASS -f /cql/admin_pw.cql ${CASS_HOSTNAME} ${PORT}"
sleep 1;
- if cqlsh -u $DEF_USER -p $DEF_PASS -f /cql/admin_pw.cql ${CASS_HOSTNAME} ${PORT};
+ if cqlsh $TO -u $DEF_USER -p $DEF_PASS -f /cql/admin_pw.cql ${CASS_HOSTNAME} ${PORT};
then
>&2 echo "Success - admin_pw.cql - Password Changed";
else
@@ -54,16 +70,17 @@ if [ $CASS_HOSTNAME ]; then
exit 0;
fi
- for f in /cql/extra/*; do
- case "$f" in
- *.cql)
- echo "$0: running $f" && cqlsh -u ${USERNAME} -p ${PASSWORD} -f "$f" ${CASS_HOSTNAME} ${PORT};
- ;;
- *)
- echo "$0: ignoring $f"
- ;;
- esac
- done
+ >&2 echo "Running Test - look for admin keyspace:"
+ >&2 echo "Running cqlsh -u $DEF_USER -p $DEF_PASS -e "describe keyspaces;" ${CASS_HOSTNAME} ${PORT}"
+ sleep 1;
+ if cqlsh $TO -u $DEF_USER -p $DEF_PASS -e "describe keyspaces;" ${CASS_HOSTNAME} ${PORT} | grep admin;
+ then
+ >&2 echo "Success - running test";
+ else
+ >&2 echo "Failure - running test";
+ exit 0;
+ fi
+
else
>&2 echo "Missing CASS_HOSTNAME";
exit 0;