auto_sanity_test.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # shellcheck disable=SC2148
  2. # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  3. TMP_DIR="${TMPDIR:-/tmp}/rocksdb-sanity-test"
  4. if [ "$#" -lt 2 ]; then
  5. echo "usage: ./auto_sanity_test.sh [new_commit] [old_commit]"
  6. echo "Missing either [new_commit] or [old_commit], perform sanity check with the latest and 10th latest commits."
  7. recent_commits=`git log | grep -e "^commit [a-z0-9]\+$"| head -n10 | sed -e 's/commit //g'`
  8. commit_new=`echo "$recent_commits" | head -n1`
  9. commit_old=`echo "$recent_commits" | tail -n1`
  10. echo "the most recent commits are:"
  11. echo "$recent_commits"
  12. else
  13. commit_new=$1
  14. commit_old=$2
  15. fi
  16. if [ ! -d $TMP_DIR ]; then
  17. mkdir $TMP_DIR
  18. fi
  19. dir_new="${TMP_DIR}/${commit_new}"
  20. dir_old="${TMP_DIR}/${commit_old}"
  21. function makestuff() {
  22. echo "make clean"
  23. make clean > /dev/null
  24. echo "make db_sanity_test -j32"
  25. make db_sanity_test -j32 > /dev/null
  26. if [ $? -ne 0 ]; then
  27. echo "[ERROR] Failed to perform 'make db_sanity_test'"
  28. exit 1
  29. fi
  30. }
  31. rm -r -f $dir_new
  32. rm -r -f $dir_old
  33. echo "Running db sanity check with commits $commit_new and $commit_old."
  34. echo "============================================================="
  35. echo "Making build $commit_new"
  36. git checkout $commit_new
  37. if [ $? -ne 0 ]; then
  38. echo "[ERROR] Can't checkout $commit_new"
  39. exit 1
  40. fi
  41. makestuff
  42. mv db_sanity_test new_db_sanity_test
  43. echo "Creating db based on the new commit --- $commit_new"
  44. ./new_db_sanity_test $dir_new create
  45. cp ./tools/db_sanity_test.cc $dir_new
  46. cp ./tools/auto_sanity_test.sh $dir_new
  47. echo "============================================================="
  48. echo "Making build $commit_old"
  49. git checkout $commit_old
  50. if [ $? -ne 0 ]; then
  51. echo "[ERROR] Can't checkout $commit_old"
  52. exit 1
  53. fi
  54. cp -f $dir_new/db_sanity_test.cc ./tools/.
  55. cp -f $dir_new/auto_sanity_test.sh ./tools/.
  56. makestuff
  57. mv db_sanity_test old_db_sanity_test
  58. echo "Creating db based on the old commit --- $commit_old"
  59. ./old_db_sanity_test $dir_old create
  60. echo "============================================================="
  61. echo "[Backward Compatibility Check]"
  62. echo "Verifying old db $dir_old using the new commit --- $commit_new"
  63. ./new_db_sanity_test $dir_old verify
  64. if [ $? -ne 0 ]; then
  65. echo "[ERROR] Backward Compatibility Check fails:"
  66. echo " Verification of $dir_old using commit $commit_new failed."
  67. exit 2
  68. fi
  69. echo "============================================================="
  70. echo "[Forward Compatibility Check]"
  71. echo "Verifying new db $dir_new using the old commit --- $commit_old"
  72. ./old_db_sanity_test $dir_new verify
  73. if [ $? -ne 0 ]; then
  74. echo "[ERROR] Forward Compatibility Check fails:"
  75. echo " $dir_new using commit $commit_old failed."
  76. exit 2
  77. fi
  78. rm old_db_sanity_test
  79. rm new_db_sanity_test
  80. rm -rf $dir_new
  81. rm -rf $dir_old
  82. echo "Auto sanity test passed!"