4
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
5
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
6
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
10
use warnings FATAL => 'all';
11
use English qw(-no_match_vars);
16
require "$trunk/bin/pt-archiver";
18
my $dp = new DSNParser(opts=>$dsn_opts);
19
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
20
my $dbh = $sb->get_dbh_for('master');
23
plan skip_all => 'Cannot connect to sandbox master';
31
my $cnf = "/tmp/12345/my.sandbox.cnf";
32
my $cmd = "$trunk/bin/pt-archiver";
34
$sb->create_dbs($dbh, ['test']);
35
$sb->load_file('master', 't/pt-archiver/samples/table1.sql');
38
`rm -f archive.test.table_1`;
40
sub { mk_archiver::main(qw(--where 1=1), "--source", "D=test,t=table_1,F=$cnf", "--file", 'archive.%D.%t') },
42
is($output, '', 'No output for archiving to a file');
43
$output = `/tmp/12345/use -N -e "select count(*) from test.table_1"`;
44
is($output + 0, 0, 'Purged all rows ok');
45
ok(-f 'archive.test.table_1', 'Archive file written OK');
46
$output = `cat archive.test.table_1`;
54
, 'File has the right stuff');
55
`rm -f archive.test.table_1`;
57
# Archive to a file, but specify only some columns.
58
$sb->load_file('master', 't/pt-archiver/samples/table1.sql');
59
`rm -f archive.test.table_1`;
61
sub { mk_archiver::main("-c", "b,c", qw(--where 1=1 --header), "--source", "D=test,t=table_1,F=$cnf", "--file", 'archive.%D.%t') },
63
$output = `cat archive.test.table_1`;
71
, 'File has the right stuff with only some columns');
72
`rm -f archive.test.table_1`;
74
# #############################################################################
76
# #############################################################################
77
$sb->wipe_clean($dbh);