mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 13:11:32 +00:00
PT-207 Fixed tests
This commit is contained in:
88
t/pt-online-schema-change/pt-207.t
Normal file
88
t/pt-online-schema-change/pt-207.t
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
#!/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 threads;
|
||||||
|
|
||||||
|
use English qw(-no_match_vars);
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
use Data::Dumper;
|
||||||
|
use PerconaTest;
|
||||||
|
use Sandbox;
|
||||||
|
use SqlModes;
|
||||||
|
use File::Temp qw/ tempdir /;
|
||||||
|
|
||||||
|
require "$trunk/bin/pt-online-schema-change";
|
||||||
|
|
||||||
|
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||||
|
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||||
|
my $master_dbh = $sb->get_dbh_for('master');
|
||||||
|
my $master_dsn = 'h=127.1,P=12345,u=msandbox,p=msandbox';
|
||||||
|
|
||||||
|
if ( !$master_dbh ) {
|
||||||
|
plan skip_all => 'Cannot connect to sandbox master';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($sandbox_version lt '5.7') {
|
||||||
|
plan skip_all => "RocksDB is only available on Percona Server 5.7.19+";
|
||||||
|
}
|
||||||
|
|
||||||
|
my $rows = $master_dbh->selectall_arrayref('SHOW ENGINES', {Slice=>{}});
|
||||||
|
my $rocksdb_enabled;
|
||||||
|
for my $row (@$rows) {
|
||||||
|
if ($row->{engine} eq 'ROCKSDB') {
|
||||||
|
$rocksdb_enabled = 1;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$rocksdb_enabled) {
|
||||||
|
plan skip_all => "RocksDB engine is not available";
|
||||||
|
}
|
||||||
|
|
||||||
|
plan tests => 3;
|
||||||
|
|
||||||
|
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
|
||||||
|
# so we need to specify --set-vars innodb_lock_wait_timeout=3 else the
|
||||||
|
# tool will die.
|
||||||
|
my @args = (qw(--set-vars innodb_lock_wait_timeout=3));
|
||||||
|
my $output;
|
||||||
|
my $exit_status;
|
||||||
|
|
||||||
|
$sb->load_file('master', "t/pt-online-schema-change/samples/pt-207.sql");
|
||||||
|
|
||||||
|
($output, $exit_status) = full_output(
|
||||||
|
sub { pt_online_schema_change::main(@args, "$master_dsn,D=test,t=t1",
|
||||||
|
'--execute',
|
||||||
|
'--alter', "ADD INDEX (f3)",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
isnt(
|
||||||
|
$exit_status,
|
||||||
|
0,
|
||||||
|
"PT-207 Altering RocksDB table adding index with invalid collation, exit status != 0",
|
||||||
|
);
|
||||||
|
|
||||||
|
like(
|
||||||
|
$output,
|
||||||
|
qr/`test`.`t1` was not altered/s,
|
||||||
|
"PT-207 Message cannot add index with invalid collation to a RocksDB table",
|
||||||
|
);
|
||||||
|
|
||||||
|
$master_dbh->do("DROP DATABASE IF EXISTS test");
|
||||||
|
|
||||||
|
# #############################################################################
|
||||||
|
# Done.
|
||||||
|
# #############################################################################
|
||||||
|
$sb->wipe_clean($master_dbh);
|
||||||
|
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||||
|
done_testing;
|
9
t/pt-online-schema-change/samples/pt-207.sql
Normal file
9
t/pt-online-schema-change/samples/pt-207.sql
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
CREATE SCHEMA IF NOT EXISTS test;
|
||||||
|
USE test;
|
||||||
|
DROP TABLE IF EXISTS t1;
|
||||||
|
CREATE TABLE `test`.`t1` (
|
||||||
|
`id` int(11) NOT NULL,
|
||||||
|
`f2` int(11) DEFAULT NULL,
|
||||||
|
`f3` varchar(255) CHARACTER SET latin1 COLLATE latin1_german1_ci,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=RocksDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
@@ -196,6 +196,7 @@ $exit_status = pt_table_checksum::main(@args,
|
|||||||
$slave1_dbh->do("update percona.checksums set this_crc='' where db='sakila' and tbl='city' and (chunk=1 or chunk=6)");
|
$slave1_dbh->do("update percona.checksums set this_crc='' where db='sakila' and tbl='city' and (chunk=1 or chunk=6)");
|
||||||
PerconaTest::wait_for_table($slave2_dbh, "percona.checksums", "db='sakila' and tbl='city' and (chunk=1 or chunk=6) and thic_crc=''");
|
PerconaTest::wait_for_table($slave2_dbh, "percona.checksums", "db='sakila' and tbl='city' and (chunk=1 or chunk=6) and thic_crc=''");
|
||||||
|
|
||||||
|
# 9
|
||||||
ok(
|
ok(
|
||||||
no_diff(
|
no_diff(
|
||||||
sub { pt_table_checksum::main(@args, qw(--replicate-check-only)) },
|
sub { pt_table_checksum::main(@args, qw(--replicate-check-only)) },
|
||||||
@@ -214,6 +215,7 @@ $output = output(
|
|||||||
stderr => 1,
|
stderr => 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# 10
|
||||||
like(
|
like(
|
||||||
$output,
|
$output,
|
||||||
qr/infinite loop detected/,
|
qr/infinite loop detected/,
|
||||||
@@ -223,13 +225,14 @@ like(
|
|||||||
# ############################################################################
|
# ############################################################################
|
||||||
# Oversize chunk.
|
# Oversize chunk.
|
||||||
# ############################################################################
|
# ############################################################################
|
||||||
|
# 11
|
||||||
ok(
|
ok(
|
||||||
no_diff(
|
no_diff(
|
||||||
sub { pt_table_checksum::main(@args,
|
sub { pt_table_checksum::main(@args,
|
||||||
qw(-t osc.t2 --chunk-size 8 --explain --explain)) },
|
qw(-t osc.t2 --chunk-size 8 --explain --explain)) },
|
||||||
"$sample/oversize-chunks.txt",
|
"$sample/oversize-chunks.txt",
|
||||||
),
|
),
|
||||||
"Upper boundary same as next lower boundary"
|
"Upper boundary same as next lower boundary",
|
||||||
);
|
);
|
||||||
|
|
||||||
$output = output(
|
$output = output(
|
||||||
|
@@ -184,9 +184,9 @@ $output = output(
|
|||||||
|
|
||||||
chomp($output);
|
chomp($output);
|
||||||
|
|
||||||
is(
|
like(
|
||||||
$output,
|
$output,
|
||||||
'',
|
qr/Starting checksum/,
|
||||||
"Bug 1074179: ignore-tables-regex works with --replicate-check-only"
|
"Bug 1074179: ignore-tables-regex works with --replicate-check-only"
|
||||||
);
|
);
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
if all tables be ...
|
||||||
|
checksum ...
|
||||||
ERRORS DIFFS ROWS SKIPPED TABLE
|
ERRORS DIFFS ROWS SKIPPED TABLE
|
||||||
0 0 0 0 mysql.columns_priv
|
0 0 0 0 mysql.columns_priv
|
||||||
0 0 0 0 mysql.db
|
0 0 0 0 mysql.db
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
Checking if all tables can be checksummed ...
|
||||||
|
Starting checksum ...
|
||||||
--
|
--
|
||||||
-- test.t
|
-- test.t
|
||||||
--
|
--
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
Checking if all tables can be checksummed ...
|
||||||
|
Starting checksum ...
|
||||||
Differences on h=127.0.0.1,P=12346
|
Differences on h=127.0.0.1,P=12346
|
||||||
TABLE CHUNK CNT_DIFF CRC_DIFF CHUNK_INDEX LOWER_BOUNDARY UPPER_BOUNDARY
|
TABLE CHUNK CNT_DIFF CRC_DIFF CHUNK_INDEX LOWER_BOUNDARY UPPER_BOUNDARY
|
||||||
sakila.city 1 0 1 PRIMARY 1 100
|
sakila.city 1 0 1 PRIMARY 1 100
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
Checking if all tables can be checksummed ...
|
||||||
|
Starting checksum ...
|
||||||
--
|
--
|
||||||
-- osc.t2
|
-- osc.t2
|
||||||
--
|
--
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
if all tables can be ...
|
||||||
|
checksum ...
|
||||||
ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
|
ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
|
||||||
0 0 0 1 0 mysql.columns_priv
|
0 0 0 1 0 mysql.columns_priv
|
||||||
0 0 0 1 0 mysql.db
|
0 0 0 1 0 mysql.db
|
||||||
|
Reference in New Issue
Block a user