pqd: Removed --execute, --execute-throttle & --mirror

This commit is contained in:
Brian Fraser
2013-01-11 13:20:19 -03:00
parent 472d850be2
commit e925a239ff
5 changed files with 12 additions and 691 deletions

View File

@@ -1,92 +0,0 @@
#!/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 Sandbox;
use PerconaTest;
require "$trunk/bin/pt-query-digest";
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh = $sb->get_dbh_for('master');
if ( !$dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
else {
plan tests => 6;
}
my $output = '';
my $cnf = 'h=127.1,P=12345,u=msandbox,p=msandbox';
my @args = qw(--report-format=query_report --limit 10 --stat);
$sb->create_dbs($dbh, [qw(test)]);
$dbh->do('use test');
$dbh->do('create table foo (a int, b int, c int)');
is_deeply(
$dbh->selectall_arrayref('select * from test.foo'),
[],
'No rows in table yet'
);
ok(
no_diff(
sub { pt_query_digest::main(@args, '--execute', $cnf,
"$trunk/t/lib/samples/slowlogs/slow018.txt") },
't/pt-query-digest/samples/slow018_execute_report_1.txt',
),
'--execute without database'
);
is_deeply(
$dbh->selectall_arrayref('select * from test.foo'),
[],
'Still no rows in table'
);
# Provide a default db to make --execute work.
$cnf .= ',D=test';
# TODO: This test is a PITA because every time the mqd output
# changes the -n of tail has to be adjusted.
#
# We tail to get everything from "Exec orig" onward. The lines
# above have the real execution time will will vary. The last 18 lines
# are sufficient to see that it actually executed without errors.
ok(
no_diff(
sub { pt_query_digest::main(@args, '--execute', $cnf,
"$trunk/t/lib/samples/slowlogs/slow018.txt") },
't/pt-query-digest/samples/slow018_execute_report_2.txt',
trf => 'tail -n 30',
sed => ["-e 's/s ##*/s/g'"],
),
'--execute with default database'
);
is_deeply(
$dbh->selectall_arrayref('select * from test.foo'),
[[qw(1 2 3)],[qw(4 5 6)]],
'Rows in table'
);
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($dbh);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
exit;

View File

@@ -1,105 +0,0 @@
#!/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 Time::HiRes qw(sleep);
use PerconaTest;
use DSNParser;
use Sandbox;
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('slave1');
if ( !$dbh1 ) {
plan skip_all => 'Cannot connect to sandbox master';
}
elsif ( !$dbh2 ) {
plan skip_all => 'Cannot connect to sandbox slave';
}
else {
plan tests => 5;
}
my $output;
my $cmd;
my $pid_file = "/tmp/pt-query-digest-mirror-test.pid";
diag(`rm $pid_file 2>/dev/null`);
# ##########################################################################
# Tests for swapping --processlist and --execute
# ##########################################################################
$dbh1->do('set global read_only=0');
$dbh2->do('set global read_only=1');
$cmd = "$trunk/bin/pt-query-digest "
. "--processlist h=127.1,P=12345,u=msandbox,p=msandbox "
. "--execute h=127.1,P=12346,u=msandbox,p=msandbox --mirror 1 "
. "--pid $pid_file";
{
local $ENV{PTDEBUG}=1;
`$cmd > /tmp/read_only.txt 2>&1 &`;
}
$dbh1->do('select sleep(1)');
$dbh1->do('set global read_only=1');
$dbh2->do('set global read_only=0');
$dbh1->do('select sleep(1)');
PerconaTest::wait_for_files($pid_file);
chomp(my $pid = `cat $pid_file`);
kill 15, $pid;
sleep 0.25;
# Verify that it's dead...
$output = `ps x | grep '^[ ]*$pid'`;
is(
$output,
'',
'It is stopped now'
);
$output = `ps -p $pid`;
unlike($output, qr/pt-query-digest/, 'It is stopped now');
$output = `grep read_only /tmp/read_only.txt`;
# Sample output:
# # main:3619 6897 read_only on execute for --execute: 1 (want 1)
# # main:3619 6897 read_only on processlist for --processlist: 0 (want 0)
# # main:3619 6897 read_only on processlist for --processlist: 0 (want 0)
# # main:3619 6897 read_only on processlist for --processlist: 0 (want 0)
# # main:3619 6897 read_only on processlist for --processlist: 0 (want 0)
# # main:3619 6897 read_only on processlist for --processlist: 0 (want 0)
# # main:3619 6897 read_only on processlist for --processlist: 0 (want 0)
# # main:3619 6897 read_only on execute for --execute: 0 (want 1)
# # main:3622 6897 read_only wrong for --execute getting a dbh from processlist
# # main:3619 6897 read_only on processlist for --processlist: 1 (want 0)
# # main:3622 6897 read_only wrong for --processlist getting a dbh from execute
# # main:3619 6897 read_only on processlist for --execute: 1 (want 1)
# # main:3619 6897 read_only on execute for --processlist: 0 (want 0)
like($output, qr/wrong for --execute getting a dbh from processlist/,
'switching --processlist works');
like($output, qr/wrong for --processlist getting a dbh from execute/,
'switching --execute works');
diag(`rm -rf /tmp/read_only.txt`);
# #############################################################################
# Done.
# #############################################################################
diag(`rm $pid_file 2>/dev/null`);
$dbh1->do('set global read_only=0');
$dbh2->do('set global read_only=1');
$sb->wipe_clean($dbh1);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
exit;

View File

@@ -1,41 +0,0 @@
# Query 1: 0 QPS, 0x concurrency, ID 0x6083030C4A5D8996 at byte 0 ________
# This item is included in the report because it matches --limit.
# Scores: Apdex = 0.50 [1.0]*, V/M = 0.00
# Query_time sparkline: | ^ |
# Time range: all events occurred at 2007-10-15 21:43:52
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 100 1
# Exec time 100 2s 2s 2s 2s 2s 0 2s
# Exec orig ti 100 2s 2s 2s 2s 2s 0 2s
# Lock time 0 0 0 0 0 0 0 0
# Rows sent 100 1 1 1 1 1 0 1
# Rows examine 0 0 0 0 0 0 0 0
# Query size 100 44 44 44 44 44 0 44
# String:
# Hosts localhost
# Users root
# Query_time distribution
# 1us
# 10us
# 100us
# 1ms
# 10ms
# 100ms
# 1s ################################################################
# 10s+
# Tables
# SHOW TABLE STATUS LIKE 'foo'\G
# SHOW CREATE TABLE `foo`\G
INSERT INTO `foo` VALUES (1, 2, 3) /*... omitted ...*/\G
# Statistic Count %/Events
# ====================================== ===== ========
# events_read 1 100.00
# events_parsed 1 100.00
# events_aggregated 1 100.00
# execute_error 1 100.00
# execute_executed 1 100.00
# execute_no_database 1 100.00
# pipeline_restarted_after_SlowLogParser 1 100.00

View File

@@ -1,30 +0,0 @@
# Exec orig ti 100 2s 2s 2s 2s 2s 0 2s
# Lock time 0 0 0 0 0 0 0 0
# Rows sent 100 1 1 1 1 1 0 1
# Rows examine 0 0 0 0 0 0 0 0
# Query size 100 44 44 44 44 44 0 44
# Exec diff ti 100 0 0 0 0 0 0 0
# String:
# Hosts localhost
# Users root
# Query_time distribution
# 1us
# 10us
# 100us
# 1ms
# 10ms
# 100ms
# 1s
# 10s+
# Tables
# SHOW TABLE STATUS LIKE 'foo'\G
# SHOW CREATE TABLE `foo`\G
INSERT INTO `foo` VALUES (1, 2, 3) /*... omitted ...*/\G
# Statistic Count %/Events
# ====================================== ===== ========
# events_read 1 100.00
# events_parsed 1 100.00
# events_aggregated 1 100.00
# execute_executed 1 100.00
# pipeline_restarted_after_SlowLogParser 1 100.00