Merge lp:~patrick-crews/drizzle/xtrabackup-tests into lp:drizzle
- xtrabackup-tests
- Merge into 7.2
Proposed by
Patrick Crews
Status: | Merged |
---|---|
Approved by: | Brian Aker |
Approved revision: | 2537 |
Merged at revision: | 2539 |
Proposed branch: | lp:~patrick-crews/drizzle/xtrabackup-tests |
Merge into: | lp:drizzle |
Diff against target: |
5180 lines (+4924/-53) 35 files modified
tests/kewpie/drizzle_tests/xtrabackup_disabled/bug514068_test.py (+186/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/bug606981_test.py (+134/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/bug722638_test.py (+225/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/bug723097_test.py (+124/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/bug729843_test.py (+82/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/bug733663_test.py (+143/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/bug759225_test.py (+142/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/bug766607_test.py (+194/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/bug810269_test.py (+167/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/bug817132_test.py (+137/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/bug884737_test.py (+122/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/galeraInfo_test.py (+108/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_basic_test.py (+114/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_csm_csv_test.py (+120/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_databases_test_disabled.py (+122/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_incremental_test.py (+204/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_nonempty_dir_test.py (+101/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_parallel_test.py (+119/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_rsync_test.py (+126/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_slave_info_test.py (+87/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_slave_test.py (+173/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_specialchar_test.py (+151/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_stream_test.py (+127/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/tar4ibd_symlink_test.py (+151/-0) tests/kewpie/drizzle_tests/xtrabackup_disabled/xb_stats_sakila_test.py (+130/-0) tests/kewpie/drizzle_tests/xtrabackup_main/xb_defaults_file_test.py (+78/-0) tests/kewpie/drizzle_tests/xtrabackup_main/xb_export_test.py (+297/-0) tests/kewpie/drizzle_tests/xtrabackup_main/xb_incremental_compressed_test.py (+219/-0) tests/kewpie/drizzle_tests/xtrabackup_main/xb_incremental_test.py (+199/-0) tests/kewpie/drizzle_tests/xtrabackup_main/xb_log_overwrap_test.py (+114/-0) tests/kewpie/drizzle_tests/xtrabackup_main/xb_part_range_test.py (+205/-0) tests/kewpie/drizzle_tests/xtrabackup_main/xb_partial_test.py (+178/-0) tests/kewpie/drizzle_tests/xtrabackup_main/xb_stats_test.py (+122/-0) tests/kewpie/lib/opts/defaults.py (+3/-53) tests/kewpie/lib/server_mgmt/drizzled.py (+20/-0) |
To merge this branch: | bzr merge lp:~patrick-crews/drizzle/xtrabackup-tests |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Drizzle Trunk | Pending | ||
Review via email: mp+100648@code.launchpad.net |
Commit message
Description of the change
Added in xtrabackup test suite
Certain tests that rely on the use of innobackupex have been moved to a _disabled suite
At present, the xtrabackup binary is failing for me / for the tests, but wanting tests in-tree if possible.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory 'tests/kewpie/drizzle_tests/xtrabackup_disabled' |
2 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/bug514068_test.py' |
3 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/bug514068_test.py 1970-01-01 00:00:00 +0000 |
4 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/bug514068_test.py 2012-04-03 16:24:26 +0000 |
5 | @@ -0,0 +1,186 @@ |
6 | +#! /usr/bin/env python |
7 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
8 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
9 | +# |
10 | +# Copyright (C) 2011 Patrick Crews |
11 | +# |
12 | +# |
13 | +# This program is free software; you can redistribute it and/or modify |
14 | +# it under the terms of the GNU General Public License as published by |
15 | +# the Free Software Foundation; either version 2 of the License, or |
16 | +# (at your option) any later version. |
17 | +# |
18 | +# This program is distributed in the hope that it will be useful, |
19 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21 | +# GNU General Public License for more details. |
22 | +# |
23 | +# You should have received a copy of the GNU General Public License |
24 | +# along with this program; if not, write to the Free Software |
25 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
26 | + |
27 | +import os |
28 | +import sys |
29 | +import shutil |
30 | +import subprocess |
31 | + |
32 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
33 | + |
34 | +server_requirements = [[]] |
35 | +servers = [] |
36 | +server_manager = None |
37 | +test_executor = None |
38 | +# we explicitly use the --no-timestamp option |
39 | +# here. We will be using a generic / vanilla backup dir |
40 | +backup_path = None |
41 | + |
42 | +class basicTest(mysqlBaseTestCase): |
43 | + |
44 | + def execute_cmd( self |
45 | + , cmd |
46 | + , stdout_path |
47 | + , stderr_path |
48 | + , exec_path=None |
49 | + , get_output=True): |
50 | + stdout_file = open(stdout_path,'w') |
51 | + stderr_file = open(stderr_path,'w') |
52 | + cmd_subproc = subprocess.Popen( cmd |
53 | + , shell=True |
54 | + , cwd=exec_path |
55 | + , stdout = stdout_file |
56 | + , stderr = stderr_file |
57 | + ) |
58 | + cmd_subproc.wait() |
59 | + retcode = cmd_subproc.returncode |
60 | + stdout_file.close() |
61 | + stderr_file.close() |
62 | + if get_output: |
63 | + data_file = open(stdout_path,'r') |
64 | + output = ''.join(data_file.readlines()) |
65 | + else: |
66 | + output = None |
67 | + return retcode, output |
68 | + |
69 | + def execute_cmd2(self, cmd, stdout_path, exec_path=None, get_output=False): |
70 | + stdout_file = open(stdout_path,'w') |
71 | + cmd_subproc = subprocess.Popen( cmd |
72 | + , shell=True |
73 | + , cwd=exec_path |
74 | + , stdout = stdout_file |
75 | + , stderr = subprocess.STDOUT |
76 | + ) |
77 | + cmd_subproc.wait() |
78 | + retcode = cmd_subproc.returncode |
79 | + stdout_file.close() |
80 | + if get_output: |
81 | + data_file = open(stdout_path,'r') |
82 | + output = ''.join(data_file.readlines()) |
83 | + else: |
84 | + output = None |
85 | + return retcode, output |
86 | + |
87 | + |
88 | + def setUp(self): |
89 | + master_server = servers[0] # assumption that this is 'master' |
90 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
91 | + # remove backup path |
92 | + if os.path.exists(backup_path): |
93 | + shutil.rmtree(backup_path) |
94 | + |
95 | + def test_bug514068(self): |
96 | + """ Bug #514068: Output to STDOUT and STDERR is not conventional |
97 | + Bug #741021: xtrabackup --prepare prints a few lines to stdout |
98 | + """ |
99 | + |
100 | + self.servers = servers |
101 | + logging = test_executor.logging |
102 | + innobackupex = test_executor.system_manager.innobackupex_path |
103 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
104 | + master_server = servers[0] # assumption that this is 'master' |
105 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
106 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
107 | + stderr_path = os.path.join(master_server.vardir,'innobackupex.err') |
108 | + exec_path = os.path.dirname(innobackupex) |
109 | + |
110 | + # populate our server with a test bed |
111 | + test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz" |
112 | + retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
113 | + |
114 | + """ |
115 | + # populate our server with a test bed |
116 | + #test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz" |
117 | + #retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
118 | + xtrabackup_basedir = os.path.dirname(innobackupex) |
119 | + datapath = os.path.join(xtrabackup_basedir,'test/inc/sakila-db') |
120 | + file_names = ['sakila-schema.sql','sakila-data.sql'] |
121 | + for file_name in file_names: |
122 | + file_name = os.path.join(datapath,file_name) |
123 | + cmd = "%s -uroot --protocol=tcp --port=%d < %s" %(master_server.mysql_client, master_server.master_port, file_name) |
124 | + retcode, output = self.execute_cmd2(cmd, output_path, exec_path, True) |
125 | + self.assertEqual(retcode,0,output) |
126 | + """ |
127 | + |
128 | + |
129 | + # take a backup |
130 | + cmd = [ innobackupex |
131 | + , "--defaults-file=%s" %master_server.cnf_file |
132 | + , "--user=root" |
133 | + , "--port=%d" %master_server.master_port |
134 | + , "--host=127.0.0.1" |
135 | + , "--no-timestamp" |
136 | + , "--ibbackup=%s" %xtrabackup |
137 | + , backup_path |
138 | + ] |
139 | + cmd = " ".join(cmd) |
140 | + retcode, output = self.execute_cmd(cmd, output_path, stderr_path, exec_path, True) |
141 | + self.assertTrue(retcode==0,output) |
142 | + |
143 | + # stop the server |
144 | + master_server.stop() |
145 | + |
146 | + # do prepare on backup |
147 | + cmd = [ innobackupex |
148 | + , "--apply-log" |
149 | + , "--no-timestamp" |
150 | + , "--use-memory=500M" |
151 | + , "--ibbackup=%s" %xtrabackup |
152 | + , backup_path |
153 | + ] |
154 | + cmd = " ".join(cmd) |
155 | + retcode, output = self.execute_cmd(cmd, output_path, stderr_path, exec_path, True) |
156 | + self.assertEqual(retcode, 0,output) |
157 | + # stdout is returned with output |
158 | + # we expect 0 lines |
159 | + self.assertEqual(len(output),0,output) |
160 | + |
161 | + # remove old datadir |
162 | + shutil.rmtree(master_server.datadir) |
163 | + os.mkdir(master_server.datadir) |
164 | + |
165 | + # restore from backup |
166 | + cmd = [ innobackupex |
167 | + , "--defaults-file=%s" %master_server.cnf_file |
168 | + , "--copy-back" |
169 | + , "--ibbackup=%s" %(xtrabackup) |
170 | + , backup_path |
171 | + ] |
172 | + cmd = " ".join(cmd) |
173 | + retcode, output = self.execute_cmd(cmd, output_path, stderr_path, exec_path, True) |
174 | + self.assertEqual(retcode, 0,output) |
175 | + # stdout is returned with output |
176 | + # we expect 0 lines |
177 | + self.assertEqual(len(output),0,output) |
178 | + |
179 | + # restart server (and ensure it doesn't crash) |
180 | + master_server.start() |
181 | + self.assertEqual(master_server.status,1, 'Server failed restart from restored datadir...') |
182 | + |
183 | + # Check the server is ok |
184 | + query = "SELECT COUNT(*) FROM DD" |
185 | + #query = "SELECT COUNT(*) FROM sakila.actor" |
186 | + expected_output = ((100L,),) |
187 | + #expected_output = ((200L,),) |
188 | + retcode, output = self.execute_query(query, master_server) |
189 | + self.assertEqual(output, expected_output, msg = "%s || %s" %(output, expected_output)) |
190 | + |
191 | + |
192 | |
193 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/bug606981_test.py' |
194 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/bug606981_test.py 1970-01-01 00:00:00 +0000 |
195 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/bug606981_test.py 2012-04-03 16:24:26 +0000 |
196 | @@ -0,0 +1,134 @@ |
197 | +#! /usr/bin/env python |
198 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
199 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
200 | +# |
201 | +# Copyright (C) 2011 Patrick Crews |
202 | +# |
203 | +# |
204 | +# This program is free software; you can redistribute it and/or modify |
205 | +# it under the terms of the GNU General Public License as published by |
206 | +# the Free Software Foundation; either version 2 of the License, or |
207 | +# (at your option) any later version. |
208 | +# |
209 | +# This program is distributed in the hope that it will be useful, |
210 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
211 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
212 | +# GNU General Public License for more details. |
213 | +# |
214 | +# You should have received a copy of the GNU General Public License |
215 | +# along with this program; if not, write to the Free Software |
216 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
217 | + |
218 | +import os |
219 | +import shutil |
220 | +import tarfile |
221 | + |
222 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
223 | + |
224 | +server_requirements = [[]] |
225 | +servers = [] |
226 | +server_manager = None |
227 | +test_executor = None |
228 | +# we explicitly use the --no-timestamp option |
229 | +# here. We will be using a generic / vanilla backup dir |
230 | +backup_path = None |
231 | + |
232 | +class basicTest(mysqlBaseTestCase): |
233 | + |
234 | + def setUp(self): |
235 | + master_server = servers[0] # assumption that this is 'master' |
236 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
237 | + # remove backup paths |
238 | + for del_path in [backup_path]: |
239 | + if os.path.exists(del_path): |
240 | + shutil.rmtree(del_path) |
241 | + |
242 | + def test_ib_stream(self): |
243 | + self.servers = servers |
244 | + innobackupex = test_executor.system_manager.innobackupex_path |
245 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
246 | + master_server = servers[0] # assumption that this is 'master' |
247 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
248 | + tar_file_path = os.path.join(backup_path,'out.tar') |
249 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
250 | + exec_path = os.path.dirname(innobackupex) |
251 | + |
252 | + # populate our server with a test bed |
253 | + test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz" |
254 | + retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
255 | + |
256 | + # Add desired option to config file |
257 | + config_file = open(master_server.cnf_file,'a') |
258 | + config_file.write("innodb_flush_method=O_DIRECT\n") |
259 | + config_file.close() |
260 | + |
261 | + # take a backup |
262 | + try: |
263 | + os.mkdir(backup_path) |
264 | + except OSError: |
265 | + pass |
266 | + cmd = [ innobackupex |
267 | + , "--defaults-file=%s" %master_server.cnf_file |
268 | + , "--stream=tar" |
269 | + , "--user=root" |
270 | + , "--port=%d" %master_server.master_port |
271 | + , "--host=127.0.0.1" |
272 | + , "--no-timestamp" |
273 | + , "--ibbackup=%s" %xtrabackup |
274 | + , "%s > %s" %(backup_path,tar_file_path) |
275 | + ] |
276 | + cmd = " ".join(cmd) |
277 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
278 | + self.assertTrue(retcode==0,output) |
279 | + expected_output = "tar4ibd: using O_DIRECT for the input file" |
280 | + self.assertTrue(expected_output in output, msg=output) |
281 | + |
282 | + # stop the server |
283 | + master_server.stop() |
284 | + |
285 | + # extract our backup tarball |
286 | + cmd = "tar -ivxf %s" %tar_file_path |
287 | + retcode, output = self.execute_cmd(cmd, output_path, backup_path, True) |
288 | + self.assertEqual(retcode,0,output) |
289 | + # Check for Bug 723318 - seems quicker than separate test case |
290 | + self.assertTrue('xtrabackup_binary' in os.listdir(backup_path) |
291 | + , msg = "Bug723318: xtrabackup_binary not included in tar archive when streaming") |
292 | + |
293 | + # do prepare on backup |
294 | + cmd = [ innobackupex |
295 | + , "--apply-log" |
296 | + , "--no-timestamp" |
297 | + , "--use-memory=500M" |
298 | + , "--ibbackup=%s" %xtrabackup |
299 | + , backup_path |
300 | + ] |
301 | + cmd = " ".join(cmd) |
302 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
303 | + self.assertEqual(retcode,0,output) |
304 | + |
305 | + # remove old datadir |
306 | + shutil.rmtree(master_server.datadir) |
307 | + os.mkdir(master_server.datadir) |
308 | + |
309 | + # restore from backup |
310 | + cmd = [ innobackupex |
311 | + , "--defaults-file=%s" %master_server.cnf_file |
312 | + , "--copy-back" |
313 | + , "--ibbackup=%s" %(xtrabackup) |
314 | + , backup_path |
315 | + ] |
316 | + cmd = " ".join(cmd) |
317 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
318 | + self.assertEqual(retcode,0, output) |
319 | + |
320 | + # restart server (and ensure it doesn't crash) |
321 | + master_server.start() |
322 | + self.assertEqual(master_server.status,1, 'Server failed restart from restored datadir...') |
323 | + |
324 | + # Check the server is ok |
325 | + query = "SELECT COUNT(*) FROM test.DD" |
326 | + expected_output = ((100L,),) |
327 | + retcode, output = self.execute_query(query, master_server) |
328 | + self.assertEqual(output, expected_output, msg = "%s || %s" %(output, expected_output)) |
329 | + |
330 | + |
331 | |
332 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/bug722638_test.py' |
333 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/bug722638_test.py 1970-01-01 00:00:00 +0000 |
334 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/bug722638_test.py 2012-04-03 16:24:26 +0000 |
335 | @@ -0,0 +1,225 @@ |
336 | +#! /usr/bin/env python |
337 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
338 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
339 | +# |
340 | +# Copyright (C) 2011 Patrick Crews |
341 | +# |
342 | +# |
343 | +# This program is free software; you can redistribute it and/or modify |
344 | +# it under the terms of the GNU General Public License as published by |
345 | +# the Free Software Foundation; either version 2 of the License, or |
346 | +# (at your option) any later version. |
347 | +# |
348 | +# This program is distributed in the hope that it will be useful, |
349 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
350 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
351 | +# GNU General Public License for more details. |
352 | +# |
353 | +# You should have received a copy of the GNU General Public License |
354 | +# along with this program; if not, write to the Free Software |
355 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
356 | + |
357 | +import os |
358 | +import time |
359 | +import shutil |
360 | +import signal |
361 | +import subprocess |
362 | + |
363 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
364 | +from lib.util.mysql_methods import execute_cmd |
365 | + |
366 | +def skip_checks(system_manager): |
367 | + # test to ensure we have a debug build |
368 | + cmd = "%s --help" %system_manager.xtrabackup_path |
369 | + output_path = os.path.join(system_manager.workdir, 'innobackupex.out') |
370 | + exec_path = system_manager.workdir |
371 | + |
372 | + retcode, output = execute_cmd(cmd, output_path, exec_path, True) |
373 | + for line in output: |
374 | + if 'debug-sync' in line and 'TRUE' in line: |
375 | + return False, '' |
376 | + else: |
377 | + return True, "Requires --debug-sync support." |
378 | + |
379 | +server_requirements = [['--innodb-file-per-table']] |
380 | +servers = [] |
381 | +server_manager = None |
382 | +test_executor = None |
383 | +# we explicitly use the --no-timestamp option |
384 | +# here. We will be using a generic / vanilla backup dir |
385 | +backup_path = None |
386 | + |
387 | +class basicTest(mysqlBaseTestCase): |
388 | + |
389 | + def setUp(self): |
390 | + master_server = servers[0] # assumption that this is 'master' |
391 | + backup_path = os.path.join(master_server.vardir, 'full_backup') |
392 | + # remove backup paths |
393 | + for del_path in [backup_path]: |
394 | + if os.path.exists(del_path): |
395 | + shutil.rmtree(del_path) |
396 | + |
397 | + def test_bug722638(self): |
398 | + self.servers = servers |
399 | + logging = test_executor.logging |
400 | + innobackupex = test_executor.system_manager.innobackupex_path |
401 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
402 | + master_server = servers[0] # assumption that this is 'master' |
403 | + backup_path = os.path.join(master_server.vardir, 'full_backup') |
404 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
405 | + suspended_file = os.path.join(backup_path, 'xtrabackup_debug_sync') |
406 | + exec_path = os.path.dirname(innobackupex) |
407 | + |
408 | + # populate our server with a test bed |
409 | + queries = [ "CREATE TABLE t1(a INT) ENGINE=InnoDB" |
410 | + , "INSERT INTO t1 VALUES (1), (2), (3)" |
411 | + , "CREATE TABLE t2(a INT) ENGINE=InnoDB" |
412 | + , "INSERT INTO t2 VALUES (1), (2), (3)" |
413 | + , "CREATE TABLE t3(a INT) ENGINE=InnoDB" |
414 | + , "INSERT INTO t3 VALUES (1), (2), (3)" |
415 | + , "CREATE TABLE t4_old(a INT) ENGINE=InnoDB" |
416 | + , "INSERT INTO t4_old VALUES (1), (2), (3)" |
417 | + ] |
418 | + retcode, result = self.execute_queries(queries, master_server) |
419 | + self.assertEqual(retcode, 0, msg=result) |
420 | + |
421 | + # take a backup |
422 | + cmd = [ xtrabackup |
423 | + , "--defaults-file=%s" %master_server.cnf_file |
424 | + , "--datadir=%s" %master_server.datadir |
425 | + , "--backup" |
426 | + , "--target-dir=%s" %backup_path |
427 | + , '--debug-sync="data_copy_thread_func"' |
428 | + ] |
429 | + output_file = open(output_path,'w') |
430 | + xtrabackup_subproc = subprocess.Popen( cmd |
431 | + , cwd=exec_path |
432 | + , env=test_executor.working_environment |
433 | + , stdout = output_file |
434 | + , stderr = subprocess.STDOUT |
435 | + ) |
436 | + |
437 | + # Wait for the xtrabackup_suspended file to be created |
438 | + timeout = 30 |
439 | + decrement = 1 |
440 | + while timeout and not os.path.exists(suspended_file): |
441 | + time.sleep(decrement) |
442 | + timeout -= decrement |
443 | + |
444 | + # Modify the original tables, then change space_ids by running DDL |
445 | + queries = [ "INSERT INTO t1 VALUES (4), (5), (6)" |
446 | + , "DROP TABLE t1" |
447 | + , "CREATE TABLE t1(a CHAR(1)) ENGINE=InnoDB" |
448 | + , 'INSERT INTO t1 VALUES ("1"), ("2"), ("3")' |
449 | + , "INSERT INTO t2 VALUES (4), (5), (6)" |
450 | + , "ALTER TABLE t2 MODIFY a BIGINT" |
451 | + , "INSERT INTO t2 VALUES (7), (8), (9)" |
452 | + , "INSERT INTO t3 VALUES (4), (5), (6)" |
453 | + , "TRUNCATE t3" |
454 | + , "INSERT INTO t3 VALUES (7), (8), (9)" |
455 | + , "INSERT INTO t4_old VALUES (4), (5), (6)" |
456 | + , "ALTER TABLE t4_old RENAME t4" |
457 | + , "INSERT INTO t4 VALUES (7), (8), (9)" |
458 | + ] |
459 | + retcode, result = self.execute_queries(queries, master_server) |
460 | + self.assertEqual(retcode, 0, msg=result) |
461 | + |
462 | + #calculate_checksums |
463 | + orig_checksums = [] |
464 | + for i in range(4): |
465 | + query = "CHECKSUM TABLE t%d" %(i+1) |
466 | + retcode, result = self.execute_query(query, master_server) |
467 | + self.assertEqual(retcode, 0, msg=result) |
468 | + orig_checksums.append(result) |
469 | + |
470 | + # Resume the xtrabackup process and remove the suspended file |
471 | + xtrabackup_subproc.send_signal(signal.SIGCONT) |
472 | + |
473 | + xtrabackup_subproc.wait() |
474 | + output_file.close() |
475 | + output_file = open(output_path,'r') |
476 | + output = ''.join(output_file.readlines()) |
477 | + self.assertEqual(xtrabackup_subproc.returncode,0,msg="Xtrabackup: uh-oh >;)") |
478 | + |
479 | + # Clear our schema so we know the backup restored |
480 | + queries = [ "DROP SCHEMA test" |
481 | + , "CREATE SCHEMA test" |
482 | + ] |
483 | + retcode, result = self.execute_queries(queries,master_server) |
484 | + self.assertEqual(retcode, 0, result) |
485 | + |
486 | + # prepare our main backup |
487 | + cmd = [ xtrabackup |
488 | + , "--prepare" |
489 | + , "--datadir=%s" %master_server.datadir |
490 | + , "--use-memory=500M" |
491 | + , "--target-dir=%s" %backup_path |
492 | + ] |
493 | + cmd = " ".join(cmd) |
494 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
495 | + self.assertTrue(retcode==0,output) |
496 | + |
497 | + # do final prepare on main backup |
498 | + cmd = [ xtrabackup |
499 | + , "--prepare" |
500 | + , "--datadir=%s" %master_server.datadir |
501 | + , "--use-memory=500M" |
502 | + , "--target-dir=%s" %backup_path |
503 | + ] |
504 | + cmd = " ".join(cmd) |
505 | + #retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
506 | + #self.assertTrue(retcode==0,output) |
507 | + |
508 | + # stop our server |
509 | + master_server.stop() |
510 | + |
511 | + # remove some files |
512 | + clear_paths = [master_server.datadir |
513 | + ,os.path.join(master_server.datadir,'test') |
514 | + ] |
515 | + for clear_path in clear_paths: |
516 | + for file_name in os.listdir(clear_path): |
517 | + if file_name.startswith('ib_logfile') or file_name == 'ibdata1' or file_name.endswith('.ibd'): |
518 | + os.remove(os.path.join(clear_path,file_name)) |
519 | + |
520 | + # copy our data files back |
521 | + for root, dirs, files in os.walk(backup_path): |
522 | + if files: |
523 | + file_info = root.split(backup_path)[1] |
524 | + for file_name in files: |
525 | + # We do a quick check to make sure |
526 | + # no names start with '/' as os.path |
527 | + # throws a hissy when it sees such things |
528 | + if file_info.startswith('/'): |
529 | + file_info = file_info[1:] |
530 | + if file_name.startswith('/'): |
531 | + file_name = file_name[1:] |
532 | + to_path = os.path.join(master_server.datadir |
533 | + , file_info |
534 | + , file_name) |
535 | + new_dir = os.path.dirname(to_path) |
536 | + try: |
537 | + if not os.path.exists(new_dir): |
538 | + os.makedirs(new_dir) |
539 | + except OSError, e: |
540 | + logging.error("Could not create directory: %s | %s" %(new_dir, e)) |
541 | + try: |
542 | + shutil.copy(os.path.join(root,file_name),to_path) |
543 | + except IOError, e: |
544 | + logging.error( "ERROR: Could not copy file: %s | %s" %(file_name, e)) |
545 | + |
546 | + # restart server (and ensure it doesn't crash) |
547 | + master_server.start() |
548 | + self.assertTrue(master_server.status==1, 'Server failed restart from restored datadir...') |
549 | + |
550 | + query = "SHOW TABLES IN test" |
551 | + retcode, result = self.execute_query(query, master_server) |
552 | + logging.test_debug("%s: %s" %(query, result)) |
553 | + |
554 | + #calculate_checksums |
555 | + for i in range(4): |
556 | + query = "CHECKSUM TABLE t%d" %(i+1) |
557 | + retcode, result = self.execute_query(query, master_server) |
558 | + self.assertEqual(retcode, 0, msg=result) |
559 | + self.assertEqual(result, orig_checksums[i], msg = "%s: %s || %s" %(query, orig_checksums[i], result)) |
560 | + |
561 | |
562 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/bug723097_test.py' |
563 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/bug723097_test.py 1970-01-01 00:00:00 +0000 |
564 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/bug723097_test.py 2012-04-03 16:24:26 +0000 |
565 | @@ -0,0 +1,124 @@ |
566 | +#! /usr/bin/env python |
567 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
568 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
569 | +# |
570 | +# Copyright (C) 2011 Patrick Crews |
571 | +# |
572 | +# |
573 | +# This program is free software; you can redistribute it and/or modify |
574 | +# it under the terms of the GNU General Public License as published by |
575 | +# the Free Software Foundation; either version 2 of the License, or |
576 | +# (at your option) any later version. |
577 | +# |
578 | +# This program is distributed in the hope that it will be useful, |
579 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
580 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
581 | +# GNU General Public License for more details. |
582 | +# |
583 | +# You should have received a copy of the GNU General Public License |
584 | +# along with this program; if not, write to the Free Software |
585 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
586 | + |
587 | +import os |
588 | +import sys |
589 | +import time |
590 | +import shutil |
591 | + |
592 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
593 | + |
594 | +server_requirements = [['--innodb-file-per-table']] |
595 | +servers = [] |
596 | +server_manager = None |
597 | +test_executor = None |
598 | +# we explicitly use the --no-timestamp option |
599 | +# here. We will be using a generic / vanilla backup dir |
600 | +backup_path = None |
601 | + |
602 | +class basicTest(mysqlBaseTestCase): |
603 | + |
604 | + def setUp(self): |
605 | + master_server = servers[0] # assumption that this is 'master' |
606 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
607 | + # remove backup path |
608 | + if os.path.exists(backup_path): |
609 | + shutil.rmtree(backup_path) |
610 | + |
611 | + def test_bug723097(self): |
612 | + """ xtrabackup's --parallel option asserts / crashes with a value of -1 """ |
613 | + self.servers = servers |
614 | + logging = test_executor.logging |
615 | + if servers[0].type not in ['mysql','percona']: |
616 | + return |
617 | + else: |
618 | + innobackupex = test_executor.system_manager.innobackupex_path |
619 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
620 | + master_server = servers[0] # assumption that this is 'master' |
621 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
622 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
623 | + exec_path = os.path.dirname(innobackupex) |
624 | + data_file_path = os.path.join(master_server.std_data,'bug723097.sql') |
625 | + |
626 | + # populate our server with a test bed |
627 | + cmd = [ master_server.mysql_client |
628 | + , "--protocol=tcp" |
629 | + , "--user=root" |
630 | + , "--port=%d" %master_server.master_port |
631 | + , "test < %s" %data_file_path |
632 | + ] |
633 | + cmd = " ".join(cmd) |
634 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
635 | + self.assertEqual(retcode,0,output) |
636 | + |
637 | + # take a backup |
638 | + cmd = [ innobackupex |
639 | + , "--defaults-file=%s" %master_server.cnf_file |
640 | + , "--user=root" |
641 | + , "--port=%d" %master_server.master_port |
642 | + , "--host=127.0.0.1" |
643 | + , "--no-timestamp" |
644 | + , "--ibbackup=%s" %xtrabackup |
645 | + , backup_path |
646 | + ] |
647 | + cmd = " ".join(cmd) |
648 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
649 | + self.assertEqual(retcode,0,output) |
650 | + |
651 | + # stop the server |
652 | + master_server.stop() |
653 | + |
654 | + # do prepare on backup |
655 | + cmd = [ innobackupex |
656 | + , "--apply-log" |
657 | + , "--no-timestamp" |
658 | + , "--use-memory=500M" |
659 | + , "--ibbackup=%s" %xtrabackup |
660 | + , backup_path |
661 | + ] |
662 | + cmd = " ".join(cmd) |
663 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
664 | + self.assertTrue(retcode==0,output) |
665 | + |
666 | + # remove old datadir |
667 | + shutil.rmtree(master_server.datadir) |
668 | + os.mkdir(master_server.datadir) |
669 | + |
670 | + # restore from backup |
671 | + cmd = [ innobackupex |
672 | + , "--defaults-file=%s" %master_server.cnf_file |
673 | + , "--copy-back" |
674 | + , "--ibbackup=%s" %(xtrabackup) |
675 | + , backup_path |
676 | + ] |
677 | + cmd = " ".join(cmd) |
678 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
679 | + self.assertEqual(retcode,0, output) |
680 | + |
681 | + # restart server (and ensure it doesn't crash) |
682 | + master_server.start() |
683 | + self.assertEqual(master_server.status,1, 'Server failed restart from restored datadir...') |
684 | + |
685 | + # Check the server is ok |
686 | + query = "SELECT * FROM messages" |
687 | + retcode, output = self.execute_query(query, master_server) |
688 | + self.assertEqual(retcode, 0, msg = output) |
689 | + |
690 | |
691 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/bug729843_test.py' |
692 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/bug729843_test.py 1970-01-01 00:00:00 +0000 |
693 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/bug729843_test.py 2012-04-03 16:24:26 +0000 |
694 | @@ -0,0 +1,82 @@ |
695 | +#! /usr/bin/env python |
696 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
697 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
698 | +# |
699 | +# Copyright (C) 2011 Patrick Crews |
700 | +# |
701 | +# |
702 | +# This program is free software; you can redistribute it and/or modify |
703 | +# it under the terms of the GNU General Public License as published by |
704 | +# the Free Software Foundation; either version 2 of the License, or |
705 | +# (at your option) any later version. |
706 | +# |
707 | +# This program is distributed in the hope that it will be useful, |
708 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
709 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
710 | +# GNU General Public License for more details. |
711 | +# |
712 | +# You should have received a copy of the GNU General Public License |
713 | +# along with this program; if not, write to the Free Software |
714 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
715 | + |
716 | +import os |
717 | +import sys |
718 | +import time |
719 | +import shutil |
720 | + |
721 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
722 | + |
723 | +server_requirements = [[]] |
724 | +servers = [] |
725 | +server_manager = None |
726 | +test_executor = None |
727 | +# we explicitly use the --no-timestamp option |
728 | +# here. We will be using a generic / vanilla backup dir |
729 | +backup_path = None |
730 | + |
731 | +class basicTest(mysqlBaseTestCase): |
732 | + |
733 | + def setUp(self): |
734 | + master_server = servers[0] # assumption that this is 'master' |
735 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
736 | + # remove backup path |
737 | + if os.path.exists(backup_path): |
738 | + shutil.rmtree(backup_path) |
739 | + |
740 | + def test_bug729843(self): |
741 | + """ Ensure passwords are not logged in """ |
742 | + self.servers = servers |
743 | + logging = test_executor.logging |
744 | + if servers[0].type not in ['mysql','percona']: |
745 | + return |
746 | + else: |
747 | + innobackupex = test_executor.system_manager.innobackupex_path |
748 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
749 | + master_server = servers[0] # assumption that this is 'master' |
750 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
751 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
752 | + exec_path = os.path.dirname(innobackupex) |
753 | + |
754 | + # populate our server with a test bed |
755 | + test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz" |
756 | + retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
757 | + |
758 | + # take a backup |
759 | + cmd = [ innobackupex |
760 | + , "--defaults-file=%s" %master_server.cnf_file |
761 | + , "--user=root" |
762 | + , "--password=secret" |
763 | + , "--port=%d" %master_server.master_port |
764 | + , "--host=127.0.0.1" |
765 | + , "--no-timestamp" |
766 | + , "--ibbackup=%s" %xtrabackup |
767 | + , backup_path |
768 | + ] |
769 | + cmd = " ".join(cmd) |
770 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
771 | + # It seems the retcode varies between 9 and 255 : / |
772 | + accepted_values = [9,255] |
773 | + self.assertTrue(retcode in accepted_values ,msg = "Retcode: %d || %s" %(retcode,output)) |
774 | + self.assertTrue("--password=secret" not in output, msg = output) |
775 | + self.assertTrue("--password=xxxxxxxx" in output, msg = output) |
776 | + |
777 | |
778 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/bug733663_test.py' |
779 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/bug733663_test.py 1970-01-01 00:00:00 +0000 |
780 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/bug733663_test.py 2012-04-03 16:24:26 +0000 |
781 | @@ -0,0 +1,143 @@ |
782 | +#! /usr/bin/env python |
783 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
784 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
785 | +# |
786 | +# Copyright (C) 2011 Patrick Crews |
787 | +# |
788 | +# |
789 | +# This program is free software; you can redistribute it and/or modify |
790 | +# it under the terms of the GNU General Public License as published by |
791 | +# the Free Software Foundation; either version 2 of the License, or |
792 | +# (at your option) any later version. |
793 | +# |
794 | +# This program is distributed in the hope that it will be useful, |
795 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
796 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
797 | +# GNU General Public License for more details. |
798 | +# |
799 | +# You should have received a copy of the GNU General Public License |
800 | +# along with this program; if not, write to the Free Software |
801 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
802 | + |
803 | +import os |
804 | +import shutil |
805 | +import subprocess |
806 | + |
807 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
808 | + |
809 | +server_requirements = [[]] |
810 | +servers = [] |
811 | +server_manager = None |
812 | +test_executor = None |
813 | +# we explicitly use the --no-timestamp option |
814 | +# here. We will be using a generic / vanilla backup dir |
815 | +backup_path = None |
816 | + |
817 | +class basicTest(mysqlBaseTestCase): |
818 | + |
819 | + def setUp(self): |
820 | + master_server = servers[0] # assumption that this is 'master' |
821 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
822 | + # remove backup paths |
823 | + for del_path in [backup_path]: |
824 | + if os.path.exists(del_path): |
825 | + shutil.rmtree(del_path) |
826 | + |
827 | + def test_bug733663(self): |
828 | + self.servers = servers |
829 | + innobackupex = test_executor.system_manager.innobackupex_path |
830 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
831 | + master_server = servers[0] # assumption that this is 'master' |
832 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
833 | + tar_file_path = os.path.join(backup_path,'out.tar') |
834 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
835 | + stderr_path = os.path.join(master_server.vardir, 'innobackupex.err') |
836 | + exec_path = os.path.dirname(innobackupex) |
837 | + |
838 | + # populate our server with a test bed |
839 | + test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz" |
840 | + retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
841 | + |
842 | + # take a backup |
843 | + try: |
844 | + os.mkdir(backup_path) |
845 | + except OSError: |
846 | + pass |
847 | + cmd = [ innobackupex |
848 | + , "--defaults-file=%s" %master_server.cnf_file |
849 | + , "--stream=tar" |
850 | + , "--user=root" |
851 | + , "--port=%d" %master_server.master_port |
852 | + , "--host=127.0.0.1" |
853 | + , "--no-timestamp" |
854 | + , "--ibbackup=%s" %xtrabackup |
855 | + , "%s > %s" %(backup_path,tar_file_path) |
856 | + ] |
857 | + cmd = " ".join(cmd) |
858 | + # The error was that innobackupex / xtrabackup |
859 | + # didn't work when splitting stdout and stderr |
860 | + stdout_file = open(output_path,'w') |
861 | + stderr_file = open(stderr_path,'w') |
862 | + cmd_subproc = subprocess.Popen( cmd |
863 | + , shell=True |
864 | + , cwd=backup_path |
865 | + , stdout = stdout_file |
866 | + , stderr = stderr_file |
867 | + ) |
868 | + cmd_subproc.wait() |
869 | + retcode = cmd_subproc.returncode |
870 | + stdout_file.close() |
871 | + stderr_file.close() |
872 | + data_file = open(output_path,'r') |
873 | + output = ''.join(data_file.readlines()) |
874 | + self.assertTrue(retcode==0,output) |
875 | + |
876 | + # stop the server |
877 | + master_server.stop() |
878 | + |
879 | + # extract our backup tarball |
880 | + cmd = "tar -ivxf %s" %tar_file_path |
881 | + retcode, output = self.execute_cmd(cmd, output_path, backup_path, True) |
882 | + self.assertEqual(retcode,0,output) |
883 | + # Check for Bug 723318 - seems quicker than separate test case |
884 | + self.assertTrue('xtrabackup_binary' in os.listdir(backup_path) |
885 | + , msg = "Bug723318: xtrabackup_binary not included in tar archive when streaming") |
886 | + |
887 | + # do prepare on backup |
888 | + cmd = [ innobackupex |
889 | + , "--apply-log" |
890 | + , "--no-timestamp" |
891 | + , "--use-memory=500M" |
892 | + , "--ibbackup=%s" %xtrabackup |
893 | + , backup_path |
894 | + ] |
895 | + cmd = " ".join(cmd) |
896 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
897 | + self.assertEqual(retcode,0,output) |
898 | + |
899 | + # remove old datadir |
900 | + shutil.rmtree(master_server.datadir) |
901 | + os.mkdir(master_server.datadir) |
902 | + |
903 | + # restore from backup |
904 | + cmd = [ innobackupex |
905 | + , "--defaults-file=%s" %master_server.cnf_file |
906 | + , "--copy-back" |
907 | + , "--ibbackup=%s" %(xtrabackup) |
908 | + , backup_path |
909 | + ] |
910 | + cmd = " ".join(cmd) |
911 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
912 | + self.assertEqual(retcode,0, output) |
913 | + |
914 | + # restart server (and ensure it doesn't crash) |
915 | + master_server.start() |
916 | + self.assertEqual(master_server.status,1, 'Server failed restart from restored datadir...') |
917 | + |
918 | + # Check the server is ok |
919 | + query = "SELECT COUNT(*) FROM test.DD" |
920 | + expected_output = ((100L,),) |
921 | + retcode, output = self.execute_query(query, master_server) |
922 | + self.assertEqual(output, expected_output, msg = "%s || %s" %(output, expected_output)) |
923 | + |
924 | + |
925 | |
926 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/bug759225_test.py' |
927 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/bug759225_test.py 1970-01-01 00:00:00 +0000 |
928 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/bug759225_test.py 2012-04-03 16:24:26 +0000 |
929 | @@ -0,0 +1,142 @@ |
930 | +#! /usr/bin/env python |
931 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
932 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
933 | +# |
934 | +# Copyright (C) 2011 Patrick Crews |
935 | +# |
936 | +# |
937 | +# This program is free software; you can redistribute it and/or modify |
938 | +# it under the terms of the GNU General Public License as published by |
939 | +# the Free Software Foundation; either version 2 of the License, or |
940 | +# (at your option) any later version. |
941 | +# |
942 | +# This program is distributed in the hope that it will be useful, |
943 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
944 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
945 | +# GNU General Public License for more details. |
946 | +# |
947 | +# You should have received a copy of the GNU General Public License |
948 | +# along with this program; if not, write to the Free Software |
949 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
950 | + |
951 | +import os |
952 | +import shutil |
953 | +import tarfile |
954 | + |
955 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
956 | + |
957 | +server_requirements = [[]] |
958 | +servers = [] |
959 | +server_manager = None |
960 | +test_executor = None |
961 | +# we explicitly use the --no-timestamp option |
962 | +# here. We will be using a generic / vanilla backup dir |
963 | +backup_path = None |
964 | + |
965 | +def skip_checks(system_manager): |
966 | + if not system_manager.code_manager.test_tree.xtradb_version: |
967 | + return True, "Test requires XtraDB." |
968 | + return False, '' |
969 | + |
970 | + |
971 | +class basicTest(mysqlBaseTestCase): |
972 | + |
973 | + def setUp(self): |
974 | + master_server = servers[0] # assumption that this is 'master' |
975 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
976 | + # remove backup paths |
977 | + for del_path in [backup_path]: |
978 | + if os.path.exists(del_path): |
979 | + shutil.rmtree(del_path) |
980 | + |
981 | + def test_bug759225(self): |
982 | + self.servers = servers |
983 | + master_server = servers[0] |
984 | + logging = test_executor.logging |
985 | + innobackupex = test_executor.system_manager.innobackupex_path |
986 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
987 | + master_server = servers[0] # assumption that this is 'master' |
988 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
989 | + tar_file_path = os.path.join(backup_path,'out.tar') |
990 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
991 | + exec_path = os.path.dirname(innobackupex) |
992 | + |
993 | + # populate our server with a test bed |
994 | + test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz" |
995 | + retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
996 | + |
997 | + # Add desired option to config file |
998 | + config_file = open(master_server.cnf_file,'a') |
999 | + config_file.write("innodb_flush_method=ALL_O_DIRECT\n") |
1000 | + config_file.close() |
1001 | + |
1002 | + # take a backup |
1003 | + try: |
1004 | + os.mkdir(backup_path) |
1005 | + except OSError: |
1006 | + pass |
1007 | + cmd = [ innobackupex |
1008 | + , "--defaults-file=%s" %master_server.cnf_file |
1009 | + , "--stream=tar" |
1010 | + , "--user=root" |
1011 | + , "--port=%d" %master_server.master_port |
1012 | + , "--host=127.0.0.1" |
1013 | + , "--no-timestamp" |
1014 | + , "--ibbackup=%s" %xtrabackup |
1015 | + , "%s > %s" %(backup_path,tar_file_path) |
1016 | + ] |
1017 | + cmd = " ".join(cmd) |
1018 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1019 | + self.assertTrue(retcode==0,output) |
1020 | + expected_output = "tar4ibd: using O_DIRECT for the input file" |
1021 | + self.assertTrue(expected_output in output, msg=output) |
1022 | + |
1023 | + # stop the server |
1024 | + master_server.stop() |
1025 | + |
1026 | + # extract our backup tarball |
1027 | + cmd = "tar -ivxf %s" %tar_file_path |
1028 | + retcode, output = self.execute_cmd(cmd, output_path, backup_path, True) |
1029 | + self.assertEqual(retcode,0,output) |
1030 | + # Check for Bug 723318 - seems quicker than separate test case |
1031 | + self.assertTrue('xtrabackup_binary' in os.listdir(backup_path) |
1032 | + , msg = "Bug723318: xtrabackup_binary not included in tar archive when streaming") |
1033 | + |
1034 | + # do prepare on backup |
1035 | + cmd = [ innobackupex |
1036 | + , "--apply-log" |
1037 | + , "--no-timestamp" |
1038 | + , "--use-memory=500M" |
1039 | + , "--ibbackup=%s" %xtrabackup |
1040 | + , backup_path |
1041 | + ] |
1042 | + cmd = " ".join(cmd) |
1043 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1044 | + self.assertEqual(retcode,0,output) |
1045 | + |
1046 | + # remove old datadir |
1047 | + shutil.rmtree(master_server.datadir) |
1048 | + os.mkdir(master_server.datadir) |
1049 | + |
1050 | + # restore from backup |
1051 | + cmd = [ innobackupex |
1052 | + , "--defaults-file=%s" %master_server.cnf_file |
1053 | + , "--copy-back" |
1054 | + , "--ibbackup=%s" %(xtrabackup) |
1055 | + , backup_path |
1056 | + ] |
1057 | + cmd = " ".join(cmd) |
1058 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1059 | + self.assertEqual(retcode,0, output) |
1060 | + |
1061 | + # restart server (and ensure it doesn't crash) |
1062 | + master_server.start() |
1063 | + self.assertEqual(master_server.status,1, 'Server failed restart from restored datadir...') |
1064 | + |
1065 | + # Check the server is ok |
1066 | + query = "SELECT COUNT(*) FROM test.DD" |
1067 | + expected_output = ((100L,),) |
1068 | + retcode, output = self.execute_query(query, master_server) |
1069 | + self.assertEqual(output, expected_output, msg = "%s || %s" %(output, expected_output)) |
1070 | + |
1071 | + |
1072 | |
1073 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/bug766607_test.py' |
1074 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/bug766607_test.py 1970-01-01 00:00:00 +0000 |
1075 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/bug766607_test.py 2012-04-03 16:24:26 +0000 |
1076 | @@ -0,0 +1,194 @@ |
1077 | +#! /usr/bin/env python |
1078 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
1079 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
1080 | +# |
1081 | +# Copyright (C) 2011 Patrick Crews |
1082 | +# |
1083 | +# |
1084 | +# This program is free software; you can redistribute it and/or modify |
1085 | +# it under the terms of the GNU General Public License as published by |
1086 | +# the Free Software Foundation; either version 2 of the License, or |
1087 | +# (at your option) any later version. |
1088 | +# |
1089 | +# This program is distributed in the hope that it will be useful, |
1090 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1091 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1092 | +# GNU General Public License for more details. |
1093 | +# |
1094 | +# You should have received a copy of the GNU General Public License |
1095 | +# along with this program; if not, write to the Free Software |
1096 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
1097 | + |
1098 | +import os |
1099 | +import shutil |
1100 | + |
1101 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
1102 | + |
1103 | +server_requirements = [['--innodb-file-per-table']] |
1104 | +servers = [] |
1105 | +server_manager = None |
1106 | +test_executor = None |
1107 | +# we explicitly use the --no-timestamp option |
1108 | +# here. We will be using a generic / vanilla backup dir |
1109 | +backup_path = None |
1110 | + |
1111 | +class basicTest(mysqlBaseTestCase): |
1112 | + |
1113 | + def setUp(self): |
1114 | + master_server = servers[0] # assumption that this is 'master' |
1115 | + backup_path = os.path.join(master_server.vardir, 'full_backup') |
1116 | + inc_backup_path = os.path.join(master_server.vardir, 'inc_backup') |
1117 | + # remove backup paths |
1118 | + for del_path in [backup_path, inc_backup_path]: |
1119 | + if os.path.exists(del_path): |
1120 | + shutil.rmtree(del_path) |
1121 | + |
1122 | + def load_table(self, table_name, row_count, server): |
1123 | + queries = [] |
1124 | + for i in range(row_count): |
1125 | + queries.append("INSERT INTO %s VALUES (%d, %d)" %(table_name,i, row_count)) |
1126 | + retcode, result = self.execute_queries(queries, server) |
1127 | + self.assertEqual(retcode, 0, msg=result) |
1128 | + |
1129 | + |
1130 | + def test_ib_incremental(self): |
1131 | + self.servers = servers |
1132 | + logging = test_executor.logging |
1133 | + if servers[0].type not in ['mysql','percona']: |
1134 | + return |
1135 | + else: |
1136 | + innobackupex = test_executor.system_manager.innobackupex_path |
1137 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
1138 | + master_server = servers[0] # assumption that this is 'master' |
1139 | + backup_path = os.path.join(master_server.vardir, 'full_backup') |
1140 | + inc_backup_path = os.path.join(master_server.vardir, 'inc_backup') |
1141 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
1142 | + exec_path = os.path.dirname(innobackupex) |
1143 | + table_name = "`test`" |
1144 | + |
1145 | + # populate our server with a test bed |
1146 | + queries = ["DROP TABLE IF EXISTS %s" %(table_name) |
1147 | + ,("CREATE TABLE %s " |
1148 | + "(`a` int(11) DEFAULT NULL, " |
1149 | + "`number` int(11) DEFAULT NULL) " |
1150 | + " ENGINE=InnoDB DEFAULT CHARSET=latin1" |
1151 | + %(table_name) |
1152 | + ) |
1153 | + ] |
1154 | + retcode, result = self.execute_queries(queries, master_server) |
1155 | + self.assertEqual(retcode, 0, msg = result) |
1156 | + row_count = 100 |
1157 | + self.load_table(table_name, row_count, master_server) |
1158 | + |
1159 | + # take a backup |
1160 | + cmd = [ xtrabackup |
1161 | + , "--defaults-file=%s" %master_server.cnf_file |
1162 | + , "--datadir=%s" %master_server.datadir |
1163 | + , "--backup" |
1164 | + , "--target-dir=%s" %backup_path |
1165 | + ] |
1166 | + cmd = " ".join(cmd) |
1167 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1168 | + self.assertTrue(retcode==0,output) |
1169 | + |
1170 | + queries = [ "CREATE TABLE t(a int) ENGINE=InnoDB" |
1171 | + , "INSERT INTO t VALUES (1), (2), (3)" |
1172 | + , "FLUSH LOGS" |
1173 | + ] |
1174 | + retcode, result = self.execute_queries(queries, master_server) |
1175 | + self.assertEqual(retcode,0,msg=result) |
1176 | + |
1177 | + # stop / restart the server |
1178 | + master_server.stop() |
1179 | + master_server.start() |
1180 | + |
1181 | + # Take an incremental backup |
1182 | + cmd = [ xtrabackup |
1183 | + , "--defaults-file=%s" %master_server.cnf_file |
1184 | + , "--datadir=%s" %master_server.datadir |
1185 | + , "--backup" |
1186 | + , "--target-dir=%s" %inc_backup_path |
1187 | + , "--incremental-basedir=%s" %backup_path |
1188 | + ] |
1189 | + cmd = " ".join(cmd) |
1190 | + logging.test_debug(cmd) |
1191 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1192 | + self.assertEqual(retcode,0,output) |
1193 | + |
1194 | + # shutdown our server |
1195 | + master_server.stop() |
1196 | + |
1197 | + # prepare our main backup |
1198 | + cmd = [ xtrabackup |
1199 | + , "--prepare" |
1200 | + , "--apply-log-only" |
1201 | + , "--datadir=%s" %master_server.datadir |
1202 | + , "--use-memory=500M" |
1203 | + , "--target-dir=%s" %backup_path |
1204 | + ] |
1205 | + cmd = " ".join(cmd) |
1206 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1207 | + self.assertTrue(retcode==0,output) |
1208 | + |
1209 | + # prepare our incremental backup |
1210 | + cmd = [ xtrabackup |
1211 | + , "--prepare" |
1212 | + , "--apply-log-only" |
1213 | + , "--datadir=%s" %master_server.datadir |
1214 | + , "--use-memory=500M" |
1215 | + , "--target-dir=%s" %backup_path |
1216 | + , "--incremental-dir=%s" %(inc_backup_path) |
1217 | + ] |
1218 | + cmd = " ".join(cmd) |
1219 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1220 | + self.assertTrue(retcode==0,output) |
1221 | + |
1222 | + # do final prepare on main backup |
1223 | + cmd = [ xtrabackup |
1224 | + , "--prepare" |
1225 | + , "--datadir=%s" %master_server.datadir |
1226 | + , "--use-memory=500M" |
1227 | + , "--target-dir=%s" %backup_path |
1228 | + ] |
1229 | + cmd = " ".join(cmd) |
1230 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1231 | + self.assertTrue(retcode==0,output) |
1232 | + |
1233 | + # copy our data files back |
1234 | + for root, dirs, files in os.walk(backup_path): |
1235 | + if files: |
1236 | + file_info = root.split(backup_path)[1] |
1237 | + for file_name in files: |
1238 | + # We do a quick check to make sure |
1239 | + # no names start with '/' as os.path |
1240 | + # throws a hissy when it sees such things |
1241 | + if file_info.startswith('/'): |
1242 | + file_info = file_info[1:] |
1243 | + if file_name.startswith('/'): |
1244 | + file_name = file_name[1:] |
1245 | + to_path = os.path.join(master_server.datadir |
1246 | + , file_info |
1247 | + , file_name) |
1248 | + new_dir = os.path.dirname(to_path) |
1249 | + try: |
1250 | + if not os.path.exists(new_dir): |
1251 | + os.makedirs(new_dir) |
1252 | + except OSError, e: |
1253 | + logging.error("Could not create directory: %s | %s" %(new_dir, e)) |
1254 | + try: |
1255 | + shutil.copy(os.path.join(root,file_name),to_path) |
1256 | + except IOError, e: |
1257 | + logging.error( "ERROR: Could not copy file: %s | %s" %(file_name, e)) |
1258 | + |
1259 | + # restart server (and ensure it doesn't crash) |
1260 | + master_server.start() |
1261 | + self.assertTrue(master_server.status==1, 'Server failed restart from restored datadir...') |
1262 | + |
1263 | + # Get a checksum for our table |
1264 | + query = "SELECT * FROM t" |
1265 | + retcode, result = self.execute_query(query, master_server) |
1266 | + self.assertEqual(retcode, 0, msg=result) |
1267 | + expected_result= ((1L,), (2L,), (3L,)) |
1268 | + self.assertEqual(result, expected_result, msg = "%s || %s" %(expected_result, result)) |
1269 | + |
1270 | + |
1271 | |
1272 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/bug810269_test.py' |
1273 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/bug810269_test.py 1970-01-01 00:00:00 +0000 |
1274 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/bug810269_test.py 2012-04-03 16:24:26 +0000 |
1275 | @@ -0,0 +1,167 @@ |
1276 | +#! /usr/bin/env python |
1277 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
1278 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
1279 | +# |
1280 | +# Copyright (C) 2011 Patrick Crews |
1281 | +# |
1282 | +# |
1283 | +# This program is free software; you can redistribute it and/or modify |
1284 | +# it under the terms of the GNU General Public License as published by |
1285 | +# the Free Software Foundation; either version 2 of the License, or |
1286 | +# (at your option) any later version. |
1287 | +# |
1288 | +# This program is distributed in the hope that it will be useful, |
1289 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1290 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1291 | +# GNU General Public License for more details. |
1292 | +# |
1293 | +# You should have received a copy of the GNU General Public License |
1294 | +# along with this program; if not, write to the Free Software |
1295 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
1296 | + |
1297 | +import os |
1298 | +import shutil |
1299 | +import tarfile |
1300 | + |
1301 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
1302 | + |
1303 | +server_requirements = [["--innodb_strict_mode --innodb_file_per_table --innodb_file_format=Barracuda"]] |
1304 | +servers = [] |
1305 | +server_manager = None |
1306 | +test_executor = None |
1307 | +# we explicitly use the --no-timestamp option |
1308 | +# here. We will be using a generic / vanilla backup dir |
1309 | +backup_path = None |
1310 | + |
1311 | +def skip_checks(system_manager): |
1312 | + if not system_manager.code_manager.test_tree.innodb_version: |
1313 | + return True, "Test requires XtraDB or Innodb plugin." |
1314 | + return False, '' |
1315 | + |
1316 | + |
1317 | +class basicTest(mysqlBaseTestCase): |
1318 | + |
1319 | + def setUp(self): |
1320 | + master_server = servers[0] # assumption that this is 'master' |
1321 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
1322 | + # remove backup paths |
1323 | + for del_path in [backup_path]: |
1324 | + if os.path.exists(del_path): |
1325 | + shutil.rmtree(del_path) |
1326 | + |
1327 | + def load_table(self, table_name, row_count, server): |
1328 | + queries = [] |
1329 | + for i in range(row_count): |
1330 | + queries.append("INSERT INTO %s VALUES (%d, %d)" %(table_name,i, row_count)) |
1331 | + retcode, result = self.execute_queries(queries, server) |
1332 | + self.assertEqual(retcode, 0, msg=result) |
1333 | + |
1334 | + def test_bug810269(self): |
1335 | + """ Bug #665210: tar4ibd does not support innodb row_format=compressed |
1336 | + Bug #810269: tar4ibd does not check for doublewrite buffer pages |
1337 | + """ |
1338 | + |
1339 | + self.servers = servers |
1340 | + master_server = servers[0] |
1341 | + logging = test_executor.logging |
1342 | + innobackupex = test_executor.system_manager.innobackupex_path |
1343 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
1344 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
1345 | + tar_file_path = os.path.join(backup_path,'out.tar') |
1346 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
1347 | + exec_path = os.path.dirname(innobackupex) |
1348 | + table_name = "t1" |
1349 | + |
1350 | + # populate our server with a test bed |
1351 | + queries = ["DROP TABLE IF EXISTS %s" %(table_name) |
1352 | + ,("CREATE TABLE %s " |
1353 | + "(`a` int(11) DEFAULT NULL, " |
1354 | + "`number` int(11) DEFAULT NULL) " |
1355 | + " ENGINE=InnoDB DEFAULT CHARSET=latin1" |
1356 | + %(table_name) |
1357 | + ) |
1358 | + # compress tables |
1359 | + ,("ALTER TABLE %s ENGINE=InnoDB " |
1360 | + "ROW_FORMAT=compressed KEY_BLOCK_SIZE=4" |
1361 | + %(table_name) |
1362 | + ) |
1363 | + ] |
1364 | + retcode, result = self.execute_queries(queries, master_server) |
1365 | + self.assertEqual(retcode, 0, msg = result) |
1366 | + row_count = 10000 |
1367 | + self.load_table(table_name, row_count, master_server) |
1368 | + |
1369 | + # get a checksum that we'll compare against post-restore |
1370 | + query = "CHECKSUM TABLE %s" %table_name |
1371 | + retcode, orig_checksum = self.execute_query(query, master_server) |
1372 | + self.assertEqual(retcode, 0, orig_checksum) |
1373 | + |
1374 | + # take a backup |
1375 | + try: |
1376 | + os.mkdir(backup_path) |
1377 | + except OSError: |
1378 | + pass |
1379 | + cmd = [ innobackupex |
1380 | + , "--defaults-file=%s" %master_server.cnf_file |
1381 | + , "--stream=tar" |
1382 | + , "--user=root" |
1383 | + , "--port=%d" %master_server.master_port |
1384 | + , "--host=127.0.0.1" |
1385 | + , "--no-timestamp" |
1386 | + , "--ibbackup=%s" %xtrabackup |
1387 | + , "%s > %s" %(backup_path,tar_file_path) |
1388 | + ] |
1389 | + cmd = " ".join(cmd) |
1390 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1391 | + self.assertTrue(retcode==0,output) |
1392 | + |
1393 | + # stop the server |
1394 | + master_server.stop() |
1395 | + |
1396 | + # extract our backup tarball |
1397 | + cmd = "tar -ivxf %s" %tar_file_path |
1398 | + retcode, output = self.execute_cmd(cmd, output_path, backup_path, True) |
1399 | + self.assertEqual(retcode,0,output) |
1400 | + # Check for Bug 723318 - seems quicker than separate test case |
1401 | + self.assertTrue('xtrabackup_binary' in os.listdir(backup_path) |
1402 | + , msg = "Bug723318: xtrabackup_binary not included in tar archive when streaming") |
1403 | + |
1404 | + # do prepare on backup |
1405 | + cmd = [ innobackupex |
1406 | + , "--apply-log" |
1407 | + , "--no-timestamp" |
1408 | + , "--use-memory=500M" |
1409 | + , "--ibbackup=%s" %xtrabackup |
1410 | + , backup_path |
1411 | + ] |
1412 | + cmd = " ".join(cmd) |
1413 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1414 | + self.assertEqual(retcode,0,output) |
1415 | + |
1416 | + # remove old datadir |
1417 | + shutil.rmtree(master_server.datadir) |
1418 | + os.mkdir(master_server.datadir) |
1419 | + |
1420 | + # restore from backup |
1421 | + cmd = [ innobackupex |
1422 | + , "--defaults-file=%s" %master_server.cnf_file |
1423 | + , "--copy-back" |
1424 | + , "--ibbackup=%s" %(xtrabackup) |
1425 | + , backup_path |
1426 | + ] |
1427 | + cmd = " ".join(cmd) |
1428 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1429 | + self.assertEqual(retcode,0, output) |
1430 | + |
1431 | + # restart server (and ensure it doesn't crash) |
1432 | + master_server.start() |
1433 | + self.assertEqual(master_server.status,1, 'Server failed restart from restored datadir...') |
1434 | + |
1435 | + # Check the server is ok |
1436 | + # get a checksum that we'll compare against pre-restore |
1437 | + query = "CHECKSUM TABLE %s" %table_name |
1438 | + retcode, restored_checksum = self.execute_query(query, master_server) |
1439 | + self.assertEqual(retcode, 0, restored_checksum) |
1440 | + self.assertEqual(orig_checksum, restored_checksum, "%s || %s" %(orig_checksum, restored_checksum)) |
1441 | + |
1442 | + |
1443 | |
1444 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/bug817132_test.py' |
1445 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/bug817132_test.py 1970-01-01 00:00:00 +0000 |
1446 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/bug817132_test.py 2012-04-03 16:24:26 +0000 |
1447 | @@ -0,0 +1,137 @@ |
1448 | +#! /usr/bin/env python |
1449 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
1450 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
1451 | +# |
1452 | +# Copyright (C) 2011 Patrick Crews |
1453 | +# |
1454 | +# |
1455 | +# This program is free software; you can redistribute it and/or modify |
1456 | +# it under the terms of the GNU General Public License as published by |
1457 | +# the Free Software Foundation; either version 2 of the License, or |
1458 | +# (at your option) any later version. |
1459 | +# |
1460 | +# This program is distributed in the hope that it will be useful, |
1461 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1462 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1463 | +# GNU General Public License for more details. |
1464 | +# |
1465 | +# You should have received a copy of the GNU General Public License |
1466 | +# along with this program; if not, write to the Free Software |
1467 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
1468 | + |
1469 | +import os |
1470 | +import sys |
1471 | +import time |
1472 | +import shutil |
1473 | + |
1474 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
1475 | + |
1476 | +def skip_checks(system_manager): |
1477 | + """ We do some pre-test checks to see if we need to skip a test or not """ |
1478 | + |
1479 | + # innobackupex --copy-back without explicit --ibbackup specification |
1480 | + # defaults to 'xtrabackup'. So any build configurations other than xtradb51 |
1481 | + # would fail in Jenkins. |
1482 | + if os.path.basename(system_manager.xtrabackup_path) != "xtrabackup": |
1483 | + return True, "Test only works with xtradb51. --ibbackup spec defaults to xtrabackup" |
1484 | + else: |
1485 | + return False, '' |
1486 | + |
1487 | +server_requirements = [[]] |
1488 | +servers = [] |
1489 | +server_manager = None |
1490 | +test_executor = None |
1491 | +# we explicitly use the --no-timestamp option |
1492 | +# here. We will be using a generic / vanilla backup dir |
1493 | +backup_path = None |
1494 | + |
1495 | +class basicTest(mysqlBaseTestCase): |
1496 | + |
1497 | + def setUp(self): |
1498 | + master_server = servers[0] # assumption that this is 'master' |
1499 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
1500 | + # remove backup path |
1501 | + if os.path.exists(backup_path): |
1502 | + shutil.rmtree(backup_path) |
1503 | + |
1504 | + def test_bug817132(self): |
1505 | + """ --copy-back without explicit --ibbackup specification defaults to 'xtrabackup'. """ |
1506 | + self.servers = servers |
1507 | + logging = test_executor.logging |
1508 | + if servers[0].type not in ['mysql','percona']: |
1509 | + return |
1510 | + else: |
1511 | + innobackupex = test_executor.system_manager.innobackupex_path |
1512 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
1513 | + master_server = servers[0] # assumption that this is 'master' |
1514 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
1515 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
1516 | + exec_path = os.path.dirname(innobackupex) |
1517 | + |
1518 | + # populate our server with a test bed |
1519 | + test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz" |
1520 | + retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
1521 | + |
1522 | + # take a backup |
1523 | + cmd = [ innobackupex |
1524 | + , "--defaults-file=%s" %master_server.cnf_file |
1525 | + , "--parallel=8" |
1526 | + , "--user=root" |
1527 | + , "--port=%d" %master_server.master_port |
1528 | + , "--host=127.0.0.1" |
1529 | + , "--no-timestamp" |
1530 | + , "--ibbackup=%s" %xtrabackup |
1531 | + , backup_path |
1532 | + ] |
1533 | + cmd = " ".join(cmd) |
1534 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1535 | + self.assertTrue(retcode==0,output) |
1536 | + |
1537 | + # stop the server |
1538 | + master_server.stop() |
1539 | + |
1540 | + # do prepare on backup |
1541 | + cmd = [ innobackupex |
1542 | + , "--apply-log" |
1543 | + , "--no-timestamp" |
1544 | + , "--use-memory=500M" |
1545 | + , "--ibbackup=%s" %xtrabackup |
1546 | + , backup_path |
1547 | + ] |
1548 | + cmd = " ".join(cmd) |
1549 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1550 | + self.assertTrue(retcode==0,output) |
1551 | + |
1552 | + # remove old datadir |
1553 | + shutil.rmtree(master_server.datadir) |
1554 | + os.mkdir(master_server.datadir) |
1555 | + |
1556 | + # We add xtrabackup to PATH |
1557 | + tmp_path = os.environ['PATH'] |
1558 | + tmp_path = "%s:%s" %(os.path.dirname(xtrabackup),tmp_path) |
1559 | + os.environ['PATH'] = tmp_path |
1560 | + |
1561 | + # restore from backup |
1562 | + cmd = [ innobackupex |
1563 | + , "--defaults-file=%s" %master_server.cnf_file |
1564 | + , "--copy-back" |
1565 | + # We don't use --ibbackup here |
1566 | + #, "--ibbackup=%s" %(xtrabackup) |
1567 | + , "--socket=%s" %master_server.socket_file |
1568 | + , backup_path |
1569 | + ] |
1570 | + cmd = " ".join(cmd) |
1571 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1572 | + self.assertEqual(retcode,0, output) |
1573 | + |
1574 | + # restart server (and ensure it doesn't crash) |
1575 | + master_server.start() |
1576 | + self.assertEqual(master_server.status,1, 'Server failed restart from restored datadir...') |
1577 | + |
1578 | + # Check the server is ok |
1579 | + query = "SELECT COUNT(*) FROM test.DD" |
1580 | + expected_output = ((100L,),) |
1581 | + retcode, output = self.execute_query(query, master_server) |
1582 | + self.assertEqual(output, expected_output, msg = "%s || %s" %(output, expected_output)) |
1583 | + |
1584 | + |
1585 | |
1586 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/bug884737_test.py' |
1587 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/bug884737_test.py 1970-01-01 00:00:00 +0000 |
1588 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/bug884737_test.py 2012-04-03 16:24:26 +0000 |
1589 | @@ -0,0 +1,122 @@ |
1590 | +#! /usr/bin/env python |
1591 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
1592 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
1593 | +# |
1594 | +# Copyright (C) 2011 Patrick Crews |
1595 | +# |
1596 | +# |
1597 | +# This program is free software; you can redistribute it and/or modify |
1598 | +# it under the terms of the GNU General Public License as published by |
1599 | +# the Free Software Foundation; either version 2 of the License, or |
1600 | +# (at your option) any later version. |
1601 | +# |
1602 | +# This program is distributed in the hope that it will be useful, |
1603 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1604 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1605 | +# GNU General Public License for more details. |
1606 | +# |
1607 | +# You should have received a copy of the GNU General Public License |
1608 | +# along with this program; if not, write to the Free Software |
1609 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
1610 | + |
1611 | +import os |
1612 | +import sys |
1613 | +import time |
1614 | +import shutil |
1615 | + |
1616 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
1617 | + |
1618 | +server_requirements = [[]] |
1619 | +servers = [] |
1620 | +server_manager = None |
1621 | +test_executor = None |
1622 | +# we explicitly use the --no-timestamp option |
1623 | +# here. We will be using a generic / vanilla backup dir |
1624 | +backup_path = None |
1625 | + |
1626 | +class basicTest(mysqlBaseTestCase): |
1627 | + |
1628 | + def setUp(self): |
1629 | + master_server = servers[0] # assumption that this is 'master' |
1630 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
1631 | + # remove backup path |
1632 | + if os.path.exists(backup_path): |
1633 | + shutil.rmtree(backup_path) |
1634 | + |
1635 | + def test_bug884737(self): |
1636 | + """ xtrabackup's --parallel option asserts / crashes with a value of -1 """ |
1637 | + self.servers = servers |
1638 | + logging = test_executor.logging |
1639 | + if servers[0].type not in ['mysql','percona']: |
1640 | + return |
1641 | + else: |
1642 | + innobackupex = test_executor.system_manager.innobackupex_path |
1643 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
1644 | + master_server = servers[0] # assumption that this is 'master' |
1645 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
1646 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
1647 | + exec_path = os.path.dirname(innobackupex) |
1648 | + |
1649 | + # populate our server with a test bed |
1650 | + test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz" |
1651 | + retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
1652 | + |
1653 | + # take a backup |
1654 | + # for -1, it defaults to 1 |
1655 | + cmd = [ innobackupex |
1656 | + , "--defaults-file=%s" %master_server.cnf_file |
1657 | + , "--parallel=-1" |
1658 | + , "--user=root" |
1659 | + , "--port=%d" %master_server.master_port |
1660 | + , "--host=127.0.0.1" |
1661 | + , "--no-timestamp" |
1662 | + , "--ibbackup=%s" %xtrabackup |
1663 | + , backup_path |
1664 | + ] |
1665 | + cmd = " ".join(cmd) |
1666 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1667 | + self.assertEqual(retcode,0,output) |
1668 | + expected_warning = "Warning: option 'parallel': signed value -1 adjusted to 1" |
1669 | + self.assertTrue(expected_warning in output, output) |
1670 | + |
1671 | + # stop the server |
1672 | + master_server.stop() |
1673 | + |
1674 | + # do prepare on backup |
1675 | + cmd = [ innobackupex |
1676 | + , "--apply-log" |
1677 | + , "--no-timestamp" |
1678 | + , "--use-memory=500M" |
1679 | + , "--ibbackup=%s" %xtrabackup |
1680 | + , backup_path |
1681 | + ] |
1682 | + cmd = " ".join(cmd) |
1683 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1684 | + self.assertTrue(retcode==0,output) |
1685 | + |
1686 | + # remove old datadir |
1687 | + shutil.rmtree(master_server.datadir) |
1688 | + os.mkdir(master_server.datadir) |
1689 | + |
1690 | + # restore from backup |
1691 | + cmd = [ innobackupex |
1692 | + , "--defaults-file=%s" %master_server.cnf_file |
1693 | + , "--copy-back" |
1694 | + , "--ibbackup=%s" %(xtrabackup) |
1695 | + , backup_path |
1696 | + ] |
1697 | + cmd = " ".join(cmd) |
1698 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1699 | + self.assertEqual(retcode,0, output) |
1700 | + |
1701 | + # restart server (and ensure it doesn't crash) |
1702 | + master_server.start() |
1703 | + self.assertEqual(master_server.status,1, 'Server failed restart from restored datadir...') |
1704 | + |
1705 | + # Check the server is ok |
1706 | + query = "SELECT COUNT(*) FROM test.DD" |
1707 | + expected_output = ((100L,),) |
1708 | + retcode, output = self.execute_query(query, master_server) |
1709 | + self.assertEqual(output, expected_output, msg = "%s || %s" %(output, expected_output)) |
1710 | + |
1711 | + |
1712 | |
1713 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/galeraInfo_test.py' |
1714 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/galeraInfo_test.py 1970-01-01 00:00:00 +0000 |
1715 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/galeraInfo_test.py 2012-04-03 16:24:26 +0000 |
1716 | @@ -0,0 +1,108 @@ |
1717 | +#! /usr/bin/env python |
1718 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
1719 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
1720 | +# |
1721 | +# Copyright (C) 2011 Patrick Crews |
1722 | +# |
1723 | +# |
1724 | +# This program is free software; you can redistribute it and/or modify |
1725 | +# it under the terms of the GNU General Public License as published by |
1726 | +# the Free Software Foundation; either version 2 of the License, or |
1727 | +# (at your option) any later version. |
1728 | +# |
1729 | +# This program is distributed in the hope that it will be useful, |
1730 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1731 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1732 | +# GNU General Public License for more details. |
1733 | +# |
1734 | +# You should have received a copy of the GNU General Public License |
1735 | +# along with this program; if not, write to the Free Software |
1736 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
1737 | + |
1738 | +import os |
1739 | +import shutil |
1740 | +import unittest |
1741 | + |
1742 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
1743 | + |
1744 | +def skip_checks(system_manager): |
1745 | + if system_manager.code_manager.test_type != 'galera': |
1746 | + return True, "Requires galera / wsrep server" |
1747 | + return False, '' |
1748 | + |
1749 | + |
1750 | +server_requirements = [[]] |
1751 | +servers = [] |
1752 | +server_manager = None |
1753 | +test_executor = None |
1754 | +# we explicitly use the --no-timestamp option |
1755 | +# here. We will be using a generic / vanilla backup dir |
1756 | +backup_path = None |
1757 | + |
1758 | +class basicTest(mysqlBaseTestCase): |
1759 | + |
1760 | + def setUp(self): |
1761 | + master_server = servers[0] # assumption that this is 'master' |
1762 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
1763 | + # remove backup path |
1764 | + if os.path.exists(backup_path): |
1765 | + shutil.rmtree(backup_path) |
1766 | + |
1767 | + |
1768 | + def test_basic1(self): |
1769 | + self.servers = servers |
1770 | + innobackupex = test_executor.system_manager.innobackupex_path |
1771 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
1772 | + master_server = servers[0] # assumption that this is 'master' |
1773 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
1774 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
1775 | + exec_path = os.path.dirname(innobackupex) |
1776 | + |
1777 | + # populate our server with a test bed |
1778 | + test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz" |
1779 | + retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
1780 | + |
1781 | + # take a backup |
1782 | + cmd = ("%s --defaults-file=%s --galera-info --user=root --port=%d" |
1783 | + " --host=127.0.0.1 --no-timestamp" |
1784 | + " --ibbackup=%s %s" %( innobackupex |
1785 | + , master_server.cnf_file |
1786 | + , master_server.master_port |
1787 | + , xtrabackup |
1788 | + , backup_path)) |
1789 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1790 | + self.assertTrue(retcode==0,output) |
1791 | + |
1792 | + # prepare our backup |
1793 | + cmd = ("%s --apply-log --galera-info --no-timestamp --use-memory=500M " |
1794 | + "--ibbackup=%s %s" %( innobackupex |
1795 | + , xtrabackup |
1796 | + , backup_path)) |
1797 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1798 | + self.assertEqual(retcode, 0, msg= output) |
1799 | + |
1800 | + # Get a test value: |
1801 | + query = "SHOW STATUS LIKE 'wsrep_local_state_uuid'" |
1802 | + retcode, result = self.execute_query(query, master_server) |
1803 | + wsrep_local_state_uuid = result[0][1] |
1804 | + |
1805 | + # Get our other galera-info value |
1806 | + query = "SHOW STATUS LIKE 'wsrep_last_committed'" |
1807 | + retcode, result = self.execute_query(query, master_server) |
1808 | + wsrep_last_committed = result[0][1] |
1809 | + |
1810 | + # check our log |
1811 | + with open(os.path.join(backup_path,'xtrabackup_galera_info'),'r') as galera_info_file: |
1812 | + galera_info = galera_info_file.readline().strip() |
1813 | + logged_wsrep_local_state_uuid, logged_wsrep_last_committed = galera_info.split(':') |
1814 | + |
1815 | + self.assertEqual( wsrep_local_state_uuid |
1816 | + , logged_wsrep_local_state_uuid |
1817 | + , msg = (wsrep_local_state_uuid, logged_wsrep_local_state_uuid) |
1818 | + ) |
1819 | + |
1820 | + self.assertEqual( wsrep_last_committed |
1821 | + , logged_wsrep_last_committed |
1822 | + , msg = (wsrep_last_committed, logged_wsrep_last_committed) |
1823 | + ) |
1824 | + |
1825 | |
1826 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_basic_test.py' |
1827 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_basic_test.py 1970-01-01 00:00:00 +0000 |
1828 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_basic_test.py 2012-04-03 16:24:26 +0000 |
1829 | @@ -0,0 +1,114 @@ |
1830 | +#! /usr/bin/env python |
1831 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
1832 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
1833 | +# |
1834 | +# Copyright (C) 2011 Patrick Crews |
1835 | +# |
1836 | +# |
1837 | +# This program is free software; you can redistribute it and/or modify |
1838 | +# it under the terms of the GNU General Public License as published by |
1839 | +# the Free Software Foundation; either version 2 of the License, or |
1840 | +# (at your option) any later version. |
1841 | +# |
1842 | +# This program is distributed in the hope that it will be useful, |
1843 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1844 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1845 | +# GNU General Public License for more details. |
1846 | +# |
1847 | +# You should have received a copy of the GNU General Public License |
1848 | +# along with this program; if not, write to the Free Software |
1849 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
1850 | + |
1851 | +import os |
1852 | +import shutil |
1853 | +import unittest |
1854 | + |
1855 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
1856 | + |
1857 | +server_requirements = [[]] |
1858 | +servers = [] |
1859 | +server_manager = None |
1860 | +test_executor = None |
1861 | +# we explicitly use the --no-timestamp option |
1862 | +# here. We will be using a generic / vanilla backup dir |
1863 | +backup_path = None |
1864 | + |
1865 | +class basicTest(mysqlBaseTestCase): |
1866 | + |
1867 | + def setUp(self): |
1868 | + master_server = servers[0] # assumption that this is 'master' |
1869 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
1870 | + # remove backup path |
1871 | + if os.path.exists(backup_path): |
1872 | + shutil.rmtree(backup_path) |
1873 | + |
1874 | + |
1875 | + def test_basic1(self): |
1876 | + self.servers = servers |
1877 | + if servers[0].type not in ['mysql','percona']: |
1878 | + return |
1879 | + else: |
1880 | + innobackupex = test_executor.system_manager.innobackupex_path |
1881 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
1882 | + master_server = servers[0] # assumption that this is 'master' |
1883 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
1884 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
1885 | + exec_path = os.path.dirname(innobackupex) |
1886 | + orig_dumpfile = os.path.join(master_server.vardir,'orig_dumpfile') |
1887 | + restored_dumpfile = os.path.join(master_server.vardir, 'restored_dumpfile') |
1888 | + |
1889 | + # populate our server with a test bed |
1890 | + test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz" |
1891 | + retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
1892 | + |
1893 | + # take a backup |
1894 | + cmd = ("%s --defaults-file=%s --user=root --port=%d" |
1895 | + " --host=127.0.0.1 --no-timestamp" |
1896 | + " --ibbackup=%s %s" %( innobackupex |
1897 | + , master_server.cnf_file |
1898 | + , master_server.master_port |
1899 | + , xtrabackup |
1900 | + , backup_path)) |
1901 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1902 | + self.assertTrue(retcode==0,output) |
1903 | + |
1904 | + # take mysqldump of our current server state |
1905 | + |
1906 | + self.take_mysqldump(master_server,databases=['test'],dump_path=orig_dumpfile) |
1907 | + |
1908 | + # shutdown our server |
1909 | + master_server.stop() |
1910 | + |
1911 | + # prepare our backup |
1912 | + cmd = ("%s --apply-log --no-timestamp --use-memory=500M " |
1913 | + "--ibbackup=%s %s" %( innobackupex |
1914 | + , xtrabackup |
1915 | + , backup_path)) |
1916 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1917 | + self.assertTrue(retcode==0,output) |
1918 | + |
1919 | + # remove old datadir |
1920 | + shutil.rmtree(master_server.datadir) |
1921 | + os.mkdir(master_server.datadir) |
1922 | + |
1923 | + # restore from backup |
1924 | + cmd = ("%s --defaults-file=%s --copy-back" |
1925 | + " --ibbackup=%s %s" %( innobackupex |
1926 | + , master_server.cnf_file |
1927 | + , xtrabackup |
1928 | + , backup_path)) |
1929 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
1930 | + self.assertTrue(retcode==0, output) |
1931 | + |
1932 | + # restart server (and ensure it doesn't crash) |
1933 | + master_server.start() |
1934 | + self.assertTrue(master_server.status==1, 'Server failed restart from restored datadir...') |
1935 | + |
1936 | + # take mysqldump of current server state |
1937 | + self.take_mysqldump(master_server, databases=['test'],dump_path=restored_dumpfile) |
1938 | + |
1939 | + # diff original vs. current server dump files |
1940 | + retcode, output = self.diff_dumpfiles(orig_dumpfile, restored_dumpfile) |
1941 | + self.assertTrue(retcode, output) |
1942 | + |
1943 | + |
1944 | |
1945 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_csm_csv_test.py' |
1946 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_csm_csv_test.py 1970-01-01 00:00:00 +0000 |
1947 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_csm_csv_test.py 2012-04-03 16:24:26 +0000 |
1948 | @@ -0,0 +1,120 @@ |
1949 | +#! /usr/bin/env python |
1950 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
1951 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
1952 | +# |
1953 | +# Copyright (C) 2011 Patrick Crews |
1954 | +# |
1955 | +# |
1956 | +# This program is free software; you can redistribute it and/or modify |
1957 | +# it under the terms of the GNU General Public License as published by |
1958 | +# the Free Software Foundation; either version 2 of the License, or |
1959 | +# (at your option) any later version. |
1960 | +# |
1961 | +# This program is distributed in the hope that it will be useful, |
1962 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1963 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1964 | +# GNU General Public License for more details. |
1965 | +# |
1966 | +# You should have received a copy of the GNU General Public License |
1967 | +# along with this program; if not, write to the Free Software |
1968 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
1969 | + |
1970 | +import os |
1971 | +import shutil |
1972 | + |
1973 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
1974 | + |
1975 | +server_requirements = [['--innodb-file-per-table']] |
1976 | +servers = [] |
1977 | +server_manager = None |
1978 | +test_executor = None |
1979 | +# we explicitly use the --no-timestamp option |
1980 | +# here. We will be using a generic / vanilla backup dir |
1981 | +backup_path = None |
1982 | + |
1983 | +class basicTest(mysqlBaseTestCase): |
1984 | + |
1985 | + def setUp(self): |
1986 | + master_server = servers[0] # assumption that this is 'master' |
1987 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
1988 | + # remove backup path |
1989 | + if os.path.exists(backup_path): |
1990 | + shutil.rmtree(backup_path) |
1991 | + |
1992 | + |
1993 | + def test_ib_csm_csv(self): |
1994 | + self.servers = servers |
1995 | + logging = test_executor.logging |
1996 | + if servers[0].type not in ['mysql','percona']: |
1997 | + return |
1998 | + else: |
1999 | + innobackupex = test_executor.system_manager.innobackupex_path |
2000 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
2001 | + master_server = servers[0] # assumption that this is 'master' |
2002 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
2003 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
2004 | + exec_path = os.path.dirname(innobackupex) |
2005 | + |
2006 | + # populate our server with a test bed |
2007 | + queries = ["CREATE TABLE csm (a INT NOT NULL ) ENGINE=CSV" |
2008 | + ] |
2009 | + row_count = 100 |
2010 | + for i in range(row_count): |
2011 | + queries.append("INSERT INTO csm VALUES (%d)" %i) |
2012 | + retcode, result = self.execute_queries(queries, master_server) |
2013 | + self.assertEqual(retcode, 0, msg=result) |
2014 | + |
2015 | + # Get a checksum for our table |
2016 | + query = "CHECKSUM TABLE csm" |
2017 | + retcode, orig_checksum = self.execute_query(query, master_server) |
2018 | + self.assertEqual(retcode, 0, msg=result) |
2019 | + logging.test_debug("Original checksum: %s" %orig_checksum) |
2020 | + |
2021 | + # take a backup |
2022 | + cmd = ("%s --defaults-file=%s --user=root --port=%d" |
2023 | + " --host=127.0.0.1 --no-timestamp" |
2024 | + " --ibbackup=%s %s" %( innobackupex |
2025 | + , master_server.cnf_file |
2026 | + , master_server.master_port |
2027 | + , xtrabackup |
2028 | + , backup_path)) |
2029 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2030 | + self.assertTrue(retcode==0,output) |
2031 | + |
2032 | + # shutdown our server |
2033 | + master_server.stop() |
2034 | + |
2035 | + # prepare our backup |
2036 | + cmd = ("%s --apply-log --no-timestamp --use-memory=500M " |
2037 | + "--ibbackup=%s %s" %( innobackupex |
2038 | + , xtrabackup |
2039 | + , backup_path)) |
2040 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2041 | + self.assertTrue(retcode==0,output) |
2042 | + |
2043 | + # remove old datadir |
2044 | + shutil.rmtree(master_server.datadir) |
2045 | + os.mkdir(master_server.datadir) |
2046 | + |
2047 | + # restore from backup |
2048 | + cmd = ("%s --defaults-file=%s --copy-back" |
2049 | + " --ibbackup=%s %s" %( innobackupex |
2050 | + , master_server.cnf_file |
2051 | + , xtrabackup |
2052 | + , backup_path)) |
2053 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2054 | + self.assertTrue(retcode==0, output) |
2055 | + |
2056 | + # restart server (and ensure it doesn't crash) |
2057 | + master_server.start() |
2058 | + self.assertTrue(master_server.status==1, 'Server failed restart from restored datadir...') |
2059 | + |
2060 | + # Get a checksum for our table |
2061 | + query = "CHECKSUM TABLE csm" |
2062 | + retcode, restored_checksum = self.execute_query(query, master_server) |
2063 | + self.assertEqual(retcode, 0, msg=result) |
2064 | + logging.test_debug("Restored checksum: %s" %restored_checksum) |
2065 | + |
2066 | + self.assertEqual(orig_checksum, restored_checksum, msg = "Orig: %s | Restored: %s" %(orig_checksum, restored_checksum)) |
2067 | + |
2068 | + |
2069 | |
2070 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_databases_test_disabled.py' |
2071 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_databases_test_disabled.py 1970-01-01 00:00:00 +0000 |
2072 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_databases_test_disabled.py 2012-04-03 16:24:26 +0000 |
2073 | @@ -0,0 +1,122 @@ |
2074 | +#! /usr/bin/env python |
2075 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
2076 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
2077 | +# |
2078 | +# Copyright (C) 2011 Patrick Crews |
2079 | +# |
2080 | +# |
2081 | +# This program is free software; you can redistribute it and/or modify |
2082 | +# it under the terms of the GNU General Public License as published by |
2083 | +# the Free Software Foundation; either version 2 of the License, or |
2084 | +# (at your option) any later version. |
2085 | +# |
2086 | +# This program is distributed in the hope that it will be useful, |
2087 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2088 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2089 | +# GNU General Public License for more details. |
2090 | +# |
2091 | +# You should have received a copy of the GNU General Public License |
2092 | +# along with this program; if not, write to the Free Software |
2093 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
2094 | + |
2095 | +import os |
2096 | +import shutil |
2097 | +import time |
2098 | + |
2099 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
2100 | + |
2101 | +server_requirements = [[],[]] |
2102 | +servers = [] |
2103 | +server_manager = None |
2104 | +test_executor = None |
2105 | +# we explicitly use the --no-timestamp option |
2106 | +# here. We will be using a generic / vanilla backup dir |
2107 | +backup_path = None |
2108 | + |
2109 | +class basicTest(mysqlBaseTestCase): |
2110 | + |
2111 | + def setUp(self): |
2112 | + master_server = servers[0] # assumption that this is 'master' |
2113 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
2114 | + # remove backup path |
2115 | + if os.path.exists(backup_path): |
2116 | + shutil.rmtree(backup_path) |
2117 | + |
2118 | + |
2119 | + def test_basic1(self): |
2120 | + self.servers = servers |
2121 | + if servers[0].type not in ['mysql','percona']: |
2122 | + return |
2123 | + else: |
2124 | + innobackupex = test_executor.system_manager.innobackupex_path |
2125 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
2126 | + master_server = servers[0] # assumption that this is 'master' |
2127 | + copy_server = servers[1] |
2128 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
2129 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
2130 | + exec_path = os.path.dirname(innobackupex) |
2131 | + |
2132 | + #populate our server with a test bed |
2133 | + test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz " |
2134 | + retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
2135 | + # create additional schemas for backup |
2136 | + schema_basename='test' |
2137 | + for i in range(6): |
2138 | + schema = schema_basename+str(i) |
2139 | + query = "CREATE SCHEMA %s" %(schema) |
2140 | + retcode, result_set = self.execute_query(query, master_server) |
2141 | + self.assertEquals(retcode,0, msg=result_set) |
2142 | + retcode, output = self.execute_randgen(test_cmd, test_executor, master_server, schema) |
2143 | + |
2144 | + # take a backup |
2145 | + cmd = ("%s --defaults-file=%s --user=root --port=%d" |
2146 | + " --host=127.0.0.1 --no-timestamp" |
2147 | + #" --databases='mysql,test,test2' " |
2148 | + " --ibbackup=%s %s" %( innobackupex |
2149 | + , master_server.cnf_file |
2150 | + , master_server.master_port |
2151 | + , xtrabackup |
2152 | + , backup_path)) |
2153 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2154 | + #print cmd |
2155 | + self.assertTrue(retcode==0,output) |
2156 | + |
2157 | + # shutdown our server |
2158 | + copy_server.stop() |
2159 | + |
2160 | + # prepare our backup |
2161 | + cmd = ("%s --apply-log --no-timestamp --use-memory=500M " |
2162 | + "--ibbackup=%s %s" %( innobackupex |
2163 | + , xtrabackup |
2164 | + , backup_path)) |
2165 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2166 | + self.assertEqual(retcode, 0,output) |
2167 | + |
2168 | + # remove old datadir |
2169 | + shutil.rmtree(copy_server.datadir) |
2170 | + os.mkdir(copy_server.datadir) |
2171 | + |
2172 | + # restore from backup |
2173 | + cmd = ("%s --defaults-file=%s --copy-back" |
2174 | + " --ibbackup=%s %s" %( innobackupex |
2175 | + , copy_server.cnf_file |
2176 | + , xtrabackup |
2177 | + , backup_path)) |
2178 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2179 | + self.assertEqual(retcode,0, output) |
2180 | + |
2181 | + # restart server (and ensure it doesn't crash) |
2182 | + copy_server.start() |
2183 | + self.assertEqual(master_server.status, 1, 'Server failed restart from restored datadir...') |
2184 | + |
2185 | + # Check schemas copied / restored |
2186 | + query = "SHOW SCHEMAS" |
2187 | + retcode, result = self.execute_query(query, copy_server) |
2188 | + # TODO have an actual check! |
2189 | + |
2190 | + # Check copy vs. orig |
2191 | + comp_result = self.check_slaves_by_checksum(master_server,[copy_server],schemas=['test','test2']) |
2192 | + self.assertEqual(comp_result, None, comp_result) |
2193 | + |
2194 | + |
2195 | + |
2196 | |
2197 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_incremental_test.py' |
2198 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_incremental_test.py 1970-01-01 00:00:00 +0000 |
2199 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_incremental_test.py 2012-04-03 16:24:26 +0000 |
2200 | @@ -0,0 +1,204 @@ |
2201 | +#! /usr/bin/env python |
2202 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
2203 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
2204 | +# |
2205 | +# Copyright (C) 2011 Patrick Crews |
2206 | +# |
2207 | +# |
2208 | +# This program is free software; you can redistribute it and/or modify |
2209 | +# it under the terms of the GNU General Public License as published by |
2210 | +# the Free Software Foundation; either version 2 of the License, or |
2211 | +# (at your option) any later version. |
2212 | +# |
2213 | +# This program is distributed in the hope that it will be useful, |
2214 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2215 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2216 | +# GNU General Public License for more details. |
2217 | +# |
2218 | +# You should have received a copy of the GNU General Public License |
2219 | +# along with this program; if not, write to the Free Software |
2220 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
2221 | + |
2222 | +import os |
2223 | +import shutil |
2224 | + |
2225 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
2226 | + |
2227 | +server_requirements = [['--innodb_file_per_table']] |
2228 | +servers = [] |
2229 | +server_manager = None |
2230 | +test_executor = None |
2231 | +# we explicitly use the --no-timestamp option |
2232 | +# here. We will be using a generic / vanilla backup dir |
2233 | +backup_path = None |
2234 | + |
2235 | +class basicTest(mysqlBaseTestCase): |
2236 | + |
2237 | + def setUp(self): |
2238 | + master_server = servers[0] # assumption that this is 'master' |
2239 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
2240 | + # remove backup path |
2241 | + if os.path.exists(backup_path): |
2242 | + shutil.rmtree(backup_path) |
2243 | + os.mkdir(backup_path) |
2244 | + |
2245 | + def load_table(self, table_name, row_count, server): |
2246 | + queries = [] |
2247 | + for i in range(row_count): |
2248 | + queries.append("INSERT INTO %s VALUES (%d, %d)" %(table_name,i, row_count)) |
2249 | + retcode, result = self.execute_queries(queries, server) |
2250 | + self.assertEqual(retcode, 0, msg=result) |
2251 | + |
2252 | + |
2253 | + def test_ib_incremental(self): |
2254 | + self.servers = servers |
2255 | + logging = test_executor.logging |
2256 | + if servers[0].type not in ['mysql','percona']: |
2257 | + return |
2258 | + else: |
2259 | + innobackupex = test_executor.system_manager.innobackupex_path |
2260 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
2261 | + master_server = servers[0] # assumption that this is 'master' |
2262 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
2263 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
2264 | + exec_path = os.path.dirname(innobackupex) |
2265 | + table_name = "`test`" |
2266 | + |
2267 | + # populate our server with a test bed |
2268 | + queries = ["DROP TABLE IF EXISTS %s" %(table_name) |
2269 | + ,("CREATE TABLE %s " |
2270 | + "(`a` int(11) DEFAULT NULL, " |
2271 | + "`number` int(11) DEFAULT NULL) " |
2272 | + " ENGINE=InnoDB DEFAULT CHARSET=latin1" |
2273 | + %(table_name) |
2274 | + ) |
2275 | + ] |
2276 | + retcode, result = self.execute_queries(queries, master_server) |
2277 | + self.assertEqual(retcode, 0, msg = result) |
2278 | + row_count = 100 |
2279 | + self.load_table(table_name, row_count, master_server) |
2280 | + |
2281 | + # take a backup |
2282 | + cmd = [ innobackupex |
2283 | + , "--defaults-file=%s" %master_server.cnf_file |
2284 | + , "--user=root" |
2285 | + , "--socket=%s" %master_server.socket_file |
2286 | + #, "--port=%d" %master_server.master_port |
2287 | + #, "--host=127.0.0.1" |
2288 | + #, "--no-timestamp" |
2289 | + , "--ibbackup=%s" %xtrabackup |
2290 | + , backup_path |
2291 | + ] |
2292 | + cmd = " ".join(cmd) |
2293 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2294 | + self.assertEqual(retcode,0,output) |
2295 | + main_backup_path = self.find_backup_path(output) |
2296 | + |
2297 | + # load more data |
2298 | + row_count = 500 |
2299 | + self.load_table(table_name, row_count, master_server) |
2300 | + |
2301 | + # Get a checksum for our table |
2302 | + query = "CHECKSUM TABLE %s" %table_name |
2303 | + retcode, orig_checksum = self.execute_query(query, master_server) |
2304 | + self.assertEqual(retcode, 0, msg=result) |
2305 | + logging.test_debug("Original checksum: %s" %orig_checksum) |
2306 | + |
2307 | + # Take an incremental backup |
2308 | + inc_backup_path = os.path.join(backup_path,'backup_inc1') |
2309 | + cmd = [ innobackupex |
2310 | + , "--defaults-file=%s" %master_server.cnf_file |
2311 | + , "--user=root" |
2312 | + , "--socket=%s" %master_server.socket_file |
2313 | + #, "--port=%d" %master_server.master_port |
2314 | + #, "--host=127.0.0.1" |
2315 | + #, "--no-timestamp" |
2316 | + , "--incremental" |
2317 | + , "--incremental-basedir=%s" %main_backup_path |
2318 | + , "--ibbackup=%s" %xtrabackup |
2319 | + , backup_path |
2320 | + ] |
2321 | + cmd = " ".join(cmd) |
2322 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2323 | + inc_backup_path = self.find_backup_path(output) |
2324 | + self.assertTrue(retcode==0,output) |
2325 | + |
2326 | + # shutdown our server |
2327 | + master_server.stop() |
2328 | + |
2329 | + # prepare our main backup |
2330 | + cmd = [ innobackupex |
2331 | + , "--defaults-file=%s" %master_server.cnf_file |
2332 | + , "--user=root" |
2333 | + , "--socket=%s" %master_server.socket_file |
2334 | + , "--apply-log" |
2335 | + , "--redo-only" |
2336 | + , "--use-memory=500M" |
2337 | + , "--ibbackup=%s" %xtrabackup |
2338 | + , main_backup_path |
2339 | + ] |
2340 | + cmd = " ".join(cmd) |
2341 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2342 | + self.assertEqual(retcode,0,output) |
2343 | + |
2344 | + # prepare our incremental backup |
2345 | + cmd = [ innobackupex |
2346 | + , "--defaults-file=%s" %master_server.cnf_file |
2347 | + , "--user=root" |
2348 | + , "--socket=%s" %master_server.socket_file |
2349 | + , "--apply-log" |
2350 | + , "--redo-only" |
2351 | + , "--use-memory=500M" |
2352 | + , "--ibbackup=%s" %xtrabackup |
2353 | + , "--incremental-dir=%s" %inc_backup_path |
2354 | + , main_backup_path |
2355 | + ] |
2356 | + cmd = " ".join(cmd) |
2357 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2358 | + self.assertTrue(retcode==0,output) |
2359 | + |
2360 | + # do final prepare on main backup |
2361 | + cmd = [ innobackupex |
2362 | + , "--defaults-file=%s" %master_server.cnf_file |
2363 | + , "--user=root" |
2364 | + , "--socket=%s" %master_server.socket_file |
2365 | + , "--apply-log" |
2366 | + , "--use-memory=500M" |
2367 | + , "--ibbackup=%s" %xtrabackup |
2368 | + , main_backup_path |
2369 | + ] |
2370 | + cmd = " ".join(cmd) |
2371 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2372 | + self.assertEqual(retcode, 0,msg = "Command: %s failed with output: %s" %(cmd,output)) |
2373 | + |
2374 | + |
2375 | + # remove old datadir |
2376 | + shutil.rmtree(master_server.datadir) |
2377 | + os.mkdir(master_server.datadir) |
2378 | + |
2379 | + # restore from backup |
2380 | + cmd = [ innobackupex |
2381 | + , "--defaults-file=%s" %master_server.cnf_file |
2382 | + , "--user=root" |
2383 | + , "--socket=%s" %master_server.socket_file |
2384 | + , "--copy-back" |
2385 | + , "--ibbackup=%s" %xtrabackup |
2386 | + , main_backup_path |
2387 | + ] |
2388 | + cmd = " ".join(cmd) |
2389 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2390 | + self.assertTrue(retcode==0, output) |
2391 | + |
2392 | + # restart server (and ensure it doesn't crash) |
2393 | + master_server.start() |
2394 | + self.assertTrue(master_server.ping(quiet=True), 'Server failed restart from restored datadir...') |
2395 | + |
2396 | + # Get a checksum for our table |
2397 | + query = "CHECKSUM TABLE %s" %table_name |
2398 | + retcode, restored_checksum = self.execute_query(query, master_server) |
2399 | + self.assertEqual(retcode, 0, msg=result) |
2400 | + logging.test_debug("Restored checksum: %s" %restored_checksum) |
2401 | + |
2402 | + self.assertEqual(orig_checksum, restored_checksum, msg = "Orig: %s | Restored: %s" %(orig_checksum, restored_checksum)) |
2403 | + |
2404 | + |
2405 | |
2406 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_nonempty_dir_test.py' |
2407 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_nonempty_dir_test.py 1970-01-01 00:00:00 +0000 |
2408 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_nonempty_dir_test.py 2012-04-03 16:24:26 +0000 |
2409 | @@ -0,0 +1,101 @@ |
2410 | +#! /usr/bin/env python |
2411 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
2412 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
2413 | +# |
2414 | +# Copyright (C) 2011 Patrick Crews |
2415 | +# |
2416 | +# |
2417 | +# This program is free software; you can redistribute it and/or modify |
2418 | +# it under the terms of the GNU General Public License as published by |
2419 | +# the Free Software Foundation; either version 2 of the License, or |
2420 | +# (at your option) any later version. |
2421 | +# |
2422 | +# This program is distributed in the hope that it will be useful, |
2423 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2424 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2425 | +# GNU General Public License for more details. |
2426 | +# |
2427 | +# You should have received a copy of the GNU General Public License |
2428 | +# along with this program; if not, write to the Free Software |
2429 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
2430 | + |
2431 | +import os |
2432 | +import shutil |
2433 | + |
2434 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
2435 | + |
2436 | +server_requirements = [['--innodb-file-per-table']] |
2437 | +servers = [] |
2438 | +server_manager = None |
2439 | +test_executor = None |
2440 | +# we explicitly use the --no-timestamp option |
2441 | +# here. We will be using a generic / vanilla backup dir |
2442 | +backup_path = None |
2443 | + |
2444 | +class basicTest(mysqlBaseTestCase): |
2445 | +# Test for bug https://bugs.launchpad.net/percona-xtrabackup/+bug/737569 |
2446 | + |
2447 | + def setUp(self): |
2448 | + master_server = servers[0] # assumption that this is 'master' |
2449 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
2450 | + # remove backup path |
2451 | + if os.path.exists(backup_path): |
2452 | + shutil.rmtree(backup_path) |
2453 | + |
2454 | + |
2455 | + def test_ib_nonempty_dir(self): |
2456 | + self.servers = servers |
2457 | + logging = test_executor.logging |
2458 | + if servers[0].type not in ['mysql','percona']: |
2459 | + return |
2460 | + else: |
2461 | + innobackupex = test_executor.system_manager.innobackupex_path |
2462 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
2463 | + master_server = servers[0] # assumption that this is 'master' |
2464 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
2465 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
2466 | + exec_path = os.path.dirname(innobackupex) |
2467 | + |
2468 | + # take a backup |
2469 | + cmd = ("%s --defaults-file=%s --user=root --port=%d" |
2470 | + " --host=127.0.0.1 --no-timestamp" |
2471 | + " --ibbackup=%s %s" %( innobackupex |
2472 | + , master_server.cnf_file |
2473 | + , master_server.master_port |
2474 | + , xtrabackup |
2475 | + , backup_path)) |
2476 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2477 | + self.assertTrue(retcode==0,output) |
2478 | + |
2479 | + # shutdown our server |
2480 | + master_server.stop() |
2481 | + |
2482 | + # prepare our backup |
2483 | + cmd = ("%s --apply-log --no-timestamp --use-memory=500M " |
2484 | + "--ibbackup=%s %s" %( innobackupex |
2485 | + , xtrabackup |
2486 | + , backup_path)) |
2487 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2488 | + self.assertTrue(retcode==0,output) |
2489 | + |
2490 | + # NOTE: We do NOT remove the old datadir |
2491 | + # This should trigger an error message upon |
2492 | + # attempting to restore |
2493 | + |
2494 | + # restore from backup |
2495 | + cmd = ("%s --defaults-file=%s --copy-back" |
2496 | + " --ibbackup=%s %s" %( innobackupex |
2497 | + , master_server.cnf_file |
2498 | + , xtrabackup |
2499 | + , backup_path)) |
2500 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2501 | + logging.test_debug("Restored retcode: %d" %retcode) |
2502 | + self.assertEqual(retcode, 255, output) |
2503 | + # Check our output for the expected error message |
2504 | + expected_msg = "Original data directory is not empty! at %s line" %(innobackupex) |
2505 | + last_line = output.strip().split('\n')[-1] |
2506 | + self.assertTrue(expected_msg in last_line, msg="Output: %s || expected message: %s" %(output, expected_msg)) |
2507 | + # restart the server to clean up |
2508 | + master_server.start() |
2509 | + |
2510 | + |
2511 | |
2512 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_parallel_test.py' |
2513 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_parallel_test.py 1970-01-01 00:00:00 +0000 |
2514 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_parallel_test.py 2012-04-03 16:24:26 +0000 |
2515 | @@ -0,0 +1,119 @@ |
2516 | +#! /usr/bin/env python |
2517 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
2518 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
2519 | +# |
2520 | +# Copyright (C) 2011 Patrick Crews |
2521 | +# |
2522 | +# |
2523 | +# This program is free software; you can redistribute it and/or modify |
2524 | +# it under the terms of the GNU General Public License as published by |
2525 | +# the Free Software Foundation; either version 2 of the License, or |
2526 | +# (at your option) any later version. |
2527 | +# |
2528 | +# This program is distributed in the hope that it will be useful, |
2529 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2530 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2531 | +# GNU General Public License for more details. |
2532 | +# |
2533 | +# You should have received a copy of the GNU General Public License |
2534 | +# along with this program; if not, write to the Free Software |
2535 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
2536 | + |
2537 | +import os |
2538 | +import sys |
2539 | +import time |
2540 | +import shutil |
2541 | + |
2542 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
2543 | + |
2544 | +server_requirements = [[]] |
2545 | +servers = [] |
2546 | +server_manager = None |
2547 | +test_executor = None |
2548 | +# we explicitly use the --no-timestamp option |
2549 | +# here. We will be using a generic / vanilla backup dir |
2550 | +backup_path = None |
2551 | + |
2552 | +class basicTest(mysqlBaseTestCase): |
2553 | + |
2554 | + def setUp(self): |
2555 | + master_server = servers[0] # assumption that this is 'master' |
2556 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
2557 | + # remove backup path |
2558 | + if os.path.exists(backup_path): |
2559 | + shutil.rmtree(backup_path) |
2560 | + |
2561 | + def test_ib_specialchar(self): |
2562 | + """ Test of use of special characters within the server password """ |
2563 | + self.servers = servers |
2564 | + logging = test_executor.logging |
2565 | + if servers[0].type not in ['mysql','percona']: |
2566 | + return |
2567 | + else: |
2568 | + innobackupex = test_executor.system_manager.innobackupex_path |
2569 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
2570 | + master_server = servers[0] # assumption that this is 'master' |
2571 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
2572 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
2573 | + exec_path = os.path.dirname(innobackupex) |
2574 | + |
2575 | + # populate our server with a test bed |
2576 | + test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz" |
2577 | + retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
2578 | + |
2579 | + # take a backup |
2580 | + cmd = [ innobackupex |
2581 | + , "--defaults-file=%s" %master_server.cnf_file |
2582 | + , "--parallel=8" |
2583 | + , "--user=root" |
2584 | + , "--port=%d" %master_server.master_port |
2585 | + , "--host=127.0.0.1" |
2586 | + , "--no-timestamp" |
2587 | + , "--ibbackup=%s" %xtrabackup |
2588 | + , backup_path |
2589 | + ] |
2590 | + cmd = " ".join(cmd) |
2591 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2592 | + self.assertTrue(retcode==0,output) |
2593 | + |
2594 | + # stop the server |
2595 | + master_server.stop() |
2596 | + |
2597 | + # do prepare on backup |
2598 | + cmd = [ innobackupex |
2599 | + , "--apply-log" |
2600 | + , "--no-timestamp" |
2601 | + , "--use-memory=500M" |
2602 | + , "--ibbackup=%s" %xtrabackup |
2603 | + , backup_path |
2604 | + ] |
2605 | + cmd = " ".join(cmd) |
2606 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2607 | + self.assertTrue(retcode==0,output) |
2608 | + |
2609 | + # remove old datadir |
2610 | + shutil.rmtree(master_server.datadir) |
2611 | + os.mkdir(master_server.datadir) |
2612 | + |
2613 | + # restore from backup |
2614 | + cmd = [ innobackupex |
2615 | + , "--defaults-file=%s" %master_server.cnf_file |
2616 | + , "--copy-back" |
2617 | + , "--ibbackup=%s" %(xtrabackup) |
2618 | + , backup_path |
2619 | + ] |
2620 | + cmd = " ".join(cmd) |
2621 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2622 | + self.assertEqual(retcode,0, output) |
2623 | + |
2624 | + # restart server (and ensure it doesn't crash) |
2625 | + master_server.start() |
2626 | + self.assertEqual(master_server.status,1, 'Server failed restart from restored datadir...') |
2627 | + |
2628 | + # Check the server is ok |
2629 | + query = "SELECT COUNT(*) FROM test.DD" |
2630 | + expected_output = ((100L,),) |
2631 | + retcode, output = self.execute_query(query, master_server) |
2632 | + self.assertEqual(output, expected_output, msg = "%s || %s" %(output, expected_output)) |
2633 | + |
2634 | + |
2635 | |
2636 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_rsync_test.py' |
2637 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_rsync_test.py 1970-01-01 00:00:00 +0000 |
2638 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_rsync_test.py 2012-04-03 16:24:26 +0000 |
2639 | @@ -0,0 +1,126 @@ |
2640 | +#! /usr/bin/env python |
2641 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
2642 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
2643 | +# |
2644 | +# Copyright (C) 2011 Patrick Crews |
2645 | +# |
2646 | +# |
2647 | +# This program is free software; you can redistribute it and/or modify |
2648 | +# it under the terms of the GNU General Public License as published by |
2649 | +# the Free Software Foundation; either version 2 of the License, or |
2650 | +# (at your option) any later version. |
2651 | +# |
2652 | +# This program is distributed in the hope that it will be useful, |
2653 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2654 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2655 | +# GNU General Public License for more details. |
2656 | +# |
2657 | +# You should have received a copy of the GNU General Public License |
2658 | +# along with this program; if not, write to the Free Software |
2659 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
2660 | + |
2661 | +import os |
2662 | +import shutil |
2663 | + |
2664 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
2665 | + |
2666 | +server_requirements = [['--innodb-file-per-table']] |
2667 | +servers = [] |
2668 | +server_manager = None |
2669 | +test_executor = None |
2670 | +# we explicitly use the --no-timestamp option |
2671 | +# here. We will be using a generic / vanilla backup dir |
2672 | +backup_path = None |
2673 | + |
2674 | +class basicTest(mysqlBaseTestCase): |
2675 | + |
2676 | + def setUp(self): |
2677 | + master_server = servers[0] # assumption that this is 'master' |
2678 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
2679 | + # remove backup path |
2680 | + if os.path.exists(backup_path): |
2681 | + shutil.rmtree(backup_path) |
2682 | + |
2683 | + def test_ib_incremental(self): |
2684 | + self.servers = servers |
2685 | + logging = test_executor.logging |
2686 | + if servers[0].type not in ['mysql','percona']: |
2687 | + return |
2688 | + else: |
2689 | + innobackupex = test_executor.system_manager.innobackupex_path |
2690 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
2691 | + master_server = servers[0] # assumption that this is 'master' |
2692 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
2693 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
2694 | + exec_path = os.path.dirname(innobackupex) |
2695 | + table_name = "`test`" |
2696 | + |
2697 | + # populate our server with a test bed |
2698 | + test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz" |
2699 | + retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
2700 | + |
2701 | + # gather some original values for comparison |
2702 | + show_tables_query = "SHOW TABLES IN test" |
2703 | + retcode, show_tables_result = self.execute_query(show_tables_query, master_server) |
2704 | + self.assertEqual(retcode, 0, msg = show_tables_result) |
2705 | + |
2706 | + # take a backup |
2707 | + cmd = [ innobackupex |
2708 | + , "--defaults-file=%s" %master_server.cnf_file |
2709 | + , "--user=root" |
2710 | + , "--port=%d" %master_server.master_port |
2711 | + , "--host=127.0.0.1" |
2712 | + , "--no-timestamp" |
2713 | + , "--ibbackup=%s" %xtrabackup |
2714 | + , backup_path |
2715 | + ] |
2716 | + cmd = " ".join(cmd) |
2717 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2718 | + self.assertTrue(retcode==0,output) |
2719 | + |
2720 | + # shutdown our server |
2721 | + master_server.stop() |
2722 | + |
2723 | + # prepare our backup |
2724 | + cmd = [ innobackupex |
2725 | + , "--apply-log" |
2726 | + , "--no-timestamp" |
2727 | + , "--use-memory=500M" |
2728 | + , "--ibbackup=%s" %xtrabackup |
2729 | + , backup_path |
2730 | + ] |
2731 | + cmd = " ".join(cmd) |
2732 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2733 | + self.assertTrue(retcode==0,output) |
2734 | + |
2735 | + # remove old datadir |
2736 | + shutil.rmtree(master_server.datadir) |
2737 | + os.mkdir(master_server.datadir) |
2738 | + |
2739 | + # restore from backup |
2740 | + cmd = ("%s --defaults-file=%s --copy-back" |
2741 | + " --ibbackup=%s %s" %( innobackupex |
2742 | + , master_server.cnf_file |
2743 | + , xtrabackup |
2744 | + , backup_path)) |
2745 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2746 | + self.assertTrue(retcode==0, output) |
2747 | + |
2748 | + # restart server (and ensure it doesn't crash) |
2749 | + master_server.start() |
2750 | + self.assertTrue(master_server.status==1, 'Server failed restart from restored datadir...') |
2751 | + |
2752 | + # gather some original values for comparison |
2753 | + show_tables_query = "SHOW TABLES IN test" |
2754 | + retcode, restored_show_tables_result = self.execute_query(show_tables_query, master_server) |
2755 | + self.assertEqual(retcode, 0, msg = restored_show_tables_result) |
2756 | + self.assertEqual(show_tables_result, restored_show_tables_result, msg = ("%s || %s" %(show_tables_result, restored_show_tables_result))) |
2757 | + query = "SELECT COUNT(*) FROM DD" |
2758 | + retcode, result = self.execute_query(query, master_server) |
2759 | + self.assertEqual(retcode,0,msg = result) |
2760 | + expected_result = ((100L,),) |
2761 | + self.assertEqual(result, expected_result, msg = "%s || %s" %(expected_result, result)) |
2762 | + |
2763 | + |
2764 | + |
2765 | + |
2766 | |
2767 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_slave_info_test.py' |
2768 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_slave_info_test.py 1970-01-01 00:00:00 +0000 |
2769 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_slave_info_test.py 2012-04-03 16:24:26 +0000 |
2770 | @@ -0,0 +1,87 @@ |
2771 | +#! /usr/bin/env python |
2772 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
2773 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
2774 | +# |
2775 | +# Copyright (C) 2011 Patrick Crews |
2776 | +# |
2777 | +# |
2778 | +# This program is free software; you can redistribute it and/or modify |
2779 | +# it under the terms of the GNU General Public License as published by |
2780 | +# the Free Software Foundation; either version 2 of the License, or |
2781 | +# (at your option) any later version. |
2782 | +# |
2783 | +# This program is distributed in the hope that it will be useful, |
2784 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2785 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2786 | +# GNU General Public License for more details. |
2787 | +# |
2788 | +# You should have received a copy of the GNU General Public License |
2789 | +# along with this program; if not, write to the Free Software |
2790 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
2791 | + |
2792 | +import os |
2793 | +import shutil |
2794 | + |
2795 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
2796 | + |
2797 | +server_requirements = [['--innodb-file-per-table']] |
2798 | +servers = [] |
2799 | +server_manager = None |
2800 | +test_executor = None |
2801 | +# we explicitly use the --no-timestamp option |
2802 | +# here. We will be using a generic / vanilla backup dir |
2803 | +backup_path = None |
2804 | + |
2805 | +class basicTest(mysqlBaseTestCase): |
2806 | + |
2807 | + def setUp(self): |
2808 | + master_server = servers[0] # assumption that this is 'master' |
2809 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
2810 | + # remove backup path |
2811 | + if os.path.exists(backup_path): |
2812 | + shutil.rmtree(backup_path) |
2813 | + |
2814 | + def test_ib_incremental(self): |
2815 | + self.servers = servers |
2816 | + logging = test_executor.logging |
2817 | + if servers[0].type not in ['mysql','percona']: |
2818 | + return |
2819 | + else: |
2820 | + innobackupex = test_executor.system_manager.innobackupex_path |
2821 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
2822 | + master_server = servers[0] # assumption that this is 'master' |
2823 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
2824 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
2825 | + exec_path = os.path.dirname(innobackupex) |
2826 | + table_name = "`test`" |
2827 | + |
2828 | + # populate our server with a test bed |
2829 | + test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz" |
2830 | + retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
2831 | + |
2832 | + # take a backup |
2833 | + # This should fail as slave-info *and* no lock |
2834 | + # are incompatible |
2835 | + cmd = [ innobackupex |
2836 | + , "--defaults-file=%s" %master_server.cnf_file |
2837 | + , "--user=root" |
2838 | + , "--port=%d" %master_server.master_port |
2839 | + , "--host=127.0.0.1" |
2840 | + , "--no-timestamp" |
2841 | + , "--slave-info" |
2842 | + , "--no-lock" |
2843 | + , "--ibbackup=%s" %xtrabackup |
2844 | + , backup_path |
2845 | + ] |
2846 | + cmd = " ".join(cmd) |
2847 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2848 | + logging.test_debug("Backup retcode: %d" %(retcode)) |
2849 | + logging.test_debug("Backup output: %s" %(output)) |
2850 | + self.assertEqual(retcode,1,output) |
2851 | + expected_output = "--slave-info is used with --no-lock but without --safe-slave-backup. The binlog position cannot be consistent with the backup data." |
2852 | + self.assertEqual(output.strip(), expected_output, msg=output) |
2853 | + |
2854 | + |
2855 | + |
2856 | + |
2857 | + |
2858 | |
2859 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_slave_test.py' |
2860 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_slave_test.py 1970-01-01 00:00:00 +0000 |
2861 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_slave_test.py 2012-04-03 16:24:26 +0000 |
2862 | @@ -0,0 +1,173 @@ |
2863 | +#! /usr/bin/env python |
2864 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
2865 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
2866 | +# |
2867 | +# Copyright (C) 2011 Patrick Crews |
2868 | +# |
2869 | +# |
2870 | +# This program is free software; you can redistribute it and/or modify |
2871 | +# it under the terms of the GNU General Public License as published by |
2872 | +# the Free Software Foundation; either version 2 of the License, or |
2873 | +# (at your option) any later version. |
2874 | +# |
2875 | +# This program is distributed in the hope that it will be useful, |
2876 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2877 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2878 | +# GNU General Public License for more details. |
2879 | +# |
2880 | +# You should have received a copy of the GNU General Public License |
2881 | +# along with this program; if not, write to the Free Software |
2882 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
2883 | + |
2884 | +import os |
2885 | +import shutil |
2886 | +import time |
2887 | +import unittest |
2888 | + |
2889 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
2890 | + |
2891 | +server_requirements = [[],[]] |
2892 | +servers = [] |
2893 | +server_manager = None |
2894 | +test_executor = None |
2895 | +# we explicitly use the --no-timestamp option |
2896 | +# here. We will be using a generic / vanilla backup dir |
2897 | +backup_path = None |
2898 | + |
2899 | +class basicTest(mysqlBaseTestCase): |
2900 | + |
2901 | + def setUp(self): |
2902 | + master_server = servers[0] # assumption that this is 'master' |
2903 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
2904 | + # remove backup path |
2905 | + if os.path.exists(backup_path): |
2906 | + shutil.rmtree(backup_path) |
2907 | + os.mkdir(backup_path) |
2908 | + |
2909 | + |
2910 | + def test_basic1(self): |
2911 | + if servers[0].type not in ['mysql','percona']: |
2912 | + return |
2913 | + else: |
2914 | + self.servers = servers |
2915 | + innobackupex = test_executor.system_manager.innobackupex_path |
2916 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
2917 | + master_server = servers[0] # assumption that this is 'master' |
2918 | + slave_server = servers[1] |
2919 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
2920 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
2921 | + exec_path = os.path.dirname(innobackupex) |
2922 | + |
2923 | + # populate our server with a test bed |
2924 | + test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz" |
2925 | + retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
2926 | + #self.assertEqual(retcode, 0, msg=output) |
2927 | + |
2928 | + # take a backup |
2929 | + cmd = [ innobackupex |
2930 | + ,"--defaults-file=%s" %master_server.cnf_file |
2931 | + ,"--user=root" |
2932 | + ,"--socket=%s" %master_server.socket_file |
2933 | + ,"--slave-info" |
2934 | + ," --ibbackup=%s" %xtrabackup |
2935 | + ,backup_path |
2936 | + ] |
2937 | + cmd = " ".join(cmd) |
2938 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2939 | + main_backup_path = self.find_backup_path(output) |
2940 | + self.assertEqual(retcode, 0, msg = output) |
2941 | + |
2942 | + # shutdown our slave server |
2943 | + slave_server.stop() |
2944 | + |
2945 | + # prepare our backup |
2946 | + cmd = [ innobackupex |
2947 | + , "--apply-log" |
2948 | + , "--use-memory=500M" |
2949 | + , "--ibbackup=%s" %xtrabackup |
2950 | + , main_backup_path |
2951 | + ] |
2952 | + cmd = " ".join(cmd) |
2953 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2954 | + self.assertEqual(retcode, 0, msg = output) |
2955 | + |
2956 | + # remove old datadir |
2957 | + shutil.rmtree(slave_server.datadir) |
2958 | + os.mkdir(slave_server.datadir) |
2959 | + |
2960 | + # restore from backup |
2961 | + cmd = [ innobackupex |
2962 | + , "--defaults-file=%s" %slave_server.cnf_file |
2963 | + , "--copy-back" |
2964 | + , "--ibbackup=%s" %xtrabackup |
2965 | + , main_backup_path |
2966 | + ] |
2967 | + cmd = " ".join(cmd) |
2968 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
2969 | + self.assertEqual(retcode,0, msg = output) |
2970 | + |
2971 | + # get binlog info for slave |
2972 | + slave_file_name = 'xtrabackup_binlog_pos_innodb' |
2973 | + """ |
2974 | + for slave_file in ['xtrabackup_slave_info', 'xtrabackup_binlog_pos_innodb']: |
2975 | + slave_file_path = os.path.join(slave_server.datadir,slave_file) |
2976 | + with open(slave_file_path,'r') as slave_data: |
2977 | + print "File: %s" %slave_file |
2978 | + for line in slave_data: |
2979 | + print line, '<<<<' |
2980 | + # end test code |
2981 | + """ |
2982 | + slave_file_path = os.path.join(slave_server.datadir,slave_file_name) |
2983 | + slave_file = open(slave_file_path,'r') |
2984 | + binlog_file, binlog_pos = slave_file.readline().strip().split('\t') |
2985 | + binlog_file = os.path.basename(binlog_file) |
2986 | + slave_file.close() |
2987 | + |
2988 | + # restart server (and ensure it doesn't crash) |
2989 | + slave_server.start() |
2990 | + self.assertEqual( slave_server.status, 1 |
2991 | + , msg = 'Server failed restart from restored datadir...') |
2992 | + |
2993 | + # update our slave's master info/ start replication |
2994 | + # we don't use server.set_master() method as we want |
2995 | + # to use binlog info produced by xtrabackup |
2996 | + # TODO: add these as parameters? |
2997 | + query = ("CHANGE MASTER TO " |
2998 | + "MASTER_HOST='127.0.0.1'," |
2999 | + "MASTER_USER='root'," |
3000 | + "MASTER_PASSWORD=''," |
3001 | + "MASTER_PORT=%d," |
3002 | + "MASTER_LOG_FILE='%s'," |
3003 | + "MASTER_LOG_POS=%d" % ( master_server.master_port |
3004 | + , binlog_file |
3005 | + , int(binlog_pos))) |
3006 | + retcode, result_set = self.execute_query(query, slave_server) |
3007 | + self.assertEqual(retcode, 0, msg=result_set) |
3008 | + |
3009 | + # TODO: check the slave status? |
3010 | + # /implement method to handle the check? |
3011 | + slave_server.slave_start() |
3012 | + |
3013 | + # compare master/slave states |
3014 | + result = self.check_slaves_by_checksum(master_server,[slave_server]) |
3015 | + self.assertEqual(result,None,msg=result) |
3016 | + |
3017 | + # create a new table on the master |
3018 | + query = ("CREATE TABLE t1 " |
3019 | + "(col1 int NOT NULL AUTO_INCREMENT PRIMARY KEY )" |
3020 | + ) |
3021 | + retcode, result_set = self.execute_query(query, master_server) |
3022 | + # insert some rows |
3023 | + query = "INSERT INTO t1 VALUES (),(),(),(),()" |
3024 | + retcode, result_set = self.execute_query(query, master_server) |
3025 | + self.assertEqual(retcode,0,msg=result_set) |
3026 | + |
3027 | + # wait a bit for the slave |
3028 | + # TODO: proper poll routine |
3029 | + time.sleep(5) |
3030 | + for query in ["SHOW CREATE TABLE t1" |
3031 | + ,"SELECT * FROM t1"]: |
3032 | + diff = self.check_slaves_by_query(master_server, [slave_server], query) |
3033 | + self.assertEqual(diff,None,msg=diff) |
3034 | + |
3035 | + |
3036 | |
3037 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_specialchar_test.py' |
3038 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_specialchar_test.py 1970-01-01 00:00:00 +0000 |
3039 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_specialchar_test.py 2012-04-03 16:24:26 +0000 |
3040 | @@ -0,0 +1,151 @@ |
3041 | +#! /usr/bin/env python |
3042 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
3043 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
3044 | +# |
3045 | +# Copyright (C) 2011 Patrick Crews |
3046 | +# |
3047 | +# |
3048 | +# This program is free software; you can redistribute it and/or modify |
3049 | +# it under the terms of the GNU General Public License as published by |
3050 | +# the Free Software Foundation; either version 2 of the License, or |
3051 | +# (at your option) any later version. |
3052 | +# |
3053 | +# This program is distributed in the hope that it will be useful, |
3054 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
3055 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3056 | +# GNU General Public License for more details. |
3057 | +# |
3058 | +# You should have received a copy of the GNU General Public License |
3059 | +# along with this program; if not, write to the Free Software |
3060 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
3061 | + |
3062 | +import os |
3063 | +import sys |
3064 | +import time |
3065 | +import shutil |
3066 | + |
3067 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
3068 | + |
3069 | +server_requirements = [['--innodb-file-per-table']] |
3070 | +servers = [] |
3071 | +server_manager = None |
3072 | +test_executor = None |
3073 | +# we explicitly use the --no-timestamp option |
3074 | +# here. We will be using a generic / vanilla backup dir |
3075 | +backup_path = None |
3076 | + |
3077 | +class basicTest(mysqlBaseTestCase): |
3078 | + def mysqladmin_set_pw(self, server, current_pass, new_pass): |
3079 | + cmd = [ server.mysqladmin |
3080 | + , "--protocol=tcp" |
3081 | + , "--user=root" |
3082 | + , "--port=%d" %server.master_port |
3083 | + , "password" |
3084 | + , "'%s'" %new_pass |
3085 | + ] |
3086 | + if current_pass: |
3087 | + cmd.append("-p'%s'" %current_pass) |
3088 | + cmd = " ".join(cmd) |
3089 | + server.logging.test_debug("mysqladmin cmd: %s" %cmd) |
3090 | + admin_output_file = os.path.join(server.vardir,'mysqladmin.out') |
3091 | + retcode, output = self.execute_cmd(cmd,admin_output_file, get_output=True) |
3092 | + self.assertEqual(retcode,0,output) |
3093 | + |
3094 | + def setUp(self): |
3095 | + master_server = servers[0] # assumption that this is 'master' |
3096 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
3097 | + # remove backup path |
3098 | + if os.path.exists(backup_path): |
3099 | + shutil.rmtree(backup_path) |
3100 | + |
3101 | + def test_ib_specialchar(self): |
3102 | + """ Test of use of special characters within the server password """ |
3103 | + self.servers = servers |
3104 | + logging = test_executor.logging |
3105 | + if servers[0].type not in ['mysql','percona']: |
3106 | + return |
3107 | + else: |
3108 | + innobackupex = test_executor.system_manager.innobackupex_path |
3109 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
3110 | + master_server = servers[0] # assumption that this is 'master' |
3111 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
3112 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
3113 | + exec_path = os.path.dirname(innobackupex) |
3114 | + table_name = "`test`" |
3115 | + |
3116 | + # populate our server with a test bed |
3117 | + test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz" |
3118 | + retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
3119 | + |
3120 | + # Insert a special char into root password |
3121 | + # ?? Just copying the original test |
3122 | + new_pass = "123&123" |
3123 | + logging.test_debug("New password: %s" %new_pass) |
3124 | + # call mysqladmin |
3125 | + self.mysqladmin_set_pw(master_server, '', new_pass) |
3126 | + |
3127 | + # take a backup |
3128 | + cmd = [ innobackupex |
3129 | + , "--defaults-file=%s" %master_server.cnf_file |
3130 | + , "--user=root" |
3131 | + , "--password='%s'" %new_pass |
3132 | + , "--port=%d" %master_server.master_port |
3133 | + , "--host=127.0.0.1" |
3134 | + , "--no-timestamp" |
3135 | + , "--ibbackup=%s" %xtrabackup |
3136 | + , backup_path |
3137 | + ] |
3138 | + cmd = " ".join(cmd) |
3139 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
3140 | + self.assertTrue(retcode==0,output) |
3141 | + |
3142 | + # Reset the password to '' |
3143 | + self.mysqladmin_set_pw(master_server, new_pass, '') |
3144 | + |
3145 | + # do prepare on backup |
3146 | + cmd = [ innobackupex |
3147 | + , "--apply-log" |
3148 | + , "--no-timestamp" |
3149 | + , "--use-memory=500M" |
3150 | + , "--ibbackup=%s" %xtrabackup |
3151 | + , backup_path |
3152 | + ] |
3153 | + cmd = " ".join(cmd) |
3154 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
3155 | + self.assertTrue(retcode==0,output) |
3156 | + |
3157 | + # stop the server |
3158 | + master_server.stop() |
3159 | + |
3160 | + # remove old datadir |
3161 | + shutil.rmtree(master_server.datadir) |
3162 | + os.mkdir(master_server.datadir) |
3163 | + |
3164 | + # restore from backup |
3165 | + cmd = [ innobackupex |
3166 | + , "--defaults-file=%s" %master_server.cnf_file |
3167 | + , "--copy-back" |
3168 | + , "--ibbackup=%s" %(xtrabackup) |
3169 | + , backup_path |
3170 | + ] |
3171 | + cmd = " ".join(cmd) |
3172 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
3173 | + self.assertEqual(retcode,0, output) |
3174 | + |
3175 | + # restart server (and ensure it doesn't crash) |
3176 | + # we skip the grant tables to avoid using the old password |
3177 | + master_server.server_options.append('--skip-grant-tables') |
3178 | + master_server.start() |
3179 | + self.assertEqual(master_server.status,1, 'Server failed restart from restored datadir...') |
3180 | + master_server.server_options.remove('--skip-grant-tables') |
3181 | + |
3182 | + # Reset the password to '' |
3183 | + #self.mysqladmin_set_pw(master_server, new_pass, '') |
3184 | + |
3185 | + # Check the server is ok |
3186 | + query = "SELECT COUNT(*) FROM test.DD" |
3187 | + expected_output = ((100L,),) |
3188 | + retcode, output = self.execute_query(query, master_server) |
3189 | + self.assertEqual(output, expected_output, msg = "%s || %s" %(output, expected_output)) |
3190 | + |
3191 | + |
3192 | |
3193 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_stream_test.py' |
3194 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_stream_test.py 1970-01-01 00:00:00 +0000 |
3195 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/ib_stream_test.py 2012-04-03 16:24:26 +0000 |
3196 | @@ -0,0 +1,127 @@ |
3197 | +#! /usr/bin/env python |
3198 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
3199 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
3200 | +# |
3201 | +# Copyright (C) 2011 Patrick Crews |
3202 | +# |
3203 | +# |
3204 | +# This program is free software; you can redistribute it and/or modify |
3205 | +# it under the terms of the GNU General Public License as published by |
3206 | +# the Free Software Foundation; either version 2 of the License, or |
3207 | +# (at your option) any later version. |
3208 | +# |
3209 | +# This program is distributed in the hope that it will be useful, |
3210 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
3211 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3212 | +# GNU General Public License for more details. |
3213 | +# |
3214 | +# You should have received a copy of the GNU General Public License |
3215 | +# along with this program; if not, write to the Free Software |
3216 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
3217 | + |
3218 | +import os |
3219 | +import shutil |
3220 | +import tarfile |
3221 | + |
3222 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
3223 | + |
3224 | +server_requirements = [[]] |
3225 | +servers = [] |
3226 | +server_manager = None |
3227 | +test_executor = None |
3228 | +# we explicitly use the --no-timestamp option |
3229 | +# here. We will be using a generic / vanilla backup dir |
3230 | +backup_path = None |
3231 | + |
3232 | +class basicTest(mysqlBaseTestCase): |
3233 | + |
3234 | + def setUp(self): |
3235 | + master_server = servers[0] # assumption that this is 'master' |
3236 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
3237 | + # remove backup paths |
3238 | + for del_path in [backup_path]: |
3239 | + if os.path.exists(del_path): |
3240 | + shutil.rmtree(del_path) |
3241 | + |
3242 | + def test_ib_stream(self): |
3243 | + self.servers = servers |
3244 | + innobackupex = test_executor.system_manager.innobackupex_path |
3245 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
3246 | + master_server = servers[0] # assumption that this is 'master' |
3247 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
3248 | + tar_file_path = os.path.join(backup_path,'out.tar') |
3249 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
3250 | + exec_path = os.path.dirname(innobackupex) |
3251 | + |
3252 | + # populate our server with a test bed |
3253 | + test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz" |
3254 | + retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
3255 | + |
3256 | + # take a backup |
3257 | + try: |
3258 | + os.mkdir(backup_path) |
3259 | + except OSError: |
3260 | + pass |
3261 | + cmd = [ innobackupex |
3262 | + , "--defaults-file=%s" %master_server.cnf_file |
3263 | + , "--stream=tar" |
3264 | + , "--user=root" |
3265 | + , "--port=%d" %master_server.master_port |
3266 | + , "--host=127.0.0.1" |
3267 | + , "--no-timestamp" |
3268 | + , "--ibbackup=%s" %xtrabackup |
3269 | + , "%s > %s" %(backup_path,tar_file_path) |
3270 | + ] |
3271 | + cmd = " ".join(cmd) |
3272 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
3273 | + self.assertTrue(retcode==0,output) |
3274 | + |
3275 | + # stop the server |
3276 | + master_server.stop() |
3277 | + |
3278 | + # extract our backup tarball |
3279 | + cmd = "tar -ivxf %s" %tar_file_path |
3280 | + retcode, output = self.execute_cmd(cmd, output_path, backup_path, True) |
3281 | + self.assertEqual(retcode,0,output) |
3282 | + # Check for Bug 723318 - seems quicker than separate test case |
3283 | + self.assertTrue('xtrabackup_binary' in os.listdir(backup_path) |
3284 | + , msg = "Bug723318: xtrabackup_binary not included in tar archive when streaming") |
3285 | + |
3286 | + # do prepare on backup |
3287 | + cmd = [ innobackupex |
3288 | + , "--apply-log" |
3289 | + , "--no-timestamp" |
3290 | + , "--use-memory=500M" |
3291 | + , "--ibbackup=%s" %xtrabackup |
3292 | + , backup_path |
3293 | + ] |
3294 | + cmd = " ".join(cmd) |
3295 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
3296 | + self.assertEqual(retcode,0,output) |
3297 | + |
3298 | + # remove old datadir |
3299 | + shutil.rmtree(master_server.datadir) |
3300 | + os.mkdir(master_server.datadir) |
3301 | + |
3302 | + # restore from backup |
3303 | + cmd = [ innobackupex |
3304 | + , "--defaults-file=%s" %master_server.cnf_file |
3305 | + , "--copy-back" |
3306 | + , "--ibbackup=%s" %(xtrabackup) |
3307 | + , backup_path |
3308 | + ] |
3309 | + cmd = " ".join(cmd) |
3310 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
3311 | + self.assertEqual(retcode,0, output) |
3312 | + |
3313 | + # restart server (and ensure it doesn't crash) |
3314 | + master_server.start() |
3315 | + self.assertEqual(master_server.status,1, 'Server failed restart from restored datadir...') |
3316 | + |
3317 | + # Check the server is ok |
3318 | + query = "SELECT COUNT(*) FROM test.DD" |
3319 | + expected_output = ((100L,),) |
3320 | + retcode, output = self.execute_query(query, master_server) |
3321 | + self.assertEqual(output, expected_output, msg = "%s || %s" %(output, expected_output)) |
3322 | + |
3323 | + |
3324 | |
3325 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/tar4ibd_symlink_test.py' |
3326 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/tar4ibd_symlink_test.py 1970-01-01 00:00:00 +0000 |
3327 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/tar4ibd_symlink_test.py 2012-04-03 16:24:26 +0000 |
3328 | @@ -0,0 +1,151 @@ |
3329 | +#! /usr/bin/env python |
3330 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
3331 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
3332 | +# |
3333 | +# Copyright (C) 2011 Patrick Crews |
3334 | +# |
3335 | +# |
3336 | +# This program is free software; you can redistribute it and/or modify |
3337 | +# it under the terms of the GNU General Public License as published by |
3338 | +# the Free Software Foundation; either version 2 of the License, or |
3339 | +# (at your option) any later version. |
3340 | +# |
3341 | +# This program is distributed in the hope that it will be useful, |
3342 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
3343 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3344 | +# GNU General Public License for more details. |
3345 | +# |
3346 | +# You should have received a copy of the GNU General Public License |
3347 | +# along with this program; if not, write to the Free Software |
3348 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
3349 | + |
3350 | +import os |
3351 | +import shutil |
3352 | +import tarfile |
3353 | + |
3354 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
3355 | + |
3356 | +server_requirements = [['--innodb-file-per-table']] |
3357 | +servers = [] |
3358 | +server_manager = None |
3359 | +test_executor = None |
3360 | +# we explicitly use the --no-timestamp option |
3361 | +# here. We will be using a generic / vanilla backup dir |
3362 | +backup_path = None |
3363 | + |
3364 | +class basicTest(mysqlBaseTestCase): |
3365 | + |
3366 | + def setUp(self): |
3367 | + master_server = servers[0] # assumption that this is 'master' |
3368 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
3369 | + # remove backup paths |
3370 | + for del_path in [backup_path]: |
3371 | + if os.path.exists(del_path): |
3372 | + shutil.rmtree(del_path) |
3373 | + |
3374 | + def test_ib_stream(self): |
3375 | + """Tests for tar4ibd + symlinks (bug #387587)""" |
3376 | + self.servers = servers |
3377 | + innobackupex = test_executor.system_manager.innobackupex_path |
3378 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
3379 | + master_server = servers[0] # assumption that this is 'master' |
3380 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
3381 | + tar_file_path = os.path.join(backup_path,'out.tar') |
3382 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
3383 | + exec_path = os.path.dirname(innobackupex) |
3384 | + |
3385 | + # populate our server with a test bed |
3386 | + test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz" |
3387 | + retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
3388 | + |
3389 | + # Move some of our .ibd files and make symlinks |
3390 | + shutil.move( os.path.join(master_server.datadir,'test/CC.ibd') |
3391 | + , master_server.vardir) |
3392 | + os.symlink(os.path.join(master_server.vardir,'CC.ibd') |
3393 | + ,os.path.join(master_server.datadir,'test/CC.ibd')) |
3394 | + |
3395 | + shutil.move( os.path.join(master_server.datadir,'test/BB.ibd') |
3396 | + , master_server.vardir) |
3397 | + os.symlink(os.path.join(master_server.vardir,'BB.ibd') |
3398 | + ,os.path.join(master_server.vardir,'BB_link.ibd')) |
3399 | + os.symlink(os.path.join(master_server.vardir,'BB_link.ibd') |
3400 | + ,os.path.join(master_server.datadir,'test/BB.ibd')) |
3401 | + |
3402 | + # take a backup |
3403 | + try: |
3404 | + os.mkdir(backup_path) |
3405 | + except OSError: |
3406 | + pass |
3407 | + cmd = [ innobackupex |
3408 | + , "--defaults-file=%s" %master_server.cnf_file |
3409 | + , "--stream=tar" |
3410 | + , "--user=root" |
3411 | + , "--port=%d" %master_server.master_port |
3412 | + , "--host=127.0.0.1" |
3413 | + , "--no-timestamp" |
3414 | + , "--ibbackup=%s" %xtrabackup |
3415 | + , "%s > %s" %(backup_path,tar_file_path) |
3416 | + ] |
3417 | + cmd = " ".join(cmd) |
3418 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
3419 | + self.assertTrue(retcode==0,output) |
3420 | + |
3421 | + # stop the server |
3422 | + master_server.stop() |
3423 | + |
3424 | + # extract our backup tarball |
3425 | + cmd = "tar -ivxf %s" %tar_file_path |
3426 | + retcode, output = self.execute_cmd(cmd, output_path, backup_path, True) |
3427 | + self.assertEqual(retcode,0,output) |
3428 | + # Check for Bug 723318 - seems quicker than separate test case |
3429 | + self.assertTrue('xtrabackup_binary' in os.listdir(backup_path) |
3430 | + , msg = "Bug723318: xtrabackup_binary not included in tar archive when streaming") |
3431 | + |
3432 | + # do prepare on backup |
3433 | + cmd = [ innobackupex |
3434 | + , "--apply-log" |
3435 | + , "--no-timestamp" |
3436 | + , "--use-memory=500M" |
3437 | + , "--ibbackup=%s" %xtrabackup |
3438 | + , backup_path |
3439 | + ] |
3440 | + cmd = " ".join(cmd) |
3441 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
3442 | + self.assertEqual(retcode,0,output) |
3443 | + |
3444 | + # remove old datadir |
3445 | + shutil.rmtree(master_server.datadir) |
3446 | + os.mkdir(master_server.datadir) |
3447 | + |
3448 | + # Remove our symlinks |
3449 | + os.remove(os.path.join(master_server.vardir,'CC.ibd')) |
3450 | + os.remove(os.path.join(master_server.vardir,'BB.ibd')) |
3451 | + os.remove(os.path.join(master_server.vardir,'BB_link.ibd')) |
3452 | + |
3453 | + # restore from backup |
3454 | + cmd = [ innobackupex |
3455 | + , "--defaults-file=%s" %master_server.cnf_file |
3456 | + , "--copy-back" |
3457 | + , "--ibbackup=%s" %(xtrabackup) |
3458 | + , backup_path |
3459 | + ] |
3460 | + cmd = " ".join(cmd) |
3461 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
3462 | + self.assertEqual(retcode,0, output) |
3463 | + |
3464 | + # restart server (and ensure it doesn't crash) |
3465 | + master_server.start() |
3466 | + self.assertEqual(master_server.status,1, 'Server failed restart from restored datadir...') |
3467 | + |
3468 | + # Check the server is ok |
3469 | + query = "SELECT COUNT(*) FROM test.BB" |
3470 | + expected_output = ((10L,),) |
3471 | + retcode, output = self.execute_query(query, master_server) |
3472 | + self.assertEqual(output, expected_output, msg = "%s || %s" %(output, expected_output)) |
3473 | + |
3474 | + query = "SELECT COUNT(*) FROM test.CC" |
3475 | + expected_output = ((100L,),) |
3476 | + retcode, output = self.execute_query(query, master_server) |
3477 | + self.assertEqual(output, expected_output, msg = "%s || %s" %(output, expected_output)) |
3478 | + |
3479 | + |
3480 | |
3481 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_disabled/xb_stats_sakila_test.py' |
3482 | --- tests/kewpie/drizzle_tests/xtrabackup_disabled/xb_stats_sakila_test.py 1970-01-01 00:00:00 +0000 |
3483 | +++ tests/kewpie/drizzle_tests/xtrabackup_disabled/xb_stats_sakila_test.py 2012-04-03 16:24:26 +0000 |
3484 | @@ -0,0 +1,130 @@ |
3485 | +#! /usr/bin/env python |
3486 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
3487 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
3488 | +# |
3489 | +# Copyright (C) 2011 Patrick Crews |
3490 | +# |
3491 | +# |
3492 | +# This program is free software; you can redistribute it and/or modify |
3493 | +# it under the terms of the GNU General Public License as published by |
3494 | +# the Free Software Foundation; either version 2 of the License, or |
3495 | +# (at your option) any later version. |
3496 | +# |
3497 | +# This program is distributed in the hope that it will be useful, |
3498 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
3499 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3500 | +# GNU General Public License for more details. |
3501 | +# |
3502 | +# You should have received a copy of the GNU General Public License |
3503 | +# along with this program; if not, write to the Free Software |
3504 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
3505 | + |
3506 | +import os |
3507 | +import shutil |
3508 | + |
3509 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
3510 | + |
3511 | +server_requirements = [[]] |
3512 | +servers = [] |
3513 | +server_manager = None |
3514 | +test_executor = None |
3515 | +# we explicitly use the --no-timestamp option |
3516 | +# here. We will be using a generic / vanilla backup dir |
3517 | +backup_path = None |
3518 | + |
3519 | +class basicTest(mysqlBaseTestCase): |
3520 | + |
3521 | + def setUp(self): |
3522 | + master_server = servers[0] # assumption that this is 'master' |
3523 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
3524 | + # remove backup path |
3525 | + if os.path.exists(backup_path): |
3526 | + shutil.rmtree(backup_path) |
3527 | + |
3528 | + def test_xb_stats(self): |
3529 | + self.servers = servers |
3530 | + logging = test_executor.logging |
3531 | + if servers[0].type not in ['mysql','percona']: |
3532 | + return |
3533 | + else: |
3534 | + innobackupex = test_executor.system_manager.innobackupex_path |
3535 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
3536 | + master_server = servers[0] # assumption that this is 'master' |
3537 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
3538 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
3539 | + exec_path = os.path.dirname(innobackupex) |
3540 | + table_name = "`test`" |
3541 | + |
3542 | + # populate our server with a test bed |
3543 | + #test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz" |
3544 | + #retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
3545 | + xtrabackup_basedir = os.path.dirname(innobackupex) |
3546 | + datapath = os.path.join(xtrabackup_basedir,'test/inc/sakila-db') |
3547 | + file_names = ['sakila-schema.sql','sakila-data.sql'] |
3548 | + for file_name in file_names: |
3549 | + file_name = os.path.join(datapath,file_name) |
3550 | + cmd = "%s -uroot --protocol=tcp --port=%d < %s" %(master_server.mysql_client, master_server.master_port, file_name) |
3551 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
3552 | + self.assertEqual(retcode,0,output) |
3553 | + |
3554 | + # take a backup |
3555 | + cmd = [ xtrabackup |
3556 | + , "--defaults-file=%s" %master_server.cnf_file |
3557 | + , "--backup" |
3558 | + , "--datadir=%s" %(master_server.datadir) |
3559 | + , "--target-dir=%s" %backup_path |
3560 | + ] |
3561 | + cmd = " ".join(cmd) |
3562 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
3563 | + self.assertEqual(retcode,0,output) |
3564 | + |
3565 | + # first prepare |
3566 | + cmd = [ xtrabackup |
3567 | + , "--defaults-file=%s" %master_server.cnf_file |
3568 | + , "--prepare" |
3569 | + , "--datadir=%s" %(master_server.datadir) |
3570 | + , "--target-dir=%s" %backup_path |
3571 | + ] |
3572 | + cmd = " ".join(cmd) |
3573 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True ) |
3574 | + self.assertEqual(retcode,0,output) |
3575 | + |
3576 | + # Attempt to use --stats, which should fail |
3577 | + # as we haven't finished our prepare statement yet |
3578 | + cmd = [ xtrabackup |
3579 | + , "--defaults-file=%s" %master_server.cnf_file |
3580 | + , "--stats" |
3581 | + , "--datadir=%s" %(backup_path) |
3582 | + ] |
3583 | + cmd = " ".join(cmd) |
3584 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
3585 | + self.assertEqual(retcode,1,output) |
3586 | + expected_output1 = "xtrabackup: Error: Cannot find log file ib_logfile0." |
3587 | + expected_output2 = "xtrabackup: Error: to use the statistics feature, you need a clean copy of the database including correctly sized log files, so you need to execute with --prepare twice to use this functionality on a backup." |
3588 | + output_split = output.split('\n') |
3589 | + line1 = output_split[7].strip() |
3590 | + line2 = output_split[8].strip() |
3591 | + self.assertEqual(line1, expected_output1, output) |
3592 | + self.assertEqual(line2, expected_output2, msg="%s | %s" %(line2, expected_output2)) |
3593 | + |
3594 | + # second prepare |
3595 | + cmd = [ xtrabackup |
3596 | + , "--defaults-file=%s" %master_server.cnf_file |
3597 | + , "--prepare" |
3598 | + , "--datadir=%s" %(master_server.datadir) |
3599 | + , "--target-dir=%s" %backup_path |
3600 | + ] |
3601 | + cmd = " ".join(cmd) |
3602 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
3603 | + self.assertEqual(retcode,0,output) |
3604 | + |
3605 | + # Attempt to use --stats, which should work this time |
3606 | + cmd = [ xtrabackup |
3607 | + , "--defaults-file=%s" %master_server.cnf_file |
3608 | + , "--stats" |
3609 | + , "--datadir=%s" %(backup_path) |
3610 | + ] |
3611 | + cmd = " ".join(cmd) |
3612 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
3613 | + self.assertEqual(retcode,0,output) |
3614 | + |
3615 | |
3616 | === added directory 'tests/kewpie/drizzle_tests/xtrabackup_main' |
3617 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_main/xb_defaults_file_test.py' |
3618 | --- tests/kewpie/drizzle_tests/xtrabackup_main/xb_defaults_file_test.py 1970-01-01 00:00:00 +0000 |
3619 | +++ tests/kewpie/drizzle_tests/xtrabackup_main/xb_defaults_file_test.py 2012-04-03 16:24:26 +0000 |
3620 | @@ -0,0 +1,78 @@ |
3621 | +#! /usr/bin/env python |
3622 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
3623 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
3624 | +# |
3625 | +# Copyright (C) 2011 Patrick Crews |
3626 | +# |
3627 | +# |
3628 | +# This program is free software; you can redistribute it and/or modify |
3629 | +# it under the terms of the GNU General Public License as published by |
3630 | +# the Free Software Foundation; either version 2 of the License, or |
3631 | +# (at your option) any later version. |
3632 | +# |
3633 | +# This program is distributed in the hope that it will be useful, |
3634 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
3635 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3636 | +# GNU General Public License for more details. |
3637 | +# |
3638 | +# You should have received a copy of the GNU General Public License |
3639 | +# along with this program; if not, write to the Free Software |
3640 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
3641 | + |
3642 | +import os |
3643 | +import sys |
3644 | +import time |
3645 | +import shutil |
3646 | + |
3647 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
3648 | + |
3649 | +server_requirements = [[]] |
3650 | +servers = [] |
3651 | +server_manager = None |
3652 | +test_executor = None |
3653 | +# we explicitly use the --no-timestamp option |
3654 | +# here. We will be using a generic / vanilla backup dir |
3655 | +backup_path = None |
3656 | + |
3657 | +class basicTest(mysqlBaseTestCase): |
3658 | + |
3659 | + def setUp(self): |
3660 | + master_server = servers[0] # assumption that this is 'master' |
3661 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
3662 | + # remove backup path |
3663 | + if os.path.exists(backup_path): |
3664 | + shutil.rmtree(backup_path) |
3665 | + |
3666 | + def test_xb_defaults_file(self): |
3667 | + """ Ensure xtrabackup fails if --defaults-file is not the first |
3668 | + argument |
3669 | + |
3670 | + """ |
3671 | + |
3672 | + self.servers = servers |
3673 | + logging = test_executor.logging |
3674 | + innobackupex = test_executor.system_manager.innobackupex_path |
3675 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
3676 | + master_server = servers[0] # assumption that this is 'master' |
3677 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
3678 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
3679 | + exec_path = os.path.dirname(innobackupex) |
3680 | + table_name = "`test`" |
3681 | + |
3682 | + # populate our server with a test bed |
3683 | + test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz" |
3684 | + retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
3685 | + |
3686 | + # take a backup |
3687 | + # This should fail as we --defaults-file must be the first argument |
3688 | + cmd = [ xtrabackup |
3689 | + , "--backup" |
3690 | + , "--defaults-file=%s" %master_server.cnf_file |
3691 | + , "--datadir=%s" %master_server.datadir |
3692 | + , "--target-dir=%s" %backup_path |
3693 | + ] |
3694 | + cmd = " ".join(cmd) |
3695 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
3696 | + self.assertEqual(retcode,1,output) |
3697 | + expected_output = "xtrabackup: Error: --defaults-file must be specified first on the command line" |
3698 | + self.assertEqual(output.strip(), expected_output, msg = "%s || %s " %(expected_output, output.strip())) |
3699 | |
3700 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_main/xb_export_test.py' |
3701 | --- tests/kewpie/drizzle_tests/xtrabackup_main/xb_export_test.py 1970-01-01 00:00:00 +0000 |
3702 | +++ tests/kewpie/drizzle_tests/xtrabackup_main/xb_export_test.py 2012-04-03 16:24:26 +0000 |
3703 | @@ -0,0 +1,297 @@ |
3704 | +#! /usr/bin/env python |
3705 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
3706 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
3707 | +# |
3708 | +# Copyright (C) 2011 Patrick Crews |
3709 | +# |
3710 | +# |
3711 | +# This program is free software; you can redistribute it and/or modify |
3712 | +# it under the terms of the GNU General Public License as published by |
3713 | +# the Free Software Foundation; either version 2 of the License, or |
3714 | +# (at your option) any later version. |
3715 | +# |
3716 | +# This program is distributed in the hope that it will be useful, |
3717 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
3718 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3719 | +# GNU General Public License for more details. |
3720 | +# |
3721 | +# You should have received a copy of the GNU General Public License |
3722 | +# along with this program; if not, write to the Free Software |
3723 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
3724 | + |
3725 | +import os |
3726 | +import shutil |
3727 | + |
3728 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
3729 | + |
3730 | +server_requirements = [['--innodb.file-per-table --innodb.file-format=Barracuda']] |
3731 | +servers = [] |
3732 | +server_manager = None |
3733 | +test_executor = None |
3734 | +# we explicitly use the --no-timestamp option |
3735 | +# here. We will be using a generic / vanilla backup dir |
3736 | +backup_path = None |
3737 | + |
3738 | +def skip_checks(system_manager): |
3739 | + if not system_manager.code_manager.test_tree.xtradb_version: |
3740 | + return True, "Test requires XtraDB." |
3741 | + return False, '' |
3742 | + |
3743 | +class basicTest(mysqlBaseTestCase): |
3744 | + |
3745 | + def setUp(self): |
3746 | + master_server = servers[0] # assumption that this is 'master' |
3747 | + backup_path = os.path.join(master_server.vardir, 'backup') |
3748 | + # remove backup paths |
3749 | + for del_path in [backup_path]: |
3750 | + if os.path.exists(del_path): |
3751 | + shutil.rmtree(del_path) |
3752 | + |
3753 | + def create_test_table(self, table_name, server): |
3754 | + queries = ["DROP TABLE IF EXISTS %s" %(table_name) |
3755 | + ,("CREATE TABLE %s " |
3756 | + "(`a` int(11) DEFAULT NULL, " |
3757 | + "`number` int(11) DEFAULT NULL) " |
3758 | + " ENGINE=InnoDB DEFAULT CHARSET=latin1" |
3759 | + %(table_name) |
3760 | + ) |
3761 | + ] |
3762 | + retcode, result = self.execute_queries(queries, server) |
3763 | + self.assertEqual(retcode, 0, msg = result) |
3764 | + |
3765 | + def load_table(self, table_name, row_count, server): |
3766 | + queries = [] |
3767 | + for i in range(row_count): |
3768 | + queries.append("INSERT INTO %s VALUES (%d, %d)" %(table_name,i, row_count)) |
3769 | + retcode, result = self.execute_queries(queries, server) |
3770 | + self.assertEqual(retcode, 0, msg=result) |
3771 | + |
3772 | + |
3773 | + def test_xb_export(self): |
3774 | + self.servers = servers |
3775 | + master_server = servers[0] |
3776 | + logging = test_executor.logging |
3777 | + xtradb_version = master_server.get_xtradb_version() |
3778 | + if not xtradb_version: |
3779 | + logging.warning("Test requires XtraDB, skipping test...") |
3780 | + return |
3781 | + else: |
3782 | + innobackupex = test_executor.system_manager.innobackupex_path |
3783 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
3784 | + master_server = servers[0] # assumption that this is 'master' |
3785 | + backup_path = os.path.join(master_server.vardir, 'backup') |
3786 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
3787 | + exec_path = os.path.dirname(innobackupex) |
3788 | + table_name = "`test`" |
3789 | + schema_name = "test" |
3790 | + |
3791 | + |
3792 | + # This is a bit hacky. We have a version-dependent server |
3793 | + # option and no clean mechanism for doing this at test-collection |
3794 | + # time |
3795 | + import_option = "--innodb_expand_import=1" |
3796 | + if master_server.version.startswith("5.5"): |
3797 | + import_option = "--innodb_import_table_from_xtrabackup=1" |
3798 | + master_server.server_options.append(import_option) |
3799 | + master_server.stop() |
3800 | + master_server.start() |
3801 | + |
3802 | + # populate our server with a test bed |
3803 | + self.create_test_table(table_name, master_server) |
3804 | + row_count = 100 |
3805 | + self.load_table(table_name, row_count, master_server) |
3806 | + |
3807 | + # take a backup |
3808 | + cmd = [ xtrabackup |
3809 | + , "--defaults-file=%s" %master_server.cnf_file |
3810 | + , "--datadir=%s" %master_server.datadir |
3811 | + , "--backup" |
3812 | + , "--target-dir=%s" %backup_path |
3813 | + ] |
3814 | + cmd = " ".join(cmd) |
3815 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
3816 | + self.assertTrue(retcode==0,output) |
3817 | + |
3818 | + # load more data |
3819 | + row_count = 100 |
3820 | + self.load_table(table_name, row_count, master_server) |
3821 | + |
3822 | + # Get a checksum for our table |
3823 | + query = "CHECKSUM TABLE %s" %table_name |
3824 | + retcode, checksum1 = self.execute_query(query, master_server) |
3825 | + self.assertEqual(retcode, 0, msg=checksum1) |
3826 | + logging.test_debug("Checksum1: %s" %checksum1) |
3827 | + |
3828 | + # Reset the server to treat it as the 'importing' server |
3829 | + # We clean the datadir + create a table w/ similar |
3830 | + # structure |
3831 | + # TODO: see how things fail if we skip / mess up this step |
3832 | + master_server.stop() |
3833 | + master_server.restore_snapshot() |
3834 | + master_server.start() |
3835 | + |
3836 | + # recreate the table: |
3837 | + self.create_test_table(table_name, master_server) |
3838 | + logging.test_debug("Server reinitialized") |
3839 | + |
3840 | + # discard the tablespace |
3841 | + query = "ALTER TABLE %s DISCARD TABLESPACE" %(table_name) |
3842 | + retcode, result = self.execute_query(query, master_server) |
3843 | + self.assertEqual(retcode,0,msg=result) |
3844 | + |
3845 | + # prepare our main backup |
3846 | + # Test the with innodb_file_per_table=0 --export bails out with an error |
3847 | + # Bug #758888 |
3848 | + cmd = [ xtrabackup |
3849 | + , "--prepare" |
3850 | + , "--datadir=%s" %master_server.datadir |
3851 | + , "--use-memory=500M" |
3852 | + , "--target-dir=%s" %backup_path |
3853 | + , "--export" |
3854 | + , "--innodb.file-per-table=0" |
3855 | + ] |
3856 | + cmd = " ".join(cmd) |
3857 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
3858 | + self.assertEqual(retcode,1,output) |
3859 | + |
3860 | + # prepare our main backup |
3861 | + cmd = [ xtrabackup |
3862 | + , "--prepare" |
3863 | + , "--datadir=%s" %master_server.datadir |
3864 | + , "--use-memory=500M" |
3865 | + , "--target-dir=%s" %backup_path |
3866 | + , "--export" |
3867 | + , "--innodb.file-per-table=1" |
3868 | + ] |
3869 | + cmd = " ".join(cmd) |
3870 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
3871 | + self.assertEqual(retcode,0,output) |
3872 | + |
3873 | + # copy our data files back |
3874 | + db_path = os.path.join(backup_path,schema_name) |
3875 | + for bkp_file in os.listdir(db_path): |
3876 | + if bkp_file.startswith('test'): |
3877 | + shutil.copy(os.path.join(db_path,bkp_file) |
3878 | + ,os.path.join(master_server.datadir,schema_name) |
3879 | + ) |
3880 | + |
3881 | + # import the tablespace |
3882 | + query = "ALTER TABLE %s IMPORT TABLESPACE" %(table_name) |
3883 | + retcode, result = self.execute_query(query, master_server) |
3884 | + self.assertEqual(retcode,0,msg=result) |
3885 | + logging.test_debug("Tablespace imported...") |
3886 | + |
3887 | + # Tablespace import is asynchronous, so shutdown the server to have |
3888 | + # consistent backup results. Otherwise we risk ending up with no test.ibd |
3889 | + # in the backup in case importing has not finished before taking backup |
3890 | + master_server.stop() |
3891 | + master_server.start() |
3892 | + self.assertTrue(master_server.status==1, 'Server failed restart from restored datadir...') |
3893 | + |
3894 | + query="SELECT COUNT(*) FROM %s" %(table_name) |
3895 | + retcode, result = self.execute_query(query, master_server) |
3896 | + self.assertEqual(retcode,0,result) |
3897 | + expected_result = ((100L,),) |
3898 | + self.assertEqual(expected_result, result, msg = "%s || %s" %(expected_result, result)) |
3899 | + |
3900 | + query = "SHOW CREATE TABLE %s" %(table_name) |
3901 | + retcode, result = self.execute_query(query, master_server) |
3902 | + self.assertEqual(retcode,0,result) |
3903 | + expected_result = (('test', 'CREATE TABLE `test` (\n `a` int(11) DEFAULT NULL,\n `number` int(11) DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=latin1'),) |
3904 | + self.assertEqual(expected_result, result, msg = "%s || %s" %(expected_result, result)) |
3905 | + |
3906 | + # Get a checksum for our table |
3907 | + query = "CHECKSUM TABLE %s" %table_name |
3908 | + retcode, checksum2 = self.execute_query(query, master_server) |
3909 | + self.assertEqual(retcode, 0, msg=checksum2) |
3910 | + logging.test_debug("Checksum2: %s" %checksum2) |
3911 | + if checksum1 != checksum2: |
3912 | + logging.warning("Initial and exported/restored checksums do not match!") |
3913 | + logging.warning("Checksum1: %s" %checksum1) |
3914 | + logging.warning("Checksum2: %s" %checksum2) |
3915 | + #self.assertEqual(checksum1,checksum2,msg="%s || %s" %(checksum1,checksum2)) |
3916 | + |
3917 | + # create a dir to hold the new backup |
3918 | + backup_path = os.path.join(backup_path,'new_backup') |
3919 | + # take a backup of the imported table |
3920 | + cmd = [ xtrabackup |
3921 | + , "--defaults-file=%s" %master_server.cnf_file |
3922 | + , "--datadir=%s" %master_server.datadir |
3923 | + , "--backup" |
3924 | + , "--target-dir=%s" %backup_path |
3925 | + ] |
3926 | + cmd = " ".join(cmd) |
3927 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
3928 | + self.assertTrue(retcode==0,output) |
3929 | + |
3930 | + # Clear our table so we know the backup restored |
3931 | + for del_table in [table_name]: |
3932 | + query = "DELETE FROM %s" %del_table |
3933 | + retcode, result = self.execute_query(query,master_server) |
3934 | + self.assertEqual(retcode, 0, result) |
3935 | + |
3936 | + # shutdown our server |
3937 | + master_server.stop() |
3938 | + |
3939 | + # prepare our main backup |
3940 | + cmd = [ xtrabackup |
3941 | + , "--prepare" |
3942 | + , "--apply-log-only" |
3943 | + , "--datadir=%s" %master_server.datadir |
3944 | + , "--use-memory=500M" |
3945 | + , "--target-dir=%s" %backup_path |
3946 | + ] |
3947 | + cmd = " ".join(cmd) |
3948 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
3949 | + self.assertTrue(retcode==0,output) |
3950 | + |
3951 | + # do final prepare on main backup |
3952 | + cmd = [ xtrabackup |
3953 | + , "--prepare" |
3954 | + , "--datadir=%s" %master_server.datadir |
3955 | + , "--use-memory=500M" |
3956 | + , "--target-dir=%s" %backup_path |
3957 | + ] |
3958 | + cmd = " ".join(cmd) |
3959 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
3960 | + self.assertTrue(retcode==0,output) |
3961 | + |
3962 | + # copy our data files back |
3963 | + for root, dirs, files in os.walk(backup_path): |
3964 | + if files: |
3965 | + file_info = root.split(backup_path)[1] |
3966 | + for file_name in files: |
3967 | + # We do a quick check to make sure |
3968 | + # no names start with '/' as os.path |
3969 | + # throws a hissy when it sees such things |
3970 | + if file_info.startswith('/'): |
3971 | + file_info = file_info[1:] |
3972 | + if file_name.startswith('/'): |
3973 | + file_name = file_name[1:] |
3974 | + to_path = os.path.join(master_server.datadir |
3975 | + , file_info |
3976 | + , file_name) |
3977 | + new_dir = os.path.dirname(to_path) |
3978 | + try: |
3979 | + if not os.path.exists(new_dir): |
3980 | + os.makedirs(new_dir) |
3981 | + except OSError, e: |
3982 | + logging.error("Could not create directory: %s | %s" %(new_dir, e)) |
3983 | + try: |
3984 | + shutil.copy(os.path.join(root,file_name),to_path) |
3985 | + except IOError, e: |
3986 | + logging.error( "ERROR: Could not copy file: %s | %s" %(file_name, e)) |
3987 | + |
3988 | + # restart server (and ensure it doesn't crash) |
3989 | + master_server.start() |
3990 | + self.assertTrue(master_server.status==1, 'Server failed restart from restored datadir...') |
3991 | + |
3992 | + # Get a checksum for our table |
3993 | + query = "CHECKSUM TABLE %s" %table_name |
3994 | + retcode, checksum3 = self.execute_query(query, master_server) |
3995 | + self.assertEqual(retcode, 0, msg=checksum3) |
3996 | + logging.test_debug("Checksum3: %s" %checksum3) |
3997 | + self.assertEqual(checksum2,checksum3,msg="%s || %s" %(checksum2,checksum3)) |
3998 | + |
3999 | + |
4000 | + |
4001 | |
4002 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_main/xb_incremental_compressed_test.py' |
4003 | --- tests/kewpie/drizzle_tests/xtrabackup_main/xb_incremental_compressed_test.py 1970-01-01 00:00:00 +0000 |
4004 | +++ tests/kewpie/drizzle_tests/xtrabackup_main/xb_incremental_compressed_test.py 2012-04-03 16:24:26 +0000 |
4005 | @@ -0,0 +1,219 @@ |
4006 | +#! /usr/bin/env python |
4007 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
4008 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
4009 | +# |
4010 | +# Copyright (C) 2011 Patrick Crews |
4011 | +# |
4012 | +# |
4013 | +# This program is free software; you can redistribute it and/or modify |
4014 | +# it under the terms of the GNU General Public License as published by |
4015 | +# the Free Software Foundation; either version 2 of the License, or |
4016 | +# (at your option) any later version. |
4017 | +# |
4018 | +# This program is distributed in the hope that it will be useful, |
4019 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
4020 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4021 | +# GNU General Public License for more details. |
4022 | +# |
4023 | +# You should have received a copy of the GNU General Public License |
4024 | +# along with this program; if not, write to the Free Software |
4025 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
4026 | + |
4027 | +import os |
4028 | +import shutil |
4029 | + |
4030 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
4031 | + |
4032 | +server_requirements = [['--innodb.file-per-table' |
4033 | + ,'--innodb.strict-mode' |
4034 | + ,'--innodb.file-format=Barracuda' |
4035 | + ]] |
4036 | +servers = [] |
4037 | +server_manager = None |
4038 | +test_executor = None |
4039 | +# we explicitly use the --no-timestamp option |
4040 | +# here. We will be using a generic / vanilla backup dir |
4041 | +backup_path = None |
4042 | + |
4043 | +def skip_checks(system_manager): |
4044 | + if not system_manager.code_manager.test_tree.innodb_version or not system_manager.code_manager.test_tree.xtradb_version: |
4045 | + return True, "Test requires XtraDB or Innodb plugin." |
4046 | + return False, '' |
4047 | + |
4048 | + |
4049 | +class basicTest(mysqlBaseTestCase): |
4050 | + |
4051 | + def setUp(self): |
4052 | + master_server = servers[0] # assumption that this is 'master' |
4053 | + backup_path = os.path.join(master_server.vardir, 'full_backup') |
4054 | + inc_backup_path = os.path.join(master_server.vardir, 'inc_backup') |
4055 | + # remove backup paths |
4056 | + for del_path in [backup_path, inc_backup_path]: |
4057 | + if os.path.exists(del_path): |
4058 | + shutil.rmtree(del_path) |
4059 | + |
4060 | + def load_table(self, table_name, row_count, server): |
4061 | + queries = [] |
4062 | + for i in range(row_count): |
4063 | + queries.append("INSERT INTO %s VALUES (%d, %d)" %(table_name,i, row_count)) |
4064 | + retcode, result = self.execute_queries(queries, server) |
4065 | + self.assertEqual(retcode, 0, msg=result) |
4066 | + |
4067 | + |
4068 | + def test_ib_incremental(self): |
4069 | + self.servers = servers |
4070 | + master_server = servers[0] |
4071 | + logging = test_executor.logging |
4072 | + retcode, innodb_version = master_server.get_innodb_version() |
4073 | + if not innodb_version: |
4074 | + logging.warning("Test requires XtraDB or Innodb plugin, skipping test...") |
4075 | + return |
4076 | + |
4077 | + else: |
4078 | + innobackupex = test_executor.system_manager.innobackupex_path |
4079 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
4080 | + master_server = servers[0] # assumption that this is 'master' |
4081 | + backup_path = os.path.join(master_server.vardir, 'full_backup') |
4082 | + inc_backup_path = os.path.join(master_server.vardir, 'inc_backup') |
4083 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
4084 | + exec_path = os.path.dirname(innobackupex) |
4085 | + table_name = "`test`" |
4086 | + page_sizes = [1,2,4,8,16] |
4087 | + |
4088 | + for page_size in page_sizes: |
4089 | + self.setUp() |
4090 | + # populate our server with a test bed |
4091 | + queries = ["DROP TABLE IF EXISTS %s" %(table_name) |
4092 | + ,("CREATE TABLE %s " |
4093 | + "(`a` int(11) DEFAULT NULL, " |
4094 | + "`number` int(11) DEFAULT NULL) " |
4095 | + " ENGINE=InnoDB DEFAULT CHARSET=latin1" |
4096 | + %(table_name) |
4097 | + ) |
4098 | + ,("ALTER TABLE test ENGINE=InnoDB " |
4099 | + "ROW_FORMAT=compressed KEY_BLOCK_SIZE=%d" %page_size |
4100 | + ) |
4101 | + ] |
4102 | + retcode, result = self.execute_queries(queries, master_server) |
4103 | + self.assertEqual(retcode, 0, msg = result) |
4104 | + row_count = 100 |
4105 | + self.load_table(table_name, row_count, master_server) |
4106 | + |
4107 | + # take a backup |
4108 | + cmd = [ xtrabackup |
4109 | + , "--defaults-file=%s" %master_server.cnf_file |
4110 | + , "--datadir=%s" %master_server.datadir |
4111 | + , "--backup" |
4112 | + , "--target-dir=%s" %backup_path |
4113 | + ] |
4114 | + cmd = " ".join(cmd) |
4115 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
4116 | + self.assertEqual(retcode,0,output) |
4117 | + |
4118 | + # load more data |
4119 | + row_count = 500 |
4120 | + self.load_table(table_name, row_count, master_server) |
4121 | + |
4122 | + # Get a checksum for our table |
4123 | + query = "CHECKSUM TABLE %s" %table_name |
4124 | + retcode, orig_checksum = self.execute_query(query, master_server) |
4125 | + self.assertEqual(retcode, 0, msg=result) |
4126 | + logging.test_debug("Original checksum: %s" %orig_checksum) |
4127 | + |
4128 | + # Take an incremental backup |
4129 | + cmd = [ xtrabackup |
4130 | + , "--defaults-file=%s" %master_server.cnf_file |
4131 | + , "--datadir=%s" %master_server.datadir |
4132 | + , "--backup" |
4133 | + , "--target-dir=%s" %inc_backup_path |
4134 | + , "--incremental-basedir=%s" %backup_path |
4135 | + ] |
4136 | + cmd = " ".join(cmd) |
4137 | + logging.test_debug(cmd) |
4138 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
4139 | + self.assertEqual(retcode,0,output) |
4140 | + |
4141 | + # Clear our table so we know the backup restored |
4142 | + query = "DELETE FROM %s" %table_name |
4143 | + retcode, result = self.execute_query(query,master_server) |
4144 | + self.assertEqual(retcode, 0, result) |
4145 | + |
4146 | + # shutdown our server |
4147 | + master_server.stop() |
4148 | + |
4149 | + # prepare our main backup |
4150 | + cmd = [ xtrabackup |
4151 | + , "--prepare" |
4152 | + , "--apply-log-only" |
4153 | + , "--datadir=%s" %master_server.datadir |
4154 | + , "--use-memory=500M" |
4155 | + , "--target-dir=%s" %backup_path |
4156 | + ] |
4157 | + cmd = " ".join(cmd) |
4158 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
4159 | + self.assertTrue(retcode==0,output) |
4160 | + |
4161 | + # prepare our incremental backup |
4162 | + cmd = [ xtrabackup |
4163 | + , "--prepare" |
4164 | + , "--apply-log-only" |
4165 | + , "--datadir=%s" %master_server.datadir |
4166 | + , "--use-memory=500M" |
4167 | + , "--target-dir=%s" %backup_path |
4168 | + , "--incremental-dir=%s" %(inc_backup_path) |
4169 | + ] |
4170 | + cmd = " ".join(cmd) |
4171 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
4172 | + self.assertTrue(retcode==0,output) |
4173 | + |
4174 | + # do final prepare on main backup |
4175 | + cmd = [ xtrabackup |
4176 | + , "--prepare" |
4177 | + , "--datadir=%s" %master_server.datadir |
4178 | + , "--use-memory=500M" |
4179 | + , "--target-dir=%s" %backup_path |
4180 | + ] |
4181 | + cmd = " ".join(cmd) |
4182 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
4183 | + self.assertTrue(retcode==0,output) |
4184 | + |
4185 | + # copy our data files back |
4186 | + for root, dirs, files in os.walk(backup_path): |
4187 | + if files: |
4188 | + file_info = root.split(backup_path)[1] |
4189 | + for file_name in files: |
4190 | + # We do a quick check to make sure |
4191 | + # no names start with '/' as os.path |
4192 | + # throws a hissy when it sees such things |
4193 | + if file_info.startswith('/'): |
4194 | + file_info = file_info[1:] |
4195 | + if file_name.startswith('/'): |
4196 | + file_name = file_name[1:] |
4197 | + to_path = os.path.join(master_server.datadir |
4198 | + , file_info |
4199 | + , file_name) |
4200 | + new_dir = os.path.dirname(to_path) |
4201 | + try: |
4202 | + if not os.path.exists(new_dir): |
4203 | + os.makedirs(new_dir) |
4204 | + except OSError, e: |
4205 | + logging.error("Could not create directory: %s | %s" %(new_dir, e)) |
4206 | + try: |
4207 | + shutil.copy(os.path.join(root,file_name),to_path) |
4208 | + except IOError, e: |
4209 | + logging.error( "ERROR: Could not copy file: %s | %s" %(file_name, e)) |
4210 | + |
4211 | + # restart server (and ensure it doesn't crash) |
4212 | + master_server.start() |
4213 | + self.assertTrue(master_server.status==1, 'Server failed restart from restored datadir...') |
4214 | + |
4215 | + # Get a checksum for our table |
4216 | + query = "CHECKSUM TABLE %s" %table_name |
4217 | + retcode, restored_checksum = self.execute_query(query, master_server) |
4218 | + self.assertEqual(retcode, 0, msg=restored_checksum) |
4219 | + logging.test_debug("Restored checksum: %s" %restored_checksum) |
4220 | + |
4221 | + self.assertEqual(orig_checksum, restored_checksum, msg = "Orig: %s | Restored: %s" %(orig_checksum, restored_checksum)) |
4222 | + |
4223 | + |
4224 | + |
4225 | |
4226 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_main/xb_incremental_test.py' |
4227 | --- tests/kewpie/drizzle_tests/xtrabackup_main/xb_incremental_test.py 1970-01-01 00:00:00 +0000 |
4228 | +++ tests/kewpie/drizzle_tests/xtrabackup_main/xb_incremental_test.py 2012-04-03 16:24:26 +0000 |
4229 | @@ -0,0 +1,199 @@ |
4230 | +#! /usr/bin/env python |
4231 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
4232 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
4233 | +# |
4234 | +# Copyright (C) 2011 Patrick Crews |
4235 | +# |
4236 | +# |
4237 | +# This program is free software; you can redistribute it and/or modify |
4238 | +# it under the terms of the GNU General Public License as published by |
4239 | +# the Free Software Foundation; either version 2 of the License, or |
4240 | +# (at your option) any later version. |
4241 | +# |
4242 | +# This program is distributed in the hope that it will be useful, |
4243 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
4244 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4245 | +# GNU General Public License for more details. |
4246 | +# |
4247 | +# You should have received a copy of the GNU General Public License |
4248 | +# along with this program; if not, write to the Free Software |
4249 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
4250 | + |
4251 | +import os |
4252 | +import shutil |
4253 | + |
4254 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
4255 | + |
4256 | +server_requirements = [['--innodb.file-per-table']] |
4257 | +servers = [] |
4258 | +server_manager = None |
4259 | +test_executor = None |
4260 | +# we explicitly use the --no-timestamp option |
4261 | +# here. We will be using a generic / vanilla backup dir |
4262 | +backup_path = None |
4263 | + |
4264 | +class basicTest(mysqlBaseTestCase): |
4265 | + |
4266 | + def setUp(self): |
4267 | + master_server = servers[0] # assumption that this is 'master' |
4268 | + backup_path = os.path.join(master_server.vardir, 'full_backup') |
4269 | + inc_backup_path = os.path.join(master_server.vardir, 'inc_backup') |
4270 | + # remove backup paths |
4271 | + for del_path in [backup_path, inc_backup_path]: |
4272 | + if os.path.exists(del_path): |
4273 | + shutil.rmtree(del_path) |
4274 | + |
4275 | + def load_table(self, table_name, row_count, server): |
4276 | + queries = [] |
4277 | + for i in range(row_count): |
4278 | + queries.append("INSERT INTO %s VALUES (%d, %d)" %(table_name,i, row_count)) |
4279 | + retcode, result = self.execute_queries(queries, server) |
4280 | + self.assertEqual(retcode, 0, msg=result) |
4281 | + |
4282 | + |
4283 | + def test_ib_incremental(self): |
4284 | + self.servers = servers |
4285 | + logging = test_executor.logging |
4286 | + if servers[0].type not in ['drizzle','mysql','percona']: |
4287 | + return |
4288 | + else: |
4289 | + innobackupex = test_executor.system_manager.innobackupex_path |
4290 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
4291 | + master_server = servers[0] # assumption that this is 'master' |
4292 | + backup_path = os.path.join(master_server.vardir, 'full_backup') |
4293 | + inc_backup_path = os.path.join(master_server.vardir, 'inc_backup') |
4294 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
4295 | + exec_path = os.path.dirname(innobackupex) |
4296 | + table_name = "`test`" |
4297 | + |
4298 | + # populate our server with a test bed |
4299 | + queries = ["DROP TABLE IF EXISTS %s" %(table_name) |
4300 | + ,("CREATE TABLE %s " |
4301 | + "(`a` int(11) DEFAULT NULL, " |
4302 | + "`number` int(11) DEFAULT NULL) " |
4303 | + " ENGINE=InnoDB " |
4304 | + %(table_name) |
4305 | + ) |
4306 | + ] |
4307 | + retcode, result = self.execute_queries(queries, master_server) |
4308 | + self.assertEqual(retcode, 0, msg = result) |
4309 | + row_count = 100 |
4310 | + self.load_table(table_name, row_count, master_server) |
4311 | + |
4312 | + # take a backup |
4313 | + cmd = [ xtrabackup |
4314 | + , "--defaults-file=%s" %master_server.cnf_file |
4315 | + , "--datadir=%s" %master_server.datadir |
4316 | + , "--backup" |
4317 | + , "--target-dir=%s" %backup_path |
4318 | + ] |
4319 | + cmd = " ".join(cmd) |
4320 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
4321 | + self.assertTrue(retcode==0,output) |
4322 | + |
4323 | + # load more data |
4324 | + row_count = 500 |
4325 | + self.load_table(table_name, row_count, master_server) |
4326 | + |
4327 | + # Get a checksum for our table |
4328 | + query = "CHECKSUM TABLE %s" %table_name |
4329 | + retcode, orig_checksum = self.execute_query(query, master_server) |
4330 | + self.assertEqual(retcode, 0, msg=result) |
4331 | + logging.test_debug("Original checksum: %s" %orig_checksum) |
4332 | + |
4333 | + # Take an incremental backup |
4334 | + cmd = [ xtrabackup |
4335 | + , "--defaults-file=%s" %master_server.cnf_file |
4336 | + , "--datadir=%s" %master_server.datadir |
4337 | + , "--backup" |
4338 | + , "--target-dir=%s" %inc_backup_path |
4339 | + , "--incremental-basedir=%s" %backup_path |
4340 | + ] |
4341 | + cmd = " ".join(cmd) |
4342 | + logging.test_debug(cmd) |
4343 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
4344 | + self.assertEqual(retcode,0,output) |
4345 | + |
4346 | + # Clear our table so we know the backup restored |
4347 | + query = "DELETE FROM %s" %table_name |
4348 | + retcode, result = self.execute_query(query,master_server) |
4349 | + self.assertEqual(retcode, 0, result) |
4350 | + |
4351 | + # shutdown our server |
4352 | + master_server.stop() |
4353 | + |
4354 | + # prepare our main backup |
4355 | + cmd = [ xtrabackup |
4356 | + , "--prepare" |
4357 | + , "--apply-log-only" |
4358 | + , "--datadir=%s" %master_server.datadir |
4359 | + , "--use-memory=500M" |
4360 | + , "--target-dir=%s" %backup_path |
4361 | + ] |
4362 | + cmd = " ".join(cmd) |
4363 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
4364 | + self.assertTrue(retcode==0,output) |
4365 | + |
4366 | + # prepare our incremental backup |
4367 | + cmd = [ xtrabackup |
4368 | + , "--prepare" |
4369 | + , "--apply-log-only" |
4370 | + , "--datadir=%s" %master_server.datadir |
4371 | + , "--use-memory=500M" |
4372 | + , "--target-dir=%s" %backup_path |
4373 | + , "--incremental-dir=%s" %(inc_backup_path) |
4374 | + ] |
4375 | + cmd = " ".join(cmd) |
4376 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
4377 | + self.assertTrue(retcode==0,output) |
4378 | + |
4379 | + # do final prepare on main backup |
4380 | + cmd = [ xtrabackup |
4381 | + , "--prepare" |
4382 | + , "--datadir=%s" %master_server.datadir |
4383 | + , "--use-memory=500M" |
4384 | + , "--target-dir=%s" %backup_path |
4385 | + ] |
4386 | + cmd = " ".join(cmd) |
4387 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
4388 | + self.assertTrue(retcode==0,output) |
4389 | + |
4390 | + # copy our data files back |
4391 | + for root, dirs, files in os.walk(backup_path): |
4392 | + if files: |
4393 | + file_info = root.split(backup_path)[1] |
4394 | + for file_name in files: |
4395 | + # We do a quick check to make sure |
4396 | + # no names start with '/' as os.path |
4397 | + # throws a hissy when it sees such things |
4398 | + if file_info.startswith('/'): |
4399 | + file_info = file_info[1:] |
4400 | + if file_name.startswith('/'): |
4401 | + file_name = file_name[1:] |
4402 | + to_path = os.path.join(master_server.datadir |
4403 | + , file_info |
4404 | + , file_name) |
4405 | + new_dir = os.path.dirname(to_path) |
4406 | + try: |
4407 | + if not os.path.exists(new_dir): |
4408 | + os.makedirs(new_dir) |
4409 | + except OSError, e: |
4410 | + logging.error("Could not create directory: %s | %s" %(new_dir, e)) |
4411 | + try: |
4412 | + shutil.copy(os.path.join(root,file_name),to_path) |
4413 | + except IOError, e: |
4414 | + logging.error( "ERROR: Could not copy file: %s | %s" %(file_name, e)) |
4415 | + |
4416 | + # restart server (and ensure it doesn't crash) |
4417 | + master_server.start() |
4418 | + self.assertTrue(master_server.status==1, 'Server failed restart from restored datadir...') |
4419 | + |
4420 | + # Get a checksum for our table |
4421 | + query = "CHECKSUM TABLE %s" %table_name |
4422 | + retcode, restored_checksum = self.execute_query(query, master_server) |
4423 | + self.assertEqual(retcode, 0, msg=restored_checksum) |
4424 | + logging.test_debug("Restored checksum: %s" %restored_checksum) |
4425 | + |
4426 | + self.assertEqual(orig_checksum, restored_checksum, msg = "Orig: %s | Restored: %s" %(orig_checksum, restored_checksum)) |
4427 | + |
4428 | + |
4429 | |
4430 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_main/xb_log_overwrap_test.py' |
4431 | --- tests/kewpie/drizzle_tests/xtrabackup_main/xb_log_overwrap_test.py 1970-01-01 00:00:00 +0000 |
4432 | +++ tests/kewpie/drizzle_tests/xtrabackup_main/xb_log_overwrap_test.py 2012-04-03 16:24:26 +0000 |
4433 | @@ -0,0 +1,114 @@ |
4434 | +#! /usr/bin/env python |
4435 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
4436 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
4437 | +# |
4438 | +# Copyright (C) 2011 Patrick Crews |
4439 | +# |
4440 | +# |
4441 | +# This program is free software; you can redistribute it and/or modify |
4442 | +# it under the terms of the GNU General Public License as published by |
4443 | +# the Free Software Foundation; either version 2 of the License, or |
4444 | +# (at your option) any later version. |
4445 | +# |
4446 | +# This program is distributed in the hope that it will be useful, |
4447 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
4448 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4449 | +# GNU General Public License for more details. |
4450 | +# |
4451 | +# You should have received a copy of the GNU General Public License |
4452 | +# along with this program; if not, write to the Free Software |
4453 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
4454 | + |
4455 | +import os |
4456 | +import time |
4457 | +import shutil |
4458 | +import signal |
4459 | +import subprocess |
4460 | + |
4461 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
4462 | + |
4463 | +server_requirements = [['--innodb_log_file_size=1M --innodb_thread_concurrency=1']] |
4464 | +servers = [] |
4465 | +server_manager = None |
4466 | +test_executor = None |
4467 | +# we explicitly use the --no-timestamp option |
4468 | +# here. We will be using a generic / vanilla backup dir |
4469 | +backup_path = None |
4470 | + |
4471 | +class basicTest(mysqlBaseTestCase): |
4472 | + |
4473 | + def setUp(self): |
4474 | + master_server = servers[0] # assumption that this is 'master' |
4475 | + backup_path = os.path.join(master_server.vardir, 'full_backup') |
4476 | + # remove backup paths |
4477 | + for del_path in [backup_path]: |
4478 | + if os.path.exists(del_path): |
4479 | + shutil.rmtree(del_path) |
4480 | + |
4481 | + def test_xb_log_overwrap(self): |
4482 | + self.servers = servers |
4483 | + logging = test_executor.logging |
4484 | + if servers[0].type not in ['mysql','percona']: |
4485 | + return |
4486 | + else: |
4487 | + innobackupex = test_executor.system_manager.innobackupex_path |
4488 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
4489 | + master_server = servers[0] # assumption that this is 'master' |
4490 | + backup_path = os.path.join(master_server.vardir, 'full_backup') |
4491 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
4492 | + suspended_file = os.path.join(backup_path, 'xtrabackup_suspended') |
4493 | + exec_path = os.path.dirname(innobackupex) |
4494 | + |
4495 | + # populate our server with a test bed |
4496 | + test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz" |
4497 | + retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
4498 | + |
4499 | + # take a backup |
4500 | + cmd = [ xtrabackup |
4501 | + , "--defaults-file=%s" %master_server.cnf_file |
4502 | + , "--datadir=%s" %master_server.datadir |
4503 | + , "--backup" |
4504 | + , "--target-dir=%s" %backup_path |
4505 | + , "--suspend-at-end" |
4506 | + ] |
4507 | + output_file = open(output_path,'w') |
4508 | + xtrabackup_subproc = subprocess.Popen( cmd |
4509 | + , cwd=exec_path |
4510 | + , env=test_executor.working_environment |
4511 | + , stdout = output_file |
4512 | + , stderr = subprocess.STDOUT |
4513 | + ) |
4514 | + |
4515 | + # Wait for the xtrabackup_suspended file to be created |
4516 | + timeout = 30 |
4517 | + decrement = 1 |
4518 | + while timeout and not os.path.exists(suspended_file): |
4519 | + time.sleep(decrement) |
4520 | + timeout -= decrement |
4521 | + # Stop the xtrabackup process |
4522 | + xtrabackup_subproc.send_signal(signal.SIGSTOP) |
4523 | + |
4524 | + # Create a large amount of log data |
4525 | + for i in range(20): |
4526 | + query = "CREATE TABLE tmp%d ENGINE=InnoDB SELECT * FROM DD" %i |
4527 | + retcode, result = self.execute_query(query, master_server) |
4528 | + self.assertEqual(retcode,0,msg = result) |
4529 | + |
4530 | + # Resume the xtrabackup process and remove the suspended file |
4531 | + xtrabackup_subproc.send_signal(signal.SIGCONT) |
4532 | + try: |
4533 | + os.remove(suspended_file) |
4534 | + except OSError: |
4535 | + pass |
4536 | + xtrabackup_subproc.wait() |
4537 | + output_file.close() |
4538 | + output_file = open(output_path,'r') |
4539 | + output = ''.join(output_file.readlines()) |
4540 | + output_file.close() |
4541 | + 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." |
4542 | + self.assertEqual(xtrabackup_subproc.returncode,1,msg=output) |
4543 | + # We currently disable this check as it appears wonky |
4544 | + # 1) Was testing fine |
4545 | + # 2) No such check in original test suite |
4546 | + #self.assertTrue(expected_warning in output, msg= "Expected warning: %s || %s" %(expected_warning,output)) |
4547 | + |
4548 | |
4549 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_main/xb_part_range_test.py' |
4550 | --- tests/kewpie/drizzle_tests/xtrabackup_main/xb_part_range_test.py 1970-01-01 00:00:00 +0000 |
4551 | +++ tests/kewpie/drizzle_tests/xtrabackup_main/xb_part_range_test.py 2012-04-03 16:24:26 +0000 |
4552 | @@ -0,0 +1,205 @@ |
4553 | +#! /usr/bin/env python |
4554 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
4555 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
4556 | +# |
4557 | +# Copyright (C) 2011 Patrick Crews |
4558 | +# |
4559 | +# |
4560 | +# This program is free software; you can redistribute it and/or modify |
4561 | +# it under the terms of the GNU General Public License as published by |
4562 | +# the Free Software Foundation; either version 2 of the License, or |
4563 | +# (at your option) any later version. |
4564 | +# |
4565 | +# This program is distributed in the hope that it will be useful, |
4566 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
4567 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4568 | +# GNU General Public License for more details. |
4569 | +# |
4570 | +# You should have received a copy of the GNU General Public License |
4571 | +# along with this program; if not, write to the Free Software |
4572 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
4573 | + |
4574 | +import os |
4575 | +import shutil |
4576 | + |
4577 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
4578 | + |
4579 | +server_requirements = [['--innodb.file-per-table']] |
4580 | +servers = [] |
4581 | +server_manager = None |
4582 | +test_executor = None |
4583 | +# we explicitly use the --no-timestamp option |
4584 | +# here. We will be using a generic / vanilla backup dir |
4585 | +backup_path = None |
4586 | + |
4587 | +class basicTest(mysqlBaseTestCase): |
4588 | + |
4589 | + def setUp(self): |
4590 | + master_server = servers[0] # assumption that this is 'master' |
4591 | + backup_path = os.path.join(master_server.vardir, 'full_backup') |
4592 | + inc_backup_path = os.path.join(master_server.vardir, 'inc_backup') |
4593 | + # remove backup paths |
4594 | + for del_path in [backup_path, inc_backup_path]: |
4595 | + if os.path.exists(del_path): |
4596 | + shutil.rmtree(del_path) |
4597 | + |
4598 | + def load_table(self, table_name, row_count, server): |
4599 | + queries = [] |
4600 | + for i in range(row_count): |
4601 | + queries.append("INSERT INTO %s VALUES (%d, %d)" %(table_name,i, row_count)) |
4602 | + retcode, result = self.execute_queries(queries, server) |
4603 | + self.assertEqual(retcode, 0, msg=result) |
4604 | + |
4605 | + |
4606 | + def test_ib_incremental(self): |
4607 | + self.servers = servers |
4608 | + logging = test_executor.logging |
4609 | + if servers[0].type not in ['drizzle','mysql','percona']: |
4610 | + return |
4611 | + else: |
4612 | + innobackupex = test_executor.system_manager.innobackupex_path |
4613 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
4614 | + master_server = servers[0] # assumption that this is 'master' |
4615 | + backup_path = os.path.join(master_server.vardir, 'full_backup') |
4616 | + inc_backup_path = os.path.join(master_server.vardir, 'inc_backup') |
4617 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
4618 | + exec_path = os.path.dirname(innobackupex) |
4619 | + table_name = "`test`" |
4620 | + |
4621 | + # populate our server with a test bed |
4622 | + queries = ["DROP TABLE IF EXISTS %s" %(table_name) |
4623 | + ,("CREATE TABLE %s " |
4624 | + "(`a` int(11) DEFAULT NULL, " |
4625 | + "`number` int(11) DEFAULT NULL) " |
4626 | + " ENGINE=InnoDB DEFAULT CHARSET=latin1 " |
4627 | + " PARTITION BY RANGE (a) " |
4628 | + " (PARTITION p0 VALUES LESS THAN (100) ENGINE = InnoDB, " |
4629 | + " PARTITION P1 VALUES LESS THAN (200) ENGINE = InnoDB, " |
4630 | + " PARTITION p2 VALUES LESS THAN (300) ENGINE = InnoDB, " |
4631 | + " PARTITION p3 VALUES LESS THAN (400) ENGINE = InnoDB, " |
4632 | + " PARTITION p4 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) " |
4633 | + %(table_name) |
4634 | + ) |
4635 | + ] |
4636 | + retcode, result = self.execute_queries(queries, master_server) |
4637 | + self.assertEqual(retcode, 0, msg = result) |
4638 | + row_count = 100 |
4639 | + self.load_table(table_name, row_count, master_server) |
4640 | + |
4641 | + # take a backup |
4642 | + cmd = [ xtrabackup |
4643 | + , "--defaults-file=%s" %master_server.cnf_file |
4644 | + , "--datadir=%s" %master_server.datadir |
4645 | + , "--backup" |
4646 | + , "--target-dir=%s" %backup_path |
4647 | + ] |
4648 | + cmd = " ".join(cmd) |
4649 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
4650 | + self.assertTrue(retcode==0,output) |
4651 | + |
4652 | + # load more data |
4653 | + row_count = 500 |
4654 | + self.load_table(table_name, row_count, master_server) |
4655 | + |
4656 | + # Get a checksum for our table |
4657 | + query = "CHECKSUM TABLE %s" %table_name |
4658 | + retcode, orig_checksum = self.execute_query(query, master_server) |
4659 | + self.assertEqual(retcode, 0, msg=result) |
4660 | + logging.test_debug("Original checksum: %s" %orig_checksum) |
4661 | + |
4662 | + # Take an incremental backup |
4663 | + cmd = [ xtrabackup |
4664 | + , "--defaults-file=%s" %master_server.cnf_file |
4665 | + , "--datadir=%s" %master_server.datadir |
4666 | + , "--backup" |
4667 | + , "--target-dir=%s" %inc_backup_path |
4668 | + , "--incremental-basedir=%s" %backup_path |
4669 | + ] |
4670 | + cmd = " ".join(cmd) |
4671 | + logging.test_debug(cmd) |
4672 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
4673 | + self.assertEqual(retcode,0,output) |
4674 | + |
4675 | + # Clear our table so we know the backup restored |
4676 | + query = "DELETE FROM %s" %table_name |
4677 | + retcode, result = self.execute_query(query,master_server) |
4678 | + self.assertEqual(retcode, 0, result) |
4679 | + |
4680 | + # shutdown our server |
4681 | + master_server.stop() |
4682 | + |
4683 | + # prepare our main backup |
4684 | + cmd = [ xtrabackup |
4685 | + , "--prepare" |
4686 | + , "--apply-log-only" |
4687 | + , "--datadir=%s" %master_server.datadir |
4688 | + , "--use-memory=500M" |
4689 | + , "--target-dir=%s" %backup_path |
4690 | + ] |
4691 | + cmd = " ".join(cmd) |
4692 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
4693 | + self.assertTrue(retcode==0,output) |
4694 | + |
4695 | + # prepare our incremental backup |
4696 | + cmd = [ xtrabackup |
4697 | + , "--prepare" |
4698 | + , "--apply-log-only" |
4699 | + , "--datadir=%s" %master_server.datadir |
4700 | + , "--use-memory=500M" |
4701 | + , "--target-dir=%s" %backup_path |
4702 | + , "--incremental-dir=%s" %(inc_backup_path) |
4703 | + ] |
4704 | + cmd = " ".join(cmd) |
4705 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
4706 | + self.assertTrue(retcode==0,output) |
4707 | + |
4708 | + # do final prepare on main backup |
4709 | + cmd = [ xtrabackup |
4710 | + , "--prepare" |
4711 | + , "--datadir=%s" %master_server.datadir |
4712 | + , "--use-memory=500M" |
4713 | + , "--target-dir=%s" %backup_path |
4714 | + ] |
4715 | + cmd = " ".join(cmd) |
4716 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
4717 | + self.assertTrue(retcode==0,output) |
4718 | + |
4719 | + # copy our data files back |
4720 | + for root, dirs, files in os.walk(backup_path): |
4721 | + if files: |
4722 | + file_info = root.split(backup_path)[1] |
4723 | + for file_name in files: |
4724 | + # We do a quick check to make sure |
4725 | + # no names start with '/' as os.path |
4726 | + # throws a hissy when it sees such things |
4727 | + if file_info.startswith('/'): |
4728 | + file_info = file_info[1:] |
4729 | + if file_name.startswith('/'): |
4730 | + file_name = file_name[1:] |
4731 | + to_path = os.path.join(master_server.datadir |
4732 | + , file_info |
4733 | + , file_name) |
4734 | + new_dir = os.path.dirname(to_path) |
4735 | + try: |
4736 | + if not os.path.exists(new_dir): |
4737 | + os.makedirs(new_dir) |
4738 | + except OSError, e: |
4739 | + logging.error("Could not create directory: %s | %s" %(new_dir, e)) |
4740 | + try: |
4741 | + shutil.copy(os.path.join(root,file_name),to_path) |
4742 | + except IOError, e: |
4743 | + logging.error( "ERROR: Could not copy file: %s | %s" %(file_name, e)) |
4744 | + |
4745 | + # restart server (and ensure it doesn't crash) |
4746 | + master_server.start() |
4747 | + self.assertTrue(master_server.status==1, 'Server failed restart from restored datadir...') |
4748 | + |
4749 | + # Get a checksum for our table |
4750 | + query = "CHECKSUM TABLE %s" %table_name |
4751 | + retcode, restored_checksum = self.execute_query(query, master_server) |
4752 | + self.assertEqual(retcode, 0, msg=result) |
4753 | + logging.test_debug("Restored checksum: %s" %restored_checksum) |
4754 | + |
4755 | + self.assertEqual(orig_checksum, restored_checksum, msg = "Orig: %s | Restored: %s" %(orig_checksum, restored_checksum)) |
4756 | + |
4757 | + |
4758 | |
4759 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_main/xb_partial_test.py' |
4760 | --- tests/kewpie/drizzle_tests/xtrabackup_main/xb_partial_test.py 1970-01-01 00:00:00 +0000 |
4761 | +++ tests/kewpie/drizzle_tests/xtrabackup_main/xb_partial_test.py 2012-04-03 16:24:26 +0000 |
4762 | @@ -0,0 +1,178 @@ |
4763 | +#! /usr/bin/env python |
4764 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
4765 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
4766 | +# |
4767 | +# Copyright (C) 2011 Patrick Crews |
4768 | +# |
4769 | +# |
4770 | +# This program is free software; you can redistribute it and/or modify |
4771 | +# it under the terms of the GNU General Public License as published by |
4772 | +# the Free Software Foundation; either version 2 of the License, or |
4773 | +# (at your option) any later version. |
4774 | +# |
4775 | +# This program is distributed in the hope that it will be useful, |
4776 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
4777 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4778 | +# GNU General Public License for more details. |
4779 | +# |
4780 | +# You should have received a copy of the GNU General Public License |
4781 | +# along with this program; if not, write to the Free Software |
4782 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
4783 | + |
4784 | +import os |
4785 | +import shutil |
4786 | + |
4787 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
4788 | + |
4789 | +server_requirements = [['--innodb.file-per-table']] |
4790 | +servers = [] |
4791 | +server_manager = None |
4792 | +test_executor = None |
4793 | +# we explicitly use the --no-timestamp option |
4794 | +# here. We will be using a generic / vanilla backup dir |
4795 | +backup_path = None |
4796 | + |
4797 | +class basicTest(mysqlBaseTestCase): |
4798 | + |
4799 | + def setUp(self): |
4800 | + master_server = servers[0] # assumption that this is 'master' |
4801 | + backup_path = os.path.join(master_server.vardir, 'full_backup') |
4802 | + inc_backup_path = os.path.join(master_server.vardir, 'inc_backup') |
4803 | + # remove backup paths |
4804 | + for del_path in [backup_path, inc_backup_path]: |
4805 | + if os.path.exists(del_path): |
4806 | + shutil.rmtree(del_path) |
4807 | + |
4808 | + def load_table(self, table_name, row_count, server): |
4809 | + queries = [] |
4810 | + for i in range(row_count): |
4811 | + queries.append("INSERT INTO %s VALUES (%d, %d)" %(table_name,i, row_count)) |
4812 | + retcode, result = self.execute_queries(queries, server) |
4813 | + self.assertEqual(retcode, 0, msg=result) |
4814 | + |
4815 | + def test_xb_partial(self): |
4816 | + self.servers = servers |
4817 | + logging = test_executor.logging |
4818 | + innobackupex = test_executor.system_manager.innobackupex_path |
4819 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
4820 | + master_server = servers[0] # assumption that this is 'master' |
4821 | + backup_path = os.path.join(master_server.vardir, 'full_backup') |
4822 | + inc_backup_path = os.path.join(master_server.vardir, 'inc_backup') |
4823 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
4824 | + exec_path = os.path.dirname(innobackupex) |
4825 | + table_name = "`test`" |
4826 | + |
4827 | + # populate our server with a test bed |
4828 | + queries = ["DROP TABLE IF EXISTS %s" %(table_name) |
4829 | + ,("CREATE TABLE %s " |
4830 | + "(`a` int(11) DEFAULT NULL, " |
4831 | + "`number` int(11) DEFAULT NULL) " |
4832 | + " ENGINE=InnoDB " |
4833 | + %(table_name) |
4834 | + ) |
4835 | + ] |
4836 | + retcode, result = self.execute_queries(queries, master_server) |
4837 | + self.assertEqual(retcode, 0, msg = result) |
4838 | + row_count = 100 |
4839 | + self.load_table(table_name, row_count, master_server) |
4840 | + |
4841 | + # Additional tables via randgen |
4842 | + test_cmd = "./gentest.pl --gendata=conf/percona/percona.zz" |
4843 | + retcode, output = self.execute_randgen(test_cmd, test_executor, master_server) |
4844 | + #self.assertEqual(retcode, 0, msg=output) |
4845 | + |
4846 | + # take a backup |
4847 | + cmd = [ xtrabackup |
4848 | + , "--defaults-file=%s" %master_server.cnf_file |
4849 | + , "--datadir=%s" %master_server.datadir |
4850 | + , "--backup" |
4851 | + , '--tables="^test[.]test|DD"' |
4852 | + , "--target-dir=%s" %backup_path |
4853 | + ] |
4854 | + cmd = " ".join(cmd) |
4855 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
4856 | + self.assertTrue(retcode==0,output) |
4857 | + |
4858 | + # Get a checksum for our `test` table |
4859 | + query = "CHECKSUM TABLE %s" %table_name |
4860 | + retcode, orig_checksum1 = self.execute_query(query, master_server) |
4861 | + self.assertEqual(retcode, 0, msg=result) |
4862 | + logging.test_debug("Original checksum1: %s" %orig_checksum1) |
4863 | + |
4864 | + # Get a checksum for our `DD` table |
4865 | + query = "CHECKSUM TABLE DD" |
4866 | + retcode, orig_checksum2 = self.execute_query(query, master_server) |
4867 | + self.assertEqual(retcode, 0, msg=result) |
4868 | + logging.test_debug("Original checksum2: %s" %orig_checksum2) |
4869 | + |
4870 | + # Clear our table so we know the backup restored |
4871 | + for del_table in [table_name,'DD']: |
4872 | + query = "DELETE FROM %s" %del_table |
4873 | + retcode, result = self.execute_query(query,master_server) |
4874 | + self.assertEqual(retcode, 0, result) |
4875 | + |
4876 | + # Remove old tables |
4877 | + for table in ['A','AA','B','BB','C','CC','D']: |
4878 | + query = "DROP TABLE %s" %table |
4879 | + retcode, result = self.execute_query(query,master_server) |
4880 | + self.assertEqual(retcode,0,result) |
4881 | + |
4882 | + |
4883 | + # shutdown our server |
4884 | + master_server.stop() |
4885 | + |
4886 | + # do final prepare on main backup |
4887 | + cmd = [ xtrabackup |
4888 | + , "--prepare" |
4889 | + , "--datadir=%s" %master_server.datadir |
4890 | + , "--use-memory=500M" |
4891 | + , "--target-dir=%s" %backup_path |
4892 | + ] |
4893 | + cmd = " ".join(cmd) |
4894 | + retcode, output = self.execute_cmd(cmd, output_path, exec_path, True) |
4895 | + self.assertTrue(retcode==0,output) |
4896 | + |
4897 | + # copy our data files back |
4898 | + for root, dirs, files in os.walk(backup_path): |
4899 | + if files: |
4900 | + file_info = root.split(backup_path)[1] |
4901 | + for file_name in files: |
4902 | + # We do a quick check to make sure |
4903 | + # no names start with '/' as os.path |
4904 | + # throws a hissy when it sees such things |
4905 | + if file_info.startswith('/'): |
4906 | + file_info = file_info[1:] |
4907 | + if file_name.startswith('/'): |
4908 | + file_name = file_name[1:] |
4909 | + to_path = os.path.join(master_server.datadir |
4910 | + , file_info |
4911 | + , file_name) |
4912 | + new_dir = os.path.dirname(to_path) |
4913 | + try: |
4914 | + if not os.path.exists(new_dir): |
4915 | + os.makedirs(new_dir) |
4916 | + except OSError, e: |
4917 | + logging.error("Could not create directory: %s | %s" %(new_dir, e)) |
4918 | + try: |
4919 | + shutil.copy(os.path.join(root,file_name),to_path) |
4920 | + except IOError, e: |
4921 | + logging.error( "ERROR: Could not copy file: %s | %s" %(file_name, e)) |
4922 | + |
4923 | + # restart server (and ensure it doesn't crash) |
4924 | + master_server.start() |
4925 | + self.assertTrue(master_server.status==1, 'Server failed restart from restored datadir...') |
4926 | + |
4927 | + # Get a checksum for our test table |
4928 | + query = "CHECKSUM TABLE %s" %table_name |
4929 | + retcode, restored_checksum1 = self.execute_query(query, master_server) |
4930 | + self.assertEqual(retcode, 0, msg=result) |
4931 | + logging.test_debug("Restored checksum1: %s" %restored_checksum1) |
4932 | + self.assertEqual(orig_checksum1, restored_checksum1, msg = "Orig: %s | Restored: %s" %(orig_checksum1, restored_checksum1)) |
4933 | + |
4934 | + # Get a checksum for our DD table |
4935 | + query = "CHECKSUM TABLE DD" |
4936 | + retcode, restored_checksum2 = self.execute_query(query, master_server) |
4937 | + self.assertEqual(retcode, 0, msg=result) |
4938 | + logging.test_debug("Restored checksum1: %s" %restored_checksum2) |
4939 | + self.assertEqual(orig_checksum2, restored_checksum2, msg = "Orig: %s | Restored: %s" %(orig_checksum2, restored_checksum2)) |
4940 | + |
4941 | |
4942 | === added file 'tests/kewpie/drizzle_tests/xtrabackup_main/xb_stats_test.py' |
4943 | --- tests/kewpie/drizzle_tests/xtrabackup_main/xb_stats_test.py 1970-01-01 00:00:00 +0000 |
4944 | +++ tests/kewpie/drizzle_tests/xtrabackup_main/xb_stats_test.py 2012-04-03 16:24:26 +0000 |
4945 | @@ -0,0 +1,122 @@ |
4946 | +#! /usr/bin/env python |
4947 | +# -*- mode: python; indent-tabs-mode: nil; -*- |
4948 | +# vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
4949 | +# |
4950 | +# Copyright (C) 2011 Patrick Crews |
4951 | +# |
4952 | +# |
4953 | +# This program is free software; you can redistribute it and/or modify |
4954 | +# it under the terms of the GNU General Public License as published by |
4955 | +# the Free Software Foundation; either version 2 of the License, or |
4956 | +# (at your option) any later version. |
4957 | +# |
4958 | +# This program is distributed in the hope that it will be useful, |
4959 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
4960 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4961 | +# GNU General Public License for more details. |
4962 | +# |
4963 | +# You should have received a copy of the GNU General Public License |
4964 | +# along with this program; if not, write to the Free Software |
4965 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
4966 | + |
4967 | +import os |
4968 | +import shutil |
4969 | + |
4970 | +from lib.util.mysqlBaseTestCase import mysqlBaseTestCase |
4971 | + |
4972 | +server_requirements = [[]] |
4973 | +servers = [] |
4974 | +server_manager = None |
4975 | +test_executor = None |
4976 | +# we explicitly use the --no-timestamp option |
4977 | +# here. We will be using a generic / vanilla backup dir |
4978 | +backup_path = None |
4979 | + |
4980 | +class basicTest(mysqlBaseTestCase): |
4981 | + |
4982 | + def setUp(self): |
4983 | + master_server = servers[0] # assumption that this is 'master' |
4984 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
4985 | + # remove backup path |
4986 | + if os.path.exists(backup_path): |
4987 | + shutil.rmtree(backup_path) |
4988 | + |
4989 | + def test_xb_stats(self): |
4990 | + self.servers = servers |
4991 | + logging = test_executor.logging |
4992 | + if servers[0].type not in ['drizzle','mysql','percona']: |
4993 | + return |
4994 | + else: |
4995 | + innobackupex = test_executor.system_manager.innobackupex_path |
4996 | + xtrabackup = test_executor.system_manager.xtrabackup_path |
4997 | + master_server = servers[0] # assumption that this is 'master' |
4998 | + backup_path = os.path.join(master_server.vardir, '_xtrabackup') |
4999 | + output_path = os.path.join(master_server.vardir, 'innobackupex.out') |
5000 | + exec_path = os.path.dirname(innobackupex) |
The diff has been truncated for viewing.