File: innochecksum_linux.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (402 lines) | stat: -rw-r--r-- 13,043 bytes parent folder | download
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
#************************************************************
# WL6045:Improve Innochecksum
# Test Case [1] Check the innochecksum tool when read from stdin and without any rewrite of checksum.
# Test Case [2] Check the innochecksum tool when read from stdin and rewrite to "crc32" checksum.
# Test Case [3] Check the innochecksum tool when read from stdin and rewrite to "none" checksum 
#               and page-type-summary output.
# Test Case [4] Check the innochecksum tool when read from stdin and rewrite to "innodb" checksum.
# Test Case [5] Test for lock: As mysqld is running, & then start the innochecksum which must fail.
#************************************************************

--source include/not_windows.inc

# Valgrind would complain about memory leaks when we crash on purpose.
--source include/not_valgrind.inc


# Avoid CrashReporter popup on Mac.
--source include/not_crashrep.inc

let MYSQLD_BASEDIR= `SELECT @@basedir`;
let MYSQLD_DATADIR= `SELECT @@datadir`;
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/my_restart.err;

SET GLOBAL innodb_file_per_table=on;

SHOW variables like '%innodb_checksum_algorithm%';
# Disable compression for this table
CREATE TABLE t1(c1 INT PRIMARY KEY,c2 VARCHAR(20)) COMPRESSION="none", ENGINE=InnoDB;
INSERT INTO t1 VALUES(1, 'Innochecksum InnoDB');
INSERT INTO t1 VALUES(2, 'Innochecksum CRC32');

--echo # Shutdown the Server
--source include/shutdown_mysqld.inc

# Test cases for read from standard input for innochecksum tool
--echo # Test[1(a)]: for read from standard input for innochecksum tool without rewrite of checksum with log option.
perl;
use strict;
use warnings;
my $innochecksum = $ENV{'INNOCHECKSUM'};
my $mysqltest_vardir= $ENV{'MYSQLTEST_VARDIR'};
my $mysqld_datadir= $ENV{'MYSQLD_DATADIR'};
exec("cat $mysqld_datadir/test/t1.ibd | $innochecksum --log='$mysqltest_vardir/tmp/mtrchecksum.log' -");
EOF

perl;
use strict;
use warnings;
use File::Copy;
my $dir = $ENV{'MYSQLTEST_VARDIR'};
my $file= 'mtrchecksum.log';
# open file in write mode
open IN_FILE,"<", "$dir/tmp/$file" or die $! ;
open OUT_FILE, ">", "$dir/tmp/tmpfile" or die $! ;
while(<IN_FILE>) {
 # Replace all intergers to #
 $_=~ s/\d+/#/g;
 $_=~ s/crc#/crc32/g;
 $_=~ s/Filename =.+/Filename = -/g;
 print OUT_FILE $_;
}
close(IN_FILE);
close(OUT_FILE);
#move the new content from tmp file to the orginal file.
move ("$dir/tmp/tmpfile", "$dir/tmp/$file");
EOF

# Print the information for log option.
cat_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log;
--remove_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log

--echo # Test[1(b)]: for read from standard input for innochecksum tool Test checking for page: 3 to page:5
perl;
use strict;
use warnings;
my $innochecksum = $ENV{'INNOCHECKSUM'};
my $mysqltest_vardir= $ENV{'MYSQLTEST_VARDIR'};
my $mysqld_datadir= $ENV{'MYSQLD_DATADIR'};
exec("cat $mysqld_datadir/test/t1.ibd | $innochecksum --log='$mysqltest_vardir/tmp/mtrchecksum.log' -s 3 -e 5 -");
EOF

perl;
use strict;
use warnings;
use File::Copy;
my $dir = $ENV{'MYSQLTEST_VARDIR'};
my $file= 'mtrchecksum.log';
# open file in write mode
open IN_FILE,"<", "$dir/tmp/$file" or die $! ;
open OUT_FILE, ">", "$dir/tmp/tmpfile" or die $! ;
while(<IN_FILE>) {
 # Replace all intergers to #
 $_=~ s/\d+/#/g;
 $_=~ s/crc#/crc32/g;
 $_=~ s/Filename =.+/Filename = -/g;
 $_=~ s/file .+ =/file - =/g;
 print OUT_FILE $_;
}
close(IN_FILE);
close(OUT_FILE);
#move the new content from tmp file to the orginal file.
move ("$dir/tmp/tmpfile", "$dir/tmp/$file");
EOF

