Branch Coverage

blib/lib/Perlbal/Service.pm
Criterion Covered Total %
branch 132 352 37.5


line true false branch
651 44 0 unless ref $self
693 0 264 unless $$self{$v}
741 0 0 if $$attrs{'dump_ignore'}
743 0 0 $$attrs{'_plugin_inserted'} ? :
750 0 0 if $check_role and $check_role ne '*' and $check_role ne $role
752 0 0 if ($check_type and $check_type eq 'size')
753 0 0 if $default =~ /^(\d+)b$/i
754 0 0 if $default =~ /^(\d+)k$/i
755 0 0 if $default =~ /^(\d+)m$/i
758 0 0 unless ($required)
759 0 0 unless defined $value
760 0 0 if defined $default and $value eq $default
763 0 0 if (my $dumper = $$attrs{'dumper'})
767 0 0 if ($check_type and $check_type eq 'bool')
768 0 0 if $value
782 0 0 if ($cv) { }
784 0 0 if ($@)
798 0 43 unless $$self{'role'}
803 1234 1092 unless $$tun{'check_role'} eq '*' or $$tun{'check_role'} eq $$self{'role'}
805 0 1092 if (exists $$defaults{$param}) { }
858 234 elsif (exists $$tun{'default'}) { }
835 0 0 unless ($$self{'pool'})
837 0 0 unless $Perlbal::vivify_pools
848 0 0 if $Perlbal::vivify_pools
851 0 0 unless $$self{'pool'}
857 0 1084 if $key eq 'nodefile' or $key eq 'balance_method'
861 1078 6 if (my $tun = $$tunables{$key})
862 1078 0 if (my $req_role = $$tun{'check_role'})
863 0 1078 unless ($$self{'role'} || '') eq $req_role or $req_role eq '*'
867 993 85 if (my $req_type = $$tun{'check_type'})
868 0 993 if (ref $req_type eq 'ARRAY' and $$req_type[0] eq 'enum') { }
40 953 elsif (ref $req_type eq 'ARRAY' and $$req_type[0] eq 'regexp') { }
85 868 elsif (ref $req_type eq 'CODE') { }
372 496 elsif ($req_type eq 'bool') { }
221 275 elsif ($req_type eq 'int') { }
146 129 elsif ($req_type eq 'size') { }
0 129 elsif ($req_type eq 'file') { }
86 43 elsif ($req_type eq 'file_or_none') { }
43 0 elsif ($req_type eq 'directory_or_none') { }
870 0 0 unless grep {$val eq $_;} @{$$req_type[1];}
874 0 40 unless $val =~ /$re/
877 1 84 unless &$req_type($self, $val, \$emsg)
880 0 372 unless defined $val
883 0 221 unless $val =~ /^\d+$/
886 0 146 if $val =~ /^(\d+)b$/i
887 36 110 if $val =~ /^(\d+)k$/i
888 0 146 if $val =~ /^(\d+)m$/i
889 0 146 unless $val =~ /^\d+$/
892 0 0 unless -f $val
894 0 86 unless -f $val or $val eq $$tun{'default'}
896 0 43 unless not defined $val or -d $val
902 4 1073 if ($$tun{'_plugin_inserted'})
913 134 943 if (ref $setter eq 'CODE') { }
920 6 0 if ($key eq 'plugins')
924 0 0 if $@
934 0 6 if $plugin eq 'none'
938 0 6 if $$self{'plugins'}{$fn}
939 0 6 unless ($Perlbal::plugins{$fn})
946 0 6 if $@
953 0 0 if ($key =~ /^extra\.(.+)$/)
960 0 0 if ($key =~ /^(.+)\.(.+)$/)
961 0 0 if (my $coderef = $$self{'plugin_setters'}{$1}{$2})
980 0 100373 unless defined $val
983 109 100264 if defined $h_on{$val}
984 263 100001 if defined $h_off{$val}
995 0 2 unless $name and $hashref and ref $hashref eq 'HASH'
996 0 2 if $$tunables{$name}
1006 0 0 unless my $tun = $$tunables{$name}
1007 0 0 unless $$tun{'_plugin_inserted'}
1016 0 0 unless $role and $creator and ref $creator eq 'CODE'
1017 0 0 if $PluginRoles{$role}
1025 0 0 unless delete $PluginRoles{$_[0]}
1041 2 1662 if (defined(my $ref = $$self{'hooks'}{$hook}))
1045 1 1 if $rval
1055 0 146 if (defined(my $ref = $$self{'hooks'}{$hook}))
1074 0 0 if (defined(my $refs = $$self{'hooks'}{$hook}))
1078 0 0 unless $$ref[0] eq $pclass
1100 0 0 unless $pclass and $key and $coderef
1108 0 0 unless $pclass and $key
1116 0 0 unless $pclass
1127 0 20 if (defined $$self{'pending_connects'}{$$be{'ipport'}})
1151 20 0 if (defined $$self{'pending_connects'}{$$be{'ipport'}} and defined $be and $$self{'pending_connects'}{$$be{'ipport'}} == $be)
1172 0 24 if (delete $$self{'waiting_client_map'}{$$cp{'fd'}})
1179 135 0 if $$self{'pool'}
1199 0 139 if ($$self{'queue_relief_size'} > 0 and scalar @{$$self{'waiting_clients'};} >= $$self{'queue_relief_size'})
1202 0 0 if rand 100 < $$self{'queue_relief_chance'}
1209 0 0 if $$cp{'closed'}
1219 0 20 if $$cp{'closed'}
1226 0 0 if $$cp{'closed'}
1240 254 0 if $$self{'generation'} == $be->generation
1243 0 0 if (defined $$self{'pool'}->node_used($be->ipport))
1264 20 119 unless ($$be{'use_count'})
1270 0 139 unless $self->verify_generation($be)
1274 20 119 if ($cp)
1275 20 0 if $be->assign_client($cp)
1285 119 0 if ($$be{'use_count'})
1287 0 119 if ($current_bored >= $$self{'backend_persist_cache'})
1296 119 0 if ($$be{'has_attention'}) { }
1312 0 0 if (defined $retry_time and $retry_time > 0)
1335 0 135 unless $cp and not $$cp{'closed'}
1341 0 135 if (my $cname = $$self{'high_priority_cookie'})
1346 0 0 unless $_ =~ /(.*)=(.*)/
1354 135 0 unless $hi_pri
1358 135 0 unless $hi_pri or $low_pri
1361 0 135 if $hi_pri
1362 0 135 if $low_pri
1369 0 115 if $$be{'closed'}
1372 0 115 unless $self->verify_generation($be)
1376 0 115 if (not $$be{'has_attention'} and $$be{'create_time'} < $now - 5)
1383 0 115 if ($$be{'disconnect_at'} and $now + 2 > $$be{'disconnect_at'})
1389 115 0 if ($be->assign_client($cp))
1396 0 0 if $$cp{'closed'}
1399 0 20 if ($hi_pri) { }
0 20 elsif ($low_pri) { }
1418 0 171 if $$self{'spawn_lock'}
1422 0 171 if ($$self{'pending_connect_count'} < 0)
1425 0 0 if $_
1437 171 0 $pool ? :
1438 0 171 if $to_create > $max_creatable
1441 0 171 if $to_create > 10
1449 0 20 unless ($pool)
1450 0 0 if (my $sp = $$self{'server_process'})
1461 0 20 unless ($ip)
1469 0 20 if $$self{'backend_no_spawn'}{"${ip}:$port"}
1472 0 20 if (my $be = $$self{'pending_connects'}{"${ip}:$port"})
1474 0 0 if ($age >= 5 and $$be{'state'} eq 'connecting') { }
0 0 elsif ($age >= 60 and $$be{'state'} eq 'verifying_backend') { }
0 0 elsif (not $$be{'closed'}) { }
1485 20 0 if (my $be = 'Perlbal::BackendHTTP'->new($self, $ip, $port, {'pool', $$self{'pool'}}))
1505 0 431 if $$self{'always_trusted'}
1508 431 0 unless $tmap
1512 0 0 if eval { do { $tmap->match($ip) } }
1521 0 2 unless $key
1522 0 2 unless defined $val and length $val or $mode eq 'remove'
1525 2 0 if ($mode eq 'insert') { }
0 0 elsif ($mode eq 'remove') { }
1551 4 89 if (@_)
1560 0 89 if (not $res and $$self{'default_service'})
1585 87 0 if (my $orig_service = $$cb{'service'})
1591 7 80 if ($$self{'role'} eq 'web_server') { }
55 25 elsif ($$self{'role'} eq 'reverse_proxy') { }
24 1 elsif ($$self{'role'} eq 'selector') { }
1624 0 42 if ($$self{'enabled'})
1625 0 0 if $mc
1632 0 42 if ($$self{'role'} eq 'upload_tracker')
1637 39 3 if (not $listener and $$self{'listen'})
1639 0 39 if ($$self{'enable_ssl'})
1640 0 0 defined $$self{'ssl_ca_path'} ? :
0 0 defined $$self{'ssl_verify_mode'} ? :
1647 0 0 unless eval 'use IO::Socket::SSL 0.98 (); 1;'
1648 0 0 unless -f $$self{'ssl_key_file'}
1649 0 0 unless -f $$self{'ssl_cert_file'}
1653 0 39 unless ($tl)
1654 0 0 if $mc
1662 42 0 $mc ? :
1672 0 0 unless ($$self{'enabled'})
1673 0 0 if $mc
1676 0 0 if ($$self{'role'} eq 'management' and not $force)
1677 0 0 if $mc
1683 0 0 if $tl
1686 0 0 $mc ? :
1698 0 0 if ($$self{'role'} eq 'reverse_proxy' or $$self{'role'} eq 'web_server')
1704 0 0 unless $be
1706 0 0 $$be{'closed'} ? :
1709 0 0 if ($$self{'role'} eq 'reverse_proxy') { }
0 0 elsif ($$self{'role'} eq 'web_server') { }
1710 0 0 if ($$self{'reproxy_cache'})
1715 0 0 defined $size ? :
1718 0 0 defined $maxsize ? :
1729 0 0 if ($$self{'pool'})
1770 0 2 unless my $cache = $$self{'reproxy_cache'}
1774 0 2 unless my $reproxy_cache_for = $reshd->header('X-REPROXY-CACHE-FOR')
1775 0 2 unless my $urls = $reshd->header('X-REPROXY-URL')
1778 2 0 $timeout_delta ? :
1787 2 4 unless $header and $value = $reshd->header($header)
1788 2 2 if uc $header eq 'CONTENT-TYPE'