| 1 | package Tapper::Reports::Receiver::Util; | ||||||||||||||||||||||||||||
| 2 | 12 | our $AUTHORITY = 'cpan:TAPPER'; | |||||||||||||||||||||||||||
| 3 | # ABSTRACT: Receive test reports | ||||||||||||||||||||||||||||
| 4 | 12 | $Tapper::Reports::Receiver::Util::VERSION = '5.0.2'; | |||||||||||||||||||||||||||
| 5 | 12 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 12 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 12 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 12 | ▶ | use DateTime::Format::Natural; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 12 | ▶ | use File::MimeInfo::Magic; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 12 | ▶ | use IO::Scalar; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 12 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 12 | ▶ | use YAML::Syck; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 12 | ▶ | use Devel::Backtrace; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 12 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 12 | ▶ | use Sys::Syslog; # core module since 1994 | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 12 | ▶ | use Tapper::Config; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 12 | ▶ | use Tapper::Model 'model'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 12 | ▶ | use Tapper::TAP::Harness; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 12 | extends 'Tapper::Base'; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 12 | has report => (is => 'rw'); | |||||||||||||||||||||||||||
| 26 | 12 | has tap => (is => 'rw'); | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | sub cfg | ||||||||||||||||||||||||||||
| 31 | 6 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
cfg: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 32 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||
| 33 | 6 | return Tapper::Config->subconfig(); | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 11 | ▶ | sub start_new_report { | ||||||||||||||||||||||||||
|
Subroutine
start_new_report: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | 11 | my ($self, $host, $port) = @_; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 11 | $self->report( model('ReportsDB')->resultset('Report')->new({ | |||||||||||||||||||||||||||
| 41 | peerport => $port, | ||||||||||||||||||||||||||||
| 42 | peerhost => $host, | ||||||||||||||||||||||||||||
| 43 | })); | ||||||||||||||||||||||||||||
| 44 | 11 | $self->report->insert; | |||||||||||||||||||||||||||
| 45 | 11 | my $tap = model('ReportsDB')->resultset('Tap')->new({ | |||||||||||||||||||||||||||
| 46 | tap => '', | ||||||||||||||||||||||||||||
| 47 | report_id => $self->report->id, | ||||||||||||||||||||||||||||
| 48 | }); | ||||||||||||||||||||||||||||
| 49 | 11 | $tap->insert; | |||||||||||||||||||||||||||
| 50 | 11 | return $self->report->id; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 10 | ▶ | sub tap_mimetype { | ||||||||||||||||||||||||||
|
Subroutine
tap_mimetype: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 55 | 10 | my ($self) = shift; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 10 | my $TAPH = IO::Scalar->new(\($self->tap)); | |||||||||||||||||||||||||||
| 58 | 10 | return mimetype($TAPH); | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | sub tap_is_archive | ||||||||||||||||||||||||||||
| 63 | 7 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
tap_is_archive: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 64 | 7 | my ($self) = shift; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 7 | ▶ | return $self->tap_mimetype =~ m,application/(x-)?(octet-stream|compressed|gzip), ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | sub write_tap_to_db | ||||||||||||||||||||||||||||
| 72 | 5 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
write_tap_to_db: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 73 | 5 | my ($self) = shift; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 5 | ▶ | $self->report->tap->tap_is_archive(1) if $self->tap_is_archive; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | 5 | $self->report->tap->tap( $self->tap ); | |||||||||||||||||||||||||||
| 77 | 5 | $self->report->tap->update; | |||||||||||||||||||||||||||
| 78 | 5 | return; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 5 | ▶ | sub get_suite { | ||||||||||||||||||||||||||
|
Subroutine
get_suite: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||
| 83 | 5 | my ($self, $suite_name, $suite_type) = @_; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 5 | ▶ | $suite_name ||= 'unknown'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$suite_name ||= "unknown"
MC/DC0%0/1
$suite_name ||= "unknown"
$suite_name
Truth table50%1/2
A
A= $suite_name
| |||||||||||||||||||||||||||||
| 86 | 5 | ▶ | $suite_type ||= 'software'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$suite_type ||= "software"
MC/DC0%0/1
$suite_type ||= "software"
$suite_type
Truth table50%1/2
A
A= $suite_type
| |||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 5 | my $suite = model("ReportsDB")->resultset('Suite')->search({name => $suite_name }, {rows => 1})->first; | |||||||||||||||||||||||||||
| 89 | 5 | ▶ | if (not $suite) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 4 | $suite = model("ReportsDB")->resultset('Suite')->new({ | |||||||||||||||||||||||||||
| 91 | name => $suite_name, | ||||||||||||||||||||||||||||
| 92 | type => $suite_type, | ||||||||||||||||||||||||||||
| 93 | description => "$suite_name test suite", | ||||||||||||||||||||||||||||
| 94 | }); | ||||||||||||||||||||||||||||
| 95 | 4 | $suite->insert; | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | 5 | return $suite; | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | sub create_report_sections | ||||||||||||||||||||||||||||
| 102 | 5 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
create_report_sections: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 103 | 5 | my ($self, $parsed_report) = @_; | |||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | # meta keys | ||||||||||||||||||||||||||||
| 106 | 5 | my $section_nr = 0; | |||||||||||||||||||||||||||
| 107 | 5 | foreach my $section ( @{$parsed_report->{tap_sections}} ) { | |||||||||||||||||||||||||||
| 108 | 8 | $section_nr++; | |||||||||||||||||||||||||||
| 109 | my $report_section = model('ReportsDB')->resultset('ReportSection')->new | ||||||||||||||||||||||||||||
| 110 | ({ | ||||||||||||||||||||||||||||
| 111 | report_id => $self->report->id, | ||||||||||||||||||||||||||||
| 112 | succession => $section_nr, | ||||||||||||||||||||||||||||
| 113 | name => $section->{section_name}, | ||||||||||||||||||||||||||||
| 114 | 8 | }); | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 8 | foreach (keys %{$section->{db_section_meta}}) | |||||||||||||||||||||||||||
| 117 | { | ||||||||||||||||||||||||||||
| 118 | 5 | my $value = $section->{db_section_meta}{$_}; | |||||||||||||||||||||||||||
| 119 | 5 | ▶ | $report_section->$_ ($value) if defined $value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 8 | $report_section->insert; | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | sub update_reportgroup_testrun_stats | ||||||||||||||||||||||||||||
| 128 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
update_reportgroup_testrun_stats: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 129 | 2 | my ($self, $testrun_id) = @_; | |||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 2 | my $reportgroupstats = model('ReportsDB')->resultset('ReportgroupTestrunStats')->find($testrun_id); | |||||||||||||||||||||||||||
| 132 | 2 | ▶ | unless ($reportgroupstats and $reportgroupstats->testrun_id) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$reportgroupstats and $reportgroupstats->testrun_id
MC/DC50%1/2
$reportgroupstats and $reportgroupstats->testrun_id
$reportgroupstats
$reportgroupstats->testrun_id
Truth table66%2/3
A and B
A= $reportgroupstatsB= $reportgroupstats->testrun_id
| |||||||||||||||||||||||||||||
| 133 | 1 | $reportgroupstats = model('ReportsDB')->resultset('ReportgroupTestrunStats')->new({ testrun_id => $testrun_id }); | |||||||||||||||||||||||||||
| 134 | 1 | $reportgroupstats->insert; | |||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 2 | $reportgroupstats->update_failed_passed; | |||||||||||||||||||||||||||
| 138 | 2 | $reportgroupstats->update; | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | sub create_report_groups | ||||||||||||||||||||||||||||
| 143 | 5 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
create_report_groups: called CC=6 SCAR=18.8
Pod
documented
| |||||||||||||||||||||||||||||
| 144 | 5 | my ($self, $parsed_report) = @_; | |||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | my ($reportgroup_arbitrary, | ||||||||||||||||||||||||||||
| 147 | $reportgroup_testrun, | ||||||||||||||||||||||||||||
| 148 | $reportgroup_primary, | ||||||||||||||||||||||||||||
| 149 | $owner | ||||||||||||||||||||||||||||
| 150 | ) = ( | ||||||||||||||||||||||||||||
| 151 | $parsed_report->{db_report_reportgroup_meta}{reportgroup_arbitrary}, | ||||||||||||||||||||||||||||
| 152 | $parsed_report->{db_report_reportgroup_meta}{reportgroup_testrun}, | ||||||||||||||||||||||||||||
| 153 | $parsed_report->{db_report_reportgroup_meta}{reportgroup_primary}, | ||||||||||||||||||||||||||||
| 154 | $parsed_report->{db_report_reportgroup_meta}{owner}, | ||||||||||||||||||||||||||||
| 155 | 5 | ); | |||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 5 | ▶ | if ($reportgroup_arbitrary and $reportgroup_arbitrary ne 'None') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$reportgroup_arbitrary and $reportgroup_arbitrary ne "None"
MC/DC0%0/2
$reportgroup_arbitrary and $reportgroup_arbitrary ne "None"
$reportgroup_arbitrary
$reportgroup_arbitrary ne "None"
Truth table33%1/3
A and B
A= $reportgroup_arbitraryB= $reportgroup_arbitrary ne "None"
| |||||||||||||||||||||||||||||
| 158 | 0 | my $reportgroup = model('ReportsDB')->resultset('ReportgroupArbitrary')->new | |||||||||||||||||||||||||||
| 159 | ({ | ||||||||||||||||||||||||||||
| 160 | report_id => $self->report->id, | ||||||||||||||||||||||||||||
| 161 | arbitrary_id => $reportgroup_arbitrary, | ||||||||||||||||||||||||||||
| 162 | primaryreport => $reportgroup_primary, | ||||||||||||||||||||||||||||
| 163 | owner => $owner, | ||||||||||||||||||||||||||||
| 164 | }); | ||||||||||||||||||||||||||||
| 165 | 0 | $reportgroup->insert; | |||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 5 | ▶ | if ($reportgroup_testrun and $reportgroup_testrun ne 'None') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$reportgroup_testrun and $reportgroup_testrun ne "None"
MC/DC50%1/2
$reportgroup_testrun and $reportgroup_testrun ne "None"
$reportgroup_testrun
$reportgroup_testrun ne "None"
Truth table66%2/3
A and B
A= $reportgroup_testrunB= $reportgroup_testrun ne "None"
| |||||||||||||||||||||||||||||
| 169 | 2 | ▶ | if (not $owner) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | # don't check existance of each element in the search chain | ||||||||||||||||||||||||||||
| 171 | 1 | eval { | |||||||||||||||||||||||||||
| 172 | 1 | $owner = model('TestrunDB')->resultset('Testrun')->find($reportgroup_testrun)->owner->login; | |||||||||||||||||||||||||||
| 173 | }; | ||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 2 | my $reportgroup = model('ReportsDB')->resultset('ReportgroupTestrun')->new | |||||||||||||||||||||||||||
| 177 | ({ | ||||||||||||||||||||||||||||
| 178 | report_id => $self->report->id, | ||||||||||||||||||||||||||||
| 179 | testrun_id => $reportgroup_testrun, | ||||||||||||||||||||||||||||
| 180 | primaryreport => $reportgroup_primary, | ||||||||||||||||||||||||||||
| 181 | owner => $owner, | ||||||||||||||||||||||||||||
| 182 | }); | ||||||||||||||||||||||||||||
| 183 | 2 | $reportgroup->insert; | |||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 2 | $self->update_reportgroup_testrun_stats($reportgroup_testrun); | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | sub create_report_comment | ||||||||||||||||||||||||||||
| 191 | 5 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
create_report_comment: called CC=2 SCAR=8.4
Pod
documented
| |||||||||||||||||||||||||||||
| 192 | 5 | my ($self, $parsed_report) = @_; | |||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 5 | my ($comment) = ( $parsed_report->{db_report_reportcomment_meta}{reportcomment} ); | |||||||||||||||||||||||||||
| 195 | 5 | ▶ | if ($comment) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 196 | 0 | my $reportcomment = model('ReportsDB')->resultset('ReportComment')->new | |||||||||||||||||||||||||||
| 197 | ({ | ||||||||||||||||||||||||||||
| 198 | report_id => $self->report->id, | ||||||||||||||||||||||||||||
| 199 | comment => $comment, | ||||||||||||||||||||||||||||
| 200 | succession => 1, | ||||||||||||||||||||||||||||
| 201 | }); | ||||||||||||||||||||||||||||
| 202 | 0 | $reportcomment->insert; | |||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | sub update_parsed_report_in_db | ||||||||||||||||||||||||||||
| 208 | 5 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
update_parsed_report_in_db: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||
| 209 | 5 | my ($self, $parsed_report) = @_; | |||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 12 | ▶ | no strict 'refs'; ## no critic (ProhibitNoStrict) | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | # lookup missing values in db | ||||||||||||||||||||||||||||
| 214 | $parsed_report->{db_report_meta}{suite_id} = $self->get_suite($parsed_report->{report_meta}{'suite-name'}, | ||||||||||||||||||||||||||||
| 215 | 5 | $parsed_report->{report_meta}{'suite-type'}, | |||||||||||||||||||||||||||
| 216 | )->id; | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | # report information | ||||||||||||||||||||||||||||
| 219 | 5 | foreach (keys %{$parsed_report->{db_report_meta}}) | |||||||||||||||||||||||||||
| 220 | { | ||||||||||||||||||||||||||||
| 221 | 14 | my $value = $parsed_report->{db_report_meta}{$_}; | |||||||||||||||||||||||||||
| 222 | 14 | ▶ | $self->report->$_( $value ) if defined $value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | # report information - date fields | ||||||||||||||||||||||||||||
| 226 | 5 | foreach (keys %{$parsed_report->{db_report_date_meta}}) | |||||||||||||||||||||||||||
| 227 | { | ||||||||||||||||||||||||||||
| 228 | 1 | my $value = $parsed_report->{db_report_date_meta}{$_}; | |||||||||||||||||||||||||||
| 229 | 1 | ▶ | $self->report->$_( DateTime::Format::Natural->new->parse_datetime($value ) ) if defined $value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | # success statistics | ||||||||||||||||||||||||||||
| 233 | 5 | foreach (keys %{$parsed_report->{stats}}) | |||||||||||||||||||||||||||
| 234 | { | ||||||||||||||||||||||||||||
| 235 | 45 | my $value = $parsed_report->{stats}{$_}; | |||||||||||||||||||||||||||
| 236 | 45 | ▶ | $self->report->$_( $value ) if defined $value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 5 | $self->report->update; | |||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 5 | $self->create_report_sections($parsed_report); | |||||||||||||||||||||||||||
| 242 | 5 | $self->create_report_groups($parsed_report); | |||||||||||||||||||||||||||
| 243 | 5 | $self->create_report_comment($parsed_report); | |||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | sub forward_to_level2_receivers | ||||||||||||||||||||||||||||
| 248 | 5 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
forward_to_level2_receivers: called CC=6 SCAR=18.3
Pod
documented
| |||||||||||||||||||||||||||||
| 249 | 5 | my ($self) = @_; | |||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | 5 | ▶ | my @level2_receivers = (keys %{$self->cfg->{receiver}{level2} || {}}); | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->cfg->{'receiver'}{'level2'} || {}
MC/DC100%1/1
$self->cfg->{'receiver'}{'level2'} || {}
$self->cfg->{'receiver'}{'level2'}
Truth table100%2/2
A
A= $self->cfg->{'receiver'}{'level2'}
| |||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | 5 | foreach my $l2receiver (@level2_receivers) { | |||||||||||||||||||||||||||
| 254 | 1 | $self->log->debug( "L2 receiver: $l2receiver" ); | |||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 1 | my $options = $self->cfg->{receiver}{level2}{$l2receiver}; | |||||||||||||||||||||||||||
| 257 | 1 | ▶ | next if $options->{disabled}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 1 | my $l2r_class = "Tapper::Reports::Receiver::Level2::$l2receiver"; | |||||||||||||||||||||||||||
| 260 | 1 | ▶ | eval "use $l2r_class"; ## no critic | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 261 | 1 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 262 | 0 | return "Could not load $l2r_class"; | |||||||||||||||||||||||||||
| 263 | } else { | ||||||||||||||||||||||||||||
| 264 | 12 | ▶ | no strict 'refs'; ## no critic | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 265 | 1 | $self->log->debug( "Call ${l2r_class}::submit()" ); | |||||||||||||||||||||||||||
| 266 | 1 | my ($error, $retval) = &{"${l2r_class}::submit"}($self, $self->report, $options); | |||||||||||||||||||||||||||
| 267 | 1 | ▶ | if ($error) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 268 | 0 | $self->log->error( "Error calling ${l2r_class}::submit: " . $retval ); | |||||||||||||||||||||||||||
| 269 | 0 | return $retval; | |||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | 1 | return 0; | |||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | sub process_request | ||||||||||||||||||||||||||||
| 279 | 11 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
process_request: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||||||||||
| 280 | 11 | my ($self, $tap) = @_; | |||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | 11 | $SIG{CHLD} = 'IGNORE'; | |||||||||||||||||||||||||||
| 283 | 11 | my $pid = fork(); | |||||||||||||||||||||||||||
| 284 | 11 | ▶ | if ($pid == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 285 | 5 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.3
| |||||||||||||||||||||||||||||
| 286 | 5 | $0 = "tapper-reports-receiver-".$self->report->id; | |||||||||||||||||||||||||||
| 287 | 5 | $self->log->debug("Processing ".$self->report->id); | |||||||||||||||||||||||||||
| 288 | 0 | ▶ | $SIG{USR1} = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 289 | 0 | local $SIG{USR1} = 'ignore'; # make handler reentrant, don't handle signal twice | |||||||||||||||||||||||||||
| 290 | 0 | my $backtrace = Devel::Backtrace->new(-start=>2, -format => '%I. %s'); | |||||||||||||||||||||||||||
| 291 | 0 | open my $fh, ">>", '/tmp/tapper-receiver-util-'.$self->report->id; | |||||||||||||||||||||||||||
| 292 | 0 | print $fh $backtrace; | |||||||||||||||||||||||||||
| 293 | 0 | close $fh; | |||||||||||||||||||||||||||
| 294 | 5 | }; | |||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 5 | $self->tap($tap); | |||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | 5 | $self->write_tap_to_db(); | |||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | 5 | my $harness = Tapper::TAP::Harness->new( tap => $self->tap, | |||||||||||||||||||||||||||
| 301 | tap_is_archive => $self->report->tap->tap_is_archive ); | ||||||||||||||||||||||||||||
| 302 | 5 | $harness->evaluate_report(); | |||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | 5 | $self->update_parsed_report_in_db( $harness->parsed_report ); | |||||||||||||||||||||||||||
| 305 | 5 | $self->forward_to_level2_receivers(); | |||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | # mark as processed | ||||||||||||||||||||||||||||
| 308 | 5 | $self->report->tap->processed(1); | |||||||||||||||||||||||||||
| 309 | 5 | $self->report->tap->update; | |||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | 0 | ▶ | } catch { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 312 | # We can not use log4perl, because that might throw another | ||||||||||||||||||||||||||||
| 313 | # exception e.g. when logfile is not writable | ||||||||||||||||||||||||||||
| 314 | 0 | openlog('Tapper-Reports-Receiver', 'nofatal, ndelay', 'local0'); | |||||||||||||||||||||||||||
| 315 | 0 | syslog('ALERT', "Error in processing report and can not safely log with Log4perl: $_"); | |||||||||||||||||||||||||||
| 316 | 0 | closelog(); | |||||||||||||||||||||||||||
| 317 | 5 | }; | |||||||||||||||||||||||||||
| 318 | 5 | exit 0; | |||||||||||||||||||||||||||
| 319 | } else { | ||||||||||||||||||||||||||||
| 320 | # noop in parent, return immediately | ||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | 12 | 1; | |||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | __END__ | ||||||||||||||||||||||||||||