mqltest.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 ~/odbserver/mql ]]; then
  7. mqlver=`ls -l mql`
  8. newmqlver=`cd ~/odbserver/; ls -l mql; cd ${CWD}`
  9. if [[ "$mqlver" != "$newmqlver" ]]; then
  10. cp -pf ~/odbserver/mql mql
  11. fi
  12. fi
  13. if [[ ! -e mql.conf ]]; then
  14. if [[ "${ODBPATH}" = "" ]]; then
  15. export ODBPATH=127.0.0.1:11001
  16. fi
  17. if [[ "${KEYSPACE}" = "" ]]; then
  18. export KEYSPACE=oktest
  19. fi
  20. fi
  21. odbpath=`./mql odbpath? log.level=error "$@"`
  22. keyspace=`./mql keyspace? log.level=error "$@"`
  23. if [[ `echo "${keyspace}" | wc -w` == "1" ]]; then
  24. logfile="${keyspace}.test.log"
  25. lastlogfile="${keyspace}.last.log"
  26. else
  27. logfile="test.log"
  28. lastlogfile="last.log"
  29. fi
  30. if [[ "${odbpath}" != "" ]]; then
  31. echo ODBPATH="${odbpath}"
  32. fi
  33. if [[ "${keyspace}" != "" ]]; then
  34. echo keyspace="${keyspace}"
  35. fi
  36. sleep 2
  37. filescount="./mql files? log.level=error "$@" | wc -l`
  38. if [[ "${filescount}" == "0" || "${filescount}" == "1" ]]; then
  39. ./mql "$@"
  40. exit $?
  41. fi
  42. filepath=`echo "$@" | awk '{print $NF}'`
  43. # remove ./
  44. filepath=${filepath/\.\//}
  45. # remove last slash
  46. filepath=${filepath%/}
  47. mqlproc=`ps -ef | grep -v grep | grep mql | grep "${filepath}"`
  48. if [[ "$mqlproc" != "" ]]; then
  49. echo "another mql test is running"
  50. exit 111
  51. fi
  52. if [[ -e ${logfile} ]]; then
  53. mv -f ${logfile} ${lastlogfile}
  54. fi
  55. ./mql "$@" 2>&1 | tee ${logfile}
  56. exit $?