| 1 |
source include/have_ndb.inc; |
| 2 |
source suite/ndb/include/backup_restore_setup.inc; |
| 3 |
|
| 4 |
--echo Verify that one can run ndb_print_backup_file on all saved backup files |
| 5 |
--echo without errors. |
| 6 |
--echo That should cover most kinds of backup files, and both newer and older |
| 7 |
--echo formats. |
| 8 |
|
| 9 |
--perl |
| 10 |
use strict; |
| 11 |
use lib "lib/"; |
| 12 |
use My::Find; |
| 13 |
use File::Basename; |
| 14 |
use File::Find; |
| 15 |
use locale ':not_characters'; |
| 16 |
|
| 17 |
my $mysql_test_dir = $ENV{MYSQL_TEST_DIR} or die "Need MYSQL_TEST_DIR"; |
| 18 |
my $basedir = dirname($mysql_test_dir); |
| 19 |
|
| 20 |
# In the RPM case, binaries and libraries are installed in the |
| 21 |
# default system locations, instead of having our own private base |
| 22 |
# directory. And we install "usr/share/mysql-test". Moving up two |
| 23 |
# more directory relative to "mysql-test" gives us a usable base |
| 24 |
# directory for RPM installs. |
| 25 |
if (! -d "$basedir/sql" and ! -d "$basedir/bin" ) |
| 26 |
{ |
| 27 |
$basedir= dirname($basedir); |
| 28 |
} |
| 29 |
my $bindir = $ENV{MTR_BINDIR} || $basedir; # Out of source set MTR_BINDIR |
| 30 |
|
| 31 |
my $NDB_PRINT_BACKUP_FILE = my_find_bin($bindir, |
| 32 |
["runtime_output_directory", "bin"], |
| 33 |
"ndb_print_backup_file"); |
| 34 |
|
| 35 |
# Directory containing backups from earlier versions of NDB |
| 36 |
my $NDB_SAVED_BACKUPS = "$ENV{MYSQL_TEST_DIR}/suite/ndb/backups"; |
| 37 |
|
| 38 |
# configuration file with backup password |
| 39 |
my $NDB_ENCRYPTED_CNF = "$ENV{MYSQL_TEST_DIR}/suite/ndb/encrypted_backup.cnf"; |
| 40 |
|
| 41 |
sub sorted |
| 42 |
{ |
| 43 |
sort(@_); |
| 44 |
} |
| 45 |
|
| 46 |
sub process |
| 47 |
{ |
| 48 |
return unless -f; |
| 49 |
my $pwd_arg; |
| 50 |
if ($File::Find::name =~ /encrypted/) |
| 51 |
{ |
| 52 |
$pwd_arg = "--defaults-extra-file=${NDB_ENCRYPTED_CNF} "; |
| 53 |
} |
| 54 |
my $pwd_arg_printable = $pwd_arg; |
| 55 |
$pwd_arg_printable =~ s|$ENV{MYSQL_TEST_DIR}/||; |
| 56 |
print "ndb_print_backup_file ${pwd_arg_printable}" . |
| 57 |
"suite/ndb/backups" . |
| 58 |
substr($File::Find::name, length($NDB_SAVED_BACKUPS)) . |
| 59 |
"\n"; |
| 60 |
|
| 61 |
my $output; |
| 62 |
open(my $fh, '-|', "$NDB_PRINT_BACKUP_FILE ${pwd_arg}$File::Find::name") |
| 63 |
or die("Unable to open $File::Find::name: $!\n"); |
| 64 |
{ |
| 65 |
local $/; |
| 66 |
$output = <$fh>; |
| 67 |
} |
| 68 |
close($fh) or die("Unable to close $File::Find::name: $!\n"); |
| 69 |
|
| 70 |
if (!defined($output)) |
| 71 |
{ |
| 72 |
die "Failed running: $NDB_PRINT_BACKUP_FILE $File::Find::name"; |
| 73 |
} |
| 74 |
# hide difference in reported byte order |
| 75 |
$output =~ s/ByteOrder: 0x\d{8}/ByteOrder: 0xXXXXXXXX/m; |
| 76 |
# make sure lines ends with LF |
| 77 |
$output =~ s/\r[\n]?/\n/gm; |
| 78 |
print length($output) . " bytes in output\n"; |
| 79 |
} |
| 80 |
|
| 81 |
find({ wanted => \&process, preprocess => \&sorted }, $NDB_SAVED_BACKUPS); |
| 82 |
|
| 83 |
EOF |
| 84 |
|
| 85 |
--echo Verify that ndb_print_backup_file can be used to check backup generated files individually (CTL, DATA, LOG) |
| 86 |
let $dump_file = $MYSQLTEST_VARDIR/tmp/ndb_mgmd_dump_file.txt; |
| 87 |
|
| 88 |
--exec $NDB_PRINT_BACKUP_FILE $NDB_SAVED_BACKUPS/packed/BACKUP-1-0.2.Data > $dump_file 2>&1 |
| 89 |
--let $assert_text= Checking .Data backup file |
| 90 |
--let $assert_select= Found 15 INSERT records |
| 91 |
--let $assert_file= $dump_file |
| 92 |
--let $assert_count= 1 |
| 93 |
--source include/assert_grep.inc |
| 94 |
|
| 95 |
--exec $NDB_PRINT_BACKUP_FILE $NDB_SAVED_BACKUPS/packed/BACKUP-1.2.ctl > $dump_file 2>&1 |
| 96 |
--let $assert_text= Checking .ctl backup file |
| 97 |
--let $assert_select= Magic: NDBBCKUP |
| 98 |
--let $assert_file= $dump_file |
| 99 |
--let $assert_count= 1 |
| 100 |
--source include/assert_grep.inc |
| 101 |
|
| 102 |
--exec $NDB_PRINT_BACKUP_FILE $NDB_SAVED_BACKUPS/packed/BACKUP-1.2.log > $dump_file 2>&1 |
| 103 |
--let $assert_text= Checking .log backup file |
| 104 |
--let $assert_select= Magic: NDBBCKUP |
| 105 |
--let $assert_file= $dump_file |
| 106 |
--let $assert_count= 1 |
| 107 |
--source include/assert_grep.inc |
| 108 |
|
| 109 |
--remove_file $dump_file |
| 110 |
|
| 111 |
--echo Verify that ndb_print_backup_file can be used to check LCP Data and CTL files individually |
| 112 |
# ByteOrder is masked until Bug#32470157 is fixed so that ndb_print_backup_file |
| 113 |
# tool works well with both little endian and big endian systems. |
| 114 |
|
| 115 |
--echo ndb_print_backup_file suite/ndb/backups/LCP/0/T22F0.ctl |
| 116 |
--replace_regex /ByteOrder: 0x\d{8}/ByteOrder: 0xXXXXXXXX/ |
| 117 |
--exec $NDB_PRINT_BACKUP_FILE $NDB_SAVED_BACKUPS/LCP/0/T22F0.ctl |
| 118 |
|
| 119 |
--echo ndb_print_backup_file suite/ndb/backups/LCP/0/T10F0.Data |
| 120 |
--replace_regex /ByteOrder: 0x\d{8}/ByteOrder: 0xXXXXXXXX/ |
| 121 |
--exec $NDB_PRINT_BACKUP_FILE $NDB_SAVED_BACKUPS/LCP/0/T10F0.Data |
| 122 |
|
| 123 |
--echo ndb_print_backup_file suite/ndb/backups/LCP/0/T19F0.ctl |
| 124 |
--replace_regex /ByteOrder: 0x\d{8}/ByteOrder: 0xXXXXXXXX/ |
| 125 |
--exec $NDB_PRINT_BACKUP_FILE $NDB_SAVED_BACKUPS/LCP/0/T19F0.ctl |
| 126 |
|
| 127 |
--echo ndb_print_backup_file suite/ndb/backups/LCP/1/T22F0.Data |
| 128 |
--replace_regex /ByteOrder: 0x\d{8}/ByteOrder: 0xXXXXXXXX/ |
| 129 |
--exec $NDB_PRINT_BACKUP_FILE $NDB_SAVED_BACKUPS/LCP/1/T22F0.Data |
| 130 |
|
| 131 |
|
| 132 |
# The following scenario is disabled until Bug#33053631 is fixed so that |
| 133 |
# ndb_print_backup_file fully handles backup or lcp files written on |
| 134 |
# systems with other byte order |
| 135 |
|
| 136 |
#--echo Verify that ndb_print_backup_file can be used to check |
| 137 |
#--echo a set of LCP CTL + DATA files that will be used to restore a fragment |
| 138 |
|
| 139 |
#--echo ndb_print_backup_file -c 0 -t 22 -f 0 --print-restored-rows |
| 140 |
#--exec cd $NDB_SAVED_BACKUPS/LCP && $NDB_PRINT_BACKUP_FILE -c 0 -t 22 -f 0 --print-restored-rows |