2
# -*- mode: python; indent-tabs-mode: nil; -*-
3
# vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
5
# Copyright (C) 2011 Patrick Crews
8
# This program is free software; you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation; either version 2 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program; if not, write to the Free Software
20
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
from lib.util.mysqlBaseTestCase import mysqlBaseTestCase
28
server_requirements = [["--innodb_strict_mode --innodb_file_per_table --innodb_file_format=Barracuda"]]
32
# we explicitly use the --no-timestamp option
33
# here. We will be using a generic / vanilla backup dir
36
class basicTest(mysqlBaseTestCase):
39
master_server = servers[0] # assumption that this is 'master'
40
backup_path = os.path.join(master_server.vardir, '_xtrabackup')
42
for del_path in [backup_path]:
43
if os.path.exists(del_path):
44
shutil.rmtree(del_path)
46
def load_table(self, table_name, row_count, server):
48
for i in range(row_count):
49
queries.append("INSERT INTO %s VALUES (%d, %d)" %(table_name,i, row_count))
50
retcode, result = self.execute_queries(queries, server)
51
self.assertEqual(retcode, 0, msg=result)
53
def test_ib_stream(self):
54
""" Bug #665210: tar4ibd does not support innodb row_format=compressed
55
Bug #810269: tar4ibd does not check for doublewrite buffer pages
58
innobackupex = test_executor.system_manager.innobackupex_path
59
xtrabackup = test_executor.system_manager.xtrabackup_path
60
master_server = servers[0] # assumption that this is 'master'
61
backup_path = os.path.join(master_server.vardir, '_xtrabackup')
62
tar_file_path = os.path.join(backup_path,'out.tar')
63
output_path = os.path.join(master_server.vardir, 'innobackupex.out')
64
exec_path = os.path.dirname(innobackupex)
67
# populate our server with a test bed
68
queries = ["DROP TABLE IF EXISTS %s" %(table_name)
70
"(`a` int(11) DEFAULT NULL, "
71
"`number` int(11) DEFAULT NULL) "
72
" ENGINE=InnoDB DEFAULT CHARSET=latin1"
76
,("ALTER TABLE %s ENGINE=InnoDB "
77
"ROW_FORMAT=compressed KEY_BLOCK_SIZE=4"
81
retcode, result = self.execute_queries(queries, master_server)
82
self.assertEqual(retcode, 0, msg = result)
84
self.load_table(table_name, row_count, master_server)
86
# get a checksum that we'll compare against post-restore
87
query = "CHECKSUM TABLE %s" %table_name
88
retcode, orig_checksum = self.execute_query(query, master_server)
89
self.assertEqual(retcode, 0, orig_checksum)
97
, "--defaults-file=%s" %master_server.cnf_file
100
, "--port=%d" %master_server.master_port
103
, "--ibbackup=%s" %xtrabackup
104
, "%s > %s" %(backup_path,tar_file_path)
107
retcode, output = self.execute_cmd(cmd, output_path, exec_path, True)
108
self.assertTrue(retcode==0,output)
113
# extract our backup tarball
114
cmd = "tar -ivxf %s" %tar_file_path
115
retcode, output = self.execute_cmd(cmd, output_path, backup_path, True)
116
self.assertEqual(retcode,0,output)
117
# Check for Bug 723318 - seems quicker than separate test case
118
self.assertTrue('xtrabackup_binary' in os.listdir(backup_path)
119
, msg = "Bug723318: xtrabackup_binary not included in tar archive when streaming")
121
# do prepare on backup
125
, "--use-memory=500M"
126
, "--ibbackup=%s" %xtrabackup
130
retcode, output = self.execute_cmd(cmd, output_path, exec_path, True)
131
self.assertEqual(retcode,0,output)
134
shutil.rmtree(master_server.datadir)
135
os.mkdir(master_server.datadir)
137
# restore from backup
139
, "--defaults-file=%s" %master_server.cnf_file
141
, "--ibbackup=%s" %(xtrabackup)
145
retcode, output = self.execute_cmd(cmd, output_path, exec_path, True)
146
self.assertEqual(retcode,0, output)
148
# restart server (and ensure it doesn't crash)
149
master_server.start()
150
self.assertEqual(master_server.status,1, 'Server failed restart from restored datadir...')
152
# Check the server is ok
153
# get a checksum that we'll compare against pre-restore
154
query = "CHECKSUM TABLE %s" %table_name
155
retcode, restored_checksum = self.execute_query(query, master_server)
156
self.assertEqual(retcode, 0, restored_checksum)
157
self.assertEqual(orig_checksum, restored_checksum, "%s || %s" %(orig_checksum, restored_checksum))
161
server_manager.reset_servers(test_executor.name)