| 1 |
#************************************************************ |
| 2 |
# WL6045:Improve Innochecksum |
| 3 |
# Test Case [1] Check the innochecksum tool when read from stdin and without any rewrite of checksum. |
| 4 |
# Test Case [2] Check the innochecksum tool when read from stdin and rewrite to "crc32" checksum. |
| 5 |
# Test Case [3] Check the innochecksum tool when read from stdin and rewrite to "none" checksum |
| 6 |
# and page-type-summary output. |
| 7 |
# Test Case [4] Check the innochecksum tool when read from stdin and rewrite to "innodb" checksum. |
| 8 |
# Test Case [5] Test for lock: As mysqld is running, & then start the innochecksum which must fail. |
| 9 |
#************************************************************ |
| 10 |
|
| 11 |
--source include/not_windows.inc |
| 12 |
|
| 13 |
# Valgrind would complain about memory leaks when we crash on purpose. |
| 14 |
--source include/not_valgrind.inc |
| 15 |
|
| 16 |
|
| 17 |
# Avoid CrashReporter popup on Mac. |
| 18 |
--source include/not_crashrep.inc |
| 19 |
|
| 20 |
let MYSQLD_BASEDIR= `SELECT @@basedir`; |
| 21 |
let MYSQLD_DATADIR= `SELECT @@datadir`; |
| 22 |
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/my_restart.err; |
| 23 |
|
| 24 |
SET GLOBAL innodb_file_per_table=on; |
| 25 |
|
| 26 |
SHOW variables like '%innodb_checksum_algorithm%'; |
| 27 |
# Disable compression for this table |
| 28 |
CREATE TABLE t1(c1 INT PRIMARY KEY,c2 VARCHAR(20)) COMPRESSION="none", ENGINE=InnoDB; |
| 29 |
INSERT INTO t1 VALUES(1, 'Innochecksum InnoDB'); |
| 30 |
INSERT INTO t1 VALUES(2, 'Innochecksum CRC32'); |
| 31 |
|
| 32 |
--echo # Shutdown the Server |
| 33 |
--source include/shutdown_mysqld.inc |
| 34 |
|
| 35 |
# Test cases for read from standard input for innochecksum tool |
| 36 |
--echo # Test[1(a)]: for read from standard input for innochecksum tool without rewrite of checksum with log option. |
| 37 |
perl; |
| 38 |
use strict; |
| 39 |
use warnings; |
| 40 |
my $innochecksum = $ENV{'INNOCHECKSUM'}; |
| 41 |
my $mysqltest_vardir= $ENV{'MYSQLTEST_VARDIR'}; |
| 42 |
my $mysqld_datadir= $ENV{'MYSQLD_DATADIR'}; |
| 43 |
exec("cat $mysqld_datadir/test/t1.ibd | $innochecksum --log='$mysqltest_vardir/tmp/mtrchecksum.log' -"); |
| 44 |
EOF |
| 45 |
|
| 46 |
perl; |
| 47 |
use strict; |
| 48 |
use warnings; |
| 49 |
use File::Copy; |
| 50 |
my $dir = $ENV{'MYSQLTEST_VARDIR'}; |
| 51 |
my $file= 'mtrchecksum.log'; |
| 52 |
# open file in write mode |
| 53 |
open IN_FILE,"<", "$dir/tmp/$file" or die $! ; |
| 54 |
open OUT_FILE, ">", "$dir/tmp/tmpfile" or die $! ; |
| 55 |
while(<IN_FILE>) { |
| 56 |
# Replace all intergers to # |
| 57 |
$_=~ s/\d+/#/g; |
| 58 |
$_=~ s/crc#/crc32/g; |
| 59 |
$_=~ s/Filename =.+/Filename = -/g; |
| 60 |
print OUT_FILE $_; |
| 61 |
} |
| 62 |
close(IN_FILE); |
| 63 |
close(OUT_FILE); |
| 64 |
#move the new content from tmp file to the orginal file. |
| 65 |
move ("$dir/tmp/tmpfile", "$dir/tmp/$file"); |
| 66 |
EOF |
| 67 |
|
| 68 |
# Print the information for log option. |
| 69 |
cat_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log; |
| 70 |
--remove_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log |
| 71 |
|
| 72 |
--echo # Test[1(b)]: for read from standard input for innochecksum tool Test checking for page: 3 to page:5 |
| 73 |
perl; |
| 74 |
use strict; |
| 75 |
use warnings; |
| 76 |
my $innochecksum = $ENV{'INNOCHECKSUM'}; |
| 77 |
my $mysqltest_vardir= $ENV{'MYSQLTEST_VARDIR'}; |
| 78 |
my $mysqld_datadir= $ENV{'MYSQLD_DATADIR'}; |
| 79 |
exec("cat $mysqld_datadir/test/t1.ibd | $innochecksum --log='$mysqltest_vardir/tmp/mtrchecksum.log' -s 3 -e 5 -"); |
| 80 |
EOF |
| 81 |
|
| 82 |
perl; |
| 83 |
use strict; |
| 84 |
use warnings; |
| 85 |
use File::Copy; |
| 86 |
my $dir = $ENV{'MYSQLTEST_VARDIR'}; |
| 87 |
my $file= 'mtrchecksum.log'; |
| 88 |
# open file in write mode |
| 89 |
open IN_FILE,"<", "$dir/tmp/$file" or die $! ; |
| 90 |
open OUT_FILE, ">", "$dir/tmp/tmpfile" or die $! ; |
| 91 |
while(<IN_FILE>) { |
| 92 |
# Replace all intergers to # |
| 93 |
$_=~ s/\d+/#/g; |
| 94 |
$_=~ s/crc#/crc32/g; |
| 95 |
$_=~ s/Filename =.+/Filename = -/g; |
| 96 |
$_=~ s/file .+ =/file - =/g; |
| 97 |
print OUT_FILE $_; |
| 98 |
} |
| 99 |
close(IN_FILE); |
| 100 |
close(OUT_FILE); |
| 101 |
#move the new content from tmp file to the orginal file. |
| 102 |
move ("$dir/tmp/tmpfile", "$dir/tmp/$file"); |
| 103 |
EOF |
| 104 |
|
| 105 |
# Print the information for log option. |
| 106 |
cat_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log; |
| 107 |
--remove_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log |
| 108 |
|
| 109 |
--echo # Test[1] End |
| 110 |
--echo # Test [2] for read from standard input for innochecksum tool with rewrite of crc32 checksum. |
| 111 |
let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd; |
| 112 |
--echo # Backup the t1.ibd before any rewrite of checksum, so used for further testing. |
| 113 |
--copy_file $t1_IBD $MYSQLD_DATADIR/test/t1.ibd.backup |
| 114 |
|
| 115 |
perl; |
| 116 |
use strict; |
| 117 |
use warnings; |
| 118 |
my $innochecksum = $ENV{'INNOCHECKSUM'}; |
| 119 |
my $mysqltest_vardir= $ENV{'MYSQLTEST_VARDIR'}; |
| 120 |
my $mysqld_datadir= $ENV{'MYSQLD_DATADIR'}; |
| 121 |
exec("cat $mysqld_datadir/test/t1.ibd | $innochecksum --log='$mysqltest_vardir/tmp/mtrchecksum.log' --write=crc32 - > $mysqltest_vardir/tmp/a.ibd"); |
| 122 |
EOF |
| 123 |
|
| 124 |
perl; |
| 125 |
use strict; |
| 126 |
use warnings; |
| 127 |
use File::Copy; |
| 128 |
my $dir = $ENV{'MYSQLTEST_VARDIR'}; |
| 129 |
my $file= 'mtrchecksum.log'; |
| 130 |
# open file in write mode |
| 131 |
open IN_FILE,"<", "$dir/tmp/$file" or die $!; |
| 132 |
open OUT_FILE, ">", "$dir/tmp/tmpfile" or die $!; |
| 133 |
while(<IN_FILE>) { |
| 134 |
# Replace all intergers to # |
| 135 |
$_=~ s/\d+/#/g; |
| 136 |
$_=~ s/crc#/crc32/g; |
| 137 |
$_=~ s/Filename =.+/Filename = -/g; |
| 138 |
$_=~ s/file .+ =/file t1.ibd =/g; |
| 139 |
print OUT_FILE $_; |
| 140 |
} |
| 141 |
close(IN_FILE); |
| 142 |
close(OUT_FILE); |
| 143 |
# move the new content from tmp file to the orginal file. |
| 144 |
move ("$dir/tmp/tmpfile", "$dir/tmp/$file"); |
| 145 |
EOF |
| 146 |
--echo # Print the information for log option. |
| 147 |
cat_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log; |
| 148 |
--remove_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log |
| 149 |
|
| 150 |
--echo # Recheck the a.ibd created file having crc32 checksum with the --strict-check=crc32 for innochecksum tool. |
| 151 |
--exec $INNOCHECKSUM --log="$MYSQLTEST_VARDIR/tmp/mtrchecksum.log" --strict-check=crc32 $MYSQLTEST_VARDIR/tmp/a.ibd |
| 152 |
|
| 153 |
perl; |
| 154 |
use strict; |
| 155 |
use warnings; |
| 156 |
use File::Copy; |
| 157 |
my $dir = $ENV{'MYSQLTEST_VARDIR'}; |
| 158 |
my $file= 'mtrchecksum.log'; |
| 159 |
# open file in write mode |
| 160 |
open IN_FILE,"<", "$dir/tmp/$file" or die $!; |
| 161 |
open OUT_FILE, ">", "$dir/tmp/tmpfile" or die $!; |
| 162 |
while(<IN_FILE>) { |
| 163 |
# Replace all intergers to # |
| 164 |
$_=~ s/\d+/#/g; |
| 165 |
$_=~ s/crc#/crc32/g; |
| 166 |
$_=~ s/Filename =.+/Filename = a.ibd/g; |
| 167 |
$_=~ s/file .+ =/file t1.ibd =/g; |
| 168 |
print OUT_FILE $_; |
| 169 |
} |
| 170 |
close(IN_FILE); |
| 171 |
close(OUT_FILE); |
| 172 |
# move the new content from tmp file to the orginal file. |
| 173 |
move ("$dir/tmp/tmpfile", "$dir/tmp/$file"); |
| 174 |
EOF |
| 175 |
|
| 176 |
# Print the information for log option. |
| 177 |
cat_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log; |
| 178 |
--remove_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log |
| 179 |
|
| 180 |
--echo #Replace the t.ibd with the newly created a.ibd having crc32 checksum. |
| 181 |
--remove_file $MYSQLD_DATADIR/test/t1.ibd |
| 182 |
--copy_file $MYSQLTEST_VARDIR/tmp/a.ibd $MYSQLD_DATADIR/test/t1.ibd |
| 183 |
--remove_file $MYSQLTEST_VARDIR/tmp/a.ibd |
| 184 |
|
| 185 |
--echo # Start the server to validate the t1.ibd having crc32 checksum. |
| 186 |
--source include/start_mysqld.inc |
| 187 |
|
| 188 |
select * from t1; |
| 189 |
|
| 190 |
--echo # Shutdown the server |
| 191 |
--source include/shutdown_mysqld.inc |
| 192 |
|
| 193 |
--echo # Test[2] End |
| 194 |
--echo # Test[3] for read from standard input for innochecksum tool with rewrite of "none" checksum. |
| 195 |
|
| 196 |
--echo # Retrieve the original t1.ibd before any rewrite of checksum, so used for further testing. |
| 197 |
--remove_file $t1_IBD |
| 198 |
--copy_file $MYSQLD_DATADIR/test/t1.ibd.backup $t1_IBD |
| 199 |
|
| 200 |
--echo # Check for innochecksum tool to read from stdin and rewrite the checksum to "none" |
| 201 |
--echo # along with check for --verbose & --page-type-summary |
| 202 |
perl; |
| 203 |
use strict; |
| 204 |
use warnings; |
| 205 |
my $innochecksum = $ENV{'INNOCHECKSUM'}; |
| 206 |
my $vardir= $ENV{'MYSQLTEST_VARDIR'}; |
| 207 |
my $mysqld_datadir= $ENV{'MYSQLD_DATADIR'}; |
| 208 |
exec("cat $mysqld_datadir/test/t1.ibd | $innochecksum -v -S --log='$vardir/tmp/mtrchecksum.log' --write=none - > $vardir/tmp/a.ibd 2>$vardir/tmp/veroutput"); |
| 209 |
EOF |
| 210 |
|
| 211 |
perl; |
| 212 |
use strict; |
| 213 |
use warnings; |
| 214 |
use File::Copy; |
| 215 |
my $dir = $ENV{'MYSQLTEST_VARDIR'}; |
| 216 |
my $file= 'mtrchecksum.log'; |
| 217 |
# open file in write mode |
| 218 |
open IN_FILE,"<", "$dir/tmp/$file" or die $!; |
| 219 |
open OUT_FILE, ">", "$dir/tmp/tmpfile" or die $!; |
| 220 |
while(<IN_FILE>) { |
| 221 |
# Replace all intergers to # |
| 222 |
$_=~ s/\d+/#/g; |
| 223 |
$_=~ s/crc#/crc32/g; |
| 224 |
$_=~ s/Filename =.+/Filename = -/g; |
| 225 |
$_=~ s/file .+ =/file - =/g;; |
| 226 |
print OUT_FILE $_; |
| 227 |
} |
| 228 |
close(IN_FILE); |
| 229 |
close(OUT_FILE); |
| 230 |
# move the new content from tmp file to the orginal file. |
| 231 |
move ("$dir/tmp/tmpfile", "$dir/tmp/$file"); |
| 232 |
|
| 233 |
$file= 'veroutput'; |
| 234 |
# open file in write mode |
| 235 |
open IN_FILE,"<", "$dir/tmp/$file" or die $!; |
| 236 |
open OUT_FILE, ">", "$dir/tmp/tmpfile" or die $!; |
| 237 |
while(<IN_FILE>) { |
| 238 |
unless ($_=~ /^debug.*$/) { |
| 239 |
# Replace all intergers to # |
| 240 |
$_=~ s/\d+/#/g; |
| 241 |
$_=~ s/log(\s+)(.*log)/log$1mtrchecksum.log/g; |
| 242 |
print OUT_FILE $_; |
| 243 |
} |
| 244 |
} |
| 245 |
close(IN_FILE); |
| 246 |
close(OUT_FILE); |
| 247 |
# move the new content from tmp file to the orginal file. |
| 248 |
move ("$dir/tmp/tmpfile", "$dir/tmp/$file"); |
| 249 |
EOF |
| 250 |
--echo # Print the content for --verbose and --page-type-summary |
| 251 |
cat_file $MYSQLTEST_VARDIR/tmp/veroutput; |
| 252 |
--remove_file $MYSQLTEST_VARDIR/tmp/veroutput |
| 253 |
|
| 254 |
--echo # Print the information for log option. |
| 255 |
cat_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log; |
| 256 |
--remove_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log |
| 257 |
|
| 258 |
--echo # Recheck the a.ibd created file having crc32 checksum with the --strict-check=none for innochecksum tool. |
| 259 |
--exec $INNOCHECKSUM --log="$MYSQLTEST_VARDIR/tmp/mtrchecksum.log" --strict-check=none $MYSQLTEST_VARDIR/tmp/a.ibd |
| 260 |
|
| 261 |
perl; |
| 262 |
use strict; |
| 263 |
use warnings; |
| 264 |
use File::Copy; |
| 265 |
my $dir = $ENV{'MYSQLTEST_VARDIR'}; |
| 266 |
my $file= 'mtrchecksum.log'; |
| 267 |
# open file in write mode |
| 268 |
open IN_FILE,"<", "$dir/tmp/$file" or die $!; |
| 269 |
open OUT_FILE, ">", "$dir/tmp/tmpfile" or die $!; |
| 270 |
while(<IN_FILE>) { |
| 271 |
# Replace all intergers to # |
| 272 |
$_=~ s/\d+/#/g; |
| 273 |
$_=~ s/crc#/crc32/g; |
| 274 |
$_=~ s/Filename =.+/Filename = a.ibd/g; |
| 275 |
$_=~ s/file .+ =/file t1.ibd =/g; |
| 276 |
print OUT_FILE $_; |
| 277 |
} |
| 278 |
close(IN_FILE); |
| 279 |
close(OUT_FILE); |
| 280 |
# move the new content from tmp file to the orginal file. |
| 281 |
move ("$dir/tmp/tmpfile", "$dir/tmp/$file"); |
| 282 |
EOF |
| 283 |
|
| 284 |
# Print the information for log option. |
| 285 |
cat_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log; |
| 286 |
--remove_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log |
| 287 |
|
| 288 |
# Replace the t.ibd with the newly created a.ibd having "none" checksum. |
| 289 |
--remove_file $MYSQLD_DATADIR/test/t1.ibd |
| 290 |
--copy_file $MYSQLTEST_VARDIR/tmp/a.ibd $MYSQLD_DATADIR/test/t1.ibd |
| 291 |
--remove_file $MYSQLTEST_VARDIR/tmp/a.ibd |
| 292 |
|
| 293 |
--echo # Start the server to validate the t1.ibd having "none" checksum. |
| 294 |
--source include/start_mysqld.inc |
| 295 |
|
| 296 |
select * from t1; |
| 297 |
|
| 298 |
--echo # Shutdown the server |
| 299 |
--source include/shutdown_mysqld.inc |
| 300 |
|
| 301 |
--echo # Test[3] End |
| 302 |
|
| 303 |
--echo # Test[4] for read from standard input for innochecksum tool with rewrite of "innodb" checksum. |
| 304 |
# Retrieve the original t1.ibd before any rewrite of checksum. |
| 305 |
--remove_file $t1_IBD |
| 306 |
--copy_file $MYSQLD_DATADIR/test/t1.ibd.backup $t1_IBD |
| 307 |
|
| 308 |
--echo # Command for innochecksum tool to read from stdin and rewrite the checksum to "innodb" |
| 309 |
perl; |
| 310 |
use strict; |
| 311 |
use warnings; |
| 312 |
my $innochecksum = $ENV{'INNOCHECKSUM'}; |
| 313 |
my $mysqltest_vardir= $ENV{'MYSQLTEST_VARDIR'}; |
| 314 |
my $mysqld_datadir= $ENV{'MYSQLD_DATADIR'}; |
| 315 |
exec("cat $mysqld_datadir/test/t1.ibd | $innochecksum --log='$mysqltest_vardir/tmp/mtrchecksum.log' --write=innodb - > $mysqltest_vardir/tmp/a.ibd"); |
| 316 |
EOF |
| 317 |
|
| 318 |
perl; |
| 319 |
use strict; |
| 320 |
use warnings; |
| 321 |
use File::Copy; |
| 322 |
my $dir = $ENV{'MYSQLTEST_VARDIR'}; |
| 323 |
my $file= 'mtrchecksum.log'; |
| 324 |
# open file in write mode |
| 325 |
open IN_FILE,"<", "$dir/tmp/$file" or die $!; |
| 326 |
open OUT_FILE, ">", "$dir/tmp/tmpfile" or die $!; |
| 327 |
while(<IN_FILE>) { |
| 328 |
# Replace all intergers to # |
| 329 |
$_=~ s/\d+/#/g; |
| 330 |
$_=~ s/crc#/crc32/g; |
| 331 |
$_=~ s/Filename =.+/Filename = -/g; |
| 332 |
$_=~ s/file .+ =/file - =/g; |
| 333 |
print OUT_FILE $_; |
| 334 |
} |
| 335 |
close(IN_FILE); |
| 336 |
close(OUT_FILE); |
| 337 |
# move the new content from tmp file to the orginal file. |
| 338 |
move ("$dir/tmp/tmpfile", "$dir/tmp/$file"); |
| 339 |
EOF |
| 340 |
--echo # Print the information for log option. |
| 341 |
cat_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log; |
| 342 |
--remove_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log |
| 343 |
|
| 344 |
--echo # Recheck the a.ibd created file having crc32 checksum with the --strict-check=innodb for innochecksum tool. |
| 345 |
--exec $INNOCHECKSUM --log="$MYSQLTEST_VARDIR/tmp/mtrchecksum.log" --strict-check=innodb $MYSQLTEST_VARDIR/tmp/a.ibd |
| 346 |
|
| 347 |
perl; |
| 348 |
use strict; |
| 349 |
use warnings; |
| 350 |
use File::Copy; |
| 351 |
my $dir = $ENV{'MYSQLTEST_VARDIR'}; |
| 352 |
my $file= 'mtrchecksum.log'; |
| 353 |
# open file in write mode |
| 354 |
open IN_FILE,"<", "$dir/tmp/$file" or die $!; |
| 355 |
open OUT_FILE, ">", "$dir/tmp/tmpfile" or die $!; |
| 356 |
while(<IN_FILE>) { |
| 357 |
# Replace all intergers to # |
| 358 |
$_=~ s/\d+/#/g; |
| 359 |
$_=~ s/crc#/crc32/g; |
| 360 |
$_=~ s/Filename =.+/Filename = a.ibd/g; |
| 361 |
$_=~ s/file .+ =/file t1.ibd =/g; |
| 362 |
print OUT_FILE $_; |
| 363 |
} |
| 364 |
close(IN_FILE); |
| 365 |
close(OUT_FILE); |
| 366 |
# move the new content from tmp file to the orginal file. |
| 367 |
move ("$dir/tmp/tmpfile", "$dir/tmp/$file"); |
| 368 |
EOF |
| 369 |
|
| 370 |
# Print the information for log option. |
| 371 |
cat_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log; |
| 372 |
--remove_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log |
| 373 |
|
| 374 |
--echo # Replace the t.ibd with the newly created a.ibd having "innodb" checksum. |
| 375 |
--remove_file $MYSQLD_DATADIR/test/t1.ibd |
| 376 |
--copy_file $MYSQLTEST_VARDIR/tmp/a.ibd $MYSQLD_DATADIR/test/t1.ibd |
| 377 |
--remove_file $MYSQLTEST_VARDIR/tmp/a.ibd |
| 378 |
|
| 379 |
--echo # Start the server to validate the t1.ibd having "innodb" checksum. |
| 380 |
--source include/start_mysqld.inc |
| 381 |
|
| 382 |
select * from t1; |
| 383 |
|
| 384 |
--echo # Test[4] End |
| 385 |
--remove_file $MYSQLD_DATADIR/test/t1.ibd.backup |
| 386 |
|
| 387 |
--echo # Test[5] for lock. |
| 388 |
--echo # Test Scenario: As mysqld is running, & then start the innochecksum which must fail. |
| 389 |
|
| 390 |
--error 1 |
| 391 |
--exec $INNOCHECKSUM $MYSQLD_DATADIR/test/t1.ibd 2> $SEARCH_FILE |
| 392 |
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR |
| 393 |
let SEARCH_PATTERN=Error: Unable to lock file:: $MYSQLD_DATADIR/test/t1.ibd; |
| 394 |
--source include/search_pattern.inc |
| 395 |
|
| 396 |
let SEARCH_PATTERN=fcntl: Resource temporarily unavailable; |
| 397 |
--source include/search_pattern.inc |
| 398 |
--remove_file $SEARCH_FILE |
| 399 |
|
| 400 |
--echo # Test[5] end |
| 401 |
# cleanup |
| 402 |
DROP TABLE t1; |