]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/tools/check_format_compatible.sh
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / rocksdb / tools / check_format_compatible.sh
1 #!/bin/bash
2 #
3 # A shell script to load some pre generated data file to a DB using ldb tool
4 # ./ldb needs to be avaible to be executed.
5 #
6 # Usage: <SCRIPT> [checkout]
7 # `checkout` can be a tag, commit or branch name. Will build using it and check DBs generated by all previous branches (or tags for very old versions without branch) can be opened by it.
8 # Return value 0 means all regression tests pass. 1 if not pass.
9
10 scriptpath=`dirname $BASH_SOURCE`
11 test_dir=${TEST_TMPDIR:-"/tmp"}"/format_compatible_check"
12 script_copy_dir=$test_dir"/script_copy"
13 input_data_path=$test_dir"/test_data_input/"
14
15 mkdir $test_dir || true
16 mkdir $input_data_path || true
17 rm -rf $script_copy_dir
18 cp $scriptpath $script_copy_dir -rf
19
20 # Generate four random files.
21 for i in {1..6}
22 do
23 input_data[$i]=$input_data_path/data$i
24 echo == Generating random input file ${input_data[$i]}
25 python - <<EOF
26 import random
27 random.seed($i)
28 symbols=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
29 with open('${input_data[$i]}', 'w') as f:
30 for i in range(1,1024):
31 k = ""
32 for j in range(1, random.randint(1,32)):
33 k=k + symbols[random.randint(0, len(symbols) - 1)]
34 vb = ""
35 for j in range(1, random.randint(0,128)):
36 vb = vb + symbols[random.randint(0, len(symbols) - 1)]
37 v = ""
38 for j in range(1, random.randint(1, 5)):
39 v = v + vb
40 print >> f, k + " ==> " + v
41 EOF
42 done
43
44 declare -a checkout_objs=("2.2.fb.branch" "2.3.fb.branch" "2.4.fb.branch" "2.5.fb.branch" "2.6.fb.branch" "2.7.fb.branch" "2.8.1.fb" "3.0.fb.branch" "3.1.fb" "3.2.fb" "3.3.fb" "3.4.fb" "3.5.fb" "3.6.fb" "3.7.fb" "3.8.fb" "3.9.fb" "3.10.fb" "3.11.fb" "3.12.fb" "3.13.fb" "4.0.fb" "4.1.fb" "4.2.fb" "4.3.fb" "4.4.fb" "4.5.fb" "4.6.fb" "4.7.fb" "4.8.fb" "4.9.fb" "4.10.fb" "4.11.fb" "4.12.fb" "4.13.fb" "5.0.fb" "5.1.fb" "5.2.fb" "5.3.fb" "5.4.fb")
45 declare -a forward_compatible_checkout_objs=("3.10.fb" "3.11.fb" "3.12.fb" "3.13.fb" "4.0.fb" "4.1.fb" "4.2.fb" "4.3.fb" "4.4.fb" "4.5.fb" "4.6.fb" "4.7.fb" "4.8.fb" "4.9.fb" "4.10.fb" "4.11.fb" "4.12.fb" "4.13.fb" "5.0.fb" "5.1.fb" "5.2.fb" "5.3.fb" "5.4.fb")
46
47 generate_db()
48 {
49 set +e
50 $script_copy_dir/generate_random_db.sh $1 $2
51 if [ $? -ne 0 ]; then
52 echo ==== Error loading data from $2 to $1 ====
53 exit 1
54 fi
55 set -e
56 }
57
58 compare_db()
59 {
60 set +e
61 $script_copy_dir/verify_random_db.sh $1 $2 $3 $4
62 if [ $? -ne 0 ]; then
63 echo ==== Read different content from $1 and $2 or error happened. ====
64 exit 1
65 fi
66 set -e
67 }
68
69 # Sandcastle sets us up with a remote that is just another directory on the same
70 # machine and doesn't have our branches. Need to fetch them so checkout works.
71 # Remote add may fail if added previously (we don't cleanup).
72 git remote add github_origin "https://github.com/facebook/rocksdb.git"
73 set -e
74 https_proxy="fwdproxy:8080" git fetch github_origin
75
76 for checkout_obj in "${checkout_objs[@]}"
77 do
78 echo == Generating DB from "$checkout_obj" ...
79 git checkout $checkout_obj
80 make clean
81 make ldb -j32
82 generate_db $input_data_path $test_dir/$checkout_obj
83 done
84
85 checkout_flag=${1:-"master"}
86
87 echo == Building $checkout_flag debug
88 git checkout $checkout_flag
89 make clean
90 make ldb -j32
91 compare_base_db_dir=$test_dir"/base_db_dir"
92 echo == Generate compare base DB to $compare_base_db_dir
93 generate_db $input_data_path $compare_base_db_dir
94
95 for checkout_obj in "${checkout_objs[@]}"
96 do
97 echo == Opening DB from "$checkout_obj" using debug build of $checkout_flag ...
98 compare_db $test_dir/$checkout_obj $compare_base_db_dir db_dump.txt 1
99 done
100
101 for checkout_obj in "${forward_compatible_checkout_objs[@]}"
102 do
103 echo == Build "$checkout_obj" and try to open DB generated using $checkout_flag...
104 git checkout $checkout_obj
105 make clean
106 make ldb -j32
107 compare_db $test_dir/$checkout_obj $compare_base_db_dir forward_${checkout_obj}_dump.txt 0
108 done
109
110 echo ==== Compatibility Test PASSED ====