2017-08-03 22:43:05 +00:00
|
|
|
#!/usr/bin/env bash
|
2019-04-18 17:51:19 +00:00
|
|
|
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
2015-04-07 23:54:39 +00:00
|
|
|
#
|
|
|
|
# A shell script to verify DB generated by generate_random_db.sh cannot opened and read correct data.
|
|
|
|
# ./ldb needs to be avaible to be executed.
|
|
|
|
#
|
|
|
|
# Usage: <SCRIPT> <DB Path>
|
|
|
|
|
|
|
|
scriptpath=`dirname $BASH_SOURCE`
|
|
|
|
if [ "$#" -lt 2 ]; then
|
2018-06-15 17:59:40 +00:00
|
|
|
echo "usage: $BASH_SOURCE <db_directory> <compare_base_db_directory> [dump_file_name] [if_try_load_options] [if_ignore_unknown_options]"
|
2015-04-07 23:54:39 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
db_dir=$1
|
|
|
|
base_db_dir=$2
|
|
|
|
dump_file_name=${3:-"dump_file.txt"}
|
2017-04-20 17:16:13 +00:00
|
|
|
try_load_options=${4:-"1"}
|
2018-06-15 17:59:40 +00:00
|
|
|
ignore_unknown_options=${5:-"0"}
|
2015-04-07 23:54:39 +00:00
|
|
|
db_dump=$db_dir"/"$dump_file_name
|
|
|
|
base_db_dump=$base_db_dir"/"$dump_file_name
|
2022-06-03 23:35:13 +00:00
|
|
|
extra_params=
|
2017-04-20 17:16:13 +00:00
|
|
|
|
2022-06-03 23:35:13 +00:00
|
|
|
if [ "$try_load_options" = "0" ]; then
|
|
|
|
extra_params=" --try_load_options=false"
|
|
|
|
elif [ "$try_load_options" = "1" ]; then
|
|
|
|
extra_params=" --try_load_options=true"
|
2017-04-20 17:16:13 +00:00
|
|
|
fi
|
2015-04-07 23:54:39 +00:00
|
|
|
|
2018-06-15 17:59:40 +00:00
|
|
|
if [ "$ignore_unknown_options" = "1" ]; then
|
2022-06-03 23:35:13 +00:00
|
|
|
extra_params="$extra_params --ignore_unknown_options"
|
2018-06-15 17:59:40 +00:00
|
|
|
fi
|
|
|
|
|
2015-04-07 23:54:39 +00:00
|
|
|
set -e
|
|
|
|
echo == Dumping data from $db_dir to $db_dump
|
2022-06-03 23:35:13 +00:00
|
|
|
./ldb dump --db=$db_dir $extra_params > $db_dump
|
2015-04-07 23:54:39 +00:00
|
|
|
|
|
|
|
echo == Dumping data from $base_db_dir to $base_db_dump
|
2022-06-03 23:35:13 +00:00
|
|
|
./ldb dump --db=$base_db_dir $extra_params > $base_db_dump
|
2015-04-07 23:54:39 +00:00
|
|
|
|
2022-06-03 23:35:13 +00:00
|
|
|
diff $db_dump $base_db_dump
|