From 7da33234f5be7c844cc353e8b92758895065bb8d Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Tue, 11 Oct 2011 08:31:42 -0600 Subject: [PATCH] Fix bug 821717: pt-tcp-model --type=requests crashes. --- Changelog | 2 ++ bin/pt-tcp-model | 2 +- t/pt-tcp-model/analyses.t | 16 +++++++++--- t/pt-tcp-model/samples/in/sorted001.txt | 33 ++++++++++++++++++++++++ t/pt-tcp-model/samples/out/sorted001.txt | 6 +++++ 5 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 t/pt-tcp-model/samples/in/sorted001.txt create mode 100644 t/pt-tcp-model/samples/out/sorted001.txt diff --git a/Changelog b/Changelog index 52fe250d..292ab296 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,7 @@ Changelog for Percona Toolkit + * Fixed bug 821717: pt-tcp-model --type=requests crashes + v1.0.1 released 2011-09-01 * Fixed bug 819421: MasterSlave::is_replication_thread() doesn't match all diff --git a/bin/pt-tcp-model b/bin/pt-tcp-model index 63036fd4..a604f35e 100755 --- a/bin/pt-tcp-model +++ b/bin/pt-tcp-model @@ -1988,7 +1988,7 @@ sub main { else { printf "%s %5.2f %9.3f %5d %5d %.6f %.6f %.6f %.6f %.6f %.6f\n", @{$event}{qw( - ts concurrency throughput arrivals completions res_time + ts concurrency throughput arrivals completions busy_time weighted_time sum_time variance_mean quantile_time obs_time)}; } $pr->update($tell) if $pr; diff --git a/t/pt-tcp-model/analyses.t b/t/pt-tcp-model/analyses.t index 7b74fa45..b71b94f3 100644 --- a/t/pt-tcp-model/analyses.t +++ b/t/pt-tcp-model/analyses.t @@ -9,7 +9,7 @@ BEGIN { use strict; use warnings FATAL => 'all'; use English qw(-no_match_vars); -use Test::More tests => 1; +use Test::More tests => 2; use PerconaTest; shift @INC; # our unshift (above) @@ -18,7 +18,8 @@ shift @INC; # PerconaTest's unshift require "$trunk/bin/pt-tcp-model"; my @args = qw(); -my $in = "$trunk/t/lib/samples/simple-tcpdump/"; +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 = ''; @@ -27,12 +28,21 @@ my $output = ''; # ############################################################################ ok( no_diff( - sub { pt_tcp_model::main(@args, "$in/simpletcp001.txt") }, + 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)' +); + # ############################################################################# # Done. # ############################################################################# diff --git a/t/pt-tcp-model/samples/in/sorted001.txt b/t/pt-tcp-model/samples/in/sorted001.txt new file mode 100644 index 00000000..45223b69 --- /dev/null +++ b/t/pt-tcp-model/samples/in/sorted001.txt @@ -0,0 +1,33 @@ + 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 diff --git a/t/pt-tcp-model/samples/out/sorted001.txt b/t/pt-tcp-model/samples/out/sorted001.txt new file mode 100644 index 00000000..f6672301 --- /dev/null +++ b/t/pt-tcp-model/samples/out/sorted001.txt @@ -0,0 +1,6 @@ +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