# Print the information for log option.
cat_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log;
--remove_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log

--echo # Test[1] End
--echo # Test [2] for read from standard input for innochecksum tool with rewrite of crc32 checksum.
let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd;
--echo # Backup the t1.ibd before any rewrite of checksum, so used for further testing.
--copy_file $t1_IBD $MYSQLD_DATADIR/test/t1.ibd.backup

perl;
use strict;
use warnings;
my $innochecksum = $ENV{'INNOCHECKSUM'};
my $mysqltest_vardir= $ENV{'MYSQLTEST_VARDIR'};
my $mysqld_datadir= $ENV{'MYSQLD_DATADIR'};
exec("cat $mysqld_datadir/test/t1.ibd | $innochecksum --log='$mysqltest_vardir/tmp/mtrchecksum.log' --write=crc32 - > $mysqltest_vardir/tmp/a.ibd");
EOF

perl;
use strict;
use warnings;
use File::Copy;
my $dir = $ENV{'MYSQLTEST_VARDIR'};
my $file= 'mtrchecksum.log';
# open file in write mode
open IN_FILE,"<", "$dir/tmp/$file" or die $!;
open OUT_FILE, ">", "$dir/tmp/tmpfile" or die $!;
while(<IN_FILE>) {
 # Replace all intergers to #
 $_=~ s/\d+/#/g;
 $_=~ s/crc#/crc32/g;
 $_=~ s/Filename =.+/Filename = -/g;
 $_=~ s/file .+ =/file t1.ibd =/g;
 print OUT_FILE $_;
}
close(IN_FILE);
close(OUT_FILE);
# move the new content from tmp file to the orginal file.
move ("$dir/tmp/tmpfile", "$dir/tmp/$file");
EOF
--echo # Print the information for log option.
cat_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log;
--remove_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log

--echo # Recheck the a.ibd created file having crc32 checksum with the --strict-check=crc32 for innochecksum tool.
--exec $INNOCHECKSUM --log="$MYSQLTEST_VARDIR/tmp/mtrchecksum.log" --strict-check=crc32 $MYSQLTEST_VARDIR/tmp/a.ibd

perl;
use strict;
use warnings;
use File::Copy;
my $dir = $ENV{'MYSQLTEST_VARDIR'};
my $file= 'mtrchecksum.log';
# open file in write mode
open IN_FILE,"<", "$dir/tmp/$file" or die $!;
open OUT_FILE, ">", "$dir/tmp/tmpfile" or die $!;
while(<IN_FILE>) {
 # Replace all intergers to #
 $_=~ s/\d+/#/g;
 $_=~ s/crc#/crc32/g;
 $_=~ s/Filename =.+/Filename = a.ibd/g;
 $_=~ s/file .+ =/file t1.ibd =/g;
 print OUT_FILE $_;
}
close(IN_FILE);
close(OUT_FILE);
# move the new content from tmp file to the orginal file.
move ("$dir/tmp/tmpfile", "$dir/tmp/$file");
EOF

# Print the information for log option.
cat_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log;
--remove_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log

--echo #Replace the t.ibd with the newly created a.ibd having crc32 checksum.
--remove_file $MYSQLD_DATADIR/test/t1.ibd
--copy_file $MYSQLTEST_VARDIR/tmp/a.ibd $MYSQLD_DATADIR/test/t1.ibd
--remove_file $MYSQLTEST_VARDIR/tmp/a.ibd

--echo # Start the server to validate the t1.ibd having crc32 checksum.
--source include/start_mysqld.inc

select * from t1;

--echo # Shutdown the server
--source include/shutdown_mysqld.inc

--echo # Test[2] End
--echo # Test[3] for read from standard input for innochecksum tool with rewrite of "none" checksum.

--echo # Retrieve the original t1.ibd before any rewrite of checksum, so used for further testing.
--remove_file $t1_IBD
--copy_file $MYSQLD_DATADIR/test/t1.ibd.backup $t1_IBD

