Merge remove-3-tools

This commit is contained in:
Daniel Nichter
2012-12-20 17:27:38 -07:00
54 changed files with 0 additions and 10341 deletions

View File

@@ -1,319 +0,0 @@
#!/usr/bin/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 tests => 23;
use LogSplitter;
use SlowLogParser;
use PerconaTest;
my $output;
my $tmpdir = '/tmp/LogSplitter';
diag(`rm -rf $tmpdir ; mkdir $tmpdir`);
my $lp = new SlowLogParser();
my $ls = new LogSplitter(
attribute => 'foo',
base_dir => $tmpdir,
parser => $lp,
session_files => 3,
quiet => 1,
);
isa_ok($ls, 'LogSplitter');
diag(`rm -rf $tmpdir ; mkdir $tmpdir`);
# This creates an implicit test to make sure that
# split_logs() will not die if the saveto_dir already
# exists. It should just use the existing dir.
diag(`mkdir $tmpdir/1`);
$ls->split("$trunk/t/lib/samples/slowlogs/slow006.txt");
is(
$ls->{n_sessions_saved},
0,
'Parsed zero sessions for bad attribute'
);
is(
$ls->{n_events_total},
6,
'Parsed all events'
);
# #############################################################################
# Test a simple split of 6 events, 3 sessions into 3 session files.
# #############################################################################
diag(`rm -rf $tmpdir/*`);
$ls = new LogSplitter(
attribute => 'Thread_id',
base_dir => $tmpdir,
parser => $lp,
session_files => 3,
quiet => 1,
merge_sessions => 0,
);
$ls->split("$trunk/t/lib/samples/slowlogs/slow006.txt");
ok(-f "$tmpdir/1/session-1.txt", 'Basic split session 1 file exists');
ok(-f "$tmpdir/1/session-2.txt", 'Basic split session 2 file exists');
ok(-f "$tmpdir/1/session-3.txt", 'Basic split session 3 file exists');
$output = `diff $tmpdir/1/session-1.txt $trunk/t/lib/samples/slowlogs/slow006-session-1.txt`;
is(
$output,
'',
'Session 1 file has correct SQL statements'
);
$output = `diff $tmpdir/1/session-2.txt $trunk/t/lib/samples/slowlogs/slow006-session-2.txt`;
is(
$output,
'',
'Session 2 file has correct SQL statements'
);
$output = `diff $tmpdir/1/session-3.txt $trunk/t/lib/samples/slowlogs/slow006-session-3.txt`;
is(
$output,
'',
'Session 3 file has correct SQL statements'
);
# #############################################################################
# Test splitting more sessions than we can have open filehandles at once.
# #############################################################################
diag(`rm -rf $tmpdir/*`);
$ls = new LogSplitter(
attribute => 'Thread_id',
base_dir => $tmpdir,
parser => $lp,
session_files => 10,
quiet => 1,
merge_sessions => 0,
max_open_files => 200,
close_lru_files => 50,
);
$ls->split("$trunk/t/lib/samples/slowlogs/slow009.txt");
chomp($output = `ls -1 $tmpdir/1/ | wc -l`);
$output =~ s/^\s*//;
is(
$output,
2000,
'Splits 2_000 sessions'
);
$output = `cat $tmpdir/1/session-2000.txt`;
like(
$output,
qr/SELECT 2001 FROM foo/,
'2_000th session has correct SQL'
);
$output = `cat $tmpdir/1/session-12.txt`;
like(
$output, qr/SELECT 12 FROM foo\n\nSELECT 1234 FROM foo/,
'Reopened and appended to previously closed session'
);
# #############################################################################
# Test max_sessions.
# #############################################################################
diag(`rm -rf $tmpdir/*`);
$ls = new LogSplitter(
attribute => 'Thread_id',
base_dir => $tmpdir,
parser => $lp,
session_files => 10,
quiet => 1,
merge_sessions => 0,
max_sessions => 10,
);
$ls->split("$trunk/t/lib/samples/slowlogs/slow009.txt");
chomp($output = `ls -1 $tmpdir/1/ | wc -l`);
$output =~ s/^\s*//;
is(
$output,
'10',
'max_sessions works (1/3)',
);
is(
$ls->{n_sessions_saved},
'10',
'max_sessions works (2/3)'
);
is(
$ls->{n_files_total},
'10',
'max_sessions works (3/3)'
);
# #############################################################################
# Check that all filehandles are closed.
# #############################################################################
is_deeply(
$ls->{session_fhs},
[],
'Closes open fhs'
);
#diag(`rm -rf $tmpdir/*`);
#$output = `cat $trunk/t/lib/samples/slow006.txt | $trunk/t/lib/samples/log_splitter.pl`;
#like($output, qr/Parsed sessions\s+3/, 'Reads STDIN implicitly');
#diag(`rm -rf $tmpdir/*`);
#$output = `cat $trunk/t/lib/samples/slow006.txt | $trunk/t/lib/samples/log_splitter.pl -`;
#like($output, qr/Parsed sessions\s+3/, 'Reads STDIN explicitly');
#diag(`rm -rf $tmpdir/*`);
#$output = `cat $trunk/t/lib/samples/slow006.txt | $trunk/t/lib/samples/log_splitter.pl blahblah`;
#like($output, qr/Parsed sessions\s+0/, 'Does nothing if no valid logs are given');
# #############################################################################
# Test session file merging.
# #############################################################################
diag(`rm -rf $tmpdir/*`);
$ls = new LogSplitter(
attribute => 'Thread_id',
base_dir => $tmpdir,
parser => $lp,
session_files => 10,
quiet => 1,
max_open_files => 200,
);
$ls->split("$trunk/t/lib/samples/slowlogs/slow009.txt");
$output = `grep 'START SESSION' $tmpdir/sessions-*.txt | cut -d' ' -f 4 | sort -n`;
like(
$output,
qr/^1\n2\n3\n[\d\n]+2001$/,
'Merges 2_000 sessions'
);
ok(
!-d "$tmpdir/1",
'Removes tmp dirs after merging'
);
# #############################################################################
# Issue 418: mk-log-player dies trying to play statements with blank lines
# #############################################################################
# LogSplitter should pre-process queries before writing them so that they
# do not contain blank lines.
diag(`rm -rf $tmpdir/*`);
$ls = new LogSplitter(
attribute => 'Thread_id',
base_dir => $tmpdir,
parser => $lp,
quiet => 1,
session_files => 1,
);
$ls->split("$trunk/t/lib/samples/slowlogs/slow020.txt");
$output = `diff $tmpdir/sessions-1.txt $trunk/t/lib/samples/split_slow020.txt`;
is(
$output,
'',
'Collapse multiple \n and \s (issue 418)'
);
# Make sure it works for --maxsessionfiles
#diag(`rm -rf $tmpdir/*`);
#$ls = new LogSplitter(
# attribute => 'Thread_id',
# saveto_dir => "$tmpdir/",
# lp => $lp,
# verbose => 0,
# maxsessionfiles => 1,
#);
#$ls->split(['t/lib/samples/slow020.txt' ]);
#$output = `diff $tmpdir/1/session-0001 $trunk/t/lib/samples/split_slow020_msf.txt`;
#is(
# $output,
# '',
# 'Collapse multiple \n and \s with --maxsessionfiles (issue 418)'
#);
# #############################################################################
# Issue 571: Add --filter to mk-log-player
# #############################################################################
my $callback = sub {
return;
};
$ls = new LogSplitter(
attribute => 'Thread_id',
base_dir => $tmpdir,
parser => $lp,
session_files => 3,
quiet => 1,
callbacks => [$callback],
);
$ls->split("$trunk/t/lib/samples/slowlogs/slow006.txt");
is(
$ls->{n_sessions_saved},
0,
'callbacks'
);
# #############################################################################
# Issue 798: Make mk-log-player --split work without an attribute
# #############################################################################
diag(`rm -rf $tmpdir/*`);
$ls = new LogSplitter(
attribute => 'Thread_id',
split_random => 1,
base_dir => $tmpdir,
parser => $lp,
session_files => 2,
quiet => 1,
);
$ls->split("$trunk/t/lib/samples/slowlogs/slow006.txt");
$output = `diff $tmpdir/sessions-1.txt $trunk/t/lib/samples/LogSplitter/slow006-random-1.txt`;
is(
$output,
'',
'Random file 1 file has correct SQL statements'
);
$output = `diff $tmpdir/sessions-2.txt $trunk/t/lib/samples/LogSplitter/slow006-random-2.txt`;
is(
$output,
'',
'Random file 2 file has correct SQL statements'
);
# #############################################################################
# Issue 1179: mk-log-player --filter example does not work
# #############################################################################
diag(`rm -rf $tmpdir/*`);
$ls = new LogSplitter(
attribute => 'cmd',
base_dir => $tmpdir,
parser => $lp,
session_files => 2,
quiet => 1,
);
$ls->split("$trunk/t/lib/samples/binlogs/binlog010.txt");
$output = `cat $tmpdir/sessions-1.txt`;
ok(
no_diff(
$output,
"t/lib/samples/LogSplitter/binlog010.txt",
cmd_output => 1,
),
"Split binlog with RBR data (issue 1179)"
);
# #############################################################################
# Done.
# #############################################################################
diag(`rm -rf $tmpdir`);
exit;

