1#!/bin/sh 2 3PREFIX=@prefix@ 4 5# stop any existing instances 6$PREFIX/bin/sqlr-stop 7sleep 2 8 9# really kill them 10ps aux > /dev/null 2> /dev/null 11if ( test "$?" = "0" ) 12then 13 kill `ps aux | grep sqlr-connection | grep -v grep | cut -c10-15` 2> /dev/null 14 kill `ps aux | grep sqlr-scaler | grep -v grep | cut -c10-15` 2> /dev/null 15 kill `ps aux | grep sqlr-listener | grep -v grep | cut -c10-15` 2> /dev/null 16else 17 kill `ps -efa | grep sqlr-connection | grep -v grep | cut -c10-15` 2> /dev/null 18 kill `ps -efa | grep sqlr-scaler | grep -v grep | cut -c10-15` 2> /dev/null 19 kill `ps -efa | grep sqlr-listener | grep -v grep | cut -c10-15` 2> /dev/null 20fi 21sleep 2 22 23# for each database/configuration... 24for DB in @TESTDBS@ 25do 26 27 # for tls, krb, and extensions tests, verify that we support oracle 28 if ( test "$DB" = "tls" -o "$DB" = "krb" -o "$DB" = "extensions" ) 29 then 30 if ( test -z "`ls $PREFIX/lib*/sqlrelay/sqlrconnection_oracle.so 2> /dev/null`" ) 31 then 32 echo "skipping $DB..." 33 echo 34 echo "================================================================================" 35 echo 36 continue 37 fi 38 39 # for the mysqlprotocol test, verify that we support the mysql 40 elif ( test "$DB" = "mysqlprotocol" ) 41 then 42 if ( test -z "`ls $PREFIX/lib*/sqlrelay/sqlrconnection_mysql.so 2> /dev/null`" ) 43 then 44 echo "skipping $DB..." 45 echo 46 echo "================================================================================" 47 echo 48 continue 49 fi 50 51 # for other tests, verify that we support the database 52 else 53 if ( test -z "`ls $PREFIX/lib*/sqlrelay/sqlrconnection_$DB.so 2> /dev/null`" ) 54 then 55 echo "skipping $DB..." 56 echo 57 echo "================================================================================" 58 echo 59 continue 60 fi 61 fi 62 63 # for router tests, also verify that we support mysql 64 if ( test "$DB" = "router" ) 65 then 66 if ( test -z "`ls $PREFIX/lib*/sqlrelay/sqlrconnection_mysql.so 2> /dev/null`" ) 67 then 68 echo "skipping $DB..." 69 echo 70 echo "================================================================================" 71 echo 72 continue 73 fi 74 fi 75 76 # testing... 77 echo "testing $DB (from `hostname`)..." 78 79 # for the router test, start the master/slave instances 80 if ( test "$DB" = "router" ) 81 then 82 $PREFIX/bin/sqlr-start -config `pwd`/sqlrelay.conf -id routermaster -backtrace `pwd` 83 sleep 2 84 85 $PREFIX/bin/sqlr-start -config `pwd`/sqlrelay.conf -id routerslave -backtrace `pwd` 86 sleep 2 87 fi 88 89 # start the instance 90 $PREFIX/bin/sqlr-start -config `pwd`/sqlrelay.conf -id ${DB}test -backtrace `pwd` 91 sleep 2 92 93 # make sure that the instance is up 94 PING="" 95 BYPASS="no" 96 for attempts in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 97 do 98 echo 99 echo "pinging $DB..." 100 if ( test "$DB" = "tls" ) 101 then 102 PING=`$PREFIX/bin/sqlrsh -host localhost -tls -tlscert $PREFIX/etc/sqlrelay.conf.d/client.pem -tlsca $PREFIX/etc/sqlrelay.conf.d/ca.pem -tlsvalidate ca -command ping 2>&1` 103 elif ( test "$DB" = "extensions" ) 104 then 105 PING=`$PREFIX/bin/sqlrsh -host localhost -user test -password test -command ping 2>&1` 106 elif ( test "$DB" = "mysqlprotocol" ) 107 then 108 PING="0: Couldn't connect to the listener." 109 if ( test -n "`netstat -an 2> /dev/null | grep LISTEN | grep 3306`" ) 110 then 111 PING="The database is up." 112 fi 113 else 114 PING=`$PREFIX/bin/sqlrsh -id ${DB}test -command ping 2>&1` 115 fi 116 117 # (this collapses whitespace) 118 PING=`echo $PING` 119 120 echo $PING 121 122 if ( test "$PING" = "0: Couldn't connect to the listener." ) 123 then 124 sleep 5 125 else 126 127 # If ssl is sufficiently old then the ssl test will 128 # fail like this. Just bypass the test in that case. 129 SSLPROBLEM=`echo "$PING" | grep "unknown message digest algorithm"` 130 if ( test -n "$SSLPROBLEM" ) 131 then 132 BYPASS="yes" 133 fi 134 break 135 fi 136 done 137 138 # bypass the test if necessary 139 if ( test "$BYPASS" = "no" ) 140 then 141 142 # run the tests 143 if ( test "$PING" = "The database is up." ) 144 then 145 146 # kinit for krb tests 147 if ( test "$DB" = "krb" ) 148 then 149 kdestroy 150 kinit 151 fi 152 153 echo 154 echo "success..." 155 echo 156 157 if ( test "$DB" = "mysqlprotocol" ) 158 then 159 ./dropin/mysql 160 else 161 ./test.sh $DB 162 fi 163 else 164 echo 165 echo "failed to start ${DB}test" 166 echo 167 echo "hit enter to continue or ctrl-c to stop..." 168 if ( test "$DB" = "krb" ) 169 then 170 read -t 20 PROMPT 2> /dev/null 171 # (ubuntu's dash doesn't support read -t) 172 if ( test "$?" != "0" ) 173 then 174 sleep 20 175 fi 176 else 177 read PROMPT 178 fi 179 fi 180 fi 181 182 # shut down the instance(s) 183 if ( test "$DB" = "router" ) 184 then 185 sleep 2 186 $PREFIX/bin/sqlr-stop -config `pwd`/sqlrelay.conf -id routermaster 187 sleep 2 188 $PREFIX/bin/sqlr-stop -config `pwd`/sqlrelay.conf -id routerslave 189 fi 190 sleep 2 191 $PREFIX/bin/sqlr-stop -config `pwd`/sqlrelay.conf -id ${DB}test 192 sleep 2 193 194 echo 195 echo "================================================================================" 196 echo 197done 198