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
27
from lib.util.mysqlBaseTestCase import mysqlBaseTestCase
29
server_requirements = [[]]
33
# we explicitly use the --no-timestamp option
34
# here. We will be using a generic / vanilla backup dir
37
class basicTest(mysqlBaseTestCase):
40
master_server = servers[0] # assumption that this is 'master'
41
backup_path = os.path.join(master_server.vardir, '_xtrabackup')
43
if os.path.exists(backup_path):
44
shutil.rmtree(backup_path)
46
def test_bug817132(self):
47
""" --copy-back without explicit --ibbackup specification defaults to 'xtrabackup'. """
48
self.servers = servers
49
logging = test_executor.logging
50
if servers[0].type not in ['mysql','percona']:
53
innobackupex = test_executor.system_manager.innobackupex_path
54
xtrabackup = test_executor.system_manager.xtrabackup_path
55
master_server = servers[0] # assumption that this is 'master'
56
backup_path = os.path.join(master_server.vardir, '_xtrabackup')
57
output_path = os.path.join(master_server.vardir, 'innobackupex.out')
58
exec_path = os.path.dirname(innobackupex)
60
# populate our server with a test bed
61
test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz"
62
retcode, output = self.execute_randgen(test_cmd, test_executor, master_server)
66
, "--defaults-file=%s" %master_server.cnf_file
69
, "--port=%d" %master_server.master_port
72
, "--ibbackup=%s" %xtrabackup
76
retcode, output = self.execute_cmd(cmd, output_path, exec_path, True)
77
self.assertTrue(retcode==0,output)
82
# do prepare on backup
87
, "--ibbackup=%s" %xtrabackup
91
retcode, output = self.execute_cmd(cmd, output_path, exec_path, True)
92
self.assertTrue(retcode==0,output)
95
shutil.rmtree(master_server.datadir)
96
os.mkdir(master_server.datadir)
98
# We add xtrabackup to PATH
99
tmp_path = os.environ['PATH']
100
tmp_path = "%s:%s" %(os.path.dirname(xtrabackup),tmp_path)
101
os.environ['PATH'] = tmp_path
103
# restore from backup
105
, "--defaults-file=%s" %master_server.cnf_file
107
# We don't use --ibbackup here
108
#, "--ibbackup=%s" %(xtrabackup)
109
, "--socket=%s" %master_server.socket_file
113
retcode, output = self.execute_cmd(cmd, output_path, exec_path, True)
114
self.assertEqual(retcode,0, output)
116
# restart server (and ensure it doesn't crash)
117
master_server.start()
118
self.assertEqual(master_server.status,1, 'Server failed restart from restored datadir...')
120
# Check the server is ok
121
query = "SELECT COUNT(*) FROM test.DD"
122
expected_output = ((100L,),)
123
retcode, output = self.execute_query(query, master_server)
124
self.assertEqual(output, expected_output, msg = "%s || %s" %(output, expected_output))
128
server_manager.reset_servers(test_executor.name)