| 1 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package Tapper::Reports::Receiver::Level2::BenchmarkAnything; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # git description: v5.0.2-1-g556a698 | ||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | our $AUTHORITY = 'cpan:SCHWIGON'; | |||||||||||||||||||||||||||||||||||||||||||||
| 7 | # ABSTRACT: Tapper - Level2 receiver plugin to forward BenchmarkAnything data | ||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | $Tapper::Reports::Receiver::Level2::BenchmarkAnything::VERSION = '5.0.3'; | |||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Data::DPath 'dpath'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Hash::Merge 'merge'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Scalar::Util 'reftype'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Tapper::Model 'model'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Tapper::Config 5.0.2; # 5.0.2 provides {_last_used_tapper_config_file} | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # TAP aggregation metrics per type | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | our @boolean_aggregation_metrics = qw(all_passed has_errors has_problems); | |||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | our @counter_aggregation_metrics = qw(failed parse_errors total passed skipped todo todo_passed); | |||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | our @textual_aggregation_metrics = qw(status); | |||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | sub submit { | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | my ($util, $report, $options) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
submit: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my $benchmark_entries_path = $options->{benchmark_entries_path}; | |||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | my $additional_metainfo_path = $options->{additional_metainfo_path}; | |||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my $store_metainfo_as_benchmarks = $options->{store_metainfo_as_benchmarks}; | |||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | my $store_testmetrics_as_benchmarks = $options->{store_testmetrics_as_benchmarks}; | |||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | return unless $benchmark_entries_path; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | try { | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | my $tap_dom = $report->get_cached_tapdom; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=45 SCAR=76.4
| |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # debug log | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my @test_metrics = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | my %test_metrics_aggregated = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | for my $section (@{$tap_dom || []}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | foreach my $section_name (keys %{$section->{section} || {}}) # there should be only one, but loop anyway... | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $section = $section->{section}{$section_name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $section_metric_name = $section_name; | |||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $section_metric_name =~ s/\.t$//; | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $section_metric_name =~ s/\W+/_/g; | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $util->log->debug("section_metric_name: $section_metric_name"); | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | # Metric name contemplation: | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | # -------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # There is a decision to make between 1) having | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | # $section_metric_name as part of the NAME field or 2) having | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | # generic NAMEs with $section_metric_name as an attribute of | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # it. | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # Here we make it part of NAME (option 1). | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | # With this it is easier to track a particular test as | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # a metric and store expectations for that test with | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # test independent attributes but consisting of the | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | # context in which we measured that metric. That | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # "scope", i.e., the fields that we use to match which | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # expectation to choose, consists then of that many | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # dimensions as we need to describe the context, | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # independent of the number of metrics we have. | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # If we had the metric as additional attribute we had | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # thousands of scope dimensions to maintain because we | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # have thousands of metric names; and we could not | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # clearly separate between the test and its context. | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # From a test philosophical perspective, that decision | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # sets the focus on the *actual result* we care for, | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # instead of some generic detail like "success". | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # From a data performance and complexity perspective, | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # I also think that having more metrics, each with | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # "normal" amount of describing attributes is better | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # distributing the data than having few generic | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # metrics with thousands of different describing | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # attributes and gazillions of data points per | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # metric. Though I'm not an expert here. | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | foreach my $entry (@boolean_aggregation_metrics, @counter_aggregation_metrics, @textual_aggregation_metrics) | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | push @test_metrics, { NAME => "tap.summary.section.${section_metric_name}.${entry}", | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | VALUE => $section->{tap}{summary}{$entry}, | |||||||||||||||||||||||||||||||||||||||||||||
| 90 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # success ratio | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my $section_total = $section->{tap}{summary}{total}; | |||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my $section_passed = $section->{tap}{summary}{passed}; | |||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | my $section_ratio = sprintf("%.2f", 100 * ($section_total == 0 ? 0 : $section_passed / $section_total)); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | push @test_metrics, { NAME => "tap.summary.section.${section_metric_name}.success_ratio", | |||||||||||||||||||||||||||||||||||||||||||||
| 97 | VALUE => $section_ratio, | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | # --- summarize all sections --- | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | # - bool metrics | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | foreach my $entry (@boolean_aggregation_metrics) { | |||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | $test_metrics_aggregated{$entry} ||= $section->{tap}{summary}{$entry}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$test_metrics_aggregated{$entry} ||= $section->{"tap"}{"summary"}{$entry}
MC/DC0%0/2
$test_metrics_aggregated{$entry} ||= $section->{"tap"}{"summary"}{$entry}
$test_metrics_aggregated{$entry}
$section->{"tap"}{"summary"}{$entry}
Truth table0%0/3
A ||= B
A= $test_metrics_aggregated{$entry}B= $section->{"tap"}{"summary"}{$entry}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # - counter metrics | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | foreach my $entry (@counter_aggregation_metrics) { | |||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | $test_metrics_aggregated{$entry} += ($section->{tap}{summary}{$entry} || 0); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$section->{'tap'}{'summary'}{$entry} || 0
MC/DC0%0/1
$section->{'tap'}{'summary'}{$entry} || 0
$section->{'tap'}{'summary'}{$entry}
Truth table0%0/2
A
A= $section->{'tap'}{'summary'}{$entry}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # - no textual aggregations of "PASS"/"FAIL"/etc. | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # Actual aggregated metrics | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # Note, that with "all.sections" containing a dot and the actual | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # metric names above not containing dots there are no collisions | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # in NAME. | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | my $suite_name = $report->suite->name || "unknown-suite-name"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$report->suite->name || 'unknown-suite-name'
MC/DC0%0/1
$report->suite->name || 'unknown-suite-name'
$report->suite->name
Truth table0%0/2
A
A= $report->suite->name
| |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | foreach my $entry (@boolean_aggregation_metrics, @counter_aggregation_metrics) { | |||||||||||||||||||||||||||||||||||||||||||||
| 120 | push @test_metrics, { NAME => "tap.summary.suite.${suite_name}.${entry}", | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | VALUE => $test_metrics_aggregated{$entry}, | |||||||||||||||||||||||||||||||||||||||||||||
| 122 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | push @test_metrics, { NAME => "tap.summary.all.${entry}", # same as general metric but with suitename as additional key | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | VALUE => $test_metrics_aggregated{$entry}, | |||||||||||||||||||||||||||||||||||||||||||||
| 125 | tapper_suite_name => $suite_name, | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # success ratios | ||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my $agg_total = $test_metrics_aggregated{total}; | |||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my $agg_passed = $test_metrics_aggregated{passed}; | |||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | my $agg_ratio = sprintf("%.2f", 100 * ($agg_total == 0 ? 0 : $agg_passed / $agg_total)); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | push @test_metrics, { NAME => "tap.summary.suite.${suite_name}.success_ratio", | |||||||||||||||||||||||||||||||||||||||||||||
| 134 | VALUE => $agg_ratio, | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | push @test_metrics, { NAME => "tap.summary.all.success_ratio", # same as general metric but with suitename as additional key | |||||||||||||||||||||||||||||||||||||||||||||
| 137 | VALUE => $agg_ratio, | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | tapper_suite_name => $suite_name, | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # You MUST localize Data::Dumper settings to strictly ONLY cover | ||||||||||||||||||||||||||||||||||||||||||||||
| 143 | # the debug output - otherwise it wrongly serializes the tap_dom | ||||||||||||||||||||||||||||||||||||||||||||||
| 144 | # cache into the DB during get_cached_tapdom(). | ||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | local $Data::Dumper::Pair = ":"; | |||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | local $Data::Dumper::Terse = 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | local $Data::Dumper::Sortkeys = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $util->log->debug("test metrics: ".Dumper(\@test_metrics)); | |||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my @benchmark_entries = dpath($benchmark_entries_path)->match($tap_dom); | |||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | @benchmark_entries = @{$benchmark_entries[0]} while $benchmark_entries[0] && reftype $benchmark_entries[0] eq "ARRAY"; # deref all array envelops | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$benchmark_entries[0] and builtin::reftype($benchmark_entries[0]) eq "ARRAY"
MC/DC0%0/2
$benchmark_entries[0] and builtin::reftype($benchmark_entries[0]) eq "ARRAY"
$benchmark_entries[0]
builtin::reftype($benchmark_entries[0]) eq "ARRAY"
Truth table0%0/3
A and B
A= $benchmark_entries[0]B= builtin::reftype($benchmark_entries[0]) eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my @metainfo_entries = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | if ($additional_metainfo_path) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 156 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | @metainfo_entries = dpath($additional_metainfo_path)->match($tap_dom); | |||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | @metainfo_entries = @{$metainfo_entries[0]} while $metainfo_entries[0] && reftype $metainfo_entries[0] eq "ARRAY"; # deref all array envelops | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$metainfo_entries[0] and builtin::reftype($metainfo_entries[0]) eq "ARRAY"
MC/DC0%0/2
$metainfo_entries[0] and builtin::reftype($metainfo_entries[0]) eq "ARRAY"
$metainfo_entries[0]
builtin::reftype($metainfo_entries[0]) eq "ARRAY"
Truth table0%0/3
A and B
A= $metainfo_entries[0]B= builtin::reftype($metainfo_entries[0]) eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | return unless @benchmark_entries; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | require BenchmarkAnything::Storage::Frontend::Lib; | |||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my $balib = BenchmarkAnything::Storage::Frontend::Lib->new(cfgfile => Tapper::Config->subconfig->{_last_used_tapper_config_file}); | |||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | my $benchmark_counter = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $balib->{queuemode} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # Part 1 - actual BenchmarkAnything data points | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | foreach my $entry (@benchmark_entries) | |||||||||||||||||||||||||||||||||||||||||||||
| 170 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | if (@metainfo_entries) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | Hash::Merge::set_behavior('LEFT_PRECEDENT'); | |||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | foreach my $metainfo (@metainfo_entries) | |||||||||||||||||||||||||||||||||||||||||||||
| 175 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | # merge each $metainfo entry into current | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | # chunk before submitting the chunk | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $entry = merge($entry, $metainfo); | |||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | # additional context info | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | $entry->{tapper_report} ||= $report->id; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$entry->{"tapper_report"} ||= $report->id
MC/DC0%0/2
$entry->{"tapper_report"} ||= $report->id
$entry->{"tapper_report"}
$report->id
Truth table0%0/3
A ||= B
A= $entry->{"tapper_report"}B= $report->id
| |||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | $entry->{tapper_testrun} ||= $report->reportgrouptestrun->testrun_id if $report->reportgrouptestrun && $report->reportgrouptestrun->testrun_id; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$report->reportgrouptestrun and $report->reportgrouptestrun->testrun_id
$entry->{"tapper_testrun"} ||= $report->reportgrouptestrun->testrun_id
MC/DC0%0/2
$report->reportgrouptestrun and $report->reportgrouptestrun->testrun_id
$report->reportgrouptestrun
$report->reportgrouptestrun->testrun_id
MC/DC0%0/2
$entry->{"tapper_testrun"} ||= $report->reportgrouptestrun->testrun_id
$entry->{"tapper_testrun"}
$report->reportgrouptestrun->testrun_id
Truth table0%0/3
A and B
A= $report->reportgrouptestrunB= $report->reportgrouptestrun->testrun_id
Truth table0%0/3
A ||= B
A= $entry->{"tapper_testrun"}B= $report->reportgrouptestrun->testrun_id
| |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | $entry->{tapper_reportgroup_arbitrary} ||= $report->reportgrouparbitrary->arbitrary_id if $report->reportgrouparbitrary && $report->reportgrouparbitrary->arbitrary_id; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$report->reportgrouparbitrary and $report->reportgrouparbitrary->arbitrary_id
$entry->{"tapper_reportgroup_arbitrary"} ||= $report->reportgrouparbitrary->arbitrary_id
MC/DC0%0/2
$report->reportgrouparbitrary and $report->reportgrouparbitrary->arbitrary_id
$report->reportgrouparbitrary
$report->reportgrouparbitrary->arbitrary_id
MC/DC0%0/2
$entry->{"tapper_reportgroup_arbitrary"} ||= $report->reportgrouparbitrary->arbitrary_id
$entry->{"tapper_reportgroup_arbitrary"}
$report->reportgrouparbitrary->arbitrary_id
Truth table0%0/3
A and B
A= $report->reportgrouparbitraryB= $report->reportgrouparbitrary->arbitrary_id
Truth table0%0/3
A ||= B
A= $entry->{"tapper_reportgroup_arbitrary"}B= $report->reportgrouparbitrary->arbitrary_id
| |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | # mark benchmkars from failed reports (and only them, for space-saving reasons) | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | $entry->{tapper_report_success} = ( $agg_ratio < 100 ? 0 : 1) if !defined $entry->{tapper_report_success}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | # debug log | ||||||||||||||||||||||||||||||||||||||||||||||
| 191 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # You MUST localize Data::Dumper settings to strictly ONLY cover | ||||||||||||||||||||||||||||||||||||||||||||||
| 193 | # the debug output - otherwise it wrongly serializes the tap_dom | ||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # cache into the DB during get_cached_tapdom(). | ||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | local $Data::Dumper::Pair = ":"; | |||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | local $Data::Dumper::Terse = 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | local $Data::Dumper::Sortkeys = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $util->log->debug("store benchmark: ".Dumper($entry)); | |||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | # actually submit data | ||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $balib->add ({BenchmarkAnythingData => [$entry]}); | |||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | $benchmark_counter++; | |||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # Part 2 - store summary numbers from test/TAP as additional metrics | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | if ($store_testmetrics_as_benchmarks) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | foreach my $entry (@test_metrics) | |||||||||||||||||||||||||||||||||||||||||||||
| 210 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | if (@metainfo_entries) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | Hash::Merge::set_behavior('LEFT_PRECEDENT'); | |||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | foreach my $metainfo (@metainfo_entries) | |||||||||||||||||||||||||||||||||||||||||||||
| 215 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 216 | # merge each $metainfo entry into current | ||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # chunk before submitting the chunk | ||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $entry = merge($entry, $metainfo); | |||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||
| 222 | # additional context info | ||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | $entry->{tapper_report} ||= $report->id; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$entry->{"tapper_report"} ||= $report->id
MC/DC0%0/2
$entry->{"tapper_report"} ||= $report->id
$entry->{"tapper_report"}
$report->id
Truth table0%0/3
A ||= B
A= $entry->{"tapper_report"}B= $report->id
| |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | $entry->{tapper_testrun} ||= $report->reportgrouptestrun->testrun_id if $report->reportgrouptestrun && $report->reportgrouptestrun->testrun_id; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$report->reportgrouptestrun and $report->reportgrouptestrun->testrun_id
$entry->{"tapper_testrun"} ||= $report->reportgrouptestrun->testrun_id
MC/DC0%0/2
$report->reportgrouptestrun and $report->reportgrouptestrun->testrun_id
$report->reportgrouptestrun
$report->reportgrouptestrun->testrun_id
MC/DC0%0/2
$entry->{"tapper_testrun"} ||= $report->reportgrouptestrun->testrun_id
$entry->{"tapper_testrun"}
$report->reportgrouptestrun->testrun_id
Truth table0%0/3
A and B
A= $report->reportgrouptestrunB= $report->reportgrouptestrun->testrun_id
Truth table0%0/3
A ||= B
A= $entry->{"tapper_testrun"}B= $report->reportgrouptestrun->testrun_id
| |||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | $entry->{tapper_reportgroup_arbitrary} ||= $report->reportgrouparbitrary->arbitrary_id if $report->reportgrouparbitrary && $report->reportgrouparbitrary->arbitrary_id; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$report->reportgrouparbitrary and $report->reportgrouparbitrary->arbitrary_id
$entry->{"tapper_reportgroup_arbitrary"} ||= $report->reportgrouparbitrary->arbitrary_id
MC/DC0%0/2
$report->reportgrouparbitrary and $report->reportgrouparbitrary->arbitrary_id
$report->reportgrouparbitrary
$report->reportgrouparbitrary->arbitrary_id
MC/DC0%0/2
$entry->{"tapper_reportgroup_arbitrary"} ||= $report->reportgrouparbitrary->arbitrary_id
$entry->{"tapper_reportgroup_arbitrary"}
$report->reportgrouparbitrary->arbitrary_id
Truth table0%0/3
A and B
A= $report->reportgrouparbitraryB= $report->reportgrouparbitrary->arbitrary_id
Truth table0%0/3
A ||= B
A= $entry->{"tapper_reportgroup_arbitrary"}B= $report->reportgrouparbitrary->arbitrary_id
| |||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | # debug log | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 229 | # You MUST localize Data::Dumper settings to strictly ONLY cover | ||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # the debug output - otherwise it wrongly serializes the tap_dom | ||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # cache into the DB during get_cached_tapdom(). | ||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | local $Data::Dumper::Pair = ":"; | |||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | local $Data::Dumper::Terse = 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | local $Data::Dumper::Sortkeys = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $util->log->debug("store test metric: ".Dumper($entry)); | |||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | # actually submit data | ||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | $balib->add ({BenchmarkAnythingData => [$entry]}); | |||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $benchmark_counter++; | |||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||
| 244 | # Part 3 - store metainfo as additional metrics | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | if ($store_metainfo_as_benchmarks) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 246 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | foreach my $entry (@metainfo_entries) | |||||||||||||||||||||||||||||||||||||||||||||
| 248 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 249 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # You MUST localize Data::Dumper settings to strictly ONLY cover | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # the debug output - otherwise it wrongly serializes the tap_dom | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | # cache into the DB during get_cached_tapdom(). | ||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | local $Data::Dumper::Pair = ":"; | |||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | local $Data::Dumper::Terse = 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | local $Data::Dumper::Sortkeys = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $util->log->debug("store metainfo: ".Dumper($entry)); | |||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $balib->add ({BenchmarkAnythingData => [$entry]}); | |||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | $benchmark_counter++; | |||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||
| 263 | # process the queue; cleanup processed queue entries; disconnect. | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | # This might take a while but we are a forked child process anyway | ||||||||||||||||||||||||||||||||||||||||||||||
| 266 | # and if we would fail the BenchmarkAnything 'processqueue' | ||||||||||||||||||||||||||||||||||||||||||||||
| 267 | # mechnanism is robust and the next child will continue. By | ||||||||||||||||||||||||||||||||||||||||||||||
| 268 | # doubling the batch size we process more than we submitted which | ||||||||||||||||||||||||||||||||||||||||||||||
| 269 | # should help cleaning up a big pile of data in case of crashes. | ||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $balib->process_raw_result_queue(2 * $benchmark_counter); | |||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $balib->gc; | |||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $balib->disconnect; | |||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||
| 275 | catch | ||||||||||||||||||||||||||||||||||||||||||||||
| 276 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | $util->log->debug("error: $_"); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | die "receiver:level2:benchmarkanything:error: $_"; | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||
| 286 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||
| 288 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||
| 290 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||
| 292 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||
| 294 | Tapper::Reports::Receiver::Level2::BenchmarkAnything - Tapper - Level2 receiver plugin to forward BenchmarkAnything data | ||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||
| 296 | =head2 submit | ||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||
| 298 | Extract BenchmarkAnything data from a report and submit them to a | ||||||||||||||||||||||||||||||||||||||||||||||
| 299 | BenchmarkAnything store. | ||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||
| 301 | =head1 ABOUT | ||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||
| 303 | I<Level 2 receivers> are other data receivers besides Tapper to | ||||||||||||||||||||||||||||||||||||||||||||||
| 304 | which data is forwarded when a report is arriving at the | ||||||||||||||||||||||||||||||||||||||||||||||
| 305 | Tapper::Reports::Receiver. | ||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||
| 307 | One example is to track benchmark values. | ||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||
| 309 | By convention, for BenchmarkAnything the data is already prepared in | ||||||||||||||||||||||||||||||||||||||||||||||
| 310 | the TAP report like this: | ||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||
| 312 | ok - measurements | ||||||||||||||||||||||||||||||||||||||||||||||
| 313 | --- | ||||||||||||||||||||||||||||||||||||||||||||||
| 314 | BenchmarkAnythingData: | ||||||||||||||||||||||||||||||||||||||||||||||
| 315 | - NAME: example.prove.duration | ||||||||||||||||||||||||||||||||||||||||||||||
| 316 | VALUE: 2.19 | ||||||||||||||||||||||||||||||||||||||||||||||
| 317 | - NAME: example.some.metric | ||||||||||||||||||||||||||||||||||||||||||||||
| 318 | VALUE: 7.00 | ||||||||||||||||||||||||||||||||||||||||||||||
| 319 | - NAME: example.some.other.metric | ||||||||||||||||||||||||||||||||||||||||||||||
| 320 | VALUE: 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 321 | ... | ||||||||||||||||||||||||||||||||||||||||||||||
| 322 | ok some other TAP stuff | ||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||
| 324 | I.e., it requires a key C<BenchmarkAnythingData> and the contained | ||||||||||||||||||||||||||||||||||||||||||||||
| 325 | array consists of chunks with keys that a BenchmarkAnything backend | ||||||||||||||||||||||||||||||||||||||||||||||
| 326 | store is expecting. | ||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||
| 328 | =head1 CONFIG | ||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||
| 330 | To activate that level2 receiver you should have an entry like this in | ||||||||||||||||||||||||||||||||||||||||||||||
| 331 | your C<tapper.cfg>: | ||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | receiver: | ||||||||||||||||||||||||||||||||||||||||||||||
| 334 | level2: | ||||||||||||||||||||||||||||||||||||||||||||||
| 335 | BenchmarkAnything: | ||||||||||||||||||||||||||||||||||||||||||||||
| 336 | # actual benchmark entries | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | benchmark_entries_path: //data/BenchmarkAnythingData | ||||||||||||||||||||||||||||||||||||||||||||||
| 338 | # optional meta info to merge into each chunk of benchmark entries | ||||||||||||||||||||||||||||||||||||||||||||||
| 339 | additional_metainfo_path: //data/PlatformDescription | ||||||||||||||||||||||||||||||||||||||||||||||
| 340 | # whether that metainfo should also stored into the benchmark store | ||||||||||||||||||||||||||||||||||||||||||||||
| 341 | store_metainfo_as_benchmarks: 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 342 | # whether test/TAP summary metrics should also stored into the benchmark store | ||||||||||||||||||||||||||||||||||||||||||||||
| 343 | store_testmetrics_as_benchmarks: 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 344 | # whether to skip that plugin | ||||||||||||||||||||||||||||||||||||||||||||||
| 345 | disabled: 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||
| 347 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||
| 349 | Steffen Schwigon <ss5@renormalist.net> | ||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||
| 351 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||
| 353 | This software is copyright (c) 2016 by Steffen Schwigon. | ||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||
| 355 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||
| 356 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||
| 358 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||