| 1 | package Tapper::CLI::Queue; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 72 | our $AUTHORITY = 'cpan:TAPPER'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | 72 | $Tapper::CLI::Queue::VERSION = '5.0.8'; | |||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 72 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 72 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 72 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 72 | ▶ | use feature qw/ say /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 72 | ▶ | use English qw/ -no_match_vars /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | # list limit default value | ||||||||||||||||||||||||||||||||||||||||||
| 12 | 72 | my $i_limit_default = 50; | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 8 | ▶ | sub b_print_single_queue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
b_print_single_queue: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 8 | my ( $or_queue ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 8 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 8 | printf "%22s: %s\n", 'Id' , $or_queue->id; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 8 | printf "%22s: %s\n", 'Name' , $or_queue->name; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 8 | printf "%22s: %s\n", 'Priority' , $or_queue->priority; | |||||||||||||||||||||||||||||||||||||||||
| 23 | 8 | printf "%22s: %s\n", 'Runcount' , $or_queue->runcount; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 8 | printf "%22s: %s\n", 'Active' , $or_queue->active; | |||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 8 | ▶ | if ( $or_queue->queuehosts->count ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | printf "%22s: %s\n", | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 'Bound hosts', | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 6 | join ', ', map { $_->host->name } $or_queue->queuehosts->all; | |||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 8 | ▶ | if ( $or_queue->deniedhosts->count ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | printf "%22s: %s\n", | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 'Denied hosts', | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | join ', ', map { $_->host->name } $or_queue->deniedhosts->all; | |||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 8 | ▶ | if ( my @a_testrun_ids = $or_queue->queued_testruns->get_column('testrun_id')->all ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 2 | my $i_counter = 0; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | my $i_max_elements = 15; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 2 | my $i_testrun_id_length = length $a_testrun_ids[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | ▶ | while ( scalar( @a_testrun_ids ) > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | printf "%22s: %s\n", | ||||||||||||||||||||||||||||||||||||||||||
| 44 | $i_counter++ ? q## : 'Queued testruns (ids)', | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | ▶ | join ', ', map { sprintf '%' . $i_testrun_id_length . 's', $_ } splice @a_testrun_ids, 0, $i_max_elements | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 8 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 3 | ▶ | sub b_print_queues { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
b_print_queues: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 3 | my ( $or_queues ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 3 | ▶ | if ( $or_queues->isa('DBIx::Class::ResultSet') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 3 | for my $or_queue ( $or_queues->all ) { | |||||||||||||||||||||||||||||||||||||||||
| 61 | 5 | b_print_single_queue( $or_queue ); | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | b_print_single_queue( $or_queues ); | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 3 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | ▶ | sub ar_get_delete_queues_parameters { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ar_get_delete_queues_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | return [ | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | [ 'id|i=i@' , 'delete particular queues', 'Can be given multiple times.', ], | |||||||||||||||||||||||||||||||||||||||||
| 77 | [ 'name|n=s@' , 'delete by queue name', 'Can be given multiple times.', ], | ||||||||||||||||||||||||||||||||||||||||||
| 78 | [ 'force|f' , 'really execute the command', ], | ||||||||||||||||||||||||||||||||||||||||||
| 79 | [ 'verbose|v' , 'print all output, without only print ids', ], | ||||||||||||||||||||||||||||||||||||||||||
| 80 | [ 'help|?' , 'Print this help message and exit.', ], | ||||||||||||||||||||||||||||||||||||||||||
| 81 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | ▶ | sub b_delete_queues { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
b_delete_queues: called CC=11 SCAR=30.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | my ( $or_app_rad ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | my $ar_parameters = ar_get_delete_queues_parameters(); | |||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | $or_app_rad->getopt( map { $_->[0] } @{$ar_parameters} ); | |||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | my $hr_options = $or_app_rad->options; | |||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 1 | ▶ | if ( $hr_options->{help} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | say {*STDERR} "Usage: $PROGRAM_NAME queue-delete [options]"; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | require Tapper::CLI::Base; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | Tapper::CLI::Base::b_print_help( $ar_parameters ); | |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | ▶ | if ( !$hr_options->{id} && !$hr_options->{name} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$hr_options->{"id"} or $hr_options->{"name"}
MC/DC0%0/2
$hr_options->{"id"} or $hr_options->{"name"}
$hr_options->{"id"}
$hr_options->{"name"}
Truth table33%1/3
A or B
A= $hr_options->{"id"}B= $hr_options->{"name"}
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | die "error: missing paramet 'id' or 'name'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | require Tapper::Model; | |||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my %h_queue_ids = map { $_ => q## } @{$hr_options->{id}}; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | foreach my $s_name ( @{$hr_options->{name}} ) { | |||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | my $or_host = | ||||||||||||||||||||||||||||||||||||||||||
| 110 | Tapper::Model::model('TestrunDB') | ||||||||||||||||||||||||||||||||||||||||||
| 111 | ->resultset('Queue') | ||||||||||||||||||||||||||||||||||||||||||
| 112 | ->find({ | ||||||||||||||||||||||||||||||||||||||||||
| 113 | name => $s_name, | ||||||||||||||||||||||||||||||||||||||||||
| 114 | is_deleted => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 115 | }) | ||||||||||||||||||||||||||||||||||||||||||
| 116 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | $h_queue_ids{$or_host->id} = $or_host; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | die "error: Can't find host by name '$s_name'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 1 | ▶ | if (! $hr_options->{force} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | say {*STDERR} "info: Skip deleting queues unless --force is used."; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | require Tapper::Cmd::Queue; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | my $or_cmd = Tapper::Cmd::Queue->new(); | |||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | foreach my $i_queue_id ( sort { $h_queue_ids{$a} cmp $h_queue_ids{$b} } keys %h_queue_ids ){ | |||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 1 | my $or_queue = $h_queue_ids{$i_queue_id}; | |||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | # host object isn't set by loop above. look for object by id. | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 1 | ▶ | if (! $or_queue ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | if (! | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 139 | $or_queue = | ||||||||||||||||||||||||||||||||||||||||||
| 140 | Tapper::Model::model('TestrunDB') | ||||||||||||||||||||||||||||||||||||||||||
| 141 | ->resultset('Queue') | ||||||||||||||||||||||||||||||||||||||||||
| 142 | ->find( $i_queue_id ) | ||||||||||||||||||||||||||||||||||||||||||
| 143 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 144 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | die "error: Can't find host by id '$i_queue_id'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | $or_cmd->del( $or_queue ); | |||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | ▶ | if ( $hr_options->{verbose} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | say 'info: Deleted queue ' . $or_queue->name . ": $i_queue_id"; | |||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 3 | ▶ | sub ar_get_list_queues_parameters { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ar_get_list_queues_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | return [ | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 3 | [ 'id|i=i@' , 'list particular preconditions', 'Can be given multiple times.', ], | |||||||||||||||||||||||||||||||||||||||||
| 165 | [ 'name|n=s@' , 'list preconditions by name', 'Can be given multiple times.', ], | ||||||||||||||||||||||||||||||||||||||||||
| 166 | [ 'minprio=i' , 'list queues with at least this priority level', ], | ||||||||||||||||||||||||||||||||||||||||||
| 167 | [ 'maxprio=i' , 'list queues with at most this priority level', ], | ||||||||||||||||||||||||||||||||||||||||||
| 168 | [ 'all' , 'list all queues, even deleted ones', ], | ||||||||||||||||||||||||||||||||||||||||||
| 169 | [ 'active' , 'list active queues', ], | ||||||||||||||||||||||||||||||||||||||||||
| 170 | [ 'limit|l=i' , "limit the number of testruns (default = $i_limit_default). A value smaller than 1 deactivates the limit.", ], | ||||||||||||||||||||||||||||||||||||||||||
| 171 | [ 'verbose|v' , 'print all output, without only print ids', ], | ||||||||||||||||||||||||||||||||||||||||||
| 172 | [ 'help|?' , 'Print this help message and exit.', ], | ||||||||||||||||||||||||||||||||||||||||||
| 173 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 3 | ▶ | sub b_list_queues { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
b_list_queues: called CC=20 SCAR=40.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 3 | my ( $or_app_rad ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 3 | my $or_querylog; | |||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 3 | require Tapper::Model; | |||||||||||||||||||||||||||||||||||||||||
| 184 | 3 | my $or_schema = Tapper::Model::model('TestrunDB'); | |||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 3 | ▶ | if ( $ENV{TAPPER_TRACE} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | require DBIx::Class::QueryLog; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $or_querylog = DBIx::Class::QueryLog->new(); | |||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $or_schema->storage->debugobj( $or_querylog ); | |||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | $or_schema->storage->debug( 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 3 | my $ar_parameters = ar_get_list_queues_parameters(); | |||||||||||||||||||||||||||||||||||||||||
| 194 | 3 | $or_app_rad->getopt( map { $_->[0] } @{$ar_parameters} ); | |||||||||||||||||||||||||||||||||||||||||
| 195 | 3 | my $hr_options = $or_app_rad->options; | |||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 3 | ▶ | if ( $hr_options->{help} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | say {*STDERR} "Usage: $PROGRAM_NAME queue-list [options]"; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | require Tapper::CLI::Base; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | Tapper::CLI::Base::b_print_help( $ar_parameters ); | |||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 3 | my $hr_search = {}; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 3 | ▶ | if ( my $ar_queue_ids = $hr_options->{id} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | if ( my $ar_queue_names = $hr_options->{name} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | $hr_search->{-or} = [ | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | { 'me.id' => { -in => $ar_queue_ids } }, | |||||||||||||||||||||||||||||||||||||||||
| 209 | { 'me.name' => { -in => $ar_queue_names } }, | ||||||||||||||||||||||||||||||||||||||||||
| 210 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $hr_search->{'me.id'} = { -in => $ar_queue_ids }; | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | elsif ( my $ar_queue_names = $hr_options->{name} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | $hr_search->{'me.name'} = { -in => $ar_queue_names }; | |||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 3 | ▶ | if ( $hr_options->{minprio} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 1 | ▶ | ($hr_search->{'me.priority'} ||= {})->{'>='} = $hr_options->{minprio}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$hr_search->{"me.priority"} ||= {}
MC/DC0%0/1
$hr_search->{"me.priority"} ||= {}
$hr_search->{"me.priority"}
Truth table50%1/2
A
A= $hr_search->{"me.priority"}
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 3 | ▶ | if ( $hr_options->{maxprio} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | 2 | ▶ | ($hr_search->{'me.priority'} ||= {})->{'<='} = $hr_options->{maxprio}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$hr_search->{"me.priority"} ||= {}
MC/DC100%1/1
$hr_search->{"me.priority"} ||= {}
$hr_search->{"me.priority"}
Truth table100%2/2
A
A= $hr_search->{"me.priority"}
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 3 | ▶ | if ( $hr_options->{active} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | $hr_search->{'me.active'} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 3 | ▶ | if ( !$hr_options->{all} && !$hr_options->{id} && !$hr_options->{name} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$hr_options->{"all"} or $hr_options->{"id"} or $hr_options->{"name"}
$hr_options->{"all"} or $hr_options->{"id"}
MC/DC33%1/3
$hr_options->{"all"} or $hr_options->{"id"} or $hr_options->{"name"}
$hr_options->{"all"}
$hr_options->{"id"}
$hr_options->{"name"}
Truth table50%2/4
A or B or C
A= $hr_options->{"all"}B= $hr_options->{"id"}C= $hr_options->{"name"}
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 2 | $hr_search->{'me.is_deleted'} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 3 | my $hr_search_options = { | |||||||||||||||||||||||||||||||||||||||||
| 235 | order_by => { -desc => 'me.id' }, | ||||||||||||||||||||||||||||||||||||||||||
| 236 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 3 | ▶ | if ( exists $hr_options->{limit} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | if ( $hr_options->{limit} > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | $hr_search_options->{rows} = $hr_options->{limit}; | |||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 3 | $hr_search_options->{rows} = $i_limit_default; | |||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 3 | ▶ | if ( $hr_options->{verbose} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 3 | $hr_search_options->{'prefetch'} = [ | |||||||||||||||||||||||||||||||||||||||||
| 247 | { 'queuehosts' => 'host', }, | ||||||||||||||||||||||||||||||||||||||||||
| 248 | { 'deniedhosts' => 'host', }, | ||||||||||||||||||||||||||||||||||||||||||
| 249 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | $hr_search_options->{'select'} = ['id','name']; | |||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 3 | my $or_queue_rs = | |||||||||||||||||||||||||||||||||||||||||
| 256 | $or_schema | ||||||||||||||||||||||||||||||||||||||||||
| 257 | ->resultset('Queue') | ||||||||||||||||||||||||||||||||||||||||||
| 258 | ->search( $hr_search, $hr_search_options ) | ||||||||||||||||||||||||||||||||||||||||||
| 259 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 3 | ▶ | if ( $hr_options->{verbose} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 3 | b_print_queues( $or_queue_rs ); | |||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | say "id name"; | |||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | foreach my $or_queue ( $or_queue_rs->all ) { | |||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | printf "%06d %s\n", $or_queue->id, $or_queue->name; | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 3 | ▶ | if ( $ENV{TAPPER_TRACE} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | require DBIx::Class::QueryLog::Analyzer; | |||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | my $or_analyzer = DBIx::Class::QueryLog::Analyzer->new({ | |||||||||||||||||||||||||||||||||||||||||
| 275 | querylog => $or_querylog, | ||||||||||||||||||||||||||||||||||||||||||
| 276 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | require Data::Dumper; | |||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | say {*STDERR} "Query count: " . scalar( @{$or_analyzer->get_sorted_queries} ); | |||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | say {*STDERR} Data::Dumper::Dumper([ | |||||||||||||||||||||||||||||||||||||||||
| 281 | $or_analyzer->get_sorted_queries | ||||||||||||||||||||||||||||||||||||||||||
| 282 | ]); | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | 2 | ▶ | sub ar_get_new_queue_parameters { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ar_get_new_queue_parameters: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | return [ | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 2 | [ 'name|n=s' , 'name', ], | |||||||||||||||||||||||||||||||||||||||||
| 294 | [ 'priority|p=i' , 'priority', ], | ||||||||||||||||||||||||||||||||||||||||||
| 295 | [ 'active|a' , 'set active flag to this value, prepend with no to unset', ], | ||||||||||||||||||||||||||||||||||||||||||
| 296 | [ 'verbose|v' , 'some more informational output', ], | ||||||||||||||||||||||||||||||||||||||||||
| 297 | [ 'help|?' , 'Print this help message and exit.', ], | ||||||||||||||||||||||||||||||||||||||||||
| 298 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 2 | ▶ | sub b_new_queue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
b_new_queue: called CC=5 SCAR=18.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | 2 | my ( $or_app_rad ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 2 | my $ar_parameters = ar_get_new_queue_parameters(); | |||||||||||||||||||||||||||||||||||||||||
| 307 | 2 | $or_app_rad->getopt( map { $_->[0] } @{$ar_parameters} ); | |||||||||||||||||||||||||||||||||||||||||
| 308 | 2 | my $hr_options = $or_app_rad->options; | |||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 2 | ▶ | if ( $hr_options->{help} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | say {*STDERR} "Usage: $PROGRAM_NAME queue-new [options]"; | |||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | require Tapper::CLI::Base; | |||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | Tapper::CLI::Base::b_print_help( $ar_parameters ); | |||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | my $hr_queue = { | ||||||||||||||||||||||||||||||||||||||||||
| 318 | name => $hr_options->{name}, | ||||||||||||||||||||||||||||||||||||||||||
| 319 | priority => $hr_options->{priority}, | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 2 | ▶ | active => $hr_options->{active} // 0, | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$hr_options->{"active"} // 0
MC/DC0%0/1
$hr_options->{"active"} // 0
$hr_options->{"active"}
Truth table50%1/2
A
A= $hr_options->{"active"}
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | 2 | require Tapper::Model; | |||||||||||||||||||||||||||||||||||||||||
| 324 | 2 | require Tapper::Cmd::Queue; | |||||||||||||||||||||||||||||||||||||||||
| 325 | 2 | my $or_cmd = Tapper::Cmd::Queue->new(); | |||||||||||||||||||||||||||||||||||||||||
| 326 | 2 | ▶ | if ( my $i_queue_id = $or_cmd->add( $hr_queue ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | 2 | ▶ | if ( $hr_options->{verbose} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | b_print_single_queue( | |||||||||||||||||||||||||||||||||||||||||
| 329 | Tapper::Model::model('TestrunDB') | ||||||||||||||||||||||||||||||||||||||||||
| 330 | ->resultset('Queue') | ||||||||||||||||||||||||||||||||||||||||||
| 331 | ->search({ id => $i_queue_id }, { rows => 1 }) | ||||||||||||||||||||||||||||||||||||||||||
| 332 | ->first | ||||||||||||||||||||||||||||||||||||||||||
| 333 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||
| 335 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 2 | say $i_queue_id; | |||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | die "error: Can't create new queue because of an unknown error\n"; | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | sub ar_get_rename_queue_parameters { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ar_get_rename_queue_parameters: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | return [ | ||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | [ 'oldname|o=s', 'name of the queue to be changed', ], | |||||||||||||||||||||||||||||||||||||||||
| 351 | [ 'newname|n=s', 'new name of the queue', ], | ||||||||||||||||||||||||||||||||||||||||||
| 352 | [ 'help|?' , 'Print this help message and exit.', ], | ||||||||||||||||||||||||||||||||||||||||||
| 353 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | sub b_rename_queue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
b_rename_queue: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | my ( $or_app_rad ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my $ar_parameters = ar_get_rename_queue_parameters(); | |||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | $or_app_rad->getopt( map { $_->[0] } @{$ar_parameters} ); | |||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my $hr_options = $or_app_rad->options; | |||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | if ( $hr_options->{help} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | say {*STDERR} "Usage: $PROGRAM_NAME queue-rename [options]"; | |||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | require Tapper::CLI::Base; | |||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | Tapper::CLI::Base::b_print_help( $ar_parameters ); | |||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | for my $s_parameter (qw/ oldname newname /) { | |||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | if (! $hr_options->{$s_parameter} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | die "error: missing argument '$s_parameter'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | require Tapper::Model; | |||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | my $or_queue = | ||||||||||||||||||||||||||||||||||||||||||
| 382 | Tapper::Model::model('TestrunDB') | ||||||||||||||||||||||||||||||||||||||||||
| 383 | ->resultset('Queue') | ||||||||||||||||||||||||||||||||||||||||||
| 384 | ->search({ name => $hr_options->{oldname} }, { rows => 1 }) | ||||||||||||||||||||||||||||||||||||||||||
| 385 | ->first | ||||||||||||||||||||||||||||||||||||||||||
| 386 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | require DateTime; | |||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | $or_queue->name( $hr_options->{newname} ); | |||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | $or_queue->updated_at( DateTime->now->strftime('%F %T') ); | |||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | $or_queue->update; | |||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | say "info: $hr_options->{oldname} is now known as $hr_options->{newname}"; | |||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | die "error: No such queue: " . $hr_options->{oldname} . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 3 | ▶ | sub ar_get_update_queue_parameters { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ar_get_update_queue_parameters: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | return [ | ||||||||||||||||||||||||||||||||||||||||||
| 405 | 3 | [ 'id|i=i' , 'id of the queue to be changed', ], | |||||||||||||||||||||||||||||||||||||||||
| 406 | [ 'name|n=s' , 'name of the queue to be changed', ], | ||||||||||||||||||||||||||||||||||||||||||
| 407 | [ 'priority|p=i', 'priority', ], | ||||||||||||||||||||||||||||||||||||||||||
| 408 | [ 'active|a=i' , 'set active flag to this value, prepend with no to unset',], | ||||||||||||||||||||||||||||||||||||||||||
| 409 | [ 'verbose|v' , 'some more informational output', ], | ||||||||||||||||||||||||||||||||||||||||||
| 410 | [ 'help|?' , 'Print this help message and exit.', ], | ||||||||||||||||||||||||||||||||||||||||||
| 411 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | 3 | ▶ | sub b_update_queue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
b_update_queue: called CC=16 SCAR=33.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | 3 | my ( $or_app_rad ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | 3 | my $ar_parameters = ar_get_update_queue_parameters(); | |||||||||||||||||||||||||||||||||||||||||
| 420 | 3 | $or_app_rad->getopt( map { $_->[0] } @{$ar_parameters} ); | |||||||||||||||||||||||||||||||||||||||||
| 421 | 3 | my $hr_options = $or_app_rad->options; | |||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | 3 | ▶ | if ( $hr_options->{help} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | say {*STDERR} "Usage: $PROGRAM_NAME queue-update [options]"; | |||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | require Tapper::CLI::Base; | |||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | Tapper::CLI::Base::b_print_help( $ar_parameters ); | |||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||
| 430 | 3 | ▶ | if ( !$hr_options->{id} && !$hr_options->{name} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$hr_options->{"id"} or $hr_options->{"name"}
MC/DC0%0/2
$hr_options->{"id"} or $hr_options->{"name"}
$hr_options->{"id"}
$hr_options->{"name"}
Truth table33%1/3
A or B
A= $hr_options->{"id"}B= $hr_options->{"name"}
| |||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | die "error: parameter 'id' or 'name' is required\n"; | |||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||
| 433 | 3 | ▶ | if ( defined $hr_options->{active} && !grep { $hr_options->{active} == $_ } 0,1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $hr_options->{"active"} and not grep({$hr_options->{"active"} == $_;} 0, 1)
MC/DC0%0/2
defined $hr_options->{"active"} and not grep({$hr_options->{"active"} == $_;} 0, 1)
defined $hr_options->{"active"}
not grep({$hr_options->{"active"} == $_;} 0, 1)
Truth table66%2/3
A and not(B)
A= defined $hr_options->{"active"}B= not grep({$hr_options->{"active"} == $_;} 0, 1)
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | die "error: invalid value for 'active'. 0 or 1 are allowed\n"; | |||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | 3 | require Tapper::Model; | |||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | 3 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | my $or_queue = | ||||||||||||||||||||||||||||||||||||||||||
| 441 | Tapper::Model::model('TestrunDB') | ||||||||||||||||||||||||||||||||||||||||||
| 442 | ->resultset('Queue') | ||||||||||||||||||||||||||||||||||||||||||
| 443 | ->find( | ||||||||||||||||||||||||||||||||||||||||||
| 444 | $hr_options->{id} | ||||||||||||||||||||||||||||||||||||||||||
| 445 | ? { id => $hr_options->{id} } | ||||||||||||||||||||||||||||||||||||||||||
| 446 | : { name => $hr_options->{name} } | ||||||||||||||||||||||||||||||||||||||||||
| 447 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 448 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | 3 | require Tapper::Cmd::Queue; | |||||||||||||||||||||||||||||||||||||||||
| 451 | 3 | my $or_cmd = Tapper::Cmd::Queue->new(); | |||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | 3 | my $b_update = 0; | |||||||||||||||||||||||||||||||||||||||||
| 454 | 3 | my $hr_new_opts = {}; | |||||||||||||||||||||||||||||||||||||||||
| 455 | 3 | ▶ | if ( defined $hr_options->{priority} && $hr_options->{priority} ne $or_queue->priority ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $hr_options->{"priority"} and $hr_options->{"priority"} ne $or_queue->priority
MC/DC50%1/2
defined $hr_options->{"priority"} and $hr_options->{"priority"} ne $or_queue->priority
defined $hr_options->{"priority"}
$hr_options->{"priority"} ne $or_queue->priority
Truth table66%2/3
A and B
A= defined $hr_options->{"priority"}B= $hr_options->{"priority"} ne $or_queue->priority
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | 1 | $b_update = 1; | |||||||||||||||||||||||||||||||||||||||||
| 457 | 1 | $hr_new_opts->{priority} = $hr_options->{priority}; | |||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||
| 459 | 3 | ▶ | if ( defined $hr_options->{active} && $hr_options->{active} ne $or_queue->active ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $hr_options->{"active"} and $hr_options->{"active"} ne $or_queue->active
MC/DC50%1/2
defined $hr_options->{"active"} and $hr_options->{"active"} ne $or_queue->active
defined $hr_options->{"active"}
$hr_options->{"active"} ne $or_queue->active
Truth table66%2/3
A and B
A= defined $hr_options->{"active"}B= $hr_options->{"active"} ne $or_queue->active
| |||||||||||||||||||||||||||||||||||||||||||
| 460 | 2 | $b_update = 1; | |||||||||||||||||||||||||||||||||||||||||
| 461 | 2 | $hr_new_opts->{active} = $hr_options->{active}; | |||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | 3 | ▶ | if ( $b_update ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 465 | 3 | ▶ | if (! $or_cmd->update( $or_queue, $hr_new_opts) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | die 'error: cannot update queue: ' . $or_queue->id . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||
| 469 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | say {*STDERR} 'info: queue is already up to date'; | |||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | 3 | ▶ | if ( $hr_options->{verbose} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 474 | 3 | b_print_single_queue( $or_queue ); | |||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||
| 476 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | say 'info: successfully updated queue ' . $or_queue->id; | |||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||
| 481 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | ▶ | die 'error: cannot find queue ' . ( $hr_options->{id} ? "by id '$hr_options->{id}'" : "by name '$hr_options->{name}'" ) . "\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||
| 490 | 71 | ▶ | sub setup { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||
| 492 | 71 | my ( $or_apprad ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||
| 494 | 71 | $or_apprad->register( 'queue-list' , \&b_list_queues , 'Show all queues matching a given condition', ); | |||||||||||||||||||||||||||||||||||||||||
| 495 | 71 | $or_apprad->register( 'queue-new' , \&b_new_queue , 'Create a queue', ); | |||||||||||||||||||||||||||||||||||||||||
| 496 | 71 | $or_apprad->register( 'queue-update', \&b_update_queue , 'Update a existing queue', ); | |||||||||||||||||||||||||||||||||||||||||
| 497 | 71 | $or_apprad->register( 'queue-rename', \&b_rename_queue , 'Rename a queue', ); | |||||||||||||||||||||||||||||||||||||||||
| 498 | 71 | $or_apprad->register( 'queue-delete', \&b_delete_queues, 'Delete an existing queue', ); | |||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||
| 500 | 71 | ▶ | if ( $or_apprad->can('group_commands') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | $or_apprad->group_commands( | |||||||||||||||||||||||||||||||||||||||||
| 502 | 'Testrun commands', | ||||||||||||||||||||||||||||||||||||||||||
| 503 | 'queue-list', | ||||||||||||||||||||||||||||||||||||||||||
| 504 | 'queue-new', | ||||||||||||||||||||||||||||||||||||||||||
| 505 | 'queue-rename', | ||||||||||||||||||||||||||||||||||||||||||
| 506 | 'queue-delete', | ||||||||||||||||||||||||||||||||||||||||||
| 507 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||
| 510 | 71 | return; | |||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||
| 514 | 72 | 1; # End of Tapper::CLI | |||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | __END__ | ||||||||||||||||||||||||||||||||||||||||||