View File

@@ -1,92 +0,0 @@
-- START SESSION Query
;
DELIMITER
ROLLBACK
use test/*!*/
SET TIMESTAMP=1289247700 ;
SET @@session.pseudo_thread_id=15 ;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1 ;
SET @@session.sql_mode=0 ;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1 ; ;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=33 ;
SET @@session.lc_time_names=0 ;
SET @@session.collation_database=DEFAULT ;
CREATE TABLE `test1` ( `kwid` int(10) unsigned NOT NULL default '0', `keyword` varchar(80) NOT NULL default ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8
SET TIMESTAMP=1289247700 ;
BEGIN
SET TIMESTAMP=1289247700 ;
INSERT INTO `test1` VALUES
(1,'watching'),(2,'poet'),(3,'просмотра'),(4,'Поэту')
COMMIT
SET TIMESTAMP=1289247700 ;
CREATE TABLE `test2` ( `kwid` int(10) unsigned NOT NULL default '0', `keyword` varchar(80) NOT NULL default ''
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SET TIMESTAMP=1289247701 ;
BEGIN
SET TIMESTAMP=1289247701 ;
INSERT INTO `test2` VALUES
(1,'watching'),(2,'poet'),(3,'просмотра'),(4,'Поэту')
COMMIT
SET TIMESTAMP=1289247988 ;
BEGIN
SET TIMESTAMP=1289247988 ;
INSERT INTO `test1` VALUES (1,'watching'),(2,'poet'),(3,'просмотра'),(4,'Поэту')
COMMIT
SET TIMESTAMP=1289247988 ;
BEGIN
SET TIMESTAMP=1289247988 ;
INSERT INTO `test2` VALUES (1,'watching'),(2,'poet'),(3,'просмотра'),(4,'Поэту')
COMMIT
SET TIMESTAMP=1289247999 ;
drop table test1
SET TIMESTAMP=1289247999 ;
drop table test2
SET TIMESTAMP=1289248000 ;
CREATE TABLE `test1` ( `kwid` int(10) unsigned NOT NULL DEFAULT '0', `keyword` varchar(80) NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8
SET TIMESTAMP=1289248000 ;
BEGIN
SET TIMESTAMP=1289248000 ;
INSERT INTO `test1` VALUES (1,'watching'),(2,'poet'),(3,'просмотра'),(4,'Поэту')
COMMIT
SET TIMESTAMP=1289248000 ;
CREATE TABLE `test2` ( `kwid` int(10) unsigned NOT NULL DEFAULT '0', `keyword` varchar(80) NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SET TIMESTAMP=1289248000 ;
BEGIN
SET TIMESTAMP=1289248000 ;
INSERT INTO `test2` VALUES (1,'watching'),(2,'poet'),(3,'просмотра'),(4,'Поэту')
COMMIT
DELIMITER
ROLLBACK ;

View File

@@ -1,12 +0,0 @@
-- START SESSION 1
use foo
SELECT col FROM foo_tbl
use bar
SELECT col FROM bar_tbl
SELECT col FROM bar_tbl

View File

@@ -1,14 +0,0 @@
-- START SESSION 2
use foo
SELECT col FROM foo_tbl
use bar
SELECT col FROM bar_tbl
use foo
SELECT col FROM foo_tbl

View File

@@ -1,19 +0,0 @@
#!/usr/bin/env perl
use strict;
require '../LogSplitter.pm';
require '../SlowLogParser.pm';
my $lp = new SlowLogParser();
my $ls = new LogSplitter(
attribute => 'Thread_id',
saveto_dir => "/tmp/logettes/",
lp => $lp,
verbose => 1,
);
my @logs;
push @logs, split(',', $ARGV[0]) if @ARGV;
$ls->split_logs(\@logs);
exit;

View File

@@ -1,6 +0,0 @@
-- MULTIPLE SESSIONS
USE `foo`
SELECT col FROM foo_tbl
-- END SESSION

View File

@@ -1,19 +0,0 @@
-- MULTIPLE SESSIONS
USE `foo`
SELECT col FROM foo_tbl
SELECT col FROM foo_tbl
USE `bar`
SELECT col FROM bar_tbl
-- END SESSION
USE `bar`
SELECT col FROM bar_tbl
SELECT col FROM bar_tbl
-- END SESSION

View File

@@ -1,14 +0,0 @@
-- START SESSION 5
use db1
SELECT * FROM foo WHERE bar = 'bar'
use db
INSERT INTO tbl VALUES (1), (2), (3)
use db2
SELECT * FROM foo

View File

@@ -1,37 +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 tests => 1;
use PerconaTest;
use Sandbox;
require "$trunk/bin/pt-log-player";
my $output;
my $tmpdir = '/tmp/mk-log-player';
my $cmd = "$trunk/bin/pt-log-player --base-dir $tmpdir";
diag(`rm -rf $tmpdir 2>/dev/null; mkdir $tmpdir`);
# #############################################################################
# Issue 571: Add --filter to mk-log-player
# #############################################################################
`$cmd --split Thread_id $trunk/t/lib/samples/binlogs/binlog001.txt --type binlog --session-files 1 --filter '\$event->{arg} && \$event->{arg} eq \"foo\"'`;
ok(
!-f "$tmpdir/sessions-1.txt",
'--filter'
);
# #############################################################################
# Done.
# #############################################################################
diag(`rm -rf $tmpdir 2>/dev/null`);
exit;

View File

@@ -1,60 +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 PerconaTest;
use Sandbox;
require "$trunk/bin/pt-log-player";
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 => 3;
}
# #############################################################################
# Issue 799: Can --set-vars unset @@SQL_MODE='NO_AUTO_VALUE_ON_ZERO'?
# #############################################################################
$sb->load_file('master', 't/pt-log-player/samples/issue_799.sql');
my $output;
$output = `$trunk/bin/pt-log-player --threads 1 --play $trunk/t/pt-log-player/samples/issue_799.txt h=127.1,P=12345,u=msandbox,p=msandbox 2>/dev/null`;
is_deeply(
$dbh->selectall_arrayref('select * from issue_799.t'),
[[0]],
"Default \@\@SQL_MODE='NO_AUTO_VALUE_ON_ZERO'"
);
$sb->load_file('master', 't/pt-log-player/samples/issue_799.sql');
$output = `$trunk/bin/pt-log-player --threads 1 --play $trunk/t/pt-log-player/samples/issue_799.txt h=127.1,P=12345,u=msandbox,p=msandbox --set-vars \@\@SQL_MODE="''"`;
is_deeply(
$dbh->selectall_arrayref('select * from issue_799.t'),
[[1]],
'--set-vars @@SQL_MODE=\'\' unsets default'
);
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($dbh);
diag(`rm -rf ./session-results-*`);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
exit;

View File

@@ -1,57 +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 PerconaTest;
use Sandbox;
require "$trunk/bin/pt-log-player";
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 => 3;
}
# #############################################################################
# Issue 903: mk-log-player --only-select does not handle comments
# #############################################################################
# This should not cause an error because the leading comment
# prevents the query from looking like a SELECT.
my $output;
$output = `$trunk/bin/pt-log-player --threads 1 --play $trunk/t/pt-log-player/samples/issue_903.txt h=127.1,P=12345,u=msandbox,p=msandbox,D=mysql 2>&1`;
like(
$output,
qr/caused an error/,
'Error without --only-select'
);
# This will cause an error now, too, because the leading comment
# is stripped.
$output = `$trunk/bin/pt-log-player --threads 1 --play $trunk/t/pt-log-player/samples/issue_903.txt h=127.1,P=12345,u=msandbox,p=msandbox,D=mysql --only-select 2>&1`;
like(
$output,
qr/caused an error/,
'Error with --only-select'
);
# #############################################################################
# Done.
# #############################################################################
diag(`rm -rf ./session-results-*`);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
exit;

View File

@@ -1,61 +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 tests => 4;
use PerconaTest;
use Sandbox;
require "$trunk/bin/pt-log-player";
my $output;
my $tmpdir = '/tmp/mk-log-player';
diag(`rm -rf $tmpdir 2>/dev/null; mkdir $tmpdir`);
# #############################################################################
# Test option sanity.
# #############################################################################
$output = `$trunk/bin/pt-log-player 2>&1`;
like(
$output,
qr/Specify at least one of --play, --split or --split-random/,
'Needs --play or --split to run'
);
$output = `$trunk/bin/pt-log-player --play foo 2>&1`;
like(
$output,
qr/Missing or invalid host/,
'--play requires host'
);
$output = `$trunk/bin/pt-log-player --play foo h=localhost --print 2>&1`;
like(
$output,
qr/foo is not a file/,
'Dies if no valid session files are given'
);
`$trunk/bin/pt-log-player --split Thread_id --base-dir $tmpdir $trunk/t/pt-log-player/samples/log001.txt`;
`$trunk/bin/pt-log-player --threads 1 --play $tmpdir/sessions-1.txt --print`;
$output = `cat $tmpdir/*`;
like(
$output,
qr/use mk_log/,
"Prints sessions' queries without DSN"
);
diag(`rm session-results-*.txt 2>/dev/null`);
# #############################################################################
# Done.
# #############################################################################
diag(`rm -rf $tmpdir 2>/dev/null`);
exit;

View File

@@ -1,98 +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 PerconaTest;
use Sandbox;
require "$trunk/bin/pt-log-player";
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 => 20;
}
my $output;
my $tmpdir = '/tmp/mk-log-player';
my $cmd = "$trunk/bin/pt-log-player --play $tmpdir -F /tmp/12345/my.sandbox.cnf h=127.1 --no-results";
diag(`rm -rf $tmpdir 2>/dev/null; mkdir $tmpdir`);
# #############################################################################
# Test that all session files gets assigned.
# #############################################################################
my @args = (qw(--dry-run --play), "$trunk/t/pt-log-player/samples/16sessions");
for my $n ( 1..16 ) {
ok(
no_diff(
sub { pt_log_player::main(@args, '--threads', $n) },
"t/pt-log-player/samples/assigned16.txt",
sed => [
"'s!$trunk/t/pt-log-player/samples/16sessions/!!g'",
"'s/Process [0-9]* plays //g'",
],
sort => '',
),
"Assigned 16 sessions to $n threads"
);
}
# #############################################################################
# Test session playing.
# #############################################################################
$sb->load_file('master', 't/pt-log-player/samples/log.sql');
`$trunk/bin/pt-log-player --base-dir $tmpdir --session-files 2 --split Thread_id $trunk/t/pt-log-player/samples/log001.txt`;
`$cmd`;
is_deeply(
$dbh->selectall_arrayref('select * from mk_log_player_1.tbl1 where a = 100 OR a = 555;'),
[[100], [555]],
'--play made table changes',
);
$sb->load_file('master', 't/pt-log-player/samples/log.sql');
`$cmd --only-select`;
is_deeply(
$dbh->selectall_arrayref('select * from mk_log_player_1.tbl1 where a = 100 OR a = 555;'),
[],
'No table changes with --only-select',
);
# #############################################################################
# Issue 418: mk-log-player dies trying to play statements with blank lines
# #############################################################################
diag(`rm -rf $tmpdir 2>/dev/null; mkdir $tmpdir`);
`$trunk/bin/pt-log-player --split Thread_id --base-dir $tmpdir $trunk/t/lib/samples/slowlogs/slow020.txt`;
ok(
no_diff(
"$cmd --threads 1 --print",
"t/pt-log-player/samples/play_slow020.txt",
),
'Play session from log with blank lines in queries (issue 418)'
);
diag(`rm session-results-*.txt 2>/dev/null`);
# #############################################################################
# Done.
# #############################################################################
diag(`rm -rf $tmpdir 2>/dev/null`);
$sb->wipe_clean($dbh);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
exit;

View File

@@ -1,17 +0,0 @@
Found 16 session files.
s01
s02
s03
s04
s05
s06
s07
s08
s09
s10
s11
s12
s13
s14
s15
s16

View File

@@ -1,4 +0,0 @@
drop database if exists issue_799;
create database issue_799;
use issue_799;
create table t (i int auto_increment unique key);

View File

@@ -1,4 +0,0 @@
-- START SESSION 1
insert into issue_799.t values (0)

View File

@@ -1 +0,0 @@
/* I'm a comment! */ SELECT a FROM tbl1;

View File

@@ -1,28 +0,0 @@
-- These test tables and rows are meant to be used
-- with the mk-log-player sample logs. The sample
-- logs can (should be able to be) played against
-- these dbs and tbls.
--
-- !!! Please Remember !!!
-- If you change even the smallest thing in this file,
-- you must verfiy that the tests still pass. The tests
-- rely closely on these values.
-- Thank you. :-)
DROP DATABASE IF EXISTS mk_log_player_1;
CREATE DATABASE mk_log_player_1;
USE mk_log_player_1;
DROP TABLE IF EXISTS tbl1;
CREATE TABLE tbl1 (
a INT
);
INSERT INTO tbl1 VALUES (1),(3),(5),(7),(9),(11),(13),(15),(17),(19),(21),(NULL),(0),(-10),(492),(4),(-20);
DROP DATABASE IF EXISTS mk_log_player_2;
CREATE DATABASE mk_log_player_2;
USE mk_log_player_2;
DROP TABLE IF EXISTS tbl2;
CREATE TABLE tbl2 (
a INT
);
INSERT INTO tbl2 VALUES (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(NULL);

View File

@@ -1,58 +0,0 @@
# Time: 071218 11:48:27 # User@Host: [SQL_SLAVE] @ []
# Thread_id: 1 Schema: mk_log_player_1
# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 10 Rows_examined: 10
# QC_Hit: No Full_scan: Yes Full_join: No Tmp_table: No Tmp_table_on_disk: No
# Filesort: No Filesort_on_disk: No Merge_passes: 0
# No InnoDB statistics available for this query
SELECT a FROM tbl1;
# Time: 071218 11:48:57 # User@Host: [SQL_SLAVE] @ []
# Thread_id: 1 Schema: mk_log_player_1
# Query_time: 0.000002 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
# QC_Hit: No Full_scan: No Full_join: No Tmp_table: No Tmp_table_on_disk: No
# Filesort: No Filesort_on_disk: No Merge_passes: 0
# No InnoDB statistics available for this query
# administrator command: ping;
# Time: 071218 11:48:57 # User@Host: [SQL_SLAVE] @ []
# Thread_id: 2
# Query_time: 0.010012 Lock_time: 0.000022 Rows_sent: 3 Rows_examined: 3
# QC_Hit: No Full_scan: No Full_join: No Tmp_table: No Tmp_table_on_disk: No
# Filesort: No Filesort_on_disk: No Merge_passes: 0
# No InnoDB statistics available for this query
use mk_log_player_2;
SELECT a FROM tbl2;
# Time: 071218 11:49:05 # User@Host: [SQL_SLAVE] @ []
# Thread_id: 1 Schema: mk_log_player_2
# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
# QC_Hit: No Full_scan: No Full_join: No Tmp_table: No Tmp_table_on_disk: No
# Filesort: No Filesort_on_disk: No Merge_passes: 0
# No InnoDB statistics available for this query
SELECT a FROM mk_log_player_2.tbl2;
# Time: 071218 11:49:07 # User@Host: [SQL_SLAVE] @ []
# Thread_id: 2
# Query_time: 0.000112 Lock_time: 0.000230 Rows_sent: 0 Rows_examined: 0
# QC_Hit: No Full_scan: No Full_join: No Tmp_table: No Tmp_table_on_disk: No
# Filesort: No Filesort_on_disk: No Merge_passes: 0
# No InnoDB statistics available for this query
DELETE FROM mk_log_player_2.tbl2 WHERE a IS NULL;
# Time: 071218 11:49:30 # User@Host: [SQL_SLAVE] @ []
# Thread_id: 3 Schema: mk_log_player_1
# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 1 Rows_examined: 10
# QC_Hit: No Full_scan: No Full_join: No Tmp_table: No Tmp_table_on_disk: No
# Filesort: No Filesort_on_disk: No Merge_passes: 0
# No InnoDB statistics available for this query
use mk_log_player_1;
SELECT a FROM tbl1 WHERE a = 3;
# Time: 071218 11:48:27 # User@Host: [SQL_SLAVE] @ []
# Thread_id: 1 Schema: mk_log_player_1
# Query_time: 0.000012 Lock_time: 0.021000 Rows_sent: 0 Rows_examined: 0
# QC_Hit: No Full_scan: No Full_join: No Tmp_table: No Tmp_table_on_disk: No
# Filesort: No Filesort_on_disk: No Merge_passes: 0
# No InnoDB statistics available for this query
UPDATE mk_log_player_1.tbl1 SET a = 100 WHERE a = 1;
# Time: 071218 11:48:27 # User@Host: [SQL_SLAVE] @ []
# Thread_id: 4 Schema: mk_log_player_1
# Query_time: 0.000012 Lock_time: 0.500000 Rows_sent: 0 Rows_examined: 0
# QC_Hit: No Full_scan: No Full_join: No Tmp_table: No Tmp_table_on_disk: No
# Filesort: No Filesort_on_disk: No Merge_passes: 0
# No InnoDB statistics available for this query
INSERT INTO mk_log_player_1.tbl1 VALUES (555);

View File

@@ -1,61 +0,0 @@
-- ONE SESSION
USE `mk_log_player_1`
SELECT a FROM tbl1
USE `mk_log_player_2`
SELECT a FROM mk_log_player_2.tbl2
USE `mk_log_player_1`
UPDATE mk_log_player_1.tbl1 SET a = 100 WHERE a = 1
SELECT a FROM tbl1 WHERE a < 10
SELECT * FROM tbl1 WHERE a IS NOT NULL
USE `mk_log_player_2`
SELECT * FROM tbl2 WHERE a > 2
SELECT * FROM tbl2 WHERE a < 1 AND a > 10
SELECT * FROM mk_log_player_1.tbl1 AS t1 LEFT JOIN mk_log_player_2.tbl2 AS t2 ON t1.a = t2.a
SELECT a FROM tbl2
SELECT a FROM tbl2
SELECT a FROM tbl2
SELECT a FROM tbl2
SELECT a FROM tbl2
USE `mk_log_player_1`
UPDATE mk_log_player_1.tbl1 SET a = 100 WHERE a = 1
SELECT a FROM tbl1 WHERE a < 10
SELECT * FROM tbl1 WHERE a IS NOT NULL
USE `mk_log_player_2`
SELECT * FROM tbl2 WHERE a > 2
SELECT * FROM tbl2 WHERE a < 1 AND a > 10
SELECT * FROM mk_log_player_1.tbl1 AS t1 LEFT JOIN mk_log_player_2.tbl2 AS t2 ON t1.a = t2.a
SELECT a FROM tbl2
SELECT a FROM tbl2
SELECT a FROM tbl2
SELECT a FROM tbl2
SELECT a FROM tbl2

View File

@@ -1,5 +0,0 @@
Found 1 session files.
Running processes...
All processes are running; waiting for them to finish...
Process 1 finished with exit status 0.
All processes have finished.

View File

@@ -1,18 +0,0 @@
-- START SESSION 103374
insert into test1.tbl6 (day, tbl5, misccol9type, misccol9, metric11, metric12, secs) values (convert_tz(current_timestamp,'EST5EDT','PST8PDT'), '239', 'foo', 'bar', 1, '1', '16.3574378490448') on duplicate key update metric11 = metric11 + 1, metric12 = metric12 + values(metric12), secs = secs + values(secs)
update test2.tbl8 set last2metric1 = last1metric1, last2time = last1time, last1metric1 = last0metric1, last1time = last0time, last0metric1 = ondeckmetric1, last0time = now() where tbl8 in (10800712)
-- START SESSION 104168
BEGIN
use test1
update test3.tblo as o inner join test3.tbl2 as e on o.animal = e.animal and o.oid = e.oid set e.tblo = o.tblo, e.col3 = o.col3 where e.tblo is null
replace into test4.tbl9(tbl5, day, todo, comment) select distinct o.tbl5, date(o.col3), 'misc', right('foo', 50) from test3.tblo as o inner join test3.tbl2 as e on o.animal = e.animal and o.oid = e.oid where e.tblo is not null and o.col1 > 0 and o.tbl2 is null and o.col3 >= date_sub(current_date, interval 30 day)
update test3.tblo as o inner join test3.tbl2 as e on o.animal = e.animal and o.oid = e.oid set o.tbl2 = e.tbl2, e.col9 = now() where o.tbl2 is null

View File

@@ -1,12 +0,0 @@
-- START SESSION 42
use db1
SELECT foo FROM tbl WHERE col=12345 ORDER BY col
-- START SESSION 11
use my_webstats
SELECT DISTINCT col FROM tbl WHERE foo=20061219

View File

@@ -1,82 +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 tests => 6;
use PerconaTest;
use Sandbox;
require "$trunk/bin/pt-log-player";
my $output;
my $tmpdir = '/tmp/mk-log-player';
my $cmd = "$trunk/bin/pt-log-player --base-dir $tmpdir";
diag(`rm -rf $tmpdir 2>/dev/null; mkdir $tmpdir`);
# #############################################################################
# Test log splitting.
# #############################################################################
$output = `$cmd --session-files 2 --split Thread_id $trunk/t/pt-log-player/samples/log001.txt`;
like(
$output,
qr/Sessions saved\s+4/,
'Reports 2 sessions saved'
);
ok(
-f "$tmpdir/sessions-1.txt",
"sessions-1.txt created"
);
ok(
-f "$tmpdir/sessions-2.txt",
"sessions-2.txt created"
);
chomp($output = `cat $tmpdir/sessions-[12].txt | wc -l`);
$output =~ s/^\s+//;
is(
$output,
34,
'Session files have correct number of lines'
);
# #############################################################################
# Issue 570: Integrate BinaryLogPrarser into mk-log-player
# #############################################################################
diag(`rm -rf $tmpdir/*`);
`$cmd --split Thread_id $trunk/t/lib/samples/binlogs/binlog001.txt --type binlog --session-files 1`;
$output = `diff $tmpdir/sessions-1.txt $trunk/t/pt-log-player/samples/split_binlog001.txt`;
is(
$output,
'',
'Split binlog001.txt'
);
# #############################################################################
# Issue 172: Make mk-query-digest able to read general logs
# #############################################################################
diag(`rm -rf $tmpdir/*`);
`$cmd --split Thread_id $trunk/t/lib/samples/genlogs/genlog001.txt --type genlog --session-files 1`;
$output = `diff $tmpdir/sessions-1.txt $trunk/t/pt-log-player/samples/split_genlog001.txt`;
is(
$output,
'',
'Split genlog001.txt'
);
# #############################################################################
# Done.
# #############################################################################
diag(`rm -rf $tmpdir 2>/dev/null`);
exit;

View File

@@ -1,59 +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 tests => 5;
use PerconaTest;
require "$trunk/bin/pt-log-player";
my $output;
my $tmpdir = '/tmp/mk-log-player';
diag(`rm -rf $tmpdir; mkdir $tmpdir`);
# #############################################################################
# Issue 798: Make mk-log-player --split work without an attribute
# #############################################################################
$output = `$trunk/bin/pt-log-player --base-dir $tmpdir --session-files 2 --split-random $trunk/t/lib/samples/slowlogs/slow006.txt`;
like(
$output,
qr/Events saved\s+6/,
'Reports 6 events saved'
);
ok(
-f "$tmpdir/sessions-1.txt",
"sessions-1.txt created"
);
ok(
-f "$tmpdir/sessions-2.txt",
"sessions-2.txt created"
);
$output = `diff $tmpdir/sessions-1.txt $trunk/t/lib/samples/LogSplitter/slow006-random-1.txt`;
is(
$output,
'',
'Random file 1 file has correct SQL statements'
);
$output = `diff $tmpdir/sessions-2.txt $trunk/t/lib/samples/LogSplitter/slow006-random-2.txt`;
is(
$output,
'',
'Random file 2 file has correct SQL statements'
);
# #############################################################################
# Done.
# #############################################################################
diag(`rm -rf $tmpdir`);
diag(`rm -rf ./session-results-*`);
exit;

View File

@@ -1,35 +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 tests => 1;
use PerconaTest;
use Sandbox;
require "$trunk/bin/pt-log-player";
my $output;
# #############################################################################
# Issue 391: Add --pid option to all scripts
# #############################################################################
`touch /tmp/mk-script.pid`;
$output = `$trunk/bin/pt-log-player --split Thread_id $trunk/t/lib/samples/binlog001.txt --type binlog --session-files 1 --pid /tmp/mk-script.pid 2>&1`;
like(
$output,
qr{PID file /tmp/mk-script.pid already exists},
'Dies if PID file already exists (issue 391)'
);
`rm -rf /tmp/mk-script.pid`;
# #############################################################################
# Done.
# #############################################################################
exit;

View File

@@ -1,61 +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 PerconaTest;
require "$trunk/bin/pt-tcp-model";
my @args = qw();
my $in1 = "$trunk/t/lib/samples/simple-tcpdump/";
my $in2 = "$trunk/t/pt-tcp-model/samples/in/";
my $out = "t/pt-tcp-model/samples/out/";
my $output = '';
$ENV{TZ}='MST7MDT';
# ############################################################################
# Basic queries that parse without problems.
# ############################################################################
ok(
no_diff(
sub { pt_tcp_model::main(@args, "$in1/simpletcp001.txt") },
"$out/simpletcp001.txt",
),
'Analysis for simpletcp001.txt'
);
ok(
no_diff(
sub { pt_tcp_model::main(@args, "$in2/sorted001.txt",
qw(--type requests --run-time 1)) },
"$out/sorted001.txt",
),
'Analysis for sorted001.txt (issue 1341)'
);
($output) = full_output(
sub { pt_tcp_model::main(@args,
'--type=requests', "$trunk/t/lib/samples/empty.txt"
) }
);
is(
$output,
'',
"--type=requests doesn't die on an empty file",
);
# #############################################################################
# Done.
# #############################################################################
done_testing;

View File

@@ -1,33 +0,0 @@
0 1318341891.407876 1318341891.407998 0.000122 127.0.0.1:59243
1 1318341891.408318 1318341891.408583 0.000265 127.0.0.1:59243
2 1318341893.456477 1318341893.456928 0.000451 127.0.0.1:59243
3 1318341893.457328 1318341893.457576 0.000248 127.0.0.1:59243
4 1318341893.461037 1318341893.461795 0.000758 127.0.0.1:59243
5 1318341893.462275 1318341893.463729 0.001454 127.0.0.1:59243
6 1318341893.464039 1318341893.464166 0.000127 127.0.0.1:59243
7 1318341893.464443 1318341893.464798 0.000355 127.0.0.1:59243
8 1318341893.464923 1318341893.465028 0.000105 127.0.0.1:59243
9 1318341893.465207 1318341893.465301 0.000094 127.0.0.1:59243
10 1318341893.465408 1318341893.465503 0.000095 127.0.0.1:59243
11 1318341893.465618 1318341893.465712 0.000094 127.0.0.1:59243
12 1318341893.465860 1318341893.465952 0.000092 127.0.0.1:59243
13 1318341893.466155 1318341893.466391 0.000236 127.0.0.1:59243
14 1318341893.466546 1318341893.466663 0.000117 127.0.0.1:59243
15 1318341893.466983 1318341893.467085 0.000102 127.0.0.1:59243
16 1318341893.467190 1318341893.467284 0.000094 127.0.0.1:59243
17 1318341893.467392 1318341893.467851 0.000459 127.0.0.1:59243
18 1318341893.468247 1318341893.468354 0.000107 127.0.0.1:59243
19 1318341893.468475 1318341893.468573 0.000098 127.0.0.1:59243
20 1318341893.468710 1318341893.468805 0.000095 127.0.0.1:59243
21 1318341893.468920 1318341893.469310 0.000390 127.0.0.1:59243
22 1318341893.469572 1318341893.469670 0.000098 127.0.0.1:59243
23 1318341893.469863 1318341893.469968 0.000105 127.0.0.1:59243
24 1318341893.470155 1318341893.470362 0.000207 127.0.0.1:59243
25 1318341893.470495 1318341893.470737 0.000242 127.0.0.1:59243
26 1318341893.470921 1318341893.471029 0.000108 127.0.0.1:59243
27 1318341893.471247 1318341893.471454 0.000207 127.0.0.1:59243
28 1318341893.471655 1318341893.471752 0.000097 127.0.0.1:59243
29 1318341897.750127 1318341897.752687 0.002560 127.0.0.1:59243
30 1318341900.468642 1318341900.472179 0.003537 127.0.0.1:59243
31 1318341906.516355 1318341906.521779 0.005424 127.0.0.1:59243
32 1318341914.969460 1318341914.972640 0.003180 127.0.0.1:59243

View File

@@ -1,3 +0,0 @@
0 1301965063.804195 1301965063.804465 0.000270 10.10.18.253:58297
1 1301965063.805481 1301965063.806026 0.000545 10.10.18.253:40135
2 1301965063.805801 1301965063.806003 0.000202 10.10.18.253:52726

View File

@@ -1,6 +0,0 @@
1318341891 0.00 1.256 2 2 0.000387 0.000387 0.000387 0.000026 0.000265 1.592124
1318341893 0.00 6.750 27 27 0.006635 0.006635 0.006635 0.000328 0.001454 4.000000
1318341897 0.00 0.333 1 1 0.002560 0.002560 0.002560 0.000000 0.002560 3.000000
1318341900 0.00 0.167 1 1 0.003537 0.003537 0.003537 0.000000 0.003537 6.000000
1318341906 0.00 0.125 1 1 0.005424 0.005424 0.005424 0.000000 0.005424 8.000000
1318341914 0.00 1.028 1 1 0.003180 0.003180 0.003180 0.000000 0.003180 0.972640

View File

@@ -1,35 +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 tests => 1;
use PerconaTest;
require "$trunk/bin/pt-trend";
my $in = "$trunk/t/lib/samples/slowlogs";
my $out = "t/pt-trend/samples/";
my @args = ();
$ENV{TZ}='MST7MDT';
ok(
no_diff(
sub { pt_trend::main(@args, "$in/slow053.txt") },
"$out/slow053.txt",
),
"Analysis for slow053.txt"
);
# #############################################################################
# Done.
# #############################################################################
exit;

View File

@@ -1,10 +0,0 @@
TS CNT SUM MIN MAX AVG
1297191601 1.000000 0.000012 0.000012 0.000012 0.000012
1297191602 1.000000 0.000012 0.000012 0.000012 0.000012
1297191603 1.000000 0.000012 0.000012 0.000012 0.000012
1297191604 1.000000 0.000012 0.000012 0.000012 0.000012
1297191605 1.000000 0.000012 0.000012 0.000012 0.000012
1297191606 1.000000 0.000012 0.000012 0.000012 0.000012
1297191607 1.000000 0.000012 0.000012 0.000012 0.000012
1297191608 1.000000 0.050012 0.050012 0.050012 0.050012
1297191609 1.000000 1.000012 1.000012 1.000012 1.000012