Fix tests to work with new --set-vars, and change --lock-wait-timeout to --set-vars innodb_lock_wait_timeout in tests.

This commit is contained in:
Daniel Nichter
2013-03-02 10:17:23 -07:00
parent 1d42a09196
commit f0b7712528
16 changed files with 30 additions and 25 deletions

View File

@@ -448,6 +448,8 @@ sub copy {
sub set_vars {
my ($self, $dbh, $vars) = @_;
return unless $vars;
foreach my $var ( sort keys %$vars ) {
my $val = $vars->{$var}->{val};

View File

@@ -29,10 +29,10 @@ if ( !$master_dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
my $o = new OptionParser(description => 'Cxn');
my $o = new OptionParser(description => 'Cxn', file => "$trunk/bin/pt-table-checksum");
$o->get_specs("$trunk/bin/pt-table-checksum");
$o->get_opts();
$dp->prop('set-vars', $o->get('set-vars'));
$dp->prop('set-vars', $o->set_vars());
sub make_cxn {
my (%args) = @_;

View File

@@ -439,7 +439,7 @@ SKIP: {
$dbh->disconnect();
$dp = new DSNParser(opts => $opts);
$dp->prop('set-vars', 'wait_timeout=1000');
$dp->prop('set-vars', { wait_timeout => { val => 1000, default => 1}});
$d = $dp->parse('h=127.0.0.1,P=12345,A=utf8,u=msandbox,p=msandbox');
my $dbh2 = $dp->get_dbh($dp->get_cxn_params($d), {mysql_use_result=>1});
sleep 2;
@@ -560,7 +560,7 @@ like(
"get_dbh dies with an unknown charset"
);
$dp->prop('set-vars', "time_zoen='UTC'");
$dp->prop('set-vars', { time_zoen => { val => 'UTC' }});
($out, undef) = full_output(sub { $dp->get_dbh($dp->get_cxn_params($dsn), {}) });
like(
@@ -575,7 +575,7 @@ $dp->prop('set-vars', undef);
# https://bugs.launchpad.net/percona-toolkit/+bug/1078887
# #############################################################################
$dp->prop('set-vars', "sql_mode=ANSI_QUOTES");
$dp->prop('set-vars', { sql_mode => { val=>'ANSI_QUOTES' }});
my $sql_mode_dbh = $dp->get_dbh($dp->get_cxn_params($dsn), {});
my (undef, $sql_mode) = $sql_mode_dbh->selectrow_array(q{SHOW VARIABLES LIKE 'sql\_mode'});
@@ -628,4 +628,4 @@ SKIP: {
# Done.
# #############################################################################
done_testing;

View File

@@ -29,7 +29,8 @@ if ( !$dbh ) {
}
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
# so we need to specify --lock-wait-timeout=3 else the tool will die.
# so we need to specify --set-vars innodb_lock_wait_timeout=3 else the
# tool will die.
my $master_dsn = 'h=127.1,P=12348,u=msandbox,p=msandbox';
my @args = (qw(--set-vars innodb_lock_wait_timeout=3));
my $output;

View File

@@ -30,7 +30,8 @@ elsif ( !$slave_dbh ) {
}
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
# so we need to specify --lock-wait-timeout=3 else the tool will die.
# so we need to specify --set-vars innodb_lock_wait_timeout=3 else the
# tool will die.
my $master_dsn = 'h=127.1,P=12345,u=msandbox,p=msandbox';
my @args = (qw(--set-vars innodb_lock_wait_timeout=3));
my $output;

View File

@@ -30,7 +30,8 @@ elsif ( !$slave_dbh ) {
}
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
# so we need to specify --lock-wait-timeout=3 else the tool will die.
# so we need to specify --set-vars innodb_lock_wait_timeout=3 else the
# tool will die.
my $master_dsn = 'h=127.1,P=12345,u=msandbox,p=msandbox';
my @args = (qw(--set-vars innodb_lock_wait_timeout=3));
my $output;

View File

@@ -40,7 +40,8 @@ elsif ( !@{$master_dbh->selectall_arrayref("show databases like 'sakila'")} ) {
}
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
# so we need to specify --lock-wait-timeout=3 else the tool will die.
# so we need to specify --set-vars innodb_lock_wait_timeout=3 else the
# tool will die.
my $master_dsn = 'h=127.1,P=12345,p=msandbox';
my @args = (qw(--set-vars innodb_lock_wait_timeout=3));
my $row;

View File

@@ -46,8 +46,6 @@ if ( $db_flavor !~ /XtraDB Cluster/ ) {
plan skip_all => "PXC tests";
}
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
# so we need to specify --lock-wait-timeout=3 else the tool will die.
my $node1_dsn = $sb->dsn_for('node1');
my $output;
my $exit;

View File

@@ -30,7 +30,8 @@ elsif ( !$slave_dbh ) {
}
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
# so we need to specify --lock-wait-timeout=3 else the tool will die.
# so we need to specify --set-vars innodb_lock_wait_timeout-3 else the
# tool will die.
my $master_dsn = 'h=127.1,P=12345,u=msandbox,p=msandbox';
my @args = (qw(--set-vars innodb_lock_wait_timeout=3));
my $output;

View File

@@ -172,7 +172,7 @@ $ENV{PTDEBUG} = $dbg || 0;
# pt-table-checksum waits for all checksums to replicate to all slaves,
# so no need to call $sb->wait_for_slaves() after this.
`$trunk/bin/pt-table-checksum h=127.1,P=12345,u=msandbox,p=msandbox --max-load '' --lock-wait 3 --chunk-size 50 --chunk-index idx_actor_last_name -t sakila.actor --quiet`;
`$trunk/bin/pt-table-checksum h=127.1,P=12345,u=msandbox,p=msandbox --max-load '' --set-vars innodb_lock_wait_timeout=3 --chunk-size 50 --chunk-index idx_actor_last_name -t sakila.actor --quiet`;
$slave_dbh->do("update percona.checksums set this_crc='' where db='sakila' and tbl='actor' and chunk=3");
$slave_dbh->do("update sakila.actor set last_name='' where actor_id=30");
@@ -192,7 +192,7 @@ like(
"--replicate with char index col (bug 911996)"
);
$output = `$trunk/bin/pt-table-checksum h=127.1,P=12345,u=msandbox,p=msandbox --max-load '' --lock-wait 3 --chunk-size 50 --chunk-index idx_actor_last_name -t sakila.actor`;
$output = `$trunk/bin/pt-table-checksum h=127.1,P=12345,u=msandbox,p=msandbox --max-load '' --set-vars innodb_lock_wait_timeout=3 --chunk-size 50 --chunk-index idx_actor_last_name -t sakila.actor`;
is(
PerconaTest::count_checksum_results($output, 'diffs'),
0,
@@ -205,7 +205,7 @@ $slave_dbh->do("update test.t set c='z' where id>8");
# pt-table-checksum waits for all checksums to replicate to all slaves,
# so no need to call $sb->wait_for_slaves() after this.
`$trunk/bin/pt-table-checksum h=127.1,P=12345,u=msandbox,p=msandbox --max-load '' --lock-wait 3 --chunk-size 2 -t test.t --quiet`;
`$trunk/bin/pt-table-checksum h=127.1,P=12345,u=msandbox,p=msandbox --max-load '' --set-vars innodb_lock_wait_timeout=3 --chunk-size 2 -t test.t --quiet`;
$output = output(
sub {

View File

@@ -46,7 +46,7 @@ $sb->load_file('master', "$sample/wrong-tbl-struct-bug-1003014.sql");
$slave_dbh->do("DELETE FROM test.aaa WHERE STOP_ARCHIVE IN (5,6,7)");
$slave_dbh->do("UPDATE test.zzz SET c='x' WHERE id IN (44,45,46)");
$output = `$trunk/bin/pt-table-checksum $master_dsn --lock-wait-timeout 3 --max-load '' -d test --chunk-size 10 2>&1`;
$output = `$trunk/bin/pt-table-checksum $master_dsn --set-vars innodb_lock_wait_timeout=3 --max-load '' -d test --chunk-size 10 2>&1`;
is(
PerconaTest::count_checksum_results($output, 'diffs'),
@@ -112,7 +112,7 @@ $sb->load_file('master', "$sample/wrong-tbl-struct-bug-1003014.sql");
$slave_dbh->do("DELETE FROM test.aaa WHERE STOP_ARCHIVE IN (5,6,7)");
$slave_dbh->do("UPDATE test.zzz SET c='x' WHERE id IN (44,45,46)");
$output = `$trunk/bin/pt-table-checksum $master_dsn --lock-wait-timeout 3 --max-load '' -d test --chunk-size 10 2>&1`;
$output = `$trunk/bin/pt-table-checksum $master_dsn --set-vars innodb_lock_wait_timeout=3 --max-load '' -d test --chunk-size 10 2>&1`;
is(
PerconaTest::count_checksum_results($output, 'diffs'),

View File

@@ -110,7 +110,7 @@ test_filters(
# Checksum the filter tables.
$master_dbh->do("DROP DATABASE IF EXISTS percona");
$sb->wait_for_slaves();
diag(`$trunk/bin/pt-table-checksum $master_dsn -d d1,d2,d3 --chunk-size 100 --quiet --lock-wait-timeout 3 --max-load ''`);
diag(`$trunk/bin/pt-table-checksum $master_dsn -d d1,d2,d3 --chunk-size 100 --quiet --set-vars innodb_lock_wait_timeout=3 --max-load ''`);
my $rows = $master_dbh->selectall_arrayref("SELECT CONCAT(db, '.', tbl) FROM percona.checksums ORDER BY db, tbl");
is_deeply(
@@ -180,7 +180,7 @@ $sb->load_file("master", "t/pt-table-sync/samples/simple-tbls.sql");
$slave_dbh->do("INSERT INTO test.empty_it VALUES (null,11,11,'eleven')");
# Create the checksums.
diag(`$trunk/bin/pt-table-checksum h=127.1,P=12345,u=msandbox,p=msandbox -d test --quiet --quiet --lock-wait-timeout 3 --max-load ''`);
diag(`$trunk/bin/pt-table-checksum h=127.1,P=12345,u=msandbox,p=msandbox -d test --quiet --quiet --set-vars innodb_lock_wait_timeout=3 --max-load ''`);
# Make sure all the tables were checksummed.
$rows = $master_dbh->selectall_arrayref("SELECT DISTINCT db, tbl FROM percona.checksums ORDER BY db, tbl");

View File

@@ -40,7 +40,7 @@ $sb->load_file("master", "t/pt-table-sync/samples/issue_560.sql");
$slave_dbh->do('UPDATE issue_560.buddy_list SET buddy_id=0 WHERE player_id IN (333,334)');
$slave_dbh->do('UPDATE issue_560.buddy_list SET buddy_id=0 WHERE player_id=486');
$output = `$trunk/bin/pt-table-checksum --replicate issue_560.checksum h=127.1,P=12345,u=msandbox,p=msandbox -d issue_560 --chunk-size 50 --lock-wait-time 3`;
$output = `$trunk/bin/pt-table-checksum --replicate issue_560.checksum h=127.1,P=12345,u=msandbox,p=msandbox -d issue_560 --chunk-size 50 --set-vars innodb_lock_wait_timeout=3`;
is(
PerconaTest::count_checksum_results($output, 'diffs'),

View File

@@ -48,7 +48,7 @@ $slave_dbh->do('UPDATE issue_375.t SET foo="z" WHERE id=10');
$slave_dbh->do('UPDATE issue_375.t SET foo="zz" WHERE id=100');
# Checksum and replicate.
diag(`$trunk/bin/pt-table-checksum --create-replicate-table --replicate issue_375.checksum h=127.1,P=12345,u=msandbox,p=msandbox -d issue_375 -t t --lock-wait-time 3 > /dev/null`);
diag(`$trunk/bin/pt-table-checksum --create-replicate-table --replicate issue_375.checksum h=127.1,P=12345,u=msandbox,p=msandbox -d issue_375 -t t --set-vars innodb_lock_wait_timeout=3 > /dev/null`);
# And now sync using the replicated checksum results/differences.
$output = output(

View File

@@ -33,7 +33,7 @@ else {
my $output;
my @args = ('--sync-to-master', 'h=127.1,P=12346,u=msandbox,p=msandbox',
qw(-d issue_375 --replicate issue_375.checksums --print));
my $pt_table_checksum = "$trunk/bin/pt-table-checksum h=127.1,P=12345,u=msandbox,p=msandbox -d issue_375 --chunk-size 20 --chunk-size-limit 0 --lock-wait-time 3";
my $pt_table_checksum = "$trunk/bin/pt-table-checksum h=127.1,P=12345,u=msandbox,p=msandbox -d issue_375 --chunk-size 20 --chunk-size-limit 0 --set-vars innodb_lock_wait_timeout=3";
# #############################################################################
# Issue 996: might not chunk inside of mk-table-checksum's boundaries

View File

@@ -44,7 +44,7 @@ $sb->create_dbs($master_dbh, [qw(test)]);
$sb->load_file('master', 't/pt-table-sync/samples/issue_37.sql');
$sb->use('master', '-e "SET SQL_LOG_BIN=0; INSERT INTO test.issue_37 VALUES (1), (2);"');
`$trunk/bin/pt-table-checksum h=127.0.0.1,P=12345,u=msandbox,p=msandbox --replicate test.checksum -d test --lock-wait-time 3 2>&1 > /dev/null`;
`$trunk/bin/pt-table-checksum h=127.0.0.1,P=12345,u=msandbox,p=msandbox --replicate test.checksum -d test --set-vars innodb_lock_wait_timeout=3 2>&1 > /dev/null`;
$output = `$trunk/bin/pt-table-sync --no-check-slave --execute u=msandbox,p=msandbox,h=127.0.0.1,P=12345,D=test,t=issue_37 h=127.1,P=12346 2>&1`;
like($output,
@@ -103,7 +103,7 @@ $slave_dbh->do('INSERT INTO db1.t1 VALUES (9)');
$slave_dbh->do('DELETE FROM db2.t1 WHERE i > 4');
# Replicate checksum of db2.t1.
$output = `$trunk/bin/pt-table-checksum h=127.1,P=12345,u=msandbox,p=msandbox --replicate db1.checksum --create-replicate-table --databases db1,db2 --lock-wait-time 3 2>&1`;
$output = `$trunk/bin/pt-table-checksum h=127.1,P=12345,u=msandbox,p=msandbox --replicate db1.checksum --create-replicate-table --databases db1,db2 --set-vars innodb_lock_wait_timeout=3 2>&1`;
like(
$output,
qr/db2.t1/,