summaryrefslogtreecommitdiff
path: root/storage/maria/ma_test_recovery
blob: 4e88824197e9bdd18f1803ee78769ecdd312b53a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh

set -e
silent="-s"
if [ -z "$maria_path" ]
then
    maria_path="."
fi

tmp=$maria_path/tmp

if test '!' -d $tmp
then
  mkdir $tmp
fi

echo "MARIA RECOVERY TESTS - success is if exit code is 0"

# runs a program inserting/deleting rows, then moves the resulting table
# elsewhere; applies the log and checks that the data file is
# identical to the saved original.
# Does not test the index file as we don't have logging for it yet.

for prog in "$maria_path/ma_test1 $silent -M -T -c" "$maria_path/ma_test2 $silent -L -K -W -P -M -T -c" "$maria_path/ma_test2 $silent -M -T -c -b"
do
  rm -f maria_log.* maria_log_control
  echo "TEST WITH $prog"
  $prog
  # derive table's name from program's name
  table=`echo $prog | sed -e 's;.*ma_\(test[0-9]\).*;\1;' `
  $maria_path/maria_chk -dvv $table > $tmp/maria_chk_message.good.txt 2>&1
  checksum=`$maria_path/maria_chk -dss $table`
  mv -f $table.MAD $tmp/$table.MAD.good
  rm $table.MAI
  echo "applying log"
  $maria_path/maria_read_log -a > $tmp/maria_read_log_$table.txt
  $maria_path/maria_chk -dvv $table > $tmp/maria_chk_message.txt 2>&1

  cmp $table.MAD $tmp/$table.MAD.good

  # QQ: Remove the following line when we also can recovert the index file
  $maria_path/maria_chk -s -r $table

  $maria_path/maria_chk -s -e $table
  checksum2=`$maria_path/maria_chk -dss $table`
  if test "$checksum" != "$checksum2"
  then
   echo "checksum differs for $table before and after recovery"
   exit 1;
  fi

# When "recovery of the table's state" is ready, we can test it like this:
#  diff $tmp/maria_chk_message.good.txt $tmp/maria_chk_message.txt > $tmp/maria_chk_diff.txt || true
#  if [ -s $tmp/maria_chk_diff.txt ]
#      then
#      echo "Differences in maria_chk -dvv, recovery not yet perfect !"
#      echo "========DIFF START======="
#      cat $tmp/maria_chk_diff.txt
#      echo "========DIFF END======="
#  fi
  rm -f $table.* $tmp/maria_chk_*.txt $tmp/maria_read_log_$table.txt
done

echo "ALL RECOVERY TESTS OK"