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
28
from lib.util.mysqlBaseTestCase import mysqlBaseTestCase
30
server_requirements = [['--innodb_log_file_size=1M --innodb_thread_concurrency=1']]
34
# we explicitly use the --no-timestamp option
35
# here. We will be using a generic / vanilla backup dir
38
class basicTest(mysqlBaseTestCase):
41
master_server = servers[0] # assumption that this is 'master'
42
backup_path = os.path.join(master_server.vardir, 'full_backup')
44
for del_path in [backup_path]:
45
if os.path.exists(del_path):
46
shutil.rmtree(del_path)
48
def test_xb_log_overwrap(self):
49
self.servers = servers
50
logging = test_executor.logging
51
if servers[0].type not in ['mysql','percona']:
54
innobackupex = test_executor.system_manager.innobackupex_path
55
xtrabackup = test_executor.system_manager.xtrabackup_path
56
master_server = servers[0] # assumption that this is 'master'
57
backup_path = os.path.join(master_server.vardir, 'full_backup')
58
output_path = os.path.join(master_server.vardir, 'innobackupex.out')
59
suspended_file = os.path.join(backup_path, 'xtrabackup_suspended')
60
exec_path = os.path.dirname(innobackupex)
62
# populate our server with a test bed
63
test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz"
64
retcode, output = self.execute_randgen(test_cmd, test_executor, master_server)
68
, "--defaults-file=%s" %master_server.cnf_file
69
, "--datadir=%s" %master_server.datadir
71
, "--target-dir=%s" %backup_path
74
output_file = open(output_path,'w')
75
xtrabackup_subproc = subprocess.Popen( cmd
77
, env=test_executor.working_environment
78
, stdout = output_file
79
, stderr = subprocess.STDOUT
82
# Wait for the xtrabackup_suspended file to be created
85
while timeout and not os.path.exists(suspended_file):
88
# Stop the xtrabackup process
89
xtrabackup_subproc.send_signal(signal.SIGSTOP)
91
# Create a large amount of log data
93
query = "CREATE TABLE tmp%d ENGINE=InnoDB SELECT * FROM DD" %i
94
retcode, result = self.execute_query(query, master_server)
95
self.assertEqual(retcode,0,msg = result)
97
# Resume the xtrabackup process and remove the suspended file
98
xtrabackup_subproc.send_signal(signal.SIGCONT)
99
os.remove(suspended_file)
101
xtrabackup_subproc.wait()
103
output_file = open(output_path,'r')
104
output = ''.join(output_file.readlines())
106
expected_warning = "xtrabackup: error: it looks like InnoDB log has wrapped around before xtrabackup could process all records due to either log copying being too slow, or log files being too small."
108
self.assertEqual(xtrabackup_subproc.returncode,1,msg=output)
109
self.assertTrue(expected_warning in output, msg= output)