You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

172 lines
4.9 KiB

  1. #!/usr/bin/env bash
  2. function usage() {
  3. echo "run iibench"
  4. echo "--mysqlbuild=$mysqlbuild"
  5. echo "[--max_row=$max_rows] [--rows_per_report=$rows_per_report] [--insert_only=$insert_only] [ --check=$check]"
  6. echo "[--commit=$commit]"
  7. }
  8. function retry() {
  9. local cmd=$*
  10. local retries
  11. local exitcode
  12. let retries=0
  13. while [ $retries -le 10 ] ; do
  14. echo `date` $cmd
  15. bash -c "$cmd"
  16. exitcode=$?
  17. echo `date` $cmd $exitcode $retries
  18. let retries=retries+1
  19. if [ $exitcode -eq 0 ] ; then break; fi
  20. sleep 10
  21. done
  22. test $exitcode = 0
  23. }
  24. mysqlbuild=
  25. commit=0
  26. check=1
  27. mysqlserver=`hostname`
  28. mysqluser=`whoami`
  29. mysqlsocket=/tmp/mysql.sock
  30. svn_server=https://svn.tokutek.com/tokudb
  31. svn_branch=.
  32. svn_revision=HEAD
  33. basedir=$HOME/svn.build
  34. builddir=$basedir/mysql.build
  35. system=`uname -s | tr [:upper:] [:lower:]`
  36. instancetype=
  37. testinstance=
  38. arch=`uname -m | tr [:upper:] [:lower:]`
  39. tracefile=/tmp/run.iibench.trace
  40. cmd=iibench
  41. dbname=$cmd
  42. engine=tokudb
  43. tblname=testit
  44. max_rows=50000000
  45. rows_per_report=1000000
  46. insert_only=1
  47. # parse the command line
  48. while [ $# -gt 0 ] ; do
  49. arg=$1; shift
  50. if [ $arg = "--replace_into" ] ; then
  51. cmd=replace_into
  52. elif [ $arg = "--insert_ignore" ] ; then
  53. cmd=insert_ignore
  54. elif [[ $arg =~ --(.*)=(.*) ]] ; then
  55. eval ${BASH_REMATCH[1]}=${BASH_REMATCH[2]}
  56. else
  57. usage; exit 1
  58. fi
  59. done
  60. if [[ $mysqlbuild =~ (.*)-(tokudb-.*)-(linux)-(x86_64) ]] ; then
  61. mysql=${BASH_REMATCH[1]}
  62. tokudb=${BASH_REMATCH[2]}
  63. system=${BASH_REMATCH[3]}
  64. arch=${BASH_REMATCH[4]}
  65. else
  66. exit 1
  67. fi
  68. # setup the dbname
  69. if [ $dbname = "iibench" ] ; then dbname=${cmd}_${engine}; fi
  70. if [ "$testinstance" != "" ] ; then dbname=${dbname}_${testinstance}; fi
  71. if [ -d /usr/local/mysql ] ; then
  72. export PATH=/usr/local/mysql/bin:$PATH
  73. fi
  74. if [ -d /usr/local/mysql/lib/mysql ] ; then
  75. export LD_LIBRARY_PATH=/usr/local/mysql/lib/mysql:$PATH
  76. fi
  77. # goto the base directory
  78. if [ ! -d $basedir ] ; then mkdir $basedir; fi
  79. pushd $basedir
  80. # update the build directory
  81. if [ $commit != 0 ] ; then
  82. if [ ! -d $builddir ] ; then mkdir $builddir; fi
  83. date=`date +%Y%m%d`
  84. testresultsdir=$builddir/$date
  85. pushd $builddir
  86. while [ ! -d $date ] ; do
  87. svn mkdir $svn_server/mysql.build/$date -m ""
  88. svn checkout -q $svn_server/mysql.build/$date
  89. if [ $? -ne 0 ] ; then rm -rf $date; fi
  90. done
  91. popd
  92. else
  93. testresultsdir=$PWD
  94. fi
  95. # checkout the code
  96. testdir=iibench-$mysqlbuild-$mysqlserver
  97. if [ "$testinstance" != "" ] ; then testdir=$testdir-$testinstance; fi
  98. rm -rf $testdir
  99. retry svn export -q -r $svn_revision $svn_server/$svn_branch/iibench $testdir
  100. exitcode=$?
  101. if [ $exitcode != 0 ] ; then
  102. retry svn export -q -r $svn_revision $svn_server/iibench $testdir
  103. exitcode=$?
  104. fi
  105. if [ $exitcode != 0 ] ; then exit 1; fi
  106. # create the iibench database
  107. mysql -S $mysqlsocket -u root -e "grant all on *.* to '$mysqluser'@'$mysqlserver'"
  108. exitcode=$?
  109. if [ $exitcode != 0 ] ; then exit 1; fi
  110. mysql -S $mysqlsocket -u $mysqluser -e "drop database if exists $dbname"
  111. exitcode=$?
  112. if [ $exitcode != 0 ] ; then exit 1; fi
  113. mysql -S $mysqlsocket -u $mysqluser -e "create database $dbname"
  114. exitcode=$?
  115. if [ $exitcode != 0 ] ; then exit 1; fi
  116. # run
  117. if [ $cmd = "iibench" -a $insert_only != 0 ] ; then
  118. runfile=$testresultsdir/$dbname-insert_only-$max_rows-$mysqlbuild-$mysqlserver
  119. else
  120. runfile=$testresultsdir/$dbname-$max_rows-$mysqlbuild-$mysqlserver
  121. fi
  122. if [ "$instancetype" != "" ] ; then runfile=$runfile-$instancetype; fi
  123. testresult="PASS"
  124. pushd $testdir/py
  125. echo `date` $cmd start $mysql $svn_branch $svn_revision $max_rows $rows_per_report >>$runfile
  126. runcmd=$cmd.py
  127. args="--db_user=$mysqluser --db_name=$dbname --db_socket=$mysqlsocket --engine=$engine --setup --max_rows=$max_rows --rows_per_report=$rows_per_report --table_name=$tblname"
  128. if [ $cmd = "iibench" -a $insert_only != 0 ] ; then runcmd="$runcmd --insert_only"; fi
  129. if [ $cmd = "replace_into" ] ; then runcmd="replace_into.py --use_replace_into"; fi
  130. if [ $cmd = "insert_ignore" ] ; then runcmd="replace_into.py"; fi
  131. ./$runcmd $args >>$runfile 2>&1
  132. exitcode=$?
  133. echo `date` $cmd complete $exitcode >>$runfile
  134. if [ $exitcode != 0 ] ; then testresult="FAIL"; fi
  135. popd
  136. if [ $check != 0 -a $testresult = "PASS" ] ; then
  137. echo `date` check table $tblname >>$runfile
  138. mysql -S $mysqlsocket -u $mysqluser -D $dbname -e "check table $tblname" >>$runfile 2>&1
  139. exitcode=$?
  140. echo `date` check table $tblname $exitcode >>$runfile
  141. if [ $exitcode != 0 ] ; then testresult="FAIL"; fi
  142. fi
  143. # commit results
  144. if [ $commit != 0 ] ; then
  145. if [ $cmd = "iibench" -a $insert_only != 0 ] ; then cmd="$cmd insert_only"; fi
  146. svn add $runfile
  147. retry svn commit -m \"$testresult $cmd $max_rows $dbname $mysqlbuild $mysqlserver `hostname`\" $runfile
  148. fi
  149. popd
  150. if [ $testresult = "PASS" ] ; then exitcode=0; else exitcode=1; fi
  151. exit $exitcode