~percona-toolkit-dev/percona-toolkit/fix-empty-table-bug-987393

« back to all changes in this revision

Viewing changes to t/pt-mysql-summary/pt-mysql-summary.t

  • Committer: Daniel Nichter
  • Date: 2012-04-03 16:14:55 UTC
  • mfrom: (217.6.22 2.0.3)
  • Revision ID: daniel@percona.com-20120403161455-ntv33vju9o6njtqv
Merge summary-tools-2.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
use PerconaTest;
14
14
 
15
15
my ($tool) = $PROGRAM_NAME =~ m/([\w-]+)\.t$/;
16
 
push @ARGV, "$trunk/t/$tool/*.sh" unless @ARGV;
17
 
system("$trunk/util/test-bash-functions $trunk/bin/$tool @ARGV");
 
16
 
 
17
use Test::More tests => 7;
 
18
use File::Temp qw( tempdir );
 
19
 
 
20
local $ENV{PTDEBUG} = "";
 
21
 
 
22
#
 
23
# --save-samples
 
24
#
 
25
 
 
26
my $dir = tempdir( "percona-testXXXXXXXX", CLEANUP => 1 );
 
27
 
 
28
`$trunk/bin/$tool --sleep 1 --save-samples $dir -- --defaults-file=/tmp/12345/my.sandbox.cnf`;
 
29
 
 
30
ok(
 
31
   -e $dir,
 
32
   "Using --save-samples doesn't mistakenly delete the target dir"
 
33
);
 
34
 
 
35
my @files = glob("$dir/*");
 
36
 
 
37
is(
 
38
   scalar @files,
 
39
   15,
 
40
   "And leaves all files in there"
 
41
);
 
42
 
 
43
undef($dir);
 
44
 
 
45
#
 
46
# --databases
 
47
#
 
48
 
 
49
my $out = `$trunk/bin/$tool --sleep 1 --databases mysql 2>/dev/null -- --defaults-file=/tmp/12345/my.sandbox.cnf`;
 
50
 
 
51
like(
 
52
   $out,
 
53
   qr/Database Tables Views SPs Trigs Funcs   FKs Partn\s+\Qmysql\E/,
 
54
   "--databases works"
 
55
);
 
56
 
 
57
# --read-samples
 
58
for my $i (2..5) {
 
59
   ok(
 
60
      no_diff(
 
61
         sub {
 
62
            local $ENV{_NO_FALSE_NEGATIVES} = 1;
 
63
            print `$trunk/bin/$tool --read-samples $trunk/t/pt-mysql-summary/samples/temp00$i  -- --defaults-file=/tmp/12345/my.sandbox.cnf | tail -n+3 | perl -wlnpe 's/Skipping schema analysis.*/Skipping schema analysis/'`
 
64
         },
 
65
         "t/pt-mysql-summary/samples/expected_output_temp00$i.txt",
 
66
      ),
 
67
      "--read-samples works for t/pt-mysql-summary/temp00$i",
 
68
   );
 
69
}
18
70
 
19
71
exit;