| 1 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # (c) Jan Gehring <jan.gehring@gmail.com> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | package Rex::TaskList::Base; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 56 | ▶ | use v5.14.4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 56 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 56 | our $VERSION = '1.16.1'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 56 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 56 | ▶ | use Rex::Shared::Var; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 56 | share qw(@SUMMARY); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 56 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 56 | ▶ | use Rex::Logger; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 56 | ▶ | use Rex::Task; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 56 | ▶ | use Rex::Config; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 56 | ▶ | use Rex::Interface::Executor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 56 | ▶ | use Rex::Fork::Manager; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 56 | ▶ | use Rex::Report; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 56 | ▶ | use Rex::Group; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 56 | ▶ | use Time::HiRes qw(time); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 56 | ▶ | use POSIX qw(floor); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 61 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 61 | my $that = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 61 | ▶ | my $proto = ref($that) || $that; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $that || $that
MC/DC0%0/2
ref $that || $that
ref $that
$that
Truth table33%1/3
A || B
A= ref $thatB= $that
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 61 | my $self = {@_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 61 | bless( $self, $proto ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 61 | $self->{IN_TRANSACTION} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 61 | $self->{DEFAULT_AUTH} = Rex::Config->get_default_auth(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 61 | $self->{tasks} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 61 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 212 | ▶ | sub create_task { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_task: called CC=33 SCAR=43.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 212 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 212 | my $task_name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 212 | my $options = pop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 212 | my $desc = pop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 212 | ▶ | if ( exists $self->{tasks}->{$task_name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | Rex::Logger::info( "Task $task_name already exists. Overwriting...", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | "warn" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 212 | Rex::Logger::debug("Creating task: $task_name"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 212 | my $func; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 212 | ▶ | if ( ref($desc) eq "CODE" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $func = $desc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $desc = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 212 | $func = pop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # matching against a task count of 2 because of the two internal tasks (filtered below) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 212 | ▶ | if ( ( scalar( keys %{ $self->{tasks} } ) ) == 2 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 39 | my $requested_env = Rex::Config->get_environment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 39 | my @environments = Rex::Commands->get_environments; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 39 | ▶ | if ( $task_name ne 'Commands:Box:get_sys_info' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$task_name ne "Commands:Box:get_sys_info" and $task_name ne "Test:run" and $requested_env ne "" and not grep({$_ eq $requested_env;} @environments)
$task_name ne "Commands:Box:get_sys_info" and $task_name ne "Test:run" and $requested_env ne ""
$task_name ne "Commands:Box:get_sys_info" and $task_name ne "Test:run"
MC/DC0%0/4
$task_name ne "Commands:Box:get_sys_info" and $task_name ne "Test:run" and $requested_env ne "" and not grep({$_ eq $requested_env;} @environments)
$task_name ne "Commands:Box:get_sys_info"
$task_name ne "Test:run"
$requested_env ne ""
not grep({$_ eq $requested_env;} @environments)
Truth table20%1/5
A and B and C and not(D)
A= $task_name ne "Commands:Box:get_sys_info"B= $task_name ne "Test:run"C= $requested_env ne ""D= not grep({$_ eq $requested_env;} @environments)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | && $task_name ne 'Test:run' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | && $requested_env ne '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | && !grep { $_ eq $requested_env } @environments ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | Rex::Logger::info( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | "Environment '$requested_env' has been requested, but it could not be found in the Rexfile. This is most likely only by mistake.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 'warn' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | Rex::Logger::info( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | "If it is intentional, you can suppress this warning by specifying an empty environment: environment '$requested_env' => sub {};", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 'warn' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 212 | my @server = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 212 | ▶ | if ($::FORCE_SERVER) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | ▶ | if ( ref $::FORCE_SERVER eq "ARRAY" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my $group_name_arr = $::FORCE_SERVER; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | for my $group_name ( @{$group_name_arr} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | if ( !Rex::Group->is_group($group_name) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | Rex::Logger::debug("Using late group-lookup"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | push @server, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if ( !Rex::Group->is_group($group_name) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | Rex::Logger::info( "No group $group_name defined.", "error" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | map { Rex::Group::Entry::Server->new( name => $_ )->get_servers; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | Rex::Group->get_group($group_name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | push( @server, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | map { Rex::Group::Entry::Server->new( name => $_ ); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | Rex::Group->get_group($group_name) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | my @servers = split( /\s+/, $::FORCE_SERVER ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | push( @server, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | map { Rex::Group::Entry::Server->new( name => $_ ); } @servers ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | Rex::Logger::debug("\tserver: $_") for @server; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 211 | ▶ | if ( scalar(@_) >= 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 13 | ▶ | if ( $_[0] eq "group" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 6 | my $groups; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 6 | ▶ | if ( ref( $_[1] ) eq "ARRAY" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 1 | $groups = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 5 | $groups = [ $_[1] ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 6 | for my $group ( @{$groups} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 7 | ▶ | if ( Rex::Group->is_group($group) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 6 | my @group_server = Rex::Group->get_group($group); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # check if the group is empty. this is mostly due to a failure. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | # so report it, and exit. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 6 | ▶ | if ( scalar @group_server == 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
scalar @group_server == 0 and "Rex::Config"->get_allow_empty_groups == 0
MC/DC0%0/2
scalar @group_server == 0 and "Rex::Config"->get_allow_empty_groups == 0
scalar @group_server == 0
"Rex::Config"->get_allow_empty_groups == 0
Truth table33%1/3
A and B
A= scalar @group_server == 0B= "Rex::Config"->get_allow_empty_groups == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | && Rex::Config->get_allow_empty_groups() == 0 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | Rex::Logger::info( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | "The group $group is empty. This is mostly due to a failure.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | "warn" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | Rex::Logger::info( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | "If this is an expected behaviour, please add the feature flag 'empty_groups'.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | "warn" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | CORE::exit(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 6 | push( @server, @group_server ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | Rex::Logger::debug("Using late group-lookup"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | ▶ | push @server, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | ▶ | if ( !Rex::Group->is_group($group) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | Rex::Logger::info( "No group $group defined.", "error" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | ▶ | if ( ref $_ && $_->isa("Rex::Group::Entry::Server") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $_ and $_->isa("Rex::Group::Entry::Server")
MC/DC0%0/2
ref $_ and $_->isa("Rex::Group::Entry::Server")
ref $_
$_->isa("Rex::Group::Entry::Server")
Truth table33%1/3
A and B
A= ref $_B= $_->isa("Rex::Group::Entry::Server")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 1 | $_->get_servers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | Rex::Group::Entry::Server->new( name => $_ )->get_servers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } Rex::Group->get_group($group); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 7 | for my $entry (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 10 | ▶ | push( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $entry and $entry->isa("Rex::Group::Entry::Server")
MC/DC50%1/2
ref $entry and $entry->isa("Rex::Group::Entry::Server")
ref $entry
$entry->isa("Rex::Group::Entry::Server")
Truth table66%2/3
A and B
A= ref $entryB= $entry->isa("Rex::Group::Entry::Server")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | @server, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | ref $entry && $entry->isa("Rex::Group::Entry::Server") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | ? $entry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | : Rex::Group::Entry::Server->new( name => $entry ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | my %task_hash = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | func => $func, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | server => [@server], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | desc => $desc, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | no_ssh => ( $options->{"no_ssh"} ? 1 : 0 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | hidden => ( $options->{"dont_register"} ? 1 : 0 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | exit_on_connect_fail => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | exists $options->{exit_on_connect_fail} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | ? $options->{exit_on_connect_fail} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 212 | ▶ | : 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | before => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | after => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | around => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | after_task_finished => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | before_task_start => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | name => $task_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | executor => Rex::Interface::Executor->create, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | connection_type => Rex::Config->get_connection_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 212 | ▶ | if ( $self->{DEFAULT_AUTH} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | $task_hash{auth} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 207 | ▶ | user => Rex::Config->get_user || undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%8/10
'Rex::Config'->get_user || undef
'Rex::Config'->get_password || undef
'Rex::Config'->get_private_key || undef
'Rex::Config'->get_public_key || undef
'Rex::Config'->get_sudo_password || undef
MC/DC0%0/1
'Rex::Config'->get_user || undef
'Rex::Config'->get_user
MC/DC100%1/1
'Rex::Config'->get_password || undef
'Rex::Config'->get_password
MC/DC100%1/1
'Rex::Config'->get_private_key || undef
'Rex::Config'->get_private_key
MC/DC100%1/1
'Rex::Config'->get_public_key || undef
'Rex::Config'->get_public_key
MC/DC0%0/1
'Rex::Config'->get_sudo_password || undef
'Rex::Config'->get_sudo_password
Truth table50%1/2
A
A= 'Rex::Config'->get_user
Truth table100%2/2
A
A= 'Rex::Config'->get_password
Truth table100%2/2
A
A= 'Rex::Config'->get_private_key
Truth table100%2/2
A
A= 'Rex::Config'->get_public_key
Truth table50%1/2
A
A= 'Rex::Config'->get_sudo_password
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | password => Rex::Config->get_password || undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | private_key => Rex::Config->get_private_key || undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | public_key => Rex::Config->get_public_key || undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | sudo_password => Rex::Config->get_sudo_password || undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 212 | ▶ | if ( exists $Rex::Commands::auth_late{$task_name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 1 | $task_hash{auth} = $Rex::Commands::auth_late{$task_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 212 | $self->{tasks}->{$task_name} = Rex::Task->new(%task_hash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 212 | return $self->{tasks}->{$task_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 17 | ▶ | sub get_tasks { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_tasks: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 17 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 60 | return grep { $self->{tasks}->{$_}->hidden() == 0 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 17 | sort { $a cmp $b } keys %{ $self->{tasks} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 96 | ▶ | sub get_all_tasks { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_all_tasks: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 96 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 96 | my $regexp = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 247 | return grep { $_ =~ $regexp } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 96 | keys %{ $self->{tasks} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 2 | ▶ | sub get_tasks_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_tasks_for: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 2 | my $host = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 2 | my @tasks; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 2 | for my $task_name ( keys %{ $self->{tasks} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 6 | my @servers = @{ $self->{tasks}->{$task_name}->server() }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 6 | ▶ | if ( ( grep { /^$host$/ } @servers ) || $#servers == -1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
grep {/^$host$/u;} @servers or $#servers == -1
MC/DC50%1/2
grep {/^$host$/u;} @servers or $#servers == -1
grep {/^$host$/u;} @servers
$#servers == -1
Truth table66%2/3
A or B
A= grep {/^$host$/u;} @serversB= $#servers == -1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 3 | push @tasks, $task_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 2 | my @ret = sort { $a cmp $b } @tasks; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 2 | return @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 273 | ▶ | sub get_task { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_task: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 273 | my ( $self, $task ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 273 | return $self->{tasks}->{$task}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 7 | ▶ | sub clear_tasks { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_tasks: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 7 | $self->{tasks} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 1 | ▶ | sub get_desc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_desc: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 1 | my $task = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 1 | return $self->{tasks}->{$task}->desc(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 192 | ▶ | sub is_task { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_task: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 192 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 192 | my $task = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 192 | ▶ | if ( exists $self->{tasks}->{$task} ) { return 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 66 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 16 | ▶ | sub current_task { shift->{__current_task__} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
current_task: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 138 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 138 | my ( $self, $task, %options ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 138 | ▶ | if ( !ref $task ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $task = Rex::TaskList->create()->get_task($task); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 138 | my $fm = Rex::Fork::Manager->new( max => $self->get_thread_count($task) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 138 | my $all_servers = $task->server; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 138 | for my $server (@$all_servers) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 138 | my $child_coderef = $self->build_child_coderef( $task, $server, %options ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 138 | ▶ | if ( $self->{IN_TRANSACTION} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | # Inside a transaction -- no forking and no chance to get zombies. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | # This only happens if someone calls do_task() from inside a transaction. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 3 | $child_coderef->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | # Not inside a transaction, so lets fork | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | # Add $forked_sub to the fork queue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 135 | $fm->add($child_coderef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 107 | Rex::Logger::debug("Waiting for children to finish"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 107 | my $ret = $fm->wait_for_all; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 107 | Rex::reconnect_lost_connections(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 107 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 138 | ▶ | sub build_child_coderef { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_child_coderef: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 138 | my ( $self, $task, $server, %options ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 32 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 32 | Rex::Logger::init(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 32 | Rex::Logger::info( "Running task " . $task->name . " on $server" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 32 | my $return_value = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | $task->clone->run( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | $server, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | in_transaction => $self->{IN_TRANSACTION}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | params => $options{params}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | args => $options{args}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 32 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 32 | ▶ | if ( $self->{IN_TRANSACTION} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 3 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 29 | my $e = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 29 | ▶ | my $exit_code = $@ ? ( $? || 1 ) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$? or 1
MC/DC100%1/1
$? or 1
$?
Truth table100%2/2
A
A= $?
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 29 | push @SUMMARY, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | task => $task->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | server => $server->to_s, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | exit_code => $exit_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | error_message => $e, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 30 | Rex::Logger::debug("Destroying all cached os information"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 30 | Rex::Logger::shutdown(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 30 | return $return_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 138 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 85 | ▶ | sub modify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
modify: called CC=8 SCAR=20.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 85 | my ( $self, $type, $task, $code, $package, $file, $line ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 85 | ▶ | if ( $package ne "main" && $package ne "Rex::CLI" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$package ne "main" and $package ne "Rex::CLI"
MC/DC100%2/2
$package ne "main" and $package ne "Rex::CLI"
$package ne "main"
$package ne "Rex::CLI"
Truth table100%3/3
A and B
A= $package ne "main"B= $package ne "Rex::CLI"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 5 | ▶ | if ( $task !~ m/:/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | #do we need to detect for base -Rex ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 4 | $package =~ s/^Rex:://; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 85 | $package =~ s/::/:/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 85 | my @all_tasks = map { $self->get_task($_); } grep { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 85 | ▶ | if ( $package ne "main" && $package ne "Rex:CLI" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$package ne "main" and $package ne "Rex:CLI"
MC/DC100%2/2
$package ne "main" and $package ne "Rex:CLI"
$package ne "main"
$package ne "Rex:CLI"
Truth table100%3/3
A and B
A= $package ne "main"B= $package ne "Rex:CLI"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 5 | $_ =~ m/^\Q$package\E:/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 80 | $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } $self->get_all_tasks($task); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 85 | ▶ | if ( !@all_tasks ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | Rex::Logger::info( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | "Can't add $type $task, as it is not yet defined\nsee $file line $line"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 85 | for my $taskref (@all_tasks) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 85 | $taskref->modify( $type => $code ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | sub set_default_auth { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_default_auth: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | my ( $self, $auth ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | $self->{DEFAULT_AUTH} = $auth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 1 | ▶ | sub is_default_auth { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_default_auth: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 1 | return $self->{DEFAULT_AUTH}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 6 | ▶ | sub set_in_transaction { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_in_transaction: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 6 | my ( $self, $val ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 6 | $self->{IN_TRANSACTION} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | sub is_transaction { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_transaction: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | return $self->{IN_TRANSACTION}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | ▶ | sub get_exit_codes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_exit_codes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | return map { $_->{exit_code} } @SUMMARY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 138 | ▶ | sub get_thread_count { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_thread_count: called CC=6 SCAR=28.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 138 | my ( $self, $task ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 138 | ▶ | my $threads = $task->parallelism || Rex::Config->get_parallelism; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$task->parallelism || 'Rex::Config'->get_parallelism
MC/DC0%0/2
$task->parallelism || 'Rex::Config'->get_parallelism
$task->parallelism
'Rex::Config'->get_parallelism
Truth table33%1/3
A || B
A= $task->parallelismB= 'Rex::Config'->get_parallelism
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 138 | my $server_count = scalar @{ $task->server }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 138 | ▶ | return $1 if $threads =~ /^(\d+)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | return floor( $server_count / $1 ) if $threads =~ /^max\s?\/(\d+)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | return floor( $server_count * $1 / 100 ) if $threads =~ /^max (\d+)%$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | return $server_count if $threads eq 'max'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | Rex::Logger::info( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | "Unrecognized thread count requested: '$threads'. Falling back to a single thread.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 'warn' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 51 | ▶ | sub get_summary { @SUMMARY } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_summary: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 56 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||