mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 13:11:32 +00:00
50 lines
1.6 KiB
Perl
50 lines
1.6 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-table-checksum";
|
|
|
|
my $dp = new DSNParser(opts=>$dsn_opts);
|
|
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
|
my $master_dbh = $sb->get_dbh_for('master');
|
|
|
|
if ( !$master_dbh ) {
|
|
plan skip_all => 'Cannot connect to sandbox master';
|
|
}
|
|
else {
|
|
plan tests => 5;
|
|
}
|
|
|
|
my $output;
|
|
my $cnf='/tmp/12345/my.sandbox.cnf';
|
|
my $cmd = "$trunk/bin/pt-table-checksum -F $cnf 127.0.0.1";
|
|
|
|
$sb->create_dbs($master_dbh, [qw(test)]);
|
|
$sb->load_file('master', 't/pt-table-checksum/samples/before.sql');
|
|
|
|
# Ensure float-precision is effective
|
|
$output = `$cmd --function sha1 --algorithm BIT_XOR -d test -t fl_test --explain 127.0.0.1`;
|
|
unlike($output, qr/ROUND\(`a`/, 'Column is not rounded');
|
|
like($output, qr/test/, 'Column is not rounded and I got output');
|
|
$output = `$cmd --function sha1 --float-precision 3 --algorithm BIT_XOR -d test -t fl_test --explain 127.0.0.1`;
|
|
like($output, qr/ROUND\(`a`, 3/, 'Column a is rounded');
|
|
like($output, qr/ROUND\(`b`, 3/, 'Column b is rounded');
|
|
like($output, qr/ISNULL\(`b`\)/, 'Column b is not rounded inside ISNULL');
|
|
|
|
# #############################################################################
|
|
# Done.
|
|
# #############################################################################
|
|
$sb->wipe_clean($master_dbh);
|
|
exit;
|