~percona-toolkit-dev/percona-toolkit/release-2.2.3

« back to all changes in this revision

Viewing changes to t/pt-archiver/bulk_insert.t

  • Committer: fraserb at gmail
  • Date: 2012-07-30 14:30:05 UTC
  • mfrom: (319.2.12 ubuntu-12-64-issues)
  • Revision ID: fraserb@gmail.com-20120730143005-7txq2wckdfwsqmke
Merged ubuntu-12-64-issues

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
if ( !$dbh ) {
23
23
   plan skip_all => 'Cannot connect to sandbox master';
24
24
}
 
25
elsif ( PerconaTest::load_data_is_disabled($dbh) ) {
 
26
   diag("LOAD DATA LOCAL INFILE is disabled, only going to test the error message");
 
27
   plan tests => 2;
 
28
}
25
29
else {
26
 
   plan tests => 10;
 
30
   plan tests => 11;
27
31
}
28
32
 
29
33
my $output;
31
35
my $cnf = "/tmp/12345/my.sandbox.cnf";
32
36
my $cmd = "$trunk/bin/pt-archiver";
33
37
 
 
38
if ( PerconaTest::load_data_is_disabled($dbh) ) {
 
39
   test_disabled_load_data($dbh, $sb, 'master', $cnf);
 
40
}
 
41
else {
 
42
 
34
43
$sb->wipe_clean($dbh);
35
44
$sb->create_dbs($dbh, ['test']);
36
45
 
84
93
   "--bulk-insert archived 7 rows (issue 1260)"
85
94
);
86
95
 
 
96
# Test that the tool bails out early if LOAD DATA LOCAL INFILE is disabled
 
97
{
 
98
   if ( -d "/tmp/2900" ) {
 
99
      diag(`$trunk/sandbox/stop-sandbox 2900 >/dev/null 2>&1`);
 
100
   }
 
101
 
 
102
   local $ENV{LOCAL_INFILE} = 0;
 
103
   diag(`$trunk/sandbox/start-sandbox master 2900 >/dev/null 2>&1`);
 
104
 
 
105
   my $master3_dbh = $sb->get_dbh_for('master3');
 
106
 
 
107
   test_disabled_load_data($master3_dbh, $sb, 'master3', "/tmp/2900/my.sandbox.cnf");
 
108
 
 
109
   diag(`$trunk/sandbox/stop-sandbox 2900 >/dev/null 2>&1`);
 
110
   $master3_dbh->disconnect() if $master3_dbh;
 
111
}
 
112
 
 
113
}
 
114
 
 
115
sub test_disabled_load_data {
 
116
   my ($dbh, $sb, $master, $cnf) = @_;
 
117
   $sb->wipe_clean($dbh);
 
118
   $sb->create_dbs($dbh, ['test']);
 
119
   $sb->load_file($master, 't/pt-archiver/samples/table5.sql');
 
120
   $dbh->do('INSERT INTO `test`.`table_5_copy` SELECT * FROM `test`.`table_5`');
 
121
 
 
122
   my ($output, undef) = full_output(
 
123
      sub { pt_archiver::main(qw(--no-ascend --limit 50 --bulk-insert),
 
124
         qw(--bulk-delete --where 1=1 --statistics),
 
125
         '--source', "D=test,t=table_5,F=$cnf",
 
126
         '--dest',   "t=table_5_dest") },
 
127
   );
 
128
 
 
129
   like($output,
 
130
      qr!\Q--bulk-insert cannot work as LOAD DATA LOCAL INFILE is disabled. See http://kb.percona.com/troubleshoot-load-data-infile!,
 
131
      "--bulk-insert throws an error if LOCAL INFILE is disabled"
 
132
   );
 
133
}
 
134
 
87
135
# #############################################################################
88
136
# Done.
89
137
# #############################################################################