--echo # Check for innochecksum tool to read from stdin and rewrite the checksum to "none"
--echo # along with check for --verbose & --page-type-summary
perl;
use strict;
use warnings;
my $innochecksum = $ENV{'INNOCHECKSUM'};
my $vardir= $ENV{'MYSQLTEST_VARDIR'};
my $mysqld_datadir= $ENV{'MYSQLD_DATADIR'};
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");
EOF

perl;
use strict;
use warnings;
use File::Copy;
my $dir = $ENV{'MYSQLTEST_VARDIR'};
my $file= 'mtrchecksum.log';
# open file in write mode
open IN_FILE,"<", "$dir/tmp/$file" or die $!;
open OUT_FILE, ">", "$dir/tmp/tmpfile" or die $!;
while(<IN_FILE>) {
 # Replace all intergers to #
 $_=~ s/\d+/#/g;
 $_=~ s/crc#/crc32/g;
 $_=~ s/Filename =.+/Filename = -/g;
 $_=~ s/file .+ =/file - =/g;;
 print OUT_FILE $_;
}
close(IN_FILE);
close(OUT_FILE);
# move the new content from tmp file to the orginal file.
move ("$dir/tmp/tmpfile", "$dir/tmp/$file");

$file= 'veroutput';
# open file in write mode
open IN_FILE,"<", "$dir/tmp/$file" or die $!;
open OUT_FILE, ">", "$dir/tmp/tmpfile" or die $!;
while(<IN_FILE>) {
  unless ($_=~ /^debug.*$/) {
    # Replace all intergers to #
    $_=~ s/\d+/#/g;
    $_=~ s/log(\s+)(.*log)/log$1mtrchecksum.log/g;
    print OUT_FILE $_;
  }
}
close(IN_FILE);
close(OUT_FILE);
# move the new content from tmp file to the orginal file.
move ("$dir/tmp/tmpfile", "$dir/tmp/$file");
EOF
--echo # Print the content for --verbose and --page-type-summary
cat_file $MYSQLTEST_VARDIR/tmp/veroutput;
--remove_file $MYSQLTEST_VARDIR/tmp/veroutput

--echo # Print the information for log option.
cat_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log;
--remove_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log

--echo # Recheck the a.ibd created file having crc32 checksum with the --strict-check=none for innochecksum tool.
--exec $INNOCHECKSUM --log="$MYSQLTEST_VARDIR/tmp/mtrchecksum.log" --strict-check=none $MYSQLTEST_VARDIR/tmp/a.ibd

perl;
use strict;
use warnings;
use File::Copy;
my $dir = $ENV{'MYSQLTEST_VARDIR'};
my $file= 'mtrchecksum.log';
# open file in write mode
open IN_FILE,"<", "$dir/tmp/$file" or die $!;
open OUT_FILE, ">", "$dir/tmp/tmpfile" or die $!;
while(<IN_FILE>) {
 # Replace all intergers to #
 $_=~ s/\d+/#/g;
 $_=~ s/crc#/crc32/g;
 $_=~ s/Filename =.+/Filename = a.ibd/g;
 $_=~ s/file .+ =/file t1.ibd =/g;
 print OUT_FILE $_;
}
close(IN_FILE);
close(OUT_FILE);
# move the new content from tmp file to the orginal file.
move ("$dir/tmp/tmpfile", "$dir/tmp/$file");
EOF

# Print the information for log option.
cat_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log;
--remove_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log

# Replace the t.ibd with the newly created a.ibd having "none" checksum.
--remove_file $MYSQLD_DATADIR/test/t1.ibd
--copy_file $MYSQLTEST_VARDIR/tmp/a.ibd $MYSQLD_DATADIR/test/t1.ibd
--remove_file $MYSQLTEST_VARDIR/tmp/a.ibd

--echo # Start the server to validate the t1.ibd having "none" checksum.
--source include/start_mysqld.inc

select * from t1;

--echo # Shutdown the server
--source include/shutdown_mysqld.inc

--echo # Test[3] End

--echo # Test[4] for read from standard input for innochecksum tool with rewrite of "innodb" checksum.
# Retrieve the original t1.ibd before any rewrite of checksum.
--remove_file $t1_IBD
--copy_file $MYSQLD_DATADIR/test/t1.ibd.backup $t1_IBD

