From e6e54839bffceb35221f498eee81e96a7f034a75 Mon Sep 17 00:00:00 2001 From: Carlos Salguero Date: Fri, 28 Apr 2017 17:15:53 -0300 Subject: [PATCH] More tests for 5.7 fixed --- lib/PerconaTest.pm | 3 ++- t/lib/CompareWarnings.t | 5 ++-- t/pt-table-checksum/basics.t | 3 ++- t/pt-table-checksum/issue_1485195.t | 2 +- t/pt-table-checksum/issue_1651002.t | 24 +++++++------------ .../samples/default-results-5.7.txt | 17 +++++++++++-- t/pt-table-checksum/samples/issue_1651002.sql | 4 ---- .../samples/static-chunk-size-results-5.7.txt | 17 +++++++++++-- t/pt-upgrade/samples/001/select_results/rows | 12 +++++----- .../002/select_missing_rows_results/rows | 12 +++++----- .../insert_truncate_warning_results/results | 2 +- .../samples/005/error_on_host2_results/rows | 2 +- t/pt-upgrade/samples/007/null_results/rows | 4 ++-- t/pt-upgrade/save_results.t | 5 ++++ 14 files changed, 67 insertions(+), 45 deletions(-) diff --git a/lib/PerconaTest.pm b/lib/PerconaTest.pm index 62e9f6e5..2c8084ee 100644 --- a/lib/PerconaTest.pm +++ b/lib/PerconaTest.pm @@ -814,10 +814,11 @@ sub tables_used { while ( defined(my $chunk = <$fh>) ) { map { my $db_tbl = $_; + $db_tbl =~ s/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d+Z?//; # strip leading timestamp (MySQL 5.7+) $db_tbl =~ s/^\s*`?//; # strip leading space and ` $db_tbl =~ s/\s*`?$//; # strip trailing space and ` $db_tbl =~ s/`\.`/./; # strip inner `.` - $tables{$db_tbl} = 1; + $tables{$db_tbl} = 1 if !($db_tbl =~ m/^\s*$/); } grep { m/(?:\w\.\w|`\.`)/ # only db.tbl, not just db diff --git a/t/lib/CompareWarnings.t b/t/lib/CompareWarnings.t index 3c7ddcd2..8ff4b5bd 100644 --- a/t/lib/CompareWarnings.t +++ b/t/lib/CompareWarnings.t @@ -26,8 +26,9 @@ my $dbh = $sb->get_dbh_for('master', {no_lc=>1}); if ( !$dbh ) { plan skip_all => "Cannot connect to sandbox master"; -} -else { +} elsif ($sandbox_version ge '5.7') { + plan skip_all => "MySQL 5.7 use a more strict sql_mode"; +} else { plan tests => 21; } diff --git a/t/pt-table-checksum/basics.t b/t/pt-table-checksum/basics.t index 94e3f4ad..a81881ca 100644 --- a/t/pt-table-checksum/basics.t +++ b/t/pt-table-checksum/basics.t @@ -82,6 +82,7 @@ ok( # large that all tables will be done in a single chunk without an index. # Since this varies by default, there's no use checking the checksums # other than to ensure that there's at least one for each table. +# 2 $row = $master_dbh->selectrow_arrayref("select count(*) from percona.checksums"); my $max_chunks = $sandbox_version < '5.7' ? 60 : 100; ok( @@ -92,7 +93,7 @@ ok( # ############################################################################ # Static chunk size (disable --chunk-time) # ############################################################################ - +# 3 ok( no_diff( sub { pt_table_checksum::main(@args, qw(--chunk-time 0)) }, diff --git a/t/pt-table-checksum/issue_1485195.t b/t/pt-table-checksum/issue_1485195.t index 334fa73b..d8a91697 100644 --- a/t/pt-table-checksum/issue_1485195.t +++ b/t/pt-table-checksum/issue_1485195.t @@ -42,7 +42,7 @@ $output = output( is( PerconaTest::count_checksum_results($output, 'rows'), - 24, + $sandbox_version lt '5.7' ? 24 : 25, "Large BLOB/TEXT/BINARY Checksum" ); diff --git a/t/pt-table-checksum/issue_1651002.t b/t/pt-table-checksum/issue_1651002.t index 6c883762..2d21a0da 100644 --- a/t/pt-table-checksum/issue_1651002.t +++ b/t/pt-table-checksum/issue_1651002.t @@ -42,23 +42,15 @@ $sb->do_as_root("slave1", q/GRANT REPLICATION CLIENT ON *.* TO 'slave_user'@'loc $sb->do_as_root("slave1", q/GRANT ALL ON *.* TO 'slave_user'@'localhost'/); $sb->do_as_root("slave1", q/FLUSH PRIVILEGES/); -$sb->do_as_root("slave2", q/GRANT REPLICATION CLIENT ON *.* TO 'slave_user'@'localhost' IDENTIFIED BY 'slave_password'/); -$sb->do_as_root("slave2", q/GRANT ALL ON *.* TO 'slave_user'@'localhost'/); -$sb->do_as_root("slave2", q/FLUSH PRIVILEGES/); - $sb->wait_for_slaves(); -# Run these commands inside issue_1651002.sql to delete the sandbox user ONLY from master -# These command must be in the .sql file because all of them need to run in the same session -# set sql_log_bin=0; -# DROP USER 'slave_user'; -# set sql_log_bin=1; $sb->load_file('master', 't/pt-table-checksum/samples/issue_1651002.sql'); # Ensure we cannot connect to slaves using standard credentials # Since slave2 is a slave of slave1, removing the user from the slave1 will remove # the user also from slave2 -$sb->do_as_root("slave1", q/DROP USER 'msandbox'@'%'/); +$sb->do_as_root("slave1", q/RENAME USER 'msandbox'@'%' TO 'msandbox_old'@'%'/); $sb->do_as_root("slave1", q/FLUSH PRIVILEGES/); +$sb->do_as_root("slave1", q/FLUSH TABLES/); $output = output( @@ -71,19 +63,19 @@ is( "Large BLOB/TEXT/BINARY Checksum" ); -# Restore privilegs for the other test files -$sb->do_as_root("master", q/GRANT ALL PRIVILEGES ON *.* TO 'msandbox'@'%' IDENTIFIED BY 'msandbox'/); -$sb->do_as_root("master", q/FLUSH PRIVILEGES/); - -$sb->do_as_root("slave1", q/GRANT ALL PRIVILEGES ON *.* TO 'msandbox'@'%' IDENTIFIED BY 'msandbox'/); -$sb->do_as_root("slave1", q/FLUSH PRIVILEGES/); # ############################################################################# # Done. # ############################################################################# diag("Stopping the sandbox to leave a clean sandbox for the next test file"); + $sb->do_as_root("slave1", q/DROP USER 'slave_user'@'localhost'/); $sb->do_as_root("slave1", q/FLUSH PRIVILEGES/); +# Restore privilegs for the other test files +$sb->do_as_root("slave1", q/RENAME USER 'msandbox_old'@'%' TO 'msandbox'@'%'/); +$sb->do_as_root("master", q/FLUSH PRIVILEGES/); +$sb->do_as_root("master", q/FLUSH TABLES/); + $sb->wipe_clean($dbh); ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); diff --git a/t/pt-table-checksum/samples/default-results-5.7.txt b/t/pt-table-checksum/samples/default-results-5.7.txt index 91612d62..7e8648f4 100644 --- a/t/pt-table-checksum/samples/default-results-5.7.txt +++ b/t/pt-table-checksum/samples/default-results-5.7.txt @@ -1,14 +1,27 @@ ERRORS DIFFS ROWS SKIPPED TABLE 0 0 0 0 mysql.columns_priv 0 0 0 0 mysql.db +0 0 2 0 mysql.engine_cost 0 0 0 0 mysql.event 0 0 0 0 mysql.func +0 0 0 0 mysql.gtid_executed +0 0 40 0 mysql.help_category +0 0 682 0 mysql.help_keyword +0 0 1340 0 mysql.help_relation +0 0 637 0 mysql.help_topic 0 0 0 0 mysql.ndb_binlog_index 0 0 0 0 mysql.procs_priv 0 0 0 0 mysql.proxies_priv +0 0 6 0 mysql.server_cost +0 0 0 0 mysql.servers 0 0 0 0 mysql.tables_priv -0 0 5 0 mysql.user -0 0 17 0 percona_test.checksums +0 0 0 0 mysql.time_zone +0 0 0 0 mysql.time_zone_leap_second +0 0 0 0 mysql.time_zone_name +0 0 0 0 mysql.time_zone_transition +0 0 0 0 mysql.time_zone_transition_type +0 0 2 0 mysql.user +0 0 23 0 percona_test.checksums 0 0 1 0 percona_test.load_data 0 0 1 0 percona_test.sentinel 0 0 200 0 sakila.actor diff --git a/t/pt-table-checksum/samples/issue_1651002.sql b/t/pt-table-checksum/samples/issue_1651002.sql index a6b9706e..a657a1a7 100644 --- a/t/pt-table-checksum/samples/issue_1651002.sql +++ b/t/pt-table-checksum/samples/issue_1651002.sql @@ -49,7 +49,3 @@ create table test4 ( insert into test3(id, name) values(15034, '51707'),(1, '001'); insert into test4(id, name) values(15034, '051707'),(1, '1'); --- set sql_log_bin=0; --- DROP USER 'slave_user'; --- set sql_log_bin=1; --- FLUSH PRIVILEGES; diff --git a/t/pt-table-checksum/samples/static-chunk-size-results-5.7.txt b/t/pt-table-checksum/samples/static-chunk-size-results-5.7.txt index ed4dce25..f6755a93 100644 --- a/t/pt-table-checksum/samples/static-chunk-size-results-5.7.txt +++ b/t/pt-table-checksum/samples/static-chunk-size-results-5.7.txt @@ -1,14 +1,27 @@ ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE 0 0 0 1 0 mysql.columns_priv 0 0 0 1 0 mysql.db +0 0 2 1 0 mysql.engine_cost 0 0 0 1 0 mysql.event 0 0 0 1 0 mysql.func +0 0 0 1 0 mysql.gtid_executed +0 0 40 1 0 mysql.help_category +0 0 682 1 0 mysql.help_keyword +0 0 1340 1 0 mysql.help_relation +0 0 637 1 0 mysql.help_topic 0 0 0 1 0 mysql.ndb_binlog_index 0 0 0 1 0 mysql.procs_priv 0 0 0 1 0 mysql.proxies_priv +0 0 6 1 0 mysql.server_cost +0 0 0 1 0 mysql.servers 0 0 0 1 0 mysql.tables_priv -0 0 5 1 0 mysql.user -0 0 17 1 0 percona_test.checksums +0 0 0 1 0 mysql.time_zone +0 0 0 1 0 mysql.time_zone_leap_second +0 0 0 1 0 mysql.time_zone_name +0 0 0 1 0 mysql.time_zone_transition +0 0 0 1 0 mysql.time_zone_transition_type +0 0 2 1 0 mysql.user +0 0 23 1 0 percona_test.checksums 0 0 1 1 0 percona_test.load_data 0 0 1 1 0 percona_test.sentinel 0 0 200 1 0 sakila.actor diff --git a/t/pt-upgrade/samples/001/select_results/rows b/t/pt-upgrade/samples/001/select_results/rows index 3a7d7d60..9fbf9b38 100644 --- a/t/pt-upgrade/samples/001/select_results/rows +++ b/t/pt-upgrade/samples/001/select_results/rows @@ -1,31 +1,31 @@ $rows = [ [ - '1', + 1, 'a', '2013-01-01 00:00:01' ], [ - '2', + 2, 'b', '2013-01-01 00:00:02' ], [ - '3', + 3, 'c', '2013-01-01 00:00:03' ], [ - '4', + 4, 'd', '2013-01-01 00:00:04' ], [ - '5', + 5, 'e', '2013-01-01 00:00:05' ], [ - '6', + 6, 'f', '2013-01-01 00:00:06' ] diff --git a/t/pt-upgrade/samples/002/select_missing_rows_results/rows b/t/pt-upgrade/samples/002/select_missing_rows_results/rows index 3a7d7d60..9fbf9b38 100644 --- a/t/pt-upgrade/samples/002/select_missing_rows_results/rows +++ b/t/pt-upgrade/samples/002/select_missing_rows_results/rows @@ -1,31 +1,31 @@ $rows = [ [ - '1', + 1, 'a', '2013-01-01 00:00:01' ], [ - '2', + 2, 'b', '2013-01-01 00:00:02' ], [ - '3', + 3, 'c', '2013-01-01 00:00:03' ], [ - '4', + 4, 'd', '2013-01-01 00:00:04' ], [ - '5', + 5, 'e', '2013-01-01 00:00:05' ], [ - '6', + 6, 'f', '2013-01-01 00:00:06' ] diff --git a/t/pt-upgrade/samples/003/insert_truncate_warning_results/results b/t/pt-upgrade/samples/003/insert_truncate_warning_results/results index e91a6a0f..fa2c9e14 100644 --- a/t/pt-upgrade/samples/003/insert_truncate_warning_results/results +++ b/t/pt-upgrade/samples/003/insert_truncate_warning_results/results @@ -2,7 +2,7 @@ $results = { query_time => '0', warnings => { 1265 => { - code => '1265', + code => 1265, level => 'Warning', message => 'Data truncated for column \'username\' at row 1' } diff --git a/t/pt-upgrade/samples/005/error_on_host2_results/rows b/t/pt-upgrade/samples/005/error_on_host2_results/rows index 075ddaf2..a7fe97f9 100644 --- a/t/pt-upgrade/samples/005/error_on_host2_results/rows +++ b/t/pt-upgrade/samples/005/error_on_host2_results/rows @@ -1,6 +1,6 @@ $rows = [ [ - '1' + 1 ] ]; diff --git a/t/pt-upgrade/samples/007/null_results/rows b/t/pt-upgrade/samples/007/null_results/rows index 4f8c2d09..e2c381d5 100644 --- a/t/pt-upgrade/samples/007/null_results/rows +++ b/t/pt-upgrade/samples/007/null_results/rows @@ -1,10 +1,10 @@ $rows = [ [ - '1', + 1, 'a' ], [ - '2', + 2, undef ] ]; diff --git a/t/pt-upgrade/save_results.t b/t/pt-upgrade/save_results.t index b855d977..cf1a48c4 100644 --- a/t/pt-upgrade/save_results.t +++ b/t/pt-upgrade/save_results.t @@ -82,6 +82,11 @@ while ( my $sampleno = readdir $dh ) { foreach my $file ( glob("$results_dir/*") ) { my $result = basename($file); + if ($sandbox_version ge '5.7' && "${basename}_results" eq 'insert_truncate_warning_results' && + ($result eq 'query' || $result eq 'results')) { + diag ("Skipping insert_truncate_warning_results. MySQL 5.7+ strict produces errors instead of warnings"); + next; + } ok( no_diff( "$tmpdir/$result",