| 1 | package Tapper::MCP::State; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 28 | our $AUTHORITY = 'cpan:TAPPER'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 28 | $Tapper::MCP::State::VERSION = '5.0.9'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 28 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 28 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 28 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 28 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 28 | ▶ | use List::Util qw/max min reduce/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 28 | ▶ | use Perl6::Junction qw/any/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 28 | ▶ | use Tapper::MCP::State::Details; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 28 | ▶ | use Tapper::Model 'model'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 28 | ▶ | use Class::Load ':all'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | has state_details => (is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 15 | ▶ | default => sub { {current_state => 'invalid'} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 28 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # needed for state comparison | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | has all_states => (is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 15 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 15 | invalid => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | started => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | reboot_install => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | installing => 4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | reboot_test => 5, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | testing => 6, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | finished => 7, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 28 | }}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | has cfg => (is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | isa => 'HashRef', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 8 | ▶ | default => sub {{}}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 28 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | has callbacks => (is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | ▶ | default => sub { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 2 | ▶ | return if not $self->cfg->{mcp_callback_handler}{plugin}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | my $class = "Tapper::MCP::State::Plugin::"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | $class .= $self->cfg->{mcp_callback_handler}{plugin}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | load_class($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | $class->new({cfg => $self->cfg}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 28 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | has valid_states => (is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 15 | ▶ | default => sub { return {'takeoff' => ['started'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 'start-install' => ['reboot_install'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 'end-install' => ['installing'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 'error-install' => ['installing'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 'warn-install' => ['installing'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 'start-guest' => ['reboot_test', 'testing'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 'error-guest' => ['reboot_test', 'testing'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 'start-testing' => ['reboot_test', 'testing'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 'end-testing' => ['testing'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 'error-testprogram' => ['testing'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 'end-testprogram' => ['testing'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 'reboot' => ['testing'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 'keep-alive' => ['ALL'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 28 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # A min implementation that handles undef as bigger than anything not smaller. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | sub mindef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 108 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mindef: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 28 | ▶ | no warnings 'uninitialized'; # written for handling undef so undef is certainly ok | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 107 | ▶ | reduce { if (not (defined $a and defined $b)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
Condition100%3/3
defined $a && defined $b
MC/DC100%2/2
defined $a && defined $b
defined $a
defined $b
Truth table100%3/3
A && B
A= defined $aB= defined $b
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 78 | { max($a,$b) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 29 | else { min($a,$b) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 108 | } @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 15 | ▶ | around BUILDARGS => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 15 | my $orig = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 15 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 15 | my $args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 15 | ▶ | if ( @_ == 1 and not $_[0] eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ == 1 and not $_[0] eq "HASH"
MC/DC50%1/2
@_ == 1 and not $_[0] eq "HASH"
@_ == 1
not $_[0] eq "HASH"
Truth table66%2/3
A and not(B)
A= @_ == 1B= not $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 8 | return $class->$orig(testrun_id => $_[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 7 | return $class->$orig(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 28 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | sub BUILD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 15 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 15 | my ($self, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 15 | $self->state_details(Tapper::MCP::State::Details->new({testrun_id => $args->{testrun_id}})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | sub is_msg_valid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 64 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_msg_valid: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 64 | my ($self, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 64 | ▶ | return 1 if $msg->{state} eq 'quit'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 61 | ▶ | return 1 if $self->valid_states->{$msg->{state}} eq 'ALL'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 61 | ▶ | if (not $self->state_details->current_state eq any(@{$self->valid_states->{$msg->{state}}})){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | my $result = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | error => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | msg => "Received $msg->{state} in state '".$self->state_details->current_state. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | "'. This message is only allowed in states ".join(", ",@{$self->valid_states->{$msg->{state}}}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | $self->state_details->results($result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 2 | ▶ | if (defined $msg->{prc_number}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | $self->state_details->prc_results($msg->{prc_number}, $result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | $self->state_details->prc_state($msg->{prc_number}, 'finished'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | ▶ | if ($self->state_details->is_all_prcs_finished()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $self->state_details->current_state('finished'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | $self->state_details->current_state('finished'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 2 | return (0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 59 | return(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | sub compare_given_state | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 6 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compare_given_state: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 6 | my ($self, $given_state) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 6 | return $self->all_states->{$given_state} <=> $self->all_states->{$self->state_details->current_state}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | sub get_current_timeout_span | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_current_timeout_span: called CC=6 SCAR=26.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 5 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 5 | my $new_timeout_date; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 5 | my $keep_alive_timeout_date = $self->state_details->keep_alive_timeout_date; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 5 | my $state = $self->state_details->current_state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | if($state =~ m{^(invalid|finished|started)$}){ $new_timeout_date = time + 60;} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 5 | elsif($state =~ m{^(reboot_install|installing)$}){$new_timeout_date = $self->state_details->installer_timeout_current_date } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | elsif($state eq 'reboot_test'){ $new_timeout_date = $self->state_details->prc_timeout_current_date(0)} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | elsif($state eq 'testing'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $new_timeout_date = $self->state_details->prc_timeout_current_date(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | for (my $prc_num = 1; $prc_num < $self->state_details->prc_count; $prc_num++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $new_timeout_date = mindef($new_timeout_date, $self->state_details->prc_timeout_current_date($prc_num)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 5 | return (mindef($new_timeout_date, $keep_alive_timeout_date) - time); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | sub state_init | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 17 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
state_init: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 17 | my ($self, $data, $revive) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 17 | ▶ | if (not $revive) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 16 | $self->state_details->state_init($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 17 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | sub update_installer_timeout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 25 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_installer_timeout: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 25 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 25 | my $now = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 25 | my $installer_timeout_date = $self->state_details->installer_timeout_current_date; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 25 | ▶ | if ( $installer_timeout_date <= $now) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 3 | my $msg = 'timeout hit '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 3 | my $state = $self->state_details->current_state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | if ($state eq 'started') { $msg .= 'during preparation. Timeout was probably too low.'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | elsif ($state eq 'reboot_install') { $msg .= 'while waiting for installer booting'} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | elsif ($state eq 'installing') { $msg .= 'while waiting for installation'} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 3 | $self->state_details->results({error => 1, msg => $msg}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 3 | $self->state_details->current_state('finished'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 3 | return (1, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 22 | return (0, $installer_timeout_date - $now); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | sub update_prc_timeout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 14 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_prc_timeout: called CC=5 SCAR=16.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 14 | my ($self, $prc_number) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 14 | my $now = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 14 | ▶ | if ($self->state_details->prc_timeout_current_date($prc_number) < $now) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | my $result = { error => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | msg => "Timeout in PRC $prc_number "}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | my $state = $self->state_details->prc_state($prc_number); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | ▶ | if ($state eq 'boot'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $result->{msg} .= 'during boot'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | $self->state_details->prc_state($prc_number, 'finished'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | elsif ($state eq 'test'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 1 | $result->{msg} .= 'while waiting for testprogram '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 1 | $result->{msg} .= $self->state_details->prc_current_test_number($prc_number); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | elsif ($state eq 'lasttest'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | $result->{msg} .= 'while waiting for message "all tests finished"'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 1 | $self->state_details->prc_state($prc_number, 'finished') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | else { return } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 2 | $self->state_details->results($result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 2 | $self->state_details->prc_results($prc_number, $result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 2 | return $self->state_details->prc_next_timeout($prc_number); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 12 | return $self->state_details->prc_timeout_current_date($prc_number) - $now; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | sub update_test_timeout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 32 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_test_timeout: called CC=9 SCAR=23.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 32 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 32 | my $now = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 32 | ▶ | if ($self->state_details->current_state eq 'reboot_test') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 7 | my $prc0_timeout_date = $self->state_details->prc_timeout_current_date(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 7 | ▶ | if ( $prc0_timeout_date <= $now) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my $msg = 'Timeout while booting testmachine'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | $self->state_details->prc_results(0, {error => 1, msg => $msg}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $self->state_details->results({error => 1, msg => $msg}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | $self->state_details->current_state('finished'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | return (1, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 7 | return (0, $prc0_timeout_date - $now); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 25 | my $new_timeout_span; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | # we need the PRC number, thus not foreach | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | PRC: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 25 | ▶ | for (my $prc_num = 0; $prc_num < $self->state_details->prc_count; $prc_num++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 68 | my $state = $self->state_details->prc_state($prc_num); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 68 | ▶ | if ($state =~ m{^(finished|preload)$}) { next PRC; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | elsif ($state eq 'boot') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 37 | ▶ | if ($self->state_details->prc_timeout_current_date($prc_num) <= $now){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | my $msg = "Timeout while booting PRC$prc_num"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $self->state_details->results({error => 1, msg => $msg}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $self->state_details->prc_results($prc_num, {error => 1, msg => $msg}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | $self->state_details->prc_state($prc_num, 'finished'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 37 | $new_timeout_span = mindef($new_timeout_span, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | $self->state_details->prc_timeout_current_date($prc_num) - time()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | elsif ($state =~ m{^(test|lasttest)$}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 14 | $new_timeout_span = mindef($new_timeout_span, $self->update_prc_timeout($prc_num)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 25 | ▶ | if ($self->state_details->is_all_prcs_finished()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 1 | $self->state_details->current_state('finished'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | return (1, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 24 | return (0, $new_timeout_span); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | sub update_keep_alive_timeout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 57 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_keep_alive_timeout: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 57 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 57 | ▶ | return (0, undef) if not defined $self->state_details->keep_alive_timeout_span; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 4 | my $timeout_cpan = $self->state_details->keep_alive_timeout_date - time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 4 | ▶ | if ($timeout_cpan > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 2 | return (0, $timeout_cpan); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 2 | ▶ | if (not $self->callbacks) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 1 | my $result = { error => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | msg => "No plugin defined in keep_alive. I deactivate keep-alive for this testrun."}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 1 | $self->state_details->results($result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 1 | $self->state_details->set_keep_alive_timeout_span( undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 1 | return (0, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 1 | return $self->callbacks->keep_alive($self->state_details); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 62 | ▶ | sub update_timeouts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_timeouts: called CC=6 SCAR=18.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 62 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 62 | my ( $error, $timeout_span ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 62 | my $state = $self->state_details->current_state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 62 | ▶ | if ($state =~ m{^(started|reboot_install|installing)$}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 25 | ( $error, $timeout_span) = $self->update_installer_timeout() } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | elsif ($state =~ m{^(reboot_test|testing)$}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 32 | ( $error, $timeout_span) = $self->update_test_timeout() } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | elsif ($state eq 'finished') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 5 | return( 1, undef) } # no timeout handling when finished | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | my $msg = 'Invalid state '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | $msg .= $self->state_details->current_state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $msg .= ' during update_timeouts'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | $self->state_details->results({error => 1, msg => $msg}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | return( 1, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 57 | my ( $alive_error, $alive_timeout_span ) = $self->update_keep_alive_timeout(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 57 | ▶ | return ($1, undef) if $error or $alive_error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$error or $alive_error
MC/DC100%2/2
$error or $alive_error
$error
$alive_error
Truth table100%3/3
A or B
A= $errorB= $alive_error
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 52 | return (0, mindef($alive_timeout_span, $timeout_span)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | sub msg_takeoff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 15 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
msg_takeoff: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 15 | my ($self, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 15 | my $timeout_span = $self->state_details->takeoff($msg->{skip_install}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 15 | return (0, $timeout_span); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | sub msg_start_install | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 10 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
msg_start_install: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 10 | my ($self, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 10 | $self->state_details->current_state('installing'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 10 | ▶ | if ($self->cfg->{autoinstall}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 1 | my $net = Tapper::MCP::Net->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | $net->write_grub_file($self->cfg->{hostname}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 1 | "timeout 2\n\ntitle Boot from first hard disc\n\tchainloader (hd0,1)+1\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 10 | return (0, $self->state_details->start_install); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | sub msg_end_install | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 6 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
msg_end_install: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 6 | my ($self, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 6 | $self->state_details->current_state('reboot_test'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 6 | $self->state_details->results({error => 0, msg => 'Installation finished'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 6 | $self->state_details->prc_state(0, 'boot'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 6 | return (0, $self->state_details->prc_boot_start(0)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | sub msg_error_install | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
msg_error_install: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | my ($self, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | $self->state_details->results({ error => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | msg => "Installation failed: ".$msg->{error}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | $self->state_details->current_state('finished'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | return (1, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | sub msg_warn_install | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
msg_warn_install: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | my ($self, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | $self->state_details->results({ error => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | msg => "Installation issue: ".$msg->{error}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | return (1, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | sub msg_error_guest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
msg_error_guest: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | my ($self, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | my $nr = $msg->{prc_number}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | $self->state_details->prc_state($nr, 'finished'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | my $result = { error => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | msg => "Starting guest $nr failed: ".$msg->{error}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | $self->state_details->results($result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | $self->state_details->prc_results( $nr, $result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | if ($self->state_details->is_all_prcs_finished()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | $self->state_details->current_state('finished'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | return (1, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | return (0, $self->state_details->get_min_prc_timeout()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | sub msg_start_guest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 10 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
msg_start_guest: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 10 | my ($self, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 10 | my $nr = $msg->{prc_number}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 10 | $self->state_details->prc_state($nr, 'boot'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 10 | $self->state_details->prc_boot_start($nr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 10 | $self->state_details->current_state('testing'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 10 | return (0, $self->state_details->get_min_prc_timeout()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | sub msg_start_testing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 7 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
msg_start_testing: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 7 | my ($self, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 7 | my $nr = $msg->{prc_number}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 7 | $self->state_details->prc_next_timeout($nr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 7 | $self->state_details->current_state('testing'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 7 | $self->state_details->prc_state($nr, 'test'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 7 | $self->state_details->prc_current_test_number($nr, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 7 | return (0, $self->state_details->get_min_prc_timeout()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | sub msg_end_testing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
msg_end_testing: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 3 | my ($self, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 3 | my $nr = $msg->{prc_number}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 3 | $self->state_details->prc_state($nr, 'finished'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | my $result = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | error => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | msg => "Testing finished in PRC ".$msg->{prc_number}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 3 | $self->state_details->prc_results($nr, $result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 3 | $self->state_details->results($result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 3 | ▶ | if ($self->state_details->is_all_prcs_finished()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 2 | $self->state_details->current_state('finished'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 2 | return (1, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 1 | return (0, $self->state_details->get_min_prc_timeout()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | sub msg_end_testprogram | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
msg_end_testprogram: called CC=2 SCAR=8.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 5 | my ($self, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 5 | my $nr = $msg->{prc_number}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 5 | my $current_test_number = $self->state_details->prc_current_test_number($nr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 5 | ▶ | if ($msg->{testprogram} != $current_test_number) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | my $result = {error => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | msg => "Invalid order of testprograms in PRC $nr. ". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | "Expected $current_test_number, got $msg->{testprogram}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | $self->state_details->prc_results($nr, $result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | $self->state_details->results($result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | $self->state_details->prc_current_test_number($nr, $msg->{testprogram}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 5 | $self->state_details->prc_next_timeout($nr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 5 | return (0, $self->state_details->get_min_prc_timeout()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | sub msg_error_testprogram | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
msg_error_testprogram: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | my ($self, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | my $nr = $msg->{prc_number}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | my $current_test_number = $self->state_details->prc_current_test_number($nr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | if ($msg->{testprogram} != $current_test_number) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | my $result = {error => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | msg => "Invalid order of testprograms in PRC $nr. ". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | "Expected $current_test_number, got $msg->{testprogram}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | $self->state_details->prc_results($nr, $result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | $self->state_details->results($result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | $self->state_details->prc_current_test_number($nr, $msg->{testprogram}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | my $result = {error => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | msg => $msg->{error}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | $self->state_details->prc_results($nr, $result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | $self->state_details->results($result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | $self->state_details->prc_next_timeout($nr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | return (0, $self->state_details->get_min_prc_timeout()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | sub msg_reboot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
msg_reboot: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | my ($self, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | my $nr = $msg->{prc_number}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | my $result = {error => 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | msg => "Host rebooted", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | $self->state_details->prc_results($nr, $result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | $self->state_details->results($result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | # reset testprogram counter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | $self->state_details->prc_current_test_number($nr, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | $self->state_details->prc_next_timeout($nr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | return (0, $self->state_details->get_min_prc_timeout()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | sub msg_quit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
msg_quit: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 3 | my ($self, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | my $result = {error => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 3 | ▶ | msg => "Testrun cancelled during state '".$self->state_details->current_state()."': ".($msg->{error} // "no reason provided"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$msg->{"error"} // "no reason provided"
MC/DC0%0/1
$msg->{"error"} // "no reason provided"
$msg->{"error"}
Truth table50%1/2
A
A= $msg->{"error"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 3 | ▶ | $result->{comment} = $msg->{error} if $msg->{error}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 3 | $self->state_details->results($result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 3 | $self->state_details->current_state('finished'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 3 | $self->state_details->set_all_prcs_current_state('finished'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 3 | return (1, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | sub msg_keep_alive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
msg_keep_alive: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | if (defined($self->state_details->keep_alive_timeout_span)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | $self->state_details->keep_alive_timeout_date( $self->state_details->keep_alive_timeout_span + time() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | sub next_state | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 59 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_state: called CC=17 SCAR=31.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 59 | my ($self, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 59 | my ($error, $timeout_span); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 59 | my $valid = $self->is_msg_valid($msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 59 | ▶ | return if not $valid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | ######################################################################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | # FIXME! return values of all msg_* functions is ignored. This is ok, but why do they generate a return value then? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | ####################################################################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 59 | my $state = $msg->{state}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 59 | ▶ | if ($state eq 'quit') { ($error, $timeout_span) = $self->msg_quit($msg) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 14 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 15 | elsif ($state eq 'takeoff') { ($error, $timeout_span) = $self->msg_takeoff($msg) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 10 | elsif ($state eq 'start-install') { ($error, $timeout_span) = $self->msg_start_install($msg) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 6 | elsif ($state eq 'end-install') { ($error, $timeout_span) = $self->msg_end_install($msg) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | elsif ($state eq 'error-install') { ($error, $timeout_span) = $self->msg_error_install($msg) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | elsif ($state eq 'warn-install') { ($error, $timeout_span) = $self->msg_warn_install($msg) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 10 | elsif ($state eq 'start-guest') { ($error, $timeout_span) = $self->msg_start_guest($msg) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | elsif ($state eq 'error-guest') { ($error, $timeout_span) = $self->msg_error_guest($msg) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 7 | elsif ($state eq 'start-testing') { ($error, $timeout_span) = $self->msg_start_testing($msg) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 3 | elsif ($state eq 'end-testing') { ($error, $timeout_span) = $self->msg_end_testing($msg) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | elsif ($state eq 'error-testprogram') { ($error, $timeout_span) = $self->msg_error_testprogram($msg) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 5 | elsif ($state eq 'end-testprogram') { ($error, $timeout_span) = $self->msg_end_testprogram($msg) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | elsif ($state eq 'reboot') { ($error, $timeout_span) = $self->msg_reboot($msg) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | elsif ($state eq 'keep-alive') { ($error, $timeout_span) = $self->msg_keep_alive($msg) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | # (TODO) add default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | # every message resets the keep-alive timeout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 59 | ▶ | if (defined($self->state_details->keep_alive_timeout_span)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 2 | $self->state_details->keep_alive_timeout_date( $self->state_details->keep_alive_timeout_span + time() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 59 | return (1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | sub update_state | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 62 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_state: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 62 | my ($self, $msg_obj) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 62 | my ($error, $timeout_span); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 62 | my $now = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 62 | my $guard; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 62 | $guard = model('TestrunDB')->txn_scope_guard; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 62 | ▶ | $guard->commit() if ref model('TestrunDB')->storage() eq 'DBIx::Class::Storage::DBI::SQLite'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 62 | ▶ | if (ref $msg_obj eq 'Tapper::Schema::TestrunDB::Result::Message') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 50 | my $msg_hash = $msg_obj->message; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 50 | $self->next_state($msg_hash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 50 | $msg_obj->delete; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } elsif (ref $msg_obj eq 'DBIx::Class::ResultSet'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 10 | foreach my $msg_result ($msg_obj->all) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 9 | my $msg_hash = $msg_result->message; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 9 | my ($success ) = $self->next_state($msg_hash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 9 | $msg_result->delete; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 9 | ▶ | last if not $success; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 62 | ($error, $timeout_span) = $self->update_timeouts(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 62 | ▶ | $guard->commit if not ref model('TestrunDB')->storage() eq 'DBIx::Class::Storage::DBI::SQLite'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 62 | return ($error, $timeout_span); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | sub testrun_finished | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 9 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
testrun_finished: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 9 | ▶ | shift->state_details->current_state eq 'finished' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 28 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||