--echo # Command for innochecksum tool to read from stdin and rewrite the checksum to "innodb"
perl;
use strict;
use warnings;
my $innochecksum = $ENV{'INNOCHECKSUM'};
my $mysqltest_vardir= $ENV{'MYSQLTEST_VARDIR'};
my $mysqld_datadir= $ENV{'MYSQLD_DATADIR'};
exec("cat $mysqld_datadir/test/t1.ibd | $innochecksum --log='$mysqltest_vardir/tmp/mtrchecksum.log' --write=innodb - > $mysqltest_vardir/tmp/a.ibd");
EOF

perl;
use strict;
use warnings;
use File::Copy;
my $dir = $ENV{'MYSQLTEST_VARDIR'};
my $file= 'mtrchecksum.log';
# open file in write mode
open IN_FILE,"<", "$dir/tmp/$file" or die $!;
open OUT_FILE, ">", "$dir/tmp/tmpfile" or die $!;
while(<IN_FILE>) {
 # Replace all intergers to #
 $_=~ s/\d+/#/g;
 $_=~ s/crc#/crc32/g;
 $_=~ s/Filename =.+/Filename = -/g;
 $_=~ s/file .+ =/file - =/g;
 print OUT_FILE $_;
}
close(IN_FILE);
close(OUT_FILE);
# move the new content from tmp file to the orginal file.
move ("$dir/tmp/tmpfile", "$dir/tmp/$file");
EOF
--echo # Print the information for log option.
cat_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log;
--remove_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log

--echo # Recheck the a.ibd created file having crc32 checksum with the --strict-check=innodb for innochecksum tool.
--exec $INNOCHECKSUM --log="$MYSQLTEST_VARDIR/tmp/mtrchecksum.log" --strict-check=innodb $MYSQLTEST_VARDIR/tmp/a.ibd

perl;
use strict;
use warnings;
use File::Copy;
my $dir = $ENV{'MYSQLTEST_VARDIR'};
my $file= 'mtrchecksum.log';
# open file in write mode
open IN_FILE,"<", "$dir/tmp/$file" or die $!;
open OUT_FILE, ">", "$dir/tmp/tmpfile" or die $!;
while(<IN_FILE>) {
 # Replace all intergers to #
 $_=~ s/\d+/#/g;
 $_=~ s/crc#/crc32/g;
 $_=~ s/Filename =.+/Filename = a.ibd/g;
 $_=~ s/file .+ =/file t1.ibd =/g;
 print OUT_FILE $_;
}
close(IN_FILE);
close(OUT_FILE);
# move the new content from tmp file to the orginal file.
move ("$dir/tmp/tmpfile", "$dir/tmp/$file");
EOF

# Print the information for log option.
cat_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log;
--remove_file $MYSQLTEST_VARDIR/tmp/mtrchecksum.log

--echo # Replace the t.ibd with the newly created a.ibd having "innodb" checksum.
--remove_file $MYSQLD_DATADIR/test/t1.ibd
--copy_file $MYSQLTEST_VARDIR/tmp/a.ibd $MYSQLD_DATADIR/test/t1.ibd
--remove_file $MYSQLTEST_VARDIR/tmp/a.ibd

--echo # Start the server to validate the t1.ibd having "innodb" checksum.
--source include/start_mysqld.inc

select * from t1;

--echo # Test[4] End
--remove_file $MYSQLD_DATADIR/test/t1.ibd.backup

--echo # Test[5] for lock.
--echo # Test Scenario: As mysqld is running, & then start the innochecksum which must fail.

--error 1
--exec $INNOCHECKSUM $MYSQLD_DATADIR/test/t1.ibd 2> $SEARCH_FILE
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
let SEARCH_PATTERN=Error: Unable to lock file:: $MYSQLD_DATADIR/test/t1.ibd;
--source include/search_pattern.inc

let SEARCH_PATTERN=fcntl: Resource temporarily unavailable;
--source include/search_pattern.inc
--remove_file $SEARCH_FILE

--echo # Test[5] end
# cleanup
DROP TABLE t1;