Skip to content

Commit c0b9fa8

Browse files
committed
Add script auto_sanity_test.sh to perform auto sanity test
Summary: Add script auto_sanity_test.sh to perform auto sanity test usage: auto_sanity_test.sh [new_commit] [old_commit] Running without commit parameter will do the sanity test with the latest and the latest 10 commit. Test Plan: ./auto_sanity_test.sh Reviewers: haobo, igor Reviewed By: igor CC: leveldb Differential Revision: https://reviews.facebook.net/D17397
1 parent 078365b commit c0b9fa8

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

tools/auto_sanity_test.sh

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
TMP_DIR="/tmp/rocksdb-sanity-test"
2+
3+
if [ "$#" -lt 2 ]; then
4+
echo "usage: ./auto_sanity_test.sh [new_commit] [old_commit]"
5+
echo "Missing either [new_commit] or [old_commit], perform sanity check with the latest and 10th latest commits."
6+
recent_commits=`git log | grep -e "^commit [a-z0-9]\+$"| head -n10 | sed -e 's/commit //g'`
7+
commit_new=`echo "$recent_commits" | head -n1`
8+
commit_old=`echo "$recent_commits" | tail -n1`
9+
echo "the most recent commits are:"
10+
echo "$recent_commits"
11+
else
12+
commit_new=$1
13+
commit_old=$2
14+
fi
15+
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+
22+
function makestuff() {
23+
echo "make clean"
24+
make clean > /dev/null
25+
echo "make db_sanity_test -j32"
26+
make db_sanity_test -j32 > /dev/null
27+
if [ $? -ne 0 ]; then
28+
echo "[ERROR] Failed to perform 'make db_sanity_test'"
29+
exit 1
30+
fi
31+
}
32+
33+
rm -r -f $dir_new
34+
rm -r -f $dir_old
35+
36+
echo "Running db sanity check with commits $commit_new and $commit_old."
37+
38+
echo "============================================================="
39+
echo "Making build $commit_new"
40+
makestuff
41+
mv db_sanity_test new_db_sanity_test
42+
echo "Creating db based on the new commit --- $commit_new"
43+
./new_db_sanity_test $dir_new create
44+
45+
echo "============================================================="
46+
echo "Making build $commit_old"
47+
makestuff
48+
mv db_sanity_test old_db_sanity_test
49+
echo "Creating db based on the old commit --- $commit_old"
50+
./old_db_sanity_test $dir_old create
51+
52+
echo "============================================================="
53+
echo "Verifying new db $dir_new using the old commit --- $commit_old"
54+
./old_db_sanity_test $dir_new verify
55+
if [ $? -ne 0 ]; then
56+
echo "[ERROR] Verification of $dir_new using commit $commit_old failed."
57+
exit 2
58+
fi
59+
60+
echo "============================================================="
61+
echo "Verifying old db $dir_old using the new commit --- $commit_new"
62+
./new_db_sanity_test $dir_old verify
63+
if [ $? -ne 0 ]; then
64+
echo "[ERROR] Verification of $dir_old using commit $commit_new failed."
65+
exit 2
66+
fi
67+
68+
rm old_db_sanity_test
69+
rm new_db_sanity_test
70+
71+
echo "Auto sanity test passed!"

0 commit comments

Comments
 (0)