mqltest.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. export LANG=zh_CN.utf8
  2. export LC_ALL=zh_CN.utf8 2>/dev/null
  3. #改变工作目录到当前脚本所在路径
  4. if [[ "$0" =~ / ]]; then cd "${0%/*}"; fi
  5. export CWD=`pwd`
  6. if [[ ! -e "mql.conf" ]]; then
  7. if [[ "${ODBPATH}" = "" ]]; then
  8. export ODBPATH=127.0.0.1:11001
  9. fi
  10. if [[ "${KEYSPACE}" = "" ]]; then
  11. export KEYSPACE=oktest
  12. fi
  13. fi
  14. odbpath=`./mql odbpath? log.level=error "$@"`
  15. keyspace=`./mql keyspace? log.level=error "$@"`
  16. if [[ `echo "${keyspace}" | wc -w` == "1" ]]; then
  17. logfile="${keyspace}.test.log"
  18. lastlogfile="${keyspace}.last.log"
  19. else
  20. logfile="test.log"
  21. lastlogfile="last.log"
  22. fi
  23. if [[ -e ${logfile} ]]; then
  24. mv -f ${logfile} ${lastlogfile}
  25. fi
  26. if [[ "${odbpath}" != "" ]]; then
  27. echo ODBPATH="${odbpath}"
  28. fi
  29. if [[ "${keyspace}" != "" ]]; then
  30. echo keyspace="${keyspace}"
  31. fi
  32. sleep 2
  33. filepath=`echo "$@" | awk '{print $NF}'`
  34. if [[ "${filepath}" == "" ]]; then
  35. ./mql "$@"
  36. exit $?
  37. fi
  38. # remove ./
  39. filepath=${filepath/\.\//}
  40. # remove last slash
  41. filepath=${filepath%/}
  42. mqlproc=`ps -ef | grep -v grep | grep mql | grep "${filepath}"`
  43. if [[ "$mqlproc" != "" ]]; then
  44. echo "another mql test is running"
  45. exit 111
  46. fi
  47. ./mql "$@" 2>&1 | tee ${logfile}
  48. exit $?