Do not use precision and scale. Use sandbox 12348 instead of 12347. Call pt_upgrade_main() instead of tool via cmd line in basics.t.

This commit is contained in:
Daniel Nichter
2012-02-07 12:39:25 -07:00
parent a08afff18b
commit 298385167e
21 changed files with 355 additions and 191 deletions

View File

@@ -169,8 +169,8 @@ SKIP: {
size => {
id => undef,
i => undef,
f => '(31,12)',
d => $DBD::mysql::VERSION ge '4.001' ? '(7,2)' : '(7)',
f => undef,
d => undef,
dt => undef,
ts => undef,
c => '(1)',

View File

@@ -16,12 +16,12 @@ use Sandbox;
require "$trunk/bin/pt-upgrade";
# This runs immediately if the server is already running, else it starts it.
diag(`$trunk/sandbox/start-sandbox master 12347 >/dev/null`);
diag(`$trunk/sandbox/start-sandbox master 12348 >/dev/null`);
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh1 = $sb->get_dbh_for('master');
my $dbh2 = $sb->get_dbh_for('slave2');
my $dbh2 = $sb->get_dbh_for('master1');
if ( !$dbh1 ) {
plan skip_all => 'Cannot connect to sandbox master';
@@ -30,96 +30,109 @@ elsif ( !$dbh2 ) {
plan skip_all => 'Cannot connect to second sandbox master';
}
else {
plan tests => 10;
plan tests => 12;
}
$sb->load_file('master', 't/pt-upgrade/samples/001/tables.sql');
$sb->load_file('slave2', 't/pt-upgrade/samples/001/tables.sql');
my @host_args = ('h=127.1,P=12345', 'P=12348');
my @op_args = (qw(-u msandbox -p msandbox),
'--compare', 'results,warnings',
'--zero-query-times',
);
my @args = (@host_args, @op_args);
my $sample = "t/pt-upgrade/samples";
my $log = "$trunk/$sample";
my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345,u=msandbox,p=msandbox P=12347 --compare results,warnings --zero-query-times";
my @args = ('--compare', 'results,warnings', '--zero-query-times');
my $sample = "$trunk/t/pt-upgrade/samples/";
# ###########################################################################
# Basic run.
# ###########################################################################
$sb->load_file('master', "$sample/001/tables.sql");
$sb->load_file('master1', "$sample/001/tables.sql");
ok(
no_diff(
"$cmd $trunk/t/pt-upgrade/samples/001/select-one.log",
't/pt-upgrade/samples/001/select-one.txt'
sub { pt_upgrade::main(@args, "$log/001/select-one.log") },
"$sample/001/select-one.txt",
),
'Report for a single query (checksum method)'
);
ok(
no_diff(
"$cmd $trunk/t/pt-upgrade/samples/001/select-everyone.log",
't/pt-upgrade/samples/001/select-everyone.txt'
sub { pt_upgrade::main(@args, "$log/001/select-everyone.log") },
"$sample/001/select-everyone.txt"
),
'Report for multiple queries (checksum method)'
);
ok(
no_diff(
"$cmd $trunk/t/pt-upgrade/samples/001/select-one.log --compare-results-method rows",
't/pt-upgrade/samples/001/select-one-rows.txt'
sub { pt_upgrade::main(@args, "$trunk/$sample/001/select-one.log",
"--compare-results-method", "rows") },
"$sample/001/select-one-rows.txt"
),
'Report for a single query (rows method)'
);
ok(
no_diff(
"$cmd $trunk/t/pt-upgrade/samples/001/select-everyone.log --compare-results-method rows",
't/pt-upgrade/samples/001/select-everyone-rows.txt'
sub { pt_upgrade::main(@args, "$trunk/$sample/001/select-everyone.log",
"--compare-results-method", "rows") },
"$sample/001/select-everyone-rows.txt"
),
'Report for multiple queries (rows method)'
);
ok(
no_diff(
"$cmd --reports queries,differences,errors $trunk/t/pt-upgrade/samples/001/select-everyone.log",
't/pt-upgrade/samples/001/select-everyone-no-stats.txt'
sub { pt_upgrade::main(@args, "$trunk/$sample/001/select-everyone.log",
"--reports", "queries,differences,errors") },
"$sample/001/select-everyone-no-stats.txt"
),
'Report without statistics'
);
ok(
no_diff(
"$cmd --reports differences,errors,statistics $trunk/t/pt-upgrade/samples/001/select-everyone.log",
't/pt-upgrade/samples/001/select-everyone-no-queries.txt'
sub { pt_upgrade::main(@args, "$trunk/$sample/001/select-everyone.log",
"--reports", "differences,errors,statistics") },
"$sample/001/select-everyone-no-queries.txt"
),
'Report without per-query reports'
);
$sb->wipe_clean($dbh1);
$sb->wipe_clean($dbh2);
# #############################################################################
# Issue 951: mk-upgrade "I need a db argument" error with
# compare-results-method=rows
# #############################################################################
$sb->load_file('master', 't/pt-upgrade/samples/002/tables.sql');
$sb->load_file('slave2', 't/pt-upgrade/samples/002/tables.sql');
$sb->load_file('master', "$sample/002/tables.sql");
$sb->load_file('master1', "$sample/002/tables.sql");
# Make a difference so diff_rows() is called.
# Make a difference on one host so diff_rows() is called.
$dbh1->do('insert into test.t values (5)');
ok(
no_diff(
sub { pt_upgrade::main(@args,
'h=127.1,P=12345,u=msandbox,p=msandbox,D=test', 'P=12347,D=test',
"$sample/002/no-db.log",
sub { pt_upgrade::main(@op_args, "$log/002/no-db.log",
'h=127.1,P=12345,D=test', 'P=12348,D=test',
qw(--compare-results-method rows --temp-database test)) },
't/pt-upgrade/samples/002/report-01.txt',
"$sample/002/report-01.txt",
),
'No db, compare results row, DSN D, --temp-database (issue 951)'
);
$sb->load_file('master', 't/pt-upgrade/samples/002/tables.sql');
$sb->load_file('slave2', 't/pt-upgrade/samples/002/tables.sql');
$sb->load_file('master', "$sample/002/tables.sql");
$sb->load_file('master1', "$sample/002/tables.sql");
$dbh1->do('insert into test.t values (5)');
ok(
no_diff(
sub { pt_upgrade::main(@args,
'h=127.1,P=12345,u=msandbox,p=msandbox,D=test', 'P=12347,D=test',
"$sample/002/no-db.log",
sub { pt_upgrade::main(@op_args, "$log/002/no-db.log",
'h=127.1,P=12345,D=test', 'P=12348,D=test',
qw(--compare-results-method rows --temp-database tmp_db)) },
't/pt-upgrade/samples/002/report-01.txt',
"$sample/002/report-01.txt",
),
'No db, compare results row, DSN D'
);
@@ -136,6 +149,35 @@ is_deeply(
"Createed temp table in --temp-database"
);
$sb->wipe_clean($dbh1);
$sb->wipe_clean($dbh2);
# #############################################################################
# Bug 926598: DBD::mysql bug causes pt-upgrade to use wrong
# precision (M) and scale (D)
# #############################################################################
$sb->load_file('master', "$sample/003/tables.sql");
$sb->load_file('master1', "$sample/003/tables.sql");
# Make a difference on one host so diff_rows() is called.
$dbh1->do('insert into test.t values (4, 1.00)');
ok(
no_diff(
sub { pt_upgrade::main(@args, "$log/003/double.log",
qw(--compare-results-method rows)) },
"$sample/003/report001.txt",
),
'M, D diff (bug 926598)',
);
my $row = $dbh1->selectrow_arrayref("show create table test.mk_upgrade_left");
like(
$row->[1],
qr/`SUM\(total\)`\s+double\sDEFAULT/,
"No M,D in table def (bug 926598)"
);
# #############################################################################
# Done.
# #############################################################################

View File

@@ -16,12 +16,12 @@ use Sandbox;
require "$trunk/bin/pt-upgrade";
# This runs immediately if the server is already running, else it starts it.
diag(`$trunk/sandbox/start-sandbox master 12347 >/dev/null`);
diag(`$trunk/sandbox/start-sandbox master 12348 >/dev/null`);
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh1 = $sb->get_dbh_for('master');
my $dbh2 = $sb->get_dbh_for('slave2');
my $dbh2 = $sb->get_dbh_for('master1');
if ( !$dbh1 ) {
plan skip_all => 'Cannot connect to sandbox master';
@@ -33,7 +33,7 @@ else {
plan tests => 1;
}
my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345,u=msandbox,p=msandbox P=12347 --compare results,warnings --zero-query-times";
my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345,u=msandbox,p=msandbox P=12348 --compare results,warnings --zero-query-times";
# Issue 391: Add --pid option to all scripts
`touch /tmp/mk-script.pid`;

View File

@@ -16,12 +16,12 @@ use Sandbox;
require "$trunk/bin/pt-upgrade";
# This runs immediately if the server is already running, else it starts it.
diag(`$trunk/sandbox/start-sandbox master 12347 >/dev/null`);
diag(`$trunk/sandbox/start-sandbox master 12348 >/dev/null`);
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh1 = $sb->get_dbh_for('master');
my $dbh2 = $sb->get_dbh_for('slave2');
my $dbh2 = $sb->get_dbh_for('master1');
if ( !$dbh1 ) {
plan skip_all => 'Cannot connect to sandbox master';
@@ -34,11 +34,11 @@ else {
}
$sb->load_file('master', 't/pt-upgrade/samples/001/tables.sql');
$sb->load_file('slave2', 't/pt-upgrade/samples/001/tables.sql');
$sb->load_file('master1', 't/pt-upgrade/samples/001/tables.sql');
# Issue 747: Make mk-upgrade rewrite non-SELECT
my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345 P=12347 -u msandbox -p msandbox --compare results,warnings --zero-query-times --convert-to-select --fingerprints";
my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345 P=12348 -u msandbox -p msandbox --compare results,warnings --zero-query-times --convert-to-select --fingerprints";
my $c1 = $dbh1->selectrow_arrayref('checksum table test.t')->[1];
my $c2 = $dbh2->selectrow_arrayref('checksum table test.t')->[1];

View File

@@ -8,7 +8,7 @@
# warning counts 0
# warning levels 0
# warnings 0
# 127.1:12345 127.1:12347
# 127.1:12345 127.1:12348
# Errors 0 0
# Warnings 0 0
# Query_time
@@ -42,7 +42,7 @@ select * from t where id is not null
# warning counts 0
# warning levels 0
# warnings 0
# 127.1:12345 127.1:12347
# 127.1:12345 127.1:12348
# Errors 0 0
# Warnings 0 0
# Query_time
@@ -75,7 +75,7 @@ select id from test.t where id > 3
# warning counts 0
# warning levels 0
# warnings 0
# 127.1:12345 127.1:12347
# 127.1:12345 127.1:12348
# Errors 0 0
# Warnings 0 0
# Query_time

View File

@@ -8,7 +8,7 @@
# warning counts 0
# warning levels 0
# warnings 0
# 127.1:12345 127.1:12347
# 127.1:12345 127.1:12348
# Errors 0 0
# Warnings 0 0
# Query_time

View File

@@ -8,7 +8,7 @@
# warning counts 0
# warning levels 0
# warnings 0
# P=12345,h=127.1,p=...,u=msandbox P=12347,h=127.1,p=...,u=msandbox
# P=12345,h=127.1,p=...,u=msandbox P=12348,h=127.1,p=...,u=msandbox
# Errors 1 1
# Warnings 1 1
# Query_time
@@ -31,7 +31,7 @@ select borked
# warning counts 0
# warning levels 0
# warnings 0
# P=12345,h=127.1,p=...,u=msandbox P=12347,h=127.1,p=...,u=msandbox
# P=12345,h=127.1,p=...,u=msandbox P=12348,h=127.1,p=...,u=msandbox
# Errors 0 0
# Warnings 0 0
# Query_time
@@ -55,7 +55,7 @@ select * from t where name='jane'
# Errors
# Query ID Host Error
# ================== ================================ ========================
# 3B323396273BC4C7-1 P=12347,h=127.1,p=...,u=msandbox Failed to execute query: DBD::mysql::st execute failed: Unknown column 'borked' in 'field list' [for Statement "select borked"] at mk-upgrade line 0, <$fh> line 2.
# 3B323396273BC4C7-1 P=12348,h=127.1,p=...,u=msandbox Failed to execute query: DBD::mysql::st execute failed: Unknown column 'borked' in 'field list' [for Statement "select borked"] at mk-upgrade line 0, <$fh> line 2.
# Statistics
# CompareResults_after_execute_skipped 2

View File

@@ -8,7 +8,7 @@
# warning counts 0
# warning levels 0
# warnings 0
# P=12345,h=127.1,p=...,u=msandbox P=12347,h=127.1,p=...,u=msandbox
# P=12345,h=127.1,p=...,u=msandbox P=12348,h=127.1,p=...,u=msandbox
# Errors 1 1
# Warnings 0 0
# Query_time
@@ -31,7 +31,7 @@ select borked
# warning counts 0
# warning levels 0
# warnings 0
# P=12345,h=127.1,p=...,u=msandbox P=12347,h=127.1,p=...,u=msandbox
# P=12345,h=127.1,p=...,u=msandbox P=12348,h=127.1,p=...,u=msandbox
# Errors 0 0
# Warnings 0 0
# Query_time
@@ -55,7 +55,7 @@ select * from t where name='jane'
# Errors
# Query ID Host Error
# ================== ================================ ========================
# 3B323396273BC4C7-1 P=12347,h=127.1,p=...,u=msandbox Failed to execute query: DBD::mysql::st execute failed: Unknown column 'borked' in 'field list' [for Statement "select borked"] at ../mk-upgrade line 7059, <$fh> line 2.
# 3B323396273BC4C7-1 P=12348,h=127.1,p=...,u=msandbox Failed to execute query: DBD::mysql::st execute failed: Unknown column 'borked' in 'field list' [for Statement "select borked"] at ../mk-upgrade line 7059, <$fh> line 2.
# Statistics
# CompareResults_after_execute_skipped 2

View File

@@ -8,7 +8,7 @@
# warning counts 0
# warning levels 0
# warnings 0
# 127.1:12345 127.1:12347
# 127.1:12345 127.1:12348
# Errors 0 0
# Warnings 0 0
# Query_time

View File

@@ -8,7 +8,7 @@
# warning counts 0
# warning levels 0
# warnings 0
# 127.1:12345 127.1:12347
# 127.1:12345 127.1:12348
# Errors 0 0
# Warnings 0 0
# Query_time

View File

@@ -8,7 +8,7 @@
# warning counts 0
# warning levels 0
# warnings 0
# 127.1:12345 127.1:12347
# 127.1:12345 127.1:12348
# Errors 0 0
# Warnings 0 0
# Query_time

View File

@@ -8,7 +8,7 @@
# warning counts 0
# warning levels 0
# warnings 0
# 127.1:12345 127.1:12347
# 127.1:12345 127.1:12348
# Errors 0 0
# Warnings 0 0
# Query_time

View File

@@ -8,7 +8,7 @@
# warning counts 0
# warning levels 0
# warnings 0
# 127.1:12345 127.1:12347
# 127.1:12345 127.1:12348
# Errors 0 0
# Warnings 0 0
# Query_time

View File

@@ -8,7 +8,7 @@
# warning counts 0
# warning levels 0
# warnings 0
# 127.1:12345 127.1:12347
# 127.1:12345 127.1:12348
# Errors 0 0
# Warnings 0 0
# Query_time
@@ -34,7 +34,7 @@ select i from t where i is not null
# Row count differences
# Query ID 127.1:12345 127.1:12347
# Query ID 127.1:12345 127.1:12348
# ================== =========== ===========
# 3C830E3839B916D7-1 4 3

View File

@@ -0,0 +1,4 @@
# User@Host: root[root] @ localhost []
# Query_time: 1 Lock_time: 0 Rows_sent: 1 Rows_examined: 1
use test;
SELECT SUM(total) FROM test.t WHERE id > 0

View File

@@ -0,0 +1,42 @@
# Query 1: ID 0xC1B1E457814417E4 at byte 0 _______________________________
# Found 1 differences in 1 samples:
# column counts 0
# column types 0
# column values 1
# row counts 0
# warning counts 0
# warning levels 0
# warnings 0
# 127.1:12345 127.1:12348
# Errors 0 0
# Warnings 0 0
# Query_time
# sum 0 0
# min 0 0
# max 0 0
# avg 0 0
# pct_95 0 0
# stddev 0 0
# median 0 0
# row_count
# sum 1 1
# min 1 1
# max 1 1
# avg 1 1
# pct_95 1 1
# stddev 0 0
# median 1 1
use `test`;
SELECT SUM(total) FROM test.t WHERE id > 0
/* C1B1E457814417E4-1 */ SELECT SUM(total) FROM test.t WHERE id > 0
# Column value differences
# Query ID Column 127.1:12345 127.1:12348
# ================== ========== =========== ===========
# C1B1E457814417E4-1 SUM(total) 14.68 13.68
# Statistics
# events 1

View File

@@ -0,0 +1,11 @@
DROP DATABASE IF EXISTS test;
CREATE DATABASE test;
USE test;
CREATE TABLE t (
id INT NOT NULL PRIMARY KEY,
total DOUBLE NOT NULL
) ENGINE=InnoDB;
INSERT INTO test.t VALUES
(1, 1.23),
(2, 4.56),
(3, 7.89);

View File

@@ -16,12 +16,12 @@ use Sandbox;
require "$trunk/bin/pt-upgrade";
# This runs immediately if the server is already running, else it starts it.
diag(`$trunk/sandbox/start-sandbox master 12347 >/dev/null`);
diag(`$trunk/sandbox/start-sandbox master 12348 >/dev/null`);
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh1 = $sb->get_dbh_for('master');
my $dbh2 = $sb->get_dbh_for('slave2');
my $dbh2 = $sb->get_dbh_for('master1');
if ( !$dbh1 ) {
plan skip_all => 'Cannot connect to sandbox master';
@@ -34,9 +34,9 @@ else {
}
$sb->load_file('master', 't/pt-upgrade/samples/001/tables.sql');
$sb->load_file('slave2', 't/pt-upgrade/samples/001/tables.sql');
$sb->load_file('master1', 't/pt-upgrade/samples/001/tables.sql');
my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345,u=msandbox,p=msandbox P=12347 --compare results,warnings --zero-query-times";
my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345,u=msandbox,p=msandbox P=12348 --compare results,warnings --zero-query-times";
# Test that non-SELECT queries are skipped by default.
ok(

View File

@@ -16,12 +16,12 @@ use Sandbox;
require "$trunk/bin/pt-upgrade";
# This runs immediately if the server is already running, else it starts it.
diag(`$trunk/sandbox/start-sandbox master 12347 >/dev/null`);
diag(`$trunk/sandbox/start-sandbox master 12348 >/dev/null`);
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh1 = $sb->get_dbh_for('master');
my $dbh2 = $sb->get_dbh_for('slave2');
my $dbh2 = $sb->get_dbh_for('master1');
if ( !$dbh1 ) {
plan skip_all => 'Cannot connect to sandbox master';
@@ -34,10 +34,10 @@ else {
}
$sb->load_file('master', 't/pt-upgrade/samples/001/tables.sql');
$sb->load_file('slave2', 't/pt-upgrade/samples/001/tables.sql');
$sb->load_file('master1', 't/pt-upgrade/samples/001/tables.sql');
my $output;
my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345,u=msandbox,p=msandbox P=12347 --compare results,warnings --zero-query-times --compare-results-method rows --limit 10";
my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345,u=msandbox,p=msandbox P=12348 --compare results,warnings --zero-query-times --compare-results-method rows --limit 10";
# This test really deals with,
# http://code.google.com/p/maatkit/issues/detail?id=754
@@ -63,7 +63,7 @@ diag(`$cmd $trunk/t/pt-upgrade/samples/001/one-error.log >/dev/null 2>&1`);
$output = `$cmd $trunk/t/pt-upgrade/samples/001/one-error.log`;
like(
$output,
qr/# 3B323396273BC4C7-1 127.1:12347 Failed to execute query.+Unknown column 'borked' in 'field list' \[for Statement "select borked"\] at .+?\n\n/,
qr/# 3B323396273BC4C7-1 127.1:12348 Failed to execute query.+Unknown column 'borked' in 'field list' \[for Statement "select borked"\] at .+?\n\n/,
'--clear-warnings',
);
@@ -79,7 +79,7 @@ like(
$output = `$cmd --no-clear-warnings $trunk/t/pt-upgrade/samples/001/one-error.log`;
like(
$output,
qr/# 3B323396273BC4C7-1 127.1:12347 Failed to execute query.+Unknown column 'borked' in 'field list' \[for Statement "select borked"\] at .+?\n\n/,
qr/# 3B323396273BC4C7-1 127.1:12348 Failed to execute query.+Unknown column 'borked' in 'field list' \[for Statement "select borked"\] at .+?\n\n/,
'--no-clear-warnings'
);