wecisecode преди 5 дни
родител
ревизия
1c953144da
променени са 3 файла, в които са добавени 87 реда и са изтрити 1 реда
  1. 3 0
      odbctest/mql/initkeyspace.sh
  2. 2 1
      odbctest/mql/make.sh
  3. 82 0
      odbctest/mql/oktest.sh

+ 3 - 0
odbctest/mql/initkeyspace.sh

@@ -121,6 +121,7 @@ spread() {
 if [[ "$2" = "clear" ]]; then
     echo "clear keyspace ${keyspace}"
     clearkeyspace
+    exit $?
 elif [[ "${keyspace}" != "" ]]; then
     clearkeyspace drop
     cd "$CWD"
@@ -132,6 +133,8 @@ elif [[ "${keyspace}" != "" ]]; then
     echo "init keyspace ${keyspace} ..."
     cd /opt/matrix/init
     ./init -keyspace=${keyspace} -silent
+    exit $?
 else
     echo "initkeyspace.sh <keyspacename>"
+    exit 1
 fi

+ 2 - 1
odbctest/mql/make.sh

@@ -38,9 +38,10 @@ fi
 
 cp initkeyspace.sh ${installpath}/matrix/mql
 cp initkeyspace.sh ${installpath}/linux_amd64
-
 cp mqltest.sh ${installpath}/matrix/mql
 cp mqltest.sh ${installpath}/linux_amd64
+cp oktest.sh ${installpath}/matrix/mql
+cp oktest.sh ${installpath}/linux_amd64
 cp pprof.sh ${installpath}/matrix/mql
 cp pprof.sh ${installpath}/linux_amd64
 

+ 82 - 0
odbctest/mql/oktest.sh

@@ -0,0 +1,82 @@
+
+echo "" > changed.log
+
+parseargs() {
+    while [[ "$*" != "" ]]; do
+        if [[ "$1" == "init=no" ]]; then
+            noinit=1
+        fi
+        shift
+    done
+}
+parseargs "$@"
+
+last_odbserver=`/opt/matrix/odbserver/odbserver -version`
+keyspace=`./mql keyspace? log.level=error "$@"`
+logfile="${keyspace}.test.log"
+
+n=0
+while [[ $n -lt 1000 ]]; do
+    n=`expr $n + 1`
+    odbserver=`~/odbserver/odbserver -version`
+    if [[ "$odbserver" != "$last_odbserver" ]]; then
+        echo "odbserver changed" >> changed.log
+        echo "$last_odbserver" >> changed.log
+        echo "$odbserver" >> changed.log
+        ./sync.sh
+        last_odbserver="$odbserver"
+
+        if [[ "noinit" != "1" ]]; then
+            ./initkeyspace.sh $keyspace
+            ret=$?
+            if [[ "$ret" != "0" ]]; then
+                exit $ret
+            fi
+        fi
+
+        n=1
+    fi
+
+    cd /opt/matrix/test
+    PREFIX="test $n"
+    endflag="$odbserver end of test $n return"
+    ttt=`date +'%Y%m%d%H%M%S'`
+    check_odbserver() {
+        sleep 10
+        while true; do
+            mglproc=`ps -ef | grep -v grep | grep mql | grep "log.prefix=${PREFIX}"`
+            if [[ "$mqlproc" == "" ]]; then
+                exit 0
+            fi
+            odbserver=`~/odbserver/odbserver -version`
+            if [[ "$odbserver" != "$last_odbserver" ]]; then
+                ps -ef | grep -v grep | grep mql | grep "log.prefix=${PREFIX}" | awk '{print $2}' | xargs kill -9
+                exit 0
+            fi
+            sleep 10
+        done
+    }
+
+    run() {
+        ret=0
+        ./mqltest.sh "$@"
+        lastline=`tail -n 1 $logfile`
+        if [[ "$lastline" != "PASS" ]]; then
+            ret=1
+            if [[ `echo "$lastline" | grep './mqltest.sh:' | grep "已杀死"` != "" ]]; then
+                ret=0
+            elif [[ `echo "$lastline" | grep './mqltest.sh:' | grep "killed"` != "" ]]; then
+                ret=0
+            fi
+        fi
+        echo "$endflag $ret" >> $logfile
+        if [[ "$ret" != "0" ]]; then
+            exit $ret
+        fi
+    }
+    check_odbserver &
+    run
+    if [[ "$ret" != "0" ]]; then
+        exit $ret
+    fi
+done