1
# Copyright (C) 2009 Sun Microsystems, Inc. All rights reserved.
2
# Use is subject to license terms.
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; version 2 of the License.
8
# This program is distributed in the hope that it will be useful, but
9
# WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
# General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
18
#####################################################################
20
# Author: Hema Sridharan
23
# Purpose: Implementation of WL#4732: The test is intended to verify
24
# the interoperability of MySQL BACKUP / RESTORE operations with other
26
# This reporter file will execute periodic backup and restore of db1
27
# while the test is running.
29
# Associated files are:
30
# mysql-test/gentest/conf/backup/backup_obj.yy
31
# mysql-test/gentest/conf/backup/backup_interop.yy
32
# mysql-test/gentest/lib/Gentest/Reporter/BackupInterop.pm
34
#####################################################################
35
package GenTest::Reporter::BackupInterop;
38
@ISA = qw(GenTest::Reporter);
42
use GenTest::Reporter;
43
use GenTest::Constants;
46
my $file = '/tmp/inter.bak';
51
my $dsn = $reporter->dsn();
53
# Execute BACKUP periodically
54
my $dbh = DBI->connect($dsn);
56
unlink('/tmp/inter.bak');
57
say("Executing BACKUP DATABASE.");
58
$dbh->do("BACKUP DATABASE db1 TO '/tmp/inter.bak'");
61
if (defined $dbh->err())
63
return STATUS_DATABASE_CORRUPTION;
75
my $dsn = $reporter->dsn();
76
my $dbh = DBI->connect($dsn);
79
my $query="SELECT COUNT(table_name) FROM INFORMATION_SCHEMA.TABLES
80
WHERE TABLE_SCHEMA='db1'";
82
#################################################################
83
# Dump the database db1 that is being backed up by using
85
#################################################################
87
our $database = 'db1';
88
my $file_bak = '/tmp/db1_dump.bak';
89
my $file_res= '/tmp/db1_dump_res.bak';
90
my $mysqldump_result = system("mysqldump --compact --order-by-primary --skip-triggers --skip-extended-insert --no-create-info --host=127.0.0.1 --port=13000 --user=root $database | sort > $file_bak");
91
return STATUS_UNKNOWN_ERROR if $mysqldump_result > 0;
95
say("Executing RESTORE FROM.");
96
$dbh->do("RESTORE FROM '/tmp/inter.bak' OVERWRITE");
98
if (defined $dbh->err())
100
return STATUS_DATABASE_CORRUPTION;
107
my $mysqldump_result = system("mysqldump --compact --order-by-primary --skip-triggers --skip-extended-insert --no-create-info --host=localhost --port=13000 --user=root $database | sort > $file_res");
108
return STATUS_UNKNOWN_ERROR if $mysqldump_result > 0;
110
my $diff_result = system("diff --unified $file_bak $file_res");
111
$diff_result = $diff_result >> 8;
112
return STATUS_UNKNOWN_ERROR if $diff_result > 1;
114
if ($diff_result == 1)
116
say("Differences between the files were found after query ".$results->[0]->query());
117
return STATUS_UNKNOWN_ERROR;
125
$dbh->do("DROP DATABASE db1");
133
return REPORTER_TYPE_PERIODIC | REPORTER_TYPE_SUCCESS;