PR-471 - Support adding explain output for slow query in JSON report as well

- Put fix into the proper place
- Added test cases
This commit is contained in:
Sveta Smirnova
2023-11-06 17:21:28 +03:00
parent ab397667e6
commit 17820dbf23
7 changed files with 909 additions and 1 deletions

View File

@@ -45,6 +45,27 @@ ok(
),
'Analysis for slow007 with --explain, no rows',
);
# output=json
SKIP: {
skip "output=json tests require 5.7" unless $sandbox_version ge '5.7';
my $jq = `which jq`;
chomp $jq;
skip "output=json tests require jq" unless -x "$jq";
ok(
no_diff(
sub { pt_query_digest::main(@args, '--output=json',
"$trunk/t/lib/samples/slowlogs/slow007.txt") },
( $sandbox_version ge '8.0' ? "t/pt-query-digest/samples/slow007_explain_json_1-80.txt"
: "t/pt-query-digest/samples/slow007_explain_json_1-57.txt"),
post_pipe => 'jq -S .',
),
'Analysis for slow007 with --explain and --output=json, no rows',
);
}
# Normalish output from EXPLAIN.
$dbh->do("insert into trees values ('apple'),('orange'),('banana')");
@@ -60,6 +81,26 @@ ok(
'Analysis for slow007 with --explain',
);
# output=json
SKIP: {
skip "output=json tests require 5.7" unless $sandbox_version ge '5.7';
my $jq = `which jq`;
chomp $jq;
skip "output=json tests require jq" unless -x "$jq";
ok(
no_diff(
sub { pt_query_digest::main(@args, '--output=json',
"$trunk/t/lib/samples/slowlogs/slow007.txt") },
( $sandbox_version ge '8.0' ? "t/pt-query-digest/samples/slow007_explain_json_2-80.txt"
: "t/pt-query-digest/samples/slow007_explain_json_2-57.txt"),
post_pipe => 'jq -S .',
),
'Analysis for slow007 with --explain and --output=json',
);
}
# #############################################################################
# Issue 1141: Add "spark charts" to mk-query-digest profile
# #############################################################################