Files
percona-toolkit/t/pt-duplicate-key-checker/clustered_keys.t
Daniel Nichter a64bf961e8 Fix test counts.
2012-06-03 15:14:30 -04:00

55 lines
1.7 KiB
Perl

#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;
use PerconaTest;
use Sandbox;
require "$trunk/bin/pt-duplicate-key-checker";
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh = $sb->get_dbh_for('master');
if ( !$dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
else {
plan tests => 2;
}
my $cnf = "/tmp/12345/my.sandbox.cnf";
my $sample = "t/pt-duplicate-key-checker/samples/";
my @args = ('-F', $cnf, qw(-h 127.1));
$sb->wipe_clean($dbh);
$sb->create_dbs($dbh, ['test']);
# #############################################################################
# Issue 295: Enhance rules for clustered keys in mk-duplicate-key-checker
# #############################################################################
$sb->load_file('master', 't/pt-duplicate-key-checker/samples/issue_295.sql', 'test');
ok(
no_diff(
sub { pt_duplicate_key_checker::main(@args, qw(-d issue_295)) },
($sandbox_version ge '5.1' ? "$sample/issue_295-51.txt"
: "$sample/issue_295.txt")
),
"Shorten, not remove, clustered dupes"
);
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($dbh);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
exit;