| 1 | package Tapper::Cmd::Scenario; | ||||||||||||||||||||||||||||||||||||||
| 2 | 2 | our $AUTHORITY = 'cpan:TAPPER'; | |||||||||||||||||||||||||||||||||||||
| 3 | 2 | $Tapper::Cmd::Scenario::VERSION = '5.0.14'; | |||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use YAML::XS; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Tapper::Model 'model'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use parent 'Tapper::Cmd'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use Tapper::Cmd::Testrun; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub create { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
create: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 19 | 0 | my ($self, $scenario, $instance) = @_; | |||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | $scenario->{instance_id} ||= $instance; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$scenario->{"instance_id"} ||= $instance
MC/DC0%0/2
$scenario->{"instance_id"} ||= $instance
$scenario->{"instance_id"}
$instance
Truth table0%0/3
A ||= B
A= $scenario->{"instance_id"}B= $instance
| |||||||||||||||||||||||||||||||||||||||
| 21 | 0 | return $self->add([$scenario]); | |||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||
| 25 | sub parse_interdep | ||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_interdep: called CC=1 SCAR=0.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 27 | 1 | my ($self, $conf) = @_; | |||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||
| 29 | # TODO | ||||||||||||||||||||||||||||||||||||||
| 30 | # 2.) check whether more than 2 testruns are local and prevent sync in this case | ||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||
| 32 | 1 | my $i_scenario_id; | |||||||||||||||||||||||||||||||||||||
| 33 | 1 | my $or_schema = model('TestrunDB'); | |||||||||||||||||||||||||||||||||||||
| 34 | 1 | ▶ | try { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.6
| |||||||||||||||||||||||||||||||||||||||
| 35 | 1 | ▶ | $or_schema->txn_do(sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=23.2
| |||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||
| 37 | my $scenario = $or_schema->resultset('Scenario')->new({ | ||||||||||||||||||||||||||||||||||||||
| 38 | type => 'interdep', | ||||||||||||||||||||||||||||||||||||||
| 39 | options => $conf->{scenario_options} || $conf->{options}, | ||||||||||||||||||||||||||||||||||||||
| 40 | name => $conf->{scenario_name} || $conf->{name}, | ||||||||||||||||||||||||||||||||||||||
| 41 | 1 | ▶ | }); | ||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$conf->{'scenario_options'} || $conf->{'options'}
$conf->{'scenario_name'} || $conf->{'name'}
MC/DC0%0/2
$conf->{'scenario_options'} || $conf->{'options'}
$conf->{'scenario_options'}
$conf->{'options'}
MC/DC0%0/2
$conf->{'scenario_name'} || $conf->{'name'}
$conf->{'scenario_name'}
$conf->{'name'}
Truth table33%1/3
A || B
A= $conf->{'scenario_options'}B= $conf->{'options'}
Truth table33%1/3
A || B
A= $conf->{'scenario_name'}B= $conf->{'name'}
| |||||||||||||||||||||||||||||||||||||||
| 42 | 1 | $scenario->insert; | |||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||
| 44 | 1 | $i_scenario_id = $scenario->id; | |||||||||||||||||||||||||||||||||||||
| 45 | 1 | my $tr = Tapper::Cmd::Testrun->new({ schema => $or_schema }); | |||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | foreach my $plan (@{$conf->{scenario_description} || $conf->{description}}) { | ||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$conf->{'scenario_description'} || $conf->{'description'}
MC/DC0%0/2
$conf->{'scenario_description'} || $conf->{'description'}
$conf->{'scenario_description'}
$conf->{'description'}
Truth table33%1/3
A || B
A= $conf->{'scenario_description'}B= $conf->{'description'}
| |||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||
| 49 | 2 | ▶ | $plan->{scenario_id} ||= $i_scenario_id; | ||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$plan->{"scenario_id"} ||= $i_scenario_id
MC/DC0%0/2
$plan->{"scenario_id"} ||= $i_scenario_id
$plan->{"scenario_id"}
$i_scenario_id
Truth table33%1/3
A ||= B
A= $plan->{"scenario_id"}B= $i_scenario_id
| |||||||||||||||||||||||||||||||||||||||
| 50 | 2 | $plan->{status} = 'schedule'; | |||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||
| 52 | # backwards compatibility for old interdep descriptions | ||||||||||||||||||||||||||||||||||||||
| 53 | 2 | ▶ | if ( $plan->{requested_hosts} ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 54 | 0 | $plan->{requested_hosts_any} = delete $plan->{requested_hosts}; | |||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||
| 57 | 2 | $tr->create($plan, $conf->{instance_id}); | |||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||
| 61 | 1 | }); | |||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 65 | 0 | die $_; | |||||||||||||||||||||||||||||||||||||
| 66 | 1 | }; | |||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||
| 68 | 1 | return $i_scenario_id; | |||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||
| 73 | 2 | ▶ | sub add { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
add: called CC=9 SCAR=25.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 74 | 2 | my ($self, $list_of_confs) = @_; | |||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||
| 76 | 2 | my @ids; | |||||||||||||||||||||||||||||||||||||
| 77 | 2 | ▶ | foreach my $conf (@{$list_of_confs || [] }) { | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$list_of_confs || []
MC/DC0%0/1
$list_of_confs || []
$list_of_confs
Truth table50%1/2
A
A= $list_of_confs
| |||||||||||||||||||||||||||||||||||||||
| 78 | 2 | ▶ | if ( $conf->{scenario_type} eq 'interdep' ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 79 | 1 | push @ids, $self->parse_interdep($conf); | |||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||
| 81 | elsif ( $conf->{scenario_type} eq 'multitest' ) { | ||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||
| 83 | my $sc = $self->schema->resultset('Scenario')->new({ | ||||||||||||||||||||||||||||||||||||||
| 84 | type => 'multitest', | ||||||||||||||||||||||||||||||||||||||
| 85 | options => $conf->{scenario_options} || $conf->{options}, | ||||||||||||||||||||||||||||||||||||||
| 86 | name => $conf->{scenario_name} || $conf->{name}, | ||||||||||||||||||||||||||||||||||||||
| 87 | 1 | ▶ | }); | ||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$conf->{'scenario_options'} || $conf->{'options'}
$conf->{'scenario_name'} || $conf->{'name'}
MC/DC0%0/2
$conf->{'scenario_options'} || $conf->{'options'}
$conf->{'scenario_options'}
$conf->{'options'}
MC/DC0%0/2
$conf->{'scenario_name'} || $conf->{'name'}
$conf->{'scenario_name'}
$conf->{'name'}
Truth table33%1/3
A || B
A= $conf->{'scenario_options'}B= $conf->{'options'}
Truth table33%1/3
A || B
A= $conf->{'scenario_name'}B= $conf->{'name'}
| |||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||
| 89 | 1 | $sc->insert; | |||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||
| 91 | 1 | ▶ | my $description = $conf->{scenario_description} || $conf->{description}; | ||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$conf->{'scenario_description'} || $conf->{'description'}
MC/DC0%0/2
$conf->{'scenario_description'} || $conf->{'description'}
$conf->{'scenario_description'}
$conf->{'description'}
Truth table33%1/3
A || B
A= $conf->{'scenario_description'}B= $conf->{'description'}
| |||||||||||||||||||||||||||||||||||||||
| 92 | 1 | $description->{scenario_id} = $sc->id; | |||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||
| 94 | 1 | my $tr = Tapper::Cmd::Testrun->new( schema => $self->schema ); | |||||||||||||||||||||||||||||||||||||
| 95 | 1 | $tr->create($description); | |||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||
| 97 | 1 | push @ids, $sc->id; | |||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||
| 100 | else { | ||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | die "Unknown scenario type '" . ( $conf->{scenario_type} || q## ) . "'"; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$conf->{'scenario_type'} || ''
MC/DC0%0/1
$conf->{'scenario_type'} || ''
$conf->{'scenario_type'}
Truth table0%0/2
A
A= $conf->{'scenario_type'}
| |||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||
| 105 | 2 | return @ids; | |||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||
| 112 | 1 | ▶ | sub del { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
del: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 113 | 1 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||
| 114 | 1 | my $scenario = model('TestrunDB')->resultset('Scenario')->find($id); | |||||||||||||||||||||||||||||||||||||
| 115 | 1 | $scenario->delete(); | |||||||||||||||||||||||||||||||||||||
| 116 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||
| 119 | 2 | 1; # End of Tapper::Cmd::Testrun | |||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||
| 121 | __END__ | ||||||||||||||||||||||||||||||||||||||