blib/lib/Langertha/Holmgang/Sim/Linux/Redis.pm

filter: Statementstmt 86.6% 430 / 496 Branchbran 61.1% 225 / 368 Conditioncond 46.4% 219 / 472 MC/DCmcdc 16.3% 38 / 233 Subroutinesub 100% 32 / 32 Podpod 100% 4 / 4 totaltotal 59.0% 948 / 1605 CC 393 SCAR 69.7
CC
393
Cov
65%
_command
2513.9
redis_cli
153.6
_info
60.9
CRAP 1062.3
« blib/lib/Langertha/Holmgang/Sim/Linux/MariaDB.pm ↑ Summary blib/lib/Langertha/Holmgang/Sim/Linux/Kubernetes.pm »
1 package Langertha::Holmgang::Sim::Linux::Redis;
2 # ABSTRACT: Redis on a simulated Linux server — redis-cli, CONFIG GET/SET/REWRITE, INFO, BGSAVE
3  
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 ▶use JSON::MaybeXS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Langertha::Holmgang::Shell ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Langertha::Holmgang::Sim::Linux ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 4 our $VERSION = '0.001';
13  
14  
15 4 our @GAPS;
16 4 our %REAL_CMD; # echte Redis-Befehle ohne Nachbildung (unten)
17  
18 # Vorgaben von Redis 7.0 (Debian 12); Werte wie CONFIG GET sie zeigt
19 4 our %DEFAULT = (
20 bind => '127.0.0.1 -::1',
21 port => '6379',
22 'protected-mode' => 'yes',
23 requirepass => '',
24 masterauth => '',
25 masteruser => '',
26 maxmemory => '0',
27 'maxmemory-policy' => 'noeviction',
28 'maxmemory-samples' => '5',
29 maxclients => '10000',
30 save => '3600 1 300 100 60 10000',
31 appendonly => 'no',
32 appendfsync => 'everysec',
33 dir => '/var/lib/redis',
34 dbfilename => 'dump.rdb',
35 timeout => '0',
36 'tcp-keepalive' => '300',
37 'tcp-backlog' => '511',
38 databases => '16',
39 loglevel => 'notice',
40 logfile => '/var/log/redis/redis-server.log',
41 daemonize => 'yes',
42 supervised => 'auto',
43 pidfile => '/run/redis/redis-server.pid',
44 'stop-writes-on-bgsave-error' => 'yes',
45 'rdbcompression' => 'yes',
46 'replica-read-only' => 'yes',
47 'replica-serve-stale-data' => 'yes',
48 'lazyfree-lazy-eviction' => 'no',
49 'slowlog-log-slower-than' => '10000',
50 'slowlog-max-len' => '128',
51 'notify-keyspace-events' => '',
52 );
53  
54 4 our %IMMUTABLE = map { $_ => 1 } qw( daemonize supervised databases pidfile );
55 4 our %BYTES = map { $_ => 1 } qw( maxmemory );
56 4 our %BOOL = map { $_ => 1 } qw( protected-mode appendonly daemonize stop-writes-on-bgsave-error rdbcompression
57 replica-read-only replica-serve-stale-data lazyfree-lazy-eviction );
58 4 our %ENUM = (
59 'maxmemory-policy' => [qw( volatile-lru allkeys-lru volatile-lfu allkeys-lfu volatile-random allkeys-random volatile-ttl noeviction )],
60 appendfsync => [qw( always everysec no )],
61 loglevel => [qw( debug verbose notice warning nothing )],
62 supervised => [qw( upstart systemd auto no )],
63 );
64 4 our %ALIAS = ( slaveof => 'replicaof', 'slave-read-only' => 'replica-read-only', 'slave-serve-stale-data' => 'replica-serve-stale-data' );
65  
66 10 ▶sub _bytes {
Subroutine _bytes: called CC=4 SCAR=15.6
67 10 my ($v) = @_;
68 10 ▶ return undef unless defined $v && $v =~ /\A\s*(\d+)\s*(b|k|kb|m|mb|g|gb)?\s*\z/i;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v and $v =~ /\A\s*(\d+)\s*(b|k|kb|m|mb|g|gb)?\s*\z/i 0 10 10
Condition33%1/3
defined $v and $v =~ /\A\s*(\d+)\s*(b|k|kb|m|mb|g|gb)?\s*\z/i
!ll&&!rl&&r
0010
MC/DC0%0/2
defined $v and $v =~ /\A\s*(\d+)\s*(b|k|kb|m|mb|g|gb)?\s*\z/i
defined $v $v =~ /\A\s*(\d+)\s*(b|k|kb|m|mb|g|gb)?\s*\z/i
Truth table33%1/3
A and B
A= defined $vB= $v =~ /\A\s*(\d+)\s*(b|k|kb|m|mb|g|gb)?\s*\z/i
ABresult
0X0
100
111
69 10 my %f = ( '' => 1, b => 1, k => 1000, kb => 1024, m => 1000_000, mb => 1024**2, g => 1000_000_000, gb => 1024**3 );
70 10 ▶ return $1 * $f{ lc( $2 // '' ) };
Condition50%1/2
$2 // ""
l!l
100
MC/DC0%0/1
$2 // ""
$2
Truth table50%1/2
A
A= $2
Aresult
11
00
71 }
72  
73 1 ▶sub _human_bytes {
Subroutine _human_bytes: called CC=4 SCAR=16.9
74 1 my ($n) = @_;
75 1 for ( [ 1024**3, 'gb' ], [ 1024**2, 'mb' ], [ 1024, 'kb' ] ) {
76 1 ▶ return ( $n / $_->[0] ) . $_->[1] if $n && $n % $_->[0] == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $n and $n % $$_[0] == 0 1 0 1
Condition33%1/3
$n and $n % $$_[0] == 0
!ll&&!rl&&r
001
MC/DC0%0/2
$n and $n % $$_[0] == 0
$n $n % $$_[0] == 0
Truth table33%1/3
A and B
A= $nB= $n % $$_[0] == 0
ABresult
0X0
100
111
77 }
78 0 return "$n";
79 }
80  
81 12 ▶sub _info_human {
Subroutine _info_human: called CC=3 SCAR=11.0
82 12 my ($n) = @_;
83 12 ▶ for ( [ 1024**3, 'G' ], [ 1024**2, 'M' ], [ 1024, 'K' ] ) { return sprintf( '%.2f%s', $n / $_->[0], $_->[1] ) if $n >= $_->[0] }
Branch: 1 branch
BranchTrueFalseTotal
if $n >= $$_[0] 9 12 21
84 3 return "${n}B";
85 }
86  
87 15 ▶sub _file_text {
Subroutine _file_text: called CC=5 SCAR=16.3
88 15 my ( $dev, $p ) = @_;
89 15 ▶ my $e = ( $dev->{files} || {} )->{$p};
Condition50%1/2
$$dev{'files'} || {}
l!l
150
MC/DC0%0/1
$$dev{'files'} || {}
$$dev{'files'}
Truth table50%1/2
A
A= $$dev{'files'}
Aresult
11
00
90 15 ▶ return undef unless defined $e;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $e 1 14 15
91 14 ▶ return ref $e eq 'HASH' ? $e->{content} // '' : $e;
Branch: 1 branch
BranchTrueFalseTotal
ref $e eq 'HASH' ? : 11 3 14
Condition50%1/2
$$e{"content"} // ""
l!l
110
MC/DC0%0/1
$$e{"content"} // ""
$$e{"content"}
Truth table50%1/2
A
A= $$e{"content"}
Aresult
11
00
92 }
93  
94 1 ▶sub _set_file {
Subroutine _set_file: called CC=2 SCAR=7.1
95 1 my ( $dev, $p, $t ) = @_;
96 1 my $e = $dev->{files}{$p};
97 1 ▶ if ( ref $e eq 'HASH' ) { my %n = %$e; delete @n{qw( size link )}; $n{content} = $t; $dev->{files}{$p} = \%n }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $e eq 'HASH') { } 1 0 1
98 0 else { $dev->{files}{$p} = $t }
99 1 return;
100 }
101  
102 # Wert pruefen und normalisieren: ( wert ) oder ( undef, fehlertext )
103 66 ▶sub _check_value {
Subroutine _check_value: called CC=11 SCAR=26.8
104 66 my ( $k, $v ) = @_;
105 66 ▶ $v //= '';
Condition50%1/2
$v //= ""
l!l
660
MC/DC0%0/1
$v //= ""
$v
Truth table50%1/2
A
A= $v
Aresult
11
00
106 66 ▶ if ( $BYTES{$k} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Langertha::Holmgang::Sim::Linux::Redis::BYTES{$k}) 10 56 66
107 10 ▶ my $b = _bytes($v) // return ( undef, "argument must be a memory value" );
Condition50%1/2
_bytes($v) // (return undef, "argument must be a memory value")
l!l
100
MC/DC0%0/1
_bytes($v) // (return undef, "argument must be a memory value")
_bytes($v)
Truth table50%1/2
A
A= _bytes($v)
Aresult
11
00
108 10 return ("$b");
109 }
110 56 ▶ if ( $BOOL{$k} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Langertha::Holmgang::Sim::Linux::Redis::BOOL{$k}) 0 56 56
111 0 my $x = lc $v;
112 0 ▶ return ( undef, "argument must be 'yes' or 'no'" ) unless $x eq 'yes' || $x eq 'no';
Branch: 1 branch
BranchTrueFalseTotal
unless $x eq "yes" or $x eq "no" 0 0 0
Condition0%0/3
$x eq "yes" or $x eq "no"
l!l&&r!l&&!r
000
MC/DC0%0/2
$x eq "yes" or $x eq "no"
$x eq "yes" $x eq "no"
Truth table0%0/3
A or B
A= $x eq "yes"B= $x eq "no"
ABresult
1X1
011
000
113 0 return ($x);
114 }
115 56 ▶ if ( my $l = $ENUM{$k} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $l = $Langertha::Holmgang::Sim::Linux::Redis::ENUM{$k}) 12 44 56
116 12 my $x = lc $v;
117 12 ▶ return ( undef, 'argument(s) must be one of the following: ' . join( ', ', @$l ) ) unless grep { $_ eq $x } @$l;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $x;} @$l 1 11 12
118 11 return ($x);
119 }
120 44 ▶ if ( $k =~ /\A(?:port|maxclients|databases|timeout|tcp-keepalive|tcp-backlog|maxmemory-samples|slowlog-log-slower-than|slowlog-max-len)\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($k =~ /\A(?:port|maxclients|databases|timeout|tcp-keepalive|tcp-backlog|maxmemory-samples|slowlog-log-slower-than|slowlog-max-len)\z/) 17 27 44
121 17 ▶ return ( undef, 'argument couldn\'t be parsed into an integer' ) unless $v =~ /\A-?\d+\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $v =~ /\A-?\d+\z/ 0 17 17
122 17 return ("$v");
123 }
124 27 return ($v);
125 }
126  
127  
128 14 ▶sub parse_conf {
Subroutine parse_conf: called CC=17 SCAR=30.8
Pod documented
129 14 my ($text) = @_;
130 14 my %v = %DEFAULT;
131 14 my $n = 0;
132 14 ▶ for my $line ( split /\n/, $text // '' ) {
Condition100%2/2
$text // ""
l!l
131
MC/DC100%1/1
$text // ""
$text
Truth table100%2/2
A
A= $text
Aresult
11
00
133 74 $n++;
134 74 ▶ next if $line =~ /\A\s*(?:#|\z)/;
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /\A\s*(?:#|\z)/ 0 74 74
135 74 my ( $k, $rest ) = $line =~ /\A\s*(\S+)\s*(.*?)\s*\z/;
136 74 $k = lc $k;
137 74 ▶ $k = $ALIAS{$k} // $k;
Condition33%1/3
$Langertha::Holmgang::Sim::Linux::Redis::ALIAS{$k} // $k
l!l&&r!l&&!r
0740
MC/DC0%0/2
$Langertha::Holmgang::Sim::Linux::Redis::ALIAS{$k} // $k
$Langertha::Holmgang::Sim::Linux::Redis::ALIAS{$k} $k
Truth table33%1/3
A // B
A= $Langertha::Holmgang::Sim::Linux::Redis::ALIAS{$k}B= $k
ABresult
1X1
011
000
138 74 ▶ next if $k eq 'include' || $k eq 'rename-command' || $k eq 'unixsocket' || $k eq 'unixsocketperm';
Branch: 1 branch
BranchTrueFalseTotal
if $k eq "include" or $k eq "rename-command" or $k eq "unixsocket" or $k eq "unixsocketperm" 0 74 74
Condition33%3/9
$k eq "include" or $k eq "rename-command" or $k eq "unixsocket" or $k eq "unixsocketperm"
l!l&&r!l&&!r
0074
$k eq "include" or $k eq "rename-command" or $k eq "unixsocket"
l!l&&r!l&&!r
0074
$k eq "include" or $k eq "rename-command"
l!l&&r!l&&!r
0074
MC/DC0%0/4
$k eq "include" or $k eq "rename-command" or $k eq "unixsocket" or $k eq "unixsocketperm"
$k eq "include" $k eq "rename-command" $k eq "unixsocket" $k eq "unixsocketperm"
Truth table20%1/5
A or B or C or D
A= $k eq "include"B= $k eq "rename-command"C= $k eq "unixsocket"D= $k eq "unixsocketperm"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
139 74 ( my $val = $rest ) =~ s/\A"(.*)"\z/$1/;
140 74 ▶ if ( $k eq 'replicaof' ) { $v{replicaof} = $val; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($k eq "replicaof") 1 73 74
141 73 ▶ if ( $k eq 'save' ) { $v{save} = $v{_save_seen}++ ? "$v{save} $val" : $val; $v{save} = '' if $val eq '""' || $val eq ''; next }
Branch: 3 branches
BranchTrueFalseTotal
if ($k eq "save") 10 63 73
$v{'_save_seen'}++ ? : 0 10 10
if $val eq "\"\"" or $val eq "" 0 10 10
Condition33%1/3
$val eq "\"\"" or $val eq ""
l!l&&r!l&&!r
0010
MC/DC0%0/2
$val eq "\"\"" or $val eq ""
$val eq "\"\"" $val eq ""
Truth table33%1/3
A or B
A= $val eq "\"\""B= $val eq ""
ABresult
1X1
011
000
142 63 ▶ return ( undef, $n, $line, 'Bad directive or wrong number of arguments' ) unless exists $DEFAULT{$k};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $Langertha::Holmgang::Sim::Linux::Redis::DEFAULT{$k} 2 61 63
143 61 ▶ my ( $x, $err ) = _check_value( $k, $k eq 'bind' ? $rest : $val );
Branch: 1 branch
BranchTrueFalseTotal
$k eq 'bind' ? : 13 48 61
144 61 ▶ return ( undef, $n, $line, $err ) unless defined $x;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $x 0 61 61
145 61 $v{$k} = $x;
146 }
147 12 delete $v{_save_seen};
148 12 return ( \%v );
149 }
150  
151 163 ▶sub _running {
Subroutine _running: called CC=4 SCAR=13.9
152 163 my ($dev) = @_;
153 163 my $r = $dev->{redis};
154 163 ▶ if ( !$r->{running} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($$r{"running"}) 9 154 163
155 9 ▶ my ($v) = parse_conf( _file_text( $dev, $r->{conf} // '/etc/redis/redis.conf' ) );
Condition100%2/2
$$r{"conf"} // "/etc/redis/redis.conf"
l!l
81
MC/DC100%1/1
$$r{"conf"} // "/etc/redis/redis.conf"
$$r{"conf"}
Truth table100%2/2
A
A= $$r{"conf"}
Aresult
11
00
156 9 ▶ $r->{running} = $v // {%DEFAULT};
Condition100%2/2
$v // {%Langertha::Holmgang::Sim::Linux::Redis::DEFAULT}
l!l
81
MC/DC100%1/1
$v // {%Langertha::Holmgang::Sim::Linux::Redis::DEFAULT}
$v
Truth table100%2/2
A
A= $v
Aresult
11
00
157 }
158 163 return $r->{running};
159 }
160  
161  
162 3 ▶sub conf_error {
Subroutine conf_error: called CC=4 SCAR=14.1
Pod documented
163 3 my ($dev) = @_;
164 3 ▶ my $r = $dev->{redis} or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $r = $$dev{"redis"} or return undef 3 0 3
165 3 ▶ my ( $v, $n, $line, $why ) = parse_conf( _file_text( $dev, $r->{conf} // '/etc/redis/redis.conf' ) );
Condition50%1/2
$$r{"conf"} // "/etc/redis/redis.conf"
l!l
30
MC/DC0%0/1
$$r{"conf"} // "/etc/redis/redis.conf"
$$r{"conf"}
Truth table50%1/2
A
A= $$r{"conf"}
Aresult
11
00
166 3 ▶ return undef if $v;
Branch: 1 branch
BranchTrueFalseTotal
if $v 2 1 3
167 1 return [ '*** FATAL CONFIG FILE ERROR (Redis 7.0.15) ***', "Reading the configuration file, at line $n", ">>> '$line'", $why ];
168 }
169  
170  
171 3 ▶sub service_event {
Subroutine service_event: called CC=20 SCAR=33.2
Pod documented
172 3 my ( $dev, $verb, $state ) = @_;
173 3 ▶ my $r = $dev->{redis} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $r = $$dev{"redis"} or return 3 0 3
174 # beim Herunterfahren sichert Redis, wenn Sicherungspunkte gesetzt sind (scheitert es, ist der Rest weg)
175 3 ▶ _bgsave($dev) if ( $verb eq 'restart' || $verb eq 'stop' ) && ( _running($dev)->{save} // '' ) ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $verb eq "restart" || $verb eq "stop" and (_running($dev)->{"save"} // "") ne "" 3 0 3
Condition50%4/8
$verb eq "restart" || $verb eq "stop" and (_running($dev)->{"save"} // "") ne ""
!ll&&!rl&&r
003
$verb eq "restart" or $verb eq "stop"
l!l&&r!l&&!r
210
_running($dev)->{"save"} // ""
l!l
30
MC/DC0%0/3
$verb eq "restart" || $verb eq "stop" and (_running($dev)->{"save"} // "") ne ""
$verb eq "restart" $verb eq "stop" _running($dev)->{"save"}
Truth table40%2/5
A or B and C
A= $verb eq "restart"B= $verb eq "stop"C= _running($dev)->{"save"}
ABCresult
00X0
1X00
0100
1X11
0111
176 3 ▶ if ( $verb eq 'start' || $verb eq 'restart' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verb eq "start" or $verb eq "restart") 2 1 3
Condition66%2/3
$verb eq "start" or $verb eq "restart"
l!l&&r!l&&!r
021
MC/DC50%1/2
$verb eq "start" or $verb eq "restart"
$verb eq "start" $verb eq "restart"
Truth table66%2/3
A or B
A= $verb eq "start"B= $verb eq "restart"
ABresult
1X1
011
000
177 2 ▶ my ($v) = parse_conf( _file_text( $dev, $r->{conf} // '/etc/redis/redis.conf' ) );
Condition50%1/2
$$r{"conf"} // "/etc/redis/redis.conf"
l!l
20
MC/DC0%0/1
$$r{"conf"} // "/etc/redis/redis.conf"
$$r{"conf"}
Truth table50%1/2
A
A= $$r{"conf"}
Aresult
11
00
178 2 ▶ $r->{running} = $v if $v;
Branch: 1 branch
BranchTrueFalseTotal
if $v 2 0 2
179 # was seit der letzten Sicherung dazukam, ist weg (RDB wird geladen); lost zaehlt es
180 2 ▶ if ( $r->{saved} && JSON::MaybeXS->new( canonical => 1 )->encode( $r->{saved} ) ne JSON::MaybeXS->new( canonical => 1 )->encode( $r->{keys} || {} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$r{"saved"} and "JSON::MaybeXS"->new("canonical", 1)->encode($$r{"saved"}) ne "JSON::MaybeXS"->new("canonical", 1)->encode($$r{"keys"} || {})) 1 1 2
Condition60%3/5
$$r{"saved"} and "JSON::MaybeXS"->new("canonical", 1)->encode($$r{"saved"}) ne "JSON::MaybeXS"->new("canonical", 1)->encode($$r{"keys"} || {})
!ll&&!rl&&r
011
$$r{'keys'} || {}
l!l
20
MC/DC50%1/2
$$r{"saved"} and "JSON::MaybeXS"->new("canonical", 1)->encode($$r{"saved"}) ne "JSON::MaybeXS"->new("canonical", 1)->encode($$r{"keys"} || {})
$$r{"saved"} "JSON::MaybeXS"->new("canonical", 1)->encode($$r{"saved"}) ne "JSON::MaybeXS"->new("canonical", 1)->encode($$r{"keys"} || {})
MC/DC0%0/1
$$r{'keys'} || {}
$$r{'keys'}
Truth table66%2/3
A and B
A= $$r{"saved"}B= "JSON::MaybeXS"->new("canonical", 1)->encode($$r{"saved"}) ne "JSON::MaybeXS"->new("canonical", 1)->encode($$r{"keys"} || {})
ABresult
0X0
100
111
Truth table50%1/2
A
A= $$r{'keys'}
Aresult
11
00
181 1 my $diff = _keys_total($r) - do { my $n = 0; $n += $_ for values %{ $r->{saved} }; $n };
182 1 ▶ $r->{lost} = ( $r->{lost} // 0 ) + ( $diff > 0 ? $diff : 1 ) if $verb eq 'restart' || $diff;
Branch: 2 branches
BranchTrueFalseTotal
if $verb eq "restart" or $diff 1 0 1
$diff > 0 ? : 1 0 1
Condition40%2/5
$verb eq "restart" or $diff
l!l&&r!l&&!r
100
$$r{"lost"} // 0
l!l
01
MC/DC0%0/2
$verb eq "restart" or $diff
$verb eq "restart" $diff
MC/DC0%0/1
$$r{"lost"} // 0
$$r{"lost"}
Truth table33%1/3
A or B
A= $verb eq "restart"B= $diff
ABresult
1X1
011
000
Truth table50%1/2
A
A= $$r{"lost"}
Aresult
11
00
183 1 $r->{keys} = { %{ $r->{saved} } };
184 1 delete $r->{data}; # ungesicherte Einzelwerte sind ebenso weg
185 }
186 2 ▶ $r->{rdb_changes} = 0 if $r->{rdb_changes};
Branch: 1 branch
BranchTrueFalseTotal
if $$r{"rdb_changes"} 1 1 2
187 2 ▶ $r->{rdb_ok} = JSON::MaybeXS::true() unless $r->{rdb_ok};
Branch: 1 branch
BranchTrueFalseTotal
unless $$r{"rdb_ok"} 1 1 2
188 }
189 3 return;
190 }
191  
192 48 ▶sub _active {
Subroutine _active: called CC=5 SCAR=16.8
193 48 my ($dev) = @_;
194 48 ▶ my $svc = ( $dev->{services} || {} )->{ $dev->{redis}{service} // 'redis-server' };
Condition50%2/4
$$dev{'services'} || {}
l!l
480
$$dev{"redis"}{"service"} // "redis-server"
l!l
480
MC/DC0%0/1
$$dev{'services'} || {}
$$dev{'services'}
MC/DC0%0/1
$$dev{"redis"}{"service"} // "redis-server"
$$dev{"redis"}{"service"}
Truth table50%1/2
A
A= $$dev{'services'}
Aresult
11
00
Truth table50%1/2
A
A= $$dev{"redis"}{"service"}
Aresult
11
00
195 48 ▶ return $svc && $svc->{active} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$svc && $$svc{'active'} ? : 47 1 48
Condition66%2/3
$svc and $$svc{"active"}
!ll&&!rl&&r
0147
MC/DC50%1/2
$svc and $$svc{"active"}
$svc $$svc{"active"}
Truth table66%2/3
A and B
A= $svcB= $$svc{"active"}
ABresult
0X0
100
111
196 }
197  
198 47 ▶sub _bound_to {
Subroutine _bound_to: called CC=5 SCAR=17.1
199 47 my ( $dev, $host ) = @_;
200 47 ▶ my $b = _running($dev)->{bind} // '';
Condition50%1/2
_running($dev)->{"bind"} // ""
l!l
470
MC/DC0%0/1
_running($dev)->{"bind"} // ""
_running($dev)->{"bind"}
Truth table50%1/2
A
A= _running($dev)->{"bind"}
Aresult
11
00
201 47 my @a = map { s/\A-//r } split /\s+/, $b;
202 47 ▶ return 1 if grep { $_ eq '0.0.0.0' || $_ eq '*' } @a;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ eq "0.0.0.0" or $_ eq "*";} @a 0 47 47
Condition33%1/3
$_ eq '0.0.0.0' || $_ eq '*'
l!l&&r!l&&!r
0076
MC/DC0%0/2
$_ eq '0.0.0.0' || $_ eq '*'
$_ eq '0.0.0.0' $_ eq '*'
Truth table33%1/3
A || B
A= $_ eq '0.0.0.0'B= $_ eq '*'
ABresult
1X1
011
000
203 47 ▶ $host = '127.0.0.1' if $host eq 'localhost';
Branch: 1 branch
BranchTrueFalseTotal
if $host eq "localhost" 0 47 47
204 47 return scalar grep { $_ eq $host } @a;
205 }
206  
207 18 ▶sub _need_failing {
Subroutine _need_failing: called CC=2 SCAR=6.9
208 18 my ( $dev, $needs ) = @_;
209 18 ▶ return Langertha::Holmgang::Sim::Linux::_failing_need( $dev, { needs => $needs || [] } );
Condition100%2/2
$needs || []
l!l
99
MC/DC100%1/1
$needs || []
$needs
Truth table100%2/2
A
A= $needs
Aresult
11
00
210 }
211  
212 6 ▶sub _bgsave {
Subroutine _bgsave: called CC=13 SCAR=26.9
213 6 my ($dev) = @_;
214 6 my $r = $dev->{redis};
215 6 ▶ my $bad = _need_failing( $dev, $r->{fork_needs} ) || _need_failing( $dev, $r->{bgsave_needs} );
Condition66%2/3
_need_failing($dev, $$r{'fork_needs'}) || _need_failing($dev, $$r{'bgsave_needs'})
l!l&&r!l&&!r
033
MC/DC50%1/2
_need_failing($dev, $$r{'fork_needs'}) || _need_failing($dev, $$r{'bgsave_needs'})
_need_failing($dev, $$r{'fork_needs'}) _need_failing($dev, $$r{'bgsave_needs'})
Truth table66%2/3
A || B
A= _need_failing($dev, $$r{'fork_needs'})B= _need_failing($dev, $$r{'bgsave_needs'})
ABresult
1X1
011
000
216 6 ▶ if ($bad) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bad) 3 3 6
217 3 ▶ $r->{rdb_ok} = JSON::MaybeXS::false() if $r->{rdb_ok} // 1;
Branch: 1 branch
BranchTrueFalseTotal
if $$r{"rdb_ok"} // 1 2 1 3
Condition100%2/2
$$r{"rdb_ok"} // 1
l!l
12
MC/DC100%1/1
$$r{"rdb_ok"} // 1
$$r{"rdb_ok"}
Truth table100%2/2
A
A= $$r{"rdb_ok"}
Aresult
11
00
218 3 return 0;
219 }
220 3 ▶ $r->{rdb_ok} = JSON::MaybeXS::true() unless $r->{rdb_ok};
Branch: 1 branch
BranchTrueFalseTotal
unless $$r{"rdb_ok"} 3 0 3
221 3 ▶ $r->{saved} = { %{ $r->{keys} || {} } };
Condition50%1/2
$$r{'keys'} || {}
l!l
30
MC/DC0%0/1
$$r{'keys'} || {}
$$r{'keys'}
Truth table50%1/2
A
A= $$r{'keys'}
Aresult
11
00
222 # die Sicherung schreibt dir/dbfilename neu (temp-Datei, dann umbenannt: redis:redis 0660, neue Zeit)
223 3 my $run = _running($dev);
224 3 ▶ ( my $dir = $run->{dir} // '/var/lib/redis' ) =~ s{/+\z}{};
Condition50%1/2
$$run{"dir"} // "/var/lib/redis"
l!l
30
MC/DC0%0/1
$$run{"dir"} // "/var/lib/redis"
$$run{"dir"}
Truth table50%1/2
A
A= $$run{"dir"}
Aresult
11
00
225 3 ▶ my $p = "$dir/" . ( $run->{dbfilename} // 'dump.rdb' );
Condition50%1/2
$$run{"dbfilename"} // "dump.rdb"
l!l
30
MC/DC0%0/1
$$run{"dbfilename"} // "dump.rdb"
$$run{"dbfilename"}
Truth table50%1/2
A
A= $$run{"dbfilename"}
Aresult
11
00
226 3 ▶ my $old = ref $dev->{files}{$p} eq 'HASH' ? $dev->{files}{$p} : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $$dev{'files'}{$p} eq 'HASH' ? : 0 3 3
227 3 ▶ $dev->{files}{$p} = { content => '', size => $old->{size} // '1M', owner => 'redis', group => 'redis', mode => '0660',
Condition50%1/2
$$old{"size"} // "1M"
l!l
03
MC/DC0%0/1
$$old{"size"} // "1M"
$$old{"size"}
Truth table50%1/2
A
A= $$old{"size"}
Aresult
11
00
228 mtime => Langertha::Holmgang::Sim::Linux::_clock($dev) };
229 3 ▶ $r->{rdb_changes} = 0 if $r->{rdb_changes};
Branch: 1 branch
BranchTrueFalseTotal
if $$r{"rdb_changes"} 3 0 3
230 3 ▶ $r->{lastsave} = ( $r->{lastsave} // 1792821600 ) + 60;
Condition50%1/2
$$r{"lastsave"} // 1792821600
l!l
03
MC/DC0%0/1
$$r{"lastsave"} // 1792821600
$$r{"lastsave"}
Truth table50%1/2
A
A= $$r{"lastsave"}
Aresult
11
00
231 3 return 1;
232 }
233  
234 1 ▶sub _keys_total { my ($r) = @_; my $n = 0; $n += $_ for values %{ $r->{keys} || {} }; return $n }
Subroutine _keys_total: called CC=3 SCAR=11.1
Condition50%1/2
$$r{'keys'} || {}
l!l
10
MC/DC0%0/1
$$r{'keys'} || {}
$$r{'keys'}
Truth table50%1/2
A
A= $$r{'keys'}
Aresult
11
00
235  
236 6 ▶sub _info {
Subroutine _info: called CC=33 SCAR=41.1
237 6 my ( $dev, $sec ) = @_;
238 6 my $r = $dev->{redis};
239 6 my $run = _running($dev);
240 6 ▶ my $used = $r->{used_memory} // 1048576;
Condition100%2/2
$$r{"used_memory"} // 1048576
l!l
33
MC/DC100%1/1
$$r{"used_memory"} // 1048576
$$r{"used_memory"}
Truth table100%2/2
A
A= $$r{"used_memory"}
Aresult
11
00
241 6 ▶ my $max = $run->{maxmemory} // 0;
Condition50%1/2
$$run{"maxmemory"} // 0
l!l
60
MC/DC0%0/1
$$run{"maxmemory"} // 0
$$run{"maxmemory"}
Truth table50%1/2
A
A= $$run{"maxmemory"}
Aresult
11
00
242 6 my %s;
243 $s{server} = [ 'redis_version:7.0.15', 'redis_mode:standalone', 'os:Linux 6.1.0-26-amd64 x86_64', 'process_id:' . ( $r->{pid} // 811 ),
244 "tcp_port:$run->{port}", 'uptime_in_seconds:' . ( $r->{uptime} // 1728000 ), 'uptime_in_days:' . int( ( $r->{uptime} // 1728000 ) / 86400 ),
245 6 ▶ 'executable:/usr/bin/redis-server', 'config_file:' . ( $r->{conf} // '/etc/redis/redis.conf' ) ];
Condition50%4/8
$$r{"pid"} // 811
l!l
06
$$r{"uptime"} // 1728000
l!l
06
$$r{"uptime"} // 1728000
l!l
06
$$r{"conf"} // "/etc/redis/redis.conf"
l!l
60
MC/DC0%0/1
$$r{"pid"} // 811
$$r{"pid"}
MC/DC0%0/1
$$r{"uptime"} // 1728000
$$r{"uptime"}
MC/DC0%0/1
$$r{"uptime"} // 1728000
$$r{"uptime"}
MC/DC0%0/1
$$r{"conf"} // "/etc/redis/redis.conf"
$$r{"conf"}
Truth table50%1/2
A
A= $$r{"pid"}
Aresult
11
00
Truth table50%1/2
A
A= $$r{"uptime"}
Aresult
11
00
Truth table50%1/2
A
A= $$r{"uptime"}
Aresult
11
00
Truth table50%1/2
A
A= $$r{"conf"}
Aresult
11
00
246 6 ▶ $s{clients} = [ 'connected_clients:' . ( $r->{clients} // 3 ), 'maxclients:' . ( $r->{effective_maxclients} // $run->{maxclients} ),
Condition40%2/5
$$r{"clients"} // 3
l!l
06
$$r{"effective_maxclients"} // $$run{"maxclients"}
l!l&&r!l&&!r
060
MC/DC0%0/1
$$r{"clients"} // 3
$$r{"clients"}
MC/DC0%0/2
$$r{"effective_maxclients"} // $$run{"maxclients"}
$$r{"effective_maxclients"} $$run{"maxclients"}
Truth table50%1/2
A
A= $$r{"clients"}
Aresult
11
00
Truth table33%1/3
A // B
A= $$r{"effective_maxclients"}B= $$run{"maxclients"}
ABresult
1X1
011
000
247 'blocked_clients:0' ];
248 $s{memory} = [ "used_memory:$used", 'used_memory_human:' . _info_human($used), 'used_memory_rss:' . int( $used * 1.08 ),
249 6 ▶ 'used_memory_peak:' . ( $r->{used_memory_peak} // $used ), "maxmemory:$max", 'maxmemory_human:' . _info_human($max),
Condition33%1/3
$$r{"used_memory_peak"} // $used
l!l&&r!l&&!r
060
MC/DC0%0/2
$$r{"used_memory_peak"} // $used
$$r{"used_memory_peak"} $used
Truth table33%1/3
A // B
A= $$r{"used_memory_peak"}B= $used
ABresult
1X1
011
000
250 "maxmemory_policy:$run->{'maxmemory-policy'}", 'mem_fragmentation_ratio:1.08', 'mem_allocator:jemalloc-5.3.0' ];
251 $s{persistence} = [ 'loading:0', 'rdb_changes_since_last_save:' . ( $r->{rdb_changes} // 0 ), 'rdb_bgsave_in_progress:0',
252 'rdb_last_save_time:' . ( $r->{lastsave} // 1792821600 ), 'rdb_last_bgsave_status:' . ( ( $r->{rdb_ok} // 1 ) ? 'ok' : 'err' ),
253 6 ▶ 'rdb_last_bgsave_time_sec:' . ( ( $r->{rdb_ok} // 1 ) ? 2 : -1 ), 'aof_enabled:' . ( $run->{appendonly} eq 'yes' ? 1 : 0 ),
Branch: 3 branches
BranchTrueFalseTotal
$$r{'rdb_ok'} // 1 ? : 5 1 6
$$r{'rdb_ok'} // 1 ? : 5 1 6
$$run{'appendonly'} eq 'yes' ? : 0 6 6
Condition100%8/8
$$r{"rdb_changes"} // 0
l!l
33
$$r{"lastsave"} // 1792821600
l!l
15
$$r{"rdb_ok"} // 1
l!l
24
$$r{"rdb_ok"} // 1
l!l
24
MC/DC100%1/1
$$r{"rdb_changes"} // 0
$$r{"rdb_changes"}
MC/DC100%1/1
$$r{"lastsave"} // 1792821600
$$r{"lastsave"}
MC/DC100%1/1
$$r{"rdb_ok"} // 1
$$r{"rdb_ok"}
MC/DC100%1/1
$$r{"rdb_ok"} // 1
$$r{"rdb_ok"}
Truth table100%2/2
A
A= $$r{"rdb_changes"}
Aresult
11
00
Truth table100%2/2
A
A= $$r{"lastsave"}
Aresult
11
00
Truth table100%2/2
A
A= $$r{"rdb_ok"}
Aresult
11
00
Truth table100%2/2
A
A= $$r{"rdb_ok"}
Aresult
11
00
254 'aof_last_write_status:ok' ];
255 6 ▶ my $st = $r->{stats} || {};
Condition50%1/2
$$r{'stats'} || {}
l!l
06
MC/DC0%0/1
$$r{'stats'} || {}
$$r{'stats'}
Truth table50%1/2
A
A= $$r{'stats'}
Aresult
11
00
256 $s{stats} = [ 'total_connections_received:' . ( $st->{total_connections_received} // 912233 ), 'rejected_connections:' . ( $st->{rejected_connections} // 0 ),
257 'expired_keys:' . ( $st->{expired_keys} // 0 ), 'evicted_keys:' . ( $st->{evicted_keys} // 0 ), 'keyspace_hits:' . ( $st->{keyspace_hits} // 1200443 ),
258 6 ▶ 'keyspace_misses:' . ( $st->{keyspace_misses} // 80211 ) ];
Condition50%6/12
$$st{"total_connections_received"} // 912233
l!l
06
$$st{"rejected_connections"} // 0
l!l
06
$$st{"expired_keys"} // 0
l!l
06
$$st{"evicted_keys"} // 0
l!l
06
$$st{"keyspace_hits"} // 1200443
l!l
06
$$st{"keyspace_misses"} // 80211
l!l
06
MC/DC0%0/1
$$st{"total_connections_received"} // 912233
$$st{"total_connections_received"}
MC/DC0%0/1
$$st{"rejected_connections"} // 0
$$st{"rejected_connections"}
MC/DC0%0/1
$$st{"expired_keys"} // 0
$$st{"expired_keys"}
MC/DC0%0/1
$$st{"evicted_keys"} // 0
$$st{"evicted_keys"}
MC/DC0%0/1
$$st{"keyspace_hits"} // 1200443
$$st{"keyspace_hits"}
MC/DC0%0/1
$$st{"keyspace_misses"} // 80211
$$st{"keyspace_misses"}
Truth table50%1/2
A
A= $$st{"total_connections_received"}
Aresult
11
00
Truth table50%1/2
A
A= $$st{"rejected_connections"}
Aresult
11
00
Truth table50%1/2
A
A= $$st{"expired_keys"}
Aresult
11
00
Truth table50%1/2
A
A= $$st{"evicted_keys"}
Aresult
11
00
Truth table50%1/2
A
A= $$st{"keyspace_hits"}
Aresult
11
00
Truth table50%1/2
A
A= $$st{"keyspace_misses"}
Aresult
11
00
259 6 ▶ if ( my $p = _replica_of( $dev ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $p = _replica_of($dev)) { } 2 4 6
260 2 my $up = _link_up( $dev, $p );
261 2 ▶ $s{replication} = [ 'role:slave', "master_host:$p->{host}", "master_port:$p->{port}", 'master_link_status:' . ( $up ? 'up' : 'down' ),
Branch: 2 branches
BranchTrueFalseTotal
$up ? : 2 0 2
$up ? : 2 0 2
262 'master_last_io_seconds_ago:' . ( $up ? 1 : -1 ), 'master_sync_in_progress:0', 'slave_read_only:1', 'connected_slaves:0' ];
263 }
264 4 ▶ else { $s{replication} = [ 'role:master', 'connected_slaves:' . ( $r->{connected_slaves} // 0 ), 'master_repl_offset:' . ( $r->{repl_offset} // 0 ) ] }
Condition50%2/4
$$r{"connected_slaves"} // 0
l!l
04
$$r{"repl_offset"} // 0
l!l
04
MC/DC0%0/1
$$r{"connected_slaves"} // 0
$$r{"connected_slaves"}
MC/DC0%0/1
$$r{"repl_offset"} // 0
$$r{"repl_offset"}
Truth table50%1/2
A
A= $$r{"connected_slaves"}
Aresult
11
00
Truth table50%1/2
A
A= $$r{"repl_offset"}
Aresult
11
00
265 6 $s{cpu} = [ 'used_cpu_sys:812.441201', 'used_cpu_user:1503.120044' ];
266 6 ▶ $s{keyspace} = [ map { "$_:keys=$r->{keys}{$_},expires=0,avg_ttl=0" } grep { $r->{keys}{$_} } sort keys %{ $r->{keys} || {} } ];
Condition50%1/2
$$r{'keys'} || {}
l!l
60
MC/DC0%0/1
$$r{'keys'} || {}
$$r{'keys'}
Truth table50%1/2
A
A= $$r{'keys'}
Aresult
11
00
267 6 my @order = qw( server clients memory persistence stats replication cpu keyspace );
268 6 ▶ my @want = !defined $sec || $sec eq '' || $sec =~ /\A(?:all|everything|default)\z/i ? @order : grep { $_ eq lc $sec } @order;
Branch: 1 branch
BranchTrueFalseTotal
!defined($sec) || $sec eq '' || $sec =~ /\A(?:all|everything|default)\z/i ? : 0 6 6
Condition33%2/6
not defined $sec or $sec eq "" or $sec =~ /\A(?:all|everything|default)\z/i
l!l&&r!l&&!r
006
not defined $sec or $sec eq ""
l!l&&r!l&&!r
006
MC/DC0%0/3
not defined $sec or $sec eq "" or $sec =~ /\A(?:all|everything|default)\z/i
not defined $sec $sec eq "" $sec =~ /\A(?:all|everything|default)\z/i
Truth table25%1/4
not(A) or B or C
A= not defined $secB= $sec eq ""C= $sec =~ /\A(?:all|everything|default)\z/i
ABCresult
1XX1
01X1
0011
0000
269 6 return join "\n", map { ( '# ' . ucfirst($_), @{ $s{$_} }, '' ) } @want;
270 }
271  
272 # Replikat: { host, port, primary } aus dem laufenden replicaof
273 9 ▶sub _replica_of {
Subroutine _replica_of: called CC=9 SCAR=24.4
274 9 my ($dev) = @_;
275 9 ▶ my $ro = _running($dev)->{replicaof} // '';
Condition100%2/2
_running($dev)->{"replicaof"} // ""
l!l
45
MC/DC100%1/1
_running($dev)->{"replicaof"} // ""
_running($dev)->{"replicaof"}
Truth table100%2/2
A
A= _running($dev)->{"replicaof"}
Aresult
11
00
276 9 ▶ return undef unless $ro =~ /\A(\S+)\s+(\d+)\z/ && lc $1 ne 'no';
Branch: 1 branch
BranchTrueFalseTotal
unless $ro =~ /\A(\S+)\s+(\d+)\z/ and lc $1 ne "no" 6 3 9
Condition66%2/3
$ro =~ /\A(\S+)\s+(\d+)\z/ and lc $1 ne "no"
!ll&&!rl&&r
603
MC/DC50%1/2
$ro =~ /\A(\S+)\s+(\d+)\z/ and lc $1 ne "no"
$ro =~ /\A(\S+)\s+(\d+)\z/ lc $1 ne "no"
Truth table66%2/3
A and B
A= $ro =~ /\A(\S+)\s+(\d+)\z/B= lc $1 ne "no"
ABresult
0X0
100
111
277 3 my ( $host, $port ) = ( $1, $2 );
278 # Primaer: das Geraet mit dieser Adresse (auch nach einer Umschaltung), sonst replica.primary
279 3 ▶ my $state = $Langertha::Holmgang::Sim::Linux::CTX ? $Langertha::Holmgang::Sim::Linux::CTX->{state} : {};
Branch: 1 branch
BranchTrueFalseTotal
$Langertha::Holmgang::Sim::Linux::CTX ? : 3 0 3
280 3 ▶ my ($by_addr) = grep { ref $state->{$_} eq 'HASH' && $state->{$_}{redis} && grep { $_ eq $host } _addrs( $state->{$_} ) } sort keys %$state;
Condition50%3/6
ref $$state{$_} eq 'HASH' && $$state{$_}{'redis'} && grep({$_ eq $host;} _addrs($$state{$_}))
!ll&&!rl&&r
033
ref $$state{$_} eq "HASH" and $$state{$_}{"redis"}
!ll&&!rl&&r
006
MC/DC33%1/3
ref $$state{$_} eq 'HASH' && $$state{$_}{'redis'} && grep({$_ eq $host;} _addrs($$state{$_}))
ref $$state{$_} eq "HASH" $$state{$_}{"redis"} grep({$_ eq $host;} _addrs($$state{$_}))
Truth table50%2/4
A and B && C
A= ref $$state{$_} eq "HASH"B= $$state{$_}{"redis"}C= grep({$_ eq $host;} _addrs($$state{$_}))
ABCresult
0XX0
10X0
1100
1111
281 3 ▶ return { host => $host, port => $port, primary => $by_addr // ( $dev->{redis}{replica} || {} )->{primary} };
Condition20%1/5
$by_addr // ($$dev{"redis"}{"replica"} || {})->{"primary"}
l!l&&r!l&&!r
300
$$dev{'redis'}{'replica'} || {}
l!l
00
MC/DC0%0/2
$by_addr // ($$dev{"redis"}{"replica"} || {})->{"primary"}
$by_addr $$dev{'redis'}{'replica'}
Truth table33%1/3
A // B
A= $by_addrB= $$dev{'redis'}{'replica'}
ABresult
1X1
011
000
282 }
283  
284 6 ▶sub _addrs {
Subroutine _addrs: called CC=3 SCAR=11.2
285 6 my ($dev) = @_;
286 6 ▶ return map { s{/\d+\z}{}r } map { @{ $_->{addr} || [] } } grep { ref eq 'HASH' } values %{ $dev->{interfaces} || {} };
Condition50%2/4
$$_{'addr'} || []
l!l
60
$$dev{'interfaces'} || {}
l!l
60
MC/DC0%0/1
$$_{'addr'} || []
$$_{'addr'}
MC/DC0%0/1
$$dev{'interfaces'} || {}
$$dev{'interfaces'}
Truth table50%1/2
A
A= $$_{'addr'}
Aresult
11
00
Truth table50%1/2
A
A= $$dev{'interfaces'}
Aresult
11
00
287 }
288  
289 # Verbindung zum Primaer steht, wenn es ihn gibt, er laeuft und masterauth zu seinem requirepass passt
290 2 ▶sub _link_up {
Subroutine _link_up: called CC=13 SCAR=35.3
291 2 my ( $dev, $p ) = @_;
292 2 ▶ my $state = $Langertha::Holmgang::Sim::Linux::CTX ? $Langertha::Holmgang::Sim::Linux::CTX->{state} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$Langertha::Holmgang::Sim::Linux::CTX ? : 2 0 2
293 2 ▶ my $pd = $state && defined $p->{primary} ? $state->{ $p->{primary} } : undef;
Branch: 1 branch
BranchTrueFalseTotal
$state && defined $$p{'primary'} ? : 2 0 2
Condition33%1/3
$state and defined $$p{"primary"}
!ll&&!rl&&r
002
MC/DC0%0/2
$state and defined $$p{"primary"}
$state defined $$p{"primary"}
Truth table33%1/3
A and B
A= $stateB= defined $$p{"primary"}
ABresult
0X0
100
111
294 2 ▶ return 0 unless $pd && $pd->{redis} && _active($pd);
Branch: 1 branch
BranchTrueFalseTotal
unless $pd and $$pd{"redis"} and _active($pd) 0 2 2
Condition33%2/6
$pd and $$pd{"redis"} and _active($pd)
!ll&&!rl&&r
002
$pd and $$pd{"redis"}
!ll&&!rl&&r
002
MC/DC0%0/3
$pd and $$pd{"redis"} and _active($pd)
$pd $$pd{"redis"} _active($pd)
Truth table25%1/4
A and B and C
A= $pdB= $$pd{"redis"}C= _active($pd)
ABCresult
0XX0
10X0
1100
1111
295 2 my $prun = _running($pd);
296 2 ▶ return 0 unless _bound_to( $pd, $p->{host} ) && $prun->{port} eq $p->{port};
Branch: 1 branch
BranchTrueFalseTotal
unless _bound_to($pd, $$p{"host"}) and $$prun{"port"} eq $$p{"port"} 0 2 2
Condition33%1/3
_bound_to($pd, $$p{"host"}) and $$prun{"port"} eq $$p{"port"}
!ll&&!rl&&r
002
MC/DC0%0/2
_bound_to($pd, $$p{"host"}) and $$prun{"port"} eq $$p{"port"}
_bound_to($pd, $$p{"host"}) $$prun{"port"} eq $$p{"port"}
Truth table33%1/3
A and B
A= _bound_to($pd, $$p{"host"})B= $$prun{"port"} eq $$p{"port"}
ABresult
0X0
100
111
297 2 ▶ return ( $prun->{requirepass} // '' ) eq '' || ( _running($dev)->{masterauth} // '' ) eq $prun->{requirepass} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
($$prun{'requirepass'} // '') eq '' || (_running($dev)->{'masterauth'} // '') eq $$prun{'requirepass'} ? : 2 0 2
Condition28%2/7
($$prun{"requirepass"} // "") eq "" or (_running($dev)->{"masterauth"} // "") eq $$prun{"requirepass"}
l!l&&r!l&&!r
200
$$prun{"requirepass"} // ""
l!l
20
_running($dev)->{"masterauth"} // ""
l!l
00
MC/DC0%0/2
($$prun{"requirepass"} // "") eq "" or (_running($dev)->{"masterauth"} // "") eq $$prun{"requirepass"}
$$prun{"requirepass"} _running($dev)->{"masterauth"}
Truth table33%1/3
A or B
A= $$prun{"requirepass"}B= _running($dev)->{"masterauth"}
ABresult
1X1
011
000
298 }
299  
300 2 ▶sub _glob_re { my ($g) = @_; ( my $re = quotemeta $g ) =~ s/\\\*/.*/g; $re =~ s/\\\?/./g; return qr/\A$re\z/i }
Subroutine _glob_re: called CC=1 SCAR=0.0
301  
302 2 ▶sub _fmt_bulk_list {
Subroutine _fmt_bulk_list: called CC=4 SCAR=14.2
303 2 my ( $raw, @v ) = @_;
304 2 ▶ return '(empty array)' if !@v && !$raw;
Branch: 1 branch
BranchTrueFalseTotal
unless @v or $raw 0 2 2
Condition33%1/3
@v or $raw
l!l&&r!l&&!r
200
MC/DC0%0/2
@v or $raw
@v $raw
Truth table33%1/3
A or B
A= @vB= $raw
ABresult
1X1
011
000
305 2 ▶ return join "\n", @v if $raw;
Branch: 1 branch
BranchTrueFalseTotal
if $raw 1 1 2
306 1 my $i = 0;
307 1 return join "\n", map { $i++; sprintf( '%d) "%s"', $i, $_ ) } @v;
308 }
309  
310 1 ▶sub _rewrite {
Subroutine _rewrite: called CC=23 SCAR=40.9
311 1 my ($dev) = @_;
312 1 my $r = $dev->{redis};
313 1 ▶ my $conf = $r->{conf} // '/etc/redis/redis.conf';
Condition50%1/2
$$r{"conf"} // "/etc/redis/redis.conf"
l!l
10
MC/DC0%0/1
$$r{"conf"} // "/etc/redis/redis.conf"
$$r{"conf"}
Truth table50%1/2
A
A= $$r{"conf"}
Aresult
11
00
314 1 my $text = _file_text( $dev, $conf );
315 1 ▶ return 0 unless defined $text;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $text 0 1 1
316 1 my $run = _running($dev);
317 1 my %seen;
318 6 ▶ my $fmt = sub {
Subroutine __ANON__: called CC=6 SCAR=19.0
319 6 my ($k) = @_;
320 6 ▶ my $v = $run->{$k} // '';
Condition50%1/2
$$run{$k} // ""
l!l
60
MC/DC0%0/1
$$run{$k} // ""
$$run{$k}
Truth table50%1/2
A
A= $$run{$k}
Aresult
11
00
321 6 ▶ $v = _human_bytes($v) if $BYTES{$k};
Branch: 1 branch
BranchTrueFalseTotal
if $Langertha::Holmgang::Sim::Linux::Redis::BYTES{$k} 1 5 6
322 6 ▶ return $k eq 'save' && $v eq '' ? qq{save ""} : $v eq '' ? qq{$k ""} : "$k $v";
Branch: 2 branches
BranchTrueFalseTotal
$k eq 'save' && $v eq '' ? : 0 6 6
$v eq '' ? : 0 6 6
Condition66%2/3
$k eq "save" and $v eq ""
!ll&&!rl&&r
510
MC/DC0%0/2
$k eq "save" and $v eq ""
$k eq "save" $v eq ""
Truth table66%2/3
A and B
A= $k eq "save"B= $v eq ""
ABresult
0X0
100
111
323 1 };
324 1 my @out;
325 1 for my $line ( split /\n/, $text ) {
326 6 my ($k) = $line =~ /\A\s*([A-Za-z][\w-]*)\s/;
327 6 ▶ $k = $ALIAS{ lc( $k // '' ) } // lc( $k // '' );
Condition50%3/6
$Langertha::Holmgang::Sim::Linux::Redis::ALIAS{lc($k // "")} // lc($k // "")
l!l
06
$k // ""
l!l
60
$k // ""
l!l
60
MC/DC0%0/1
$Langertha::Holmgang::Sim::Linux::Redis::ALIAS{lc($k // "")} // lc($k // "")
$Langertha::Holmgang::Sim::Linux::Redis::ALIAS{lc($k // "")}
Truth table50%1/2
A
A= $Langertha::Holmgang::Sim::Linux::Redis::ALIAS{lc($k // "")}
Aresult
11
00
328 6 ▶ if ( length $k && ( exists $DEFAULT{$k} || $k eq 'replicaof' ) && $line !~ /\A\s*#/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $k and exists $Langertha::Holmgang::Sim::Linux::Redis::DEFAULT{$k} || $k eq "replicaof" and not $line =~ /\A\s*#/) 6 0 6
Condition33%3/9
length $k and exists $Langertha::Holmgang::Sim::Linux::Redis::DEFAULT{$k} || $k eq "replicaof" and not $line =~ /\A\s*#/
!ll&&!rl&&r
006
length $k and exists $Langertha::Holmgang::Sim::Linux::Redis::DEFAULT{$k} || $k eq "replicaof"
!ll&&!rl&&r
006
exists $Langertha::Holmgang::Sim::Linux::Redis::DEFAULT{$k} or $k eq "replicaof"
l!l&&r!l&&!r
600
MC/DC0%0/4
length $k and exists $Langertha::Holmgang::Sim::Linux::Redis::DEFAULT{$k} || $k eq "replicaof" and not $line =~ /\A\s*#/
length $k exists $Langertha::Holmgang::Sim::Linux::Redis::DEFAULT{$k} $k eq "replicaof" not $line =~ /\A\s*#/
Truth table16%1/6
A and B or C and not(D)
A= length $kB= exists $Langertha::Holmgang::Sim::Linux::Redis::DEFAULT{$k}C= $k eq "replicaof"D= not $line =~ /\A\s*#/
ABCDresult
0XXX0
100X0
11X00
10100
11X11
10111
329 6 ▶ next if $seen{$k}++; # doppelte Zeilen (save) fasst REWRITE zusammen
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$k}++ 0 6 6
330 6 ▶ push @out, $k eq 'replicaof' && !( $run->{replicaof} // '' ) ? () : $fmt->($k);
Branch: 1 branch
BranchTrueFalseTotal
$k eq 'replicaof' && !($$run{'replicaof'} // '') ? : 0 6 6
Condition20%1/5
$k eq "replicaof" and not $$run{"replicaof"} // ""
!ll&&!rl&&r
600
$$run{"replicaof"} // ""
l!l
00
MC/DC0%0/2
$k eq "replicaof" and not $$run{"replicaof"} // ""
$k eq "replicaof" $$run{"replicaof"}
Truth table33%1/3
A and not(B)
A= $k eq "replicaof"B= $$run{"replicaof"}
ABresult
0X0
110
101
331 6 next;
332 }
333 0 push @out, $line;
334 }
335 1 ▶ my @new = grep { !$seen{$_} && ( $run->{$_} // '' ) ne ( $DEFAULT{$_} // '' ) } sort keys %DEFAULT;
Condition57%4/7
!$seen{$_} && ($$run{$_} // '') ne ($Langertha::Holmgang::Sim::Linux::Redis::DEFAULT{$_} // '')
!ll&&!rl&&r
6260
$$run{$_} // ""
l!l
260
$Langertha::Holmgang::Sim::Linux::Redis::DEFAULT{$_} // ""
l!l
260
MC/DC50%1/2
!$seen{$_} && ($$run{$_} // '') ne ($Langertha::Holmgang::Sim::Linux::Redis::DEFAULT{$_} // '')
!$seen{$_} $$run{$_}
MC/DC0%0/1
$Langertha::Holmgang::Sim::Linux::Redis::DEFAULT{$_} // ""
$Langertha::Holmgang::Sim::Linux::Redis::DEFAULT{$_}
Truth table66%2/3
not(A) && B
A= !$seen{$_}B= $$run{$_}
ABresult
0X0
100
111
Truth table50%1/2
A
A= $Langertha::Holmgang::Sim::Linux::Redis::DEFAULT{$_}
Aresult
11
00
336 1 ▶ push @new, 'replicaof' if !$seen{replicaof} && ( $run->{replicaof} // '' ) ne '';
Branch: 1 branch
BranchTrueFalseTotal
if not $seen{"replicaof"} and ($$run{"replicaof"} // "") ne "" 0 1 1
Condition40%2/5
not $seen{"replicaof"} and ($$run{"replicaof"} // "") ne ""
!ll&&!rl&&r
010
$$run{"replicaof"} // ""
l!l
01
MC/DC0%0/2
not $seen{"replicaof"} and ($$run{"replicaof"} // "") ne ""
not $seen{"replicaof"} $$run{"replicaof"}
Truth table33%1/3
not(A) and B
A= not $seen{"replicaof"}B= $$run{"replicaof"}
ABresult
0X0
100
111
337 1 ▶ if (@new) {
Branch: 1 branch
BranchTrueFalseTotal
if (@new) 0 1 1
338 0 ▶ push @out, '# Generated by CONFIG REWRITE' unless grep { $_ eq '# Generated by CONFIG REWRITE' } @out;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq "# Generated by CONFIG REWRITE";} @out 0 0 0
339 0 push @out, map { $fmt->($_) } @new;
340 }
341 1 _set_file( $dev, $conf, join( "\n", @out ) . "\n" );
342 1 return 1;
343 }
344  
345 7 ▶sub _err { my ($m) = @_; return ( "(error) $m", 1 ) }
Subroutine _err: called CC=1 SCAR=0.0
346  
347 # Ein Befehl (Woerter) -> ( ausgabe, ok )
348 45 ▶sub _command {
Subroutine _command: called CC=174 SCAR=78.3
349 45 my ( $dev, $w, $o ) = @_;
350 45 my $r = $dev->{redis};
351 45 my $run = _running($dev);
352 45 my @w = @$w;
353 45 ▶ my $cmd = uc( shift(@w) // '' );
Condition50%1/2
shift @w // ""
l!l
450
MC/DC0%0/1
shift @w // ""
shift @w
Truth table50%1/2
A
A= shift @w
Aresult
11
00
354 45 my $raw = $o->{raw};
355 45 ▶ if ( $cmd eq 'AUTH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "AUTH") 0 45 45
356 0 ▶ my $pw = pop @w // '';
Condition0%0/2
pop @w // ""
l!l
00
MC/DC0%0/1
pop @w // ""
pop @w
Truth table0%0/2
A
A= pop @w
Aresult
11
00
357 return _err('ERR AUTH <password> called without any password configured for the default user. Are you sure your configuration is correct?')
358 0 ▶ if ( $run->{requirepass} // '' ) eq '';
Branch: 1 branch
BranchTrueFalseTotal
if ($$run{"requirepass"} // "") eq "" 0 0 0
Condition0%0/2
$$run{"requirepass"} // ""
l!l
00
MC/DC0%0/1
$$run{"requirepass"} // ""
$$run{"requirepass"}
Truth table0%0/2
A
A= $$run{"requirepass"}
Aresult
11
00
359 0 ▶ return _err('WRONGPASS invalid username-password pair or user is disabled.') unless $pw eq $run->{requirepass};
Branch: 1 branch
BranchTrueFalseTotal
unless $pw eq $$run{"requirepass"} 0 0 0
360 0 $o->{authed} = 1;
361 0 return ( 'OK', 1 );
362 }
363 45 ▶ return _err('NOAUTH Authentication required.') if ( $run->{requirepass} // '' ) ne '' && !$o->{authed};
Branch: 1 branch
BranchTrueFalseTotal
if ($$run{"requirepass"} // "") ne "" and not $$o{"authed"} 1 44 45
Condition80%4/5
($$run{"requirepass"} // "") ne "" and not $$o{"authed"}
!ll&&!rl&&r
4131
$$run{"requirepass"} // ""
l!l
450
MC/DC50%1/2
($$run{"requirepass"} // "") ne "" and not $$o{"authed"}
$$run{"requirepass"} not $$o{"authed"}
Truth table66%2/3
A and not(B)
A= $$run{"requirepass"}B= not $$o{"authed"}
ABresult
0X0
100
111
364 44 ▶ return ( 'PONG', 1 ) if $cmd eq 'PING' && !@w;
Branch: 1 branch
BranchTrueFalseTotal
if $cmd eq "PING" and not @w 3 41 44
Condition66%2/3
$cmd eq "PING" and not @w
!ll&&!rl&&r
4103
MC/DC50%1/2
$cmd eq "PING" and not @w
$cmd eq "PING" not @w
Truth table66%2/3
A and not(B)
A= $cmd eq "PING"B= not @w
ABresult
0X0
100
111
365 41 ▶ return ( $w[0], 1 ) if $cmd eq 'PING';
Branch: 1 branch
BranchTrueFalseTotal
if $cmd eq "PING" 0 41 41
366 41 ▶ if ( $cmd eq 'INFO' ) { return ( _info( $dev, $w[0] ), 1 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "INFO") 6 35 41
367 35 ▶ if ( $cmd eq 'DBSIZE' ) { my $db = $o->{db} // 0; return ( ( $raw ? '' : '(integer) ' ) . ( $r->{keys}{"db$db"} // 0 ), 1 ) }
Branch: 2 branches
BranchTrueFalseTotal
if ($cmd eq "DBSIZE") 1 34 35
$raw ? : 0 1 1
Condition50%2/4
$$o{"db"} // 0
l!l
01
$$r{"keys"}{"db$db"} // 0
l!l
10
MC/DC0%0/1
$$o{"db"} // 0
$$o{"db"}
MC/DC0%0/1
$$r{"keys"}{"db$db"} // 0
$$r{"keys"}{"db$db"}
Truth table50%1/2
A
A= $$o{"db"}
Aresult
11
00
Truth table50%1/2
A
A= $$r{"keys"}{"db$db"}
Aresult
11
00
368 0 ▶ if ( $cmd eq 'LASTSAVE' ) { return ( ( $raw ? '' : '(integer) ' ) . ( $r->{lastsave} // 1792821600 ), 1 ) }
Branch: 2 branches
BranchTrueFalseTotal
if ($cmd eq "LASTSAVE") 0 34 34
$raw ? : 0 0 0
Condition0%0/2
$$r{"lastsave"} // 1792821600
l!l
00
MC/DC0%0/1
$$r{"lastsave"} // 1792821600
$$r{"lastsave"}
Truth table0%0/2
A
A= $$r{"lastsave"}
Aresult
11
00
369 34 ▶ if ( $cmd eq 'BGSAVE' || $cmd eq 'SAVE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "BGSAVE" or $cmd eq "SAVE") 2 32 34
Condition66%2/3
$cmd eq "BGSAVE" or $cmd eq "SAVE"
l!l&&r!l&&!r
2032
MC/DC50%1/2
$cmd eq "BGSAVE" or $cmd eq "SAVE"
$cmd eq "BGSAVE" $cmd eq "SAVE"
Truth table66%2/3
A or B
A= $cmd eq "BGSAVE"B= $cmd eq "SAVE"
ABresult
1X1
011
000
370 # fork scheitert: sofort ERR; Schreiben scheitert (Rechte, Platz): erst im Kind
371 2 my $fork_bad = _need_failing( $dev, $r->{fork_needs} );
372 2 my $ok = _bgsave($dev);
373 2 ▶ return _err('ERR') if $fork_bad || ( $cmd eq 'SAVE' && !$ok );
Branch: 1 branch
BranchTrueFalseTotal
if $fork_bad or $cmd eq "SAVE" and not $ok 0 2 2
Condition33%2/6
$fork_bad or $cmd eq "SAVE" and not $ok
l!l&&r!l&&!r
002
$cmd eq "SAVE" and not $ok
!ll&&!rl&&r
200
MC/DC0%0/3
$fork_bad or $cmd eq "SAVE" and not $ok
$fork_bad $cmd eq "SAVE" not $ok
Truth table25%1/4
A or B and not(C)
A= $fork_badB= $cmd eq "SAVE"C= not $ok
ABCresult
1XX1
0111
00X0
0100
374 2 ▶ return ( $cmd eq 'SAVE' ? 'OK' : 'Background saving started', 1 );
Branch: 1 branch
BranchTrueFalseTotal
$cmd eq 'SAVE' ? : 0 2 2
375 }
376 32 ▶ if ( $cmd eq 'ROLE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "ROLE") 0 32 32
377 0 my $p = _replica_of($dev);
378 0 ▶ return ( _fmt_bulk_list( $raw, 'slave', $p->{host}, $p->{port}, _link_up( $dev, $p ) ? 'connected' : 'connect' ), 1 ) if $p;
Branch: 2 branches
BranchTrueFalseTotal
if $p 0 0 0
_link_up($dev, $p) ? : 0 0 0
379 0 ▶ return ( _fmt_bulk_list( $raw, 'master', $r->{repl_offset} // 0 ), 1 );
Condition0%0/2
$$r{"repl_offset"} // 0
l!l
00
MC/DC0%0/1
$$r{"repl_offset"} // 0
$$r{"repl_offset"}
Truth table0%0/2
A
A= $$r{"repl_offset"}
Aresult
11
00
380 }
381 32 ▶ if ( $cmd eq 'REPLICAOF' || $cmd eq 'SLAVEOF' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "REPLICAOF" or $cmd eq "SLAVEOF") 2 30 32
Condition66%2/3
$cmd eq "REPLICAOF" or $cmd eq "SLAVEOF"
l!l&&r!l&&!r
2030
MC/DC50%1/2
$cmd eq "REPLICAOF" or $cmd eq "SLAVEOF"
$cmd eq "REPLICAOF" $cmd eq "SLAVEOF"
Truth table66%2/3
A or B
A= $cmd eq "REPLICAOF"B= $cmd eq "SLAVEOF"
ABresult
1X1
011
000
382 2 ▶ return _err("ERR wrong number of arguments for '" . lc($cmd) . "' command") unless @w == 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @w == 2 0 2 2
383 2 ▶ if ( uc $w[0] eq 'NO' && uc $w[1] eq 'ONE' ) { $run->{replicaof} = ''; return ( 'OK', 1 ) }
Branch: 1 branch
BranchTrueFalseTotal
if (uc $w[0] eq "NO" and uc $w[1] eq "ONE") 1 1 2
Condition66%2/3
uc $w[0] eq "NO" and uc $w[1] eq "ONE"
!ll&&!rl&&r
101
MC/DC50%1/2
uc $w[0] eq "NO" and uc $w[1] eq "ONE"
uc $w[0] eq "NO" uc $w[1] eq "ONE"
Truth table66%2/3
A and B
A= uc $w[0] eq "NO"B= uc $w[1] eq "ONE"
ABresult
0X0
100
111
384 1 ▶ return _err('ERR value is out of range, must be positive') unless $w[1] =~ /\A\d+\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $w[1] =~ /\A\d+\z/ 0 1 1
385 1 $run->{replicaof} = "$w[0] $w[1]";
386 1 return ( 'OK', 1 );
387 }
388 0 ▶ if ( $cmd eq 'ACL' && uc( $w[0] // '' ) eq 'WHOAMI' ) { return ( $raw ? 'default' : '"default"', 1 ) }
Branch: 2 branches
BranchTrueFalseTotal
if ($cmd eq "ACL" and uc($w[0] // "") eq "WHOAMI") 0 30 30
$raw ? : 0 0 0
Condition20%1/5
$cmd eq "ACL" and uc($w[0] // "") eq "WHOAMI"
!ll&&!rl&&r
3000
$w[0] // ""
l!l
00
MC/DC0%0/2
$cmd eq "ACL" and uc($w[0] // "") eq "WHOAMI"
$cmd eq "ACL" $w[0]
Truth table33%1/3
A and B
A= $cmd eq "ACL"B= $w[0]
ABresult
0X0
100
111
389 30 ▶ if ( $cmd eq 'CLIENT' && uc( $w[0] // '' ) eq 'LIST' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "CLIENT" and uc($w[0] // "") eq "LIST") 0 30 30
Condition20%1/5
$cmd eq "CLIENT" and uc($w[0] // "") eq "LIST"
!ll&&!rl&&r
3000
$w[0] // ""
l!l
00
MC/DC0%0/2
$cmd eq "CLIENT" and uc($w[0] // "") eq "LIST"
$cmd eq "CLIENT" $w[0]
Truth table33%1/3
A and B
A= $cmd eq "CLIENT"B= $w[0]
ABresult
0X0
100
111
390 0 ▶ my $n = $r->{clients} // 3;
Condition0%0/2
$$r{"clients"} // 3
l!l
00
MC/DC0%0/1
$$r{"clients"} // 3
$$r{"clients"}
Truth table0%0/2
A
A= $$r{"clients"}
Aresult
11
00
391 0 ▶ my @l = map { "id=$_ addr=" . ( $r->{client_addr} // '10.20.0.21' ) . ':' . ( 40000 + $_ ) . " laddr=127.0.0.1:6379 fd=" . ( 8 + $_ ) . " name= age=812 idle=0 flags=N db=0 cmd=get user=default" } 1 .. ( $n > 5 ? 5 : $n );
Branch: 1 branch
BranchTrueFalseTotal
$n > 5 ? : 0 0 0
Condition0%0/2
$$r{"client_addr"} // "10.20.0.21"
l!l
00
MC/DC0%0/1
$$r{"client_addr"} // "10.20.0.21"
$$r{"client_addr"}
Truth table0%0/2
A
A= $$r{"client_addr"}
Aresult
11
00
392 0 return ( join( "\n", @l ), 1 );
393 }
394 0 ▶ if ( $cmd eq 'FLUSHALL' ) { $r->{flushed} = ( $r->{flushed} // 0 ) + _keys_total($r); $r->{keys} = {}; return ( 'OK', 1 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "FLUSHALL") 0 30 30
Condition0%0/2
$$r{"flushed"} // 0
l!l
00
MC/DC0%0/1
$$r{"flushed"} // 0
$$r{"flushed"}
Truth table0%0/2
A
A= $$r{"flushed"}
Aresult
11
00
395 0 ▶ if ( $cmd eq 'FLUSHDB' ) { $r->{flushed} = ( $r->{flushed} // 0 ) + ( $r->{keys}{ 'db' . ( $o->{db} // 0 ) } // 0 ); delete $r->{keys}{ 'db' . ( $o->{db} // 0 ) }; return ( 'OK', 1 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "FLUSHDB") 0 30 30
Condition0%0/8
$$r{"flushed"} // 0
l!l
00
$$r{"keys"}{'db' . ($$o{"db"} // 0)} // 0
l!l
00
$$o{"db"} // 0
l!l
00
$$o{"db"} // 0
l!l
00
MC/DC0%0/1
$$r{"flushed"} // 0
$$r{"flushed"}
MC/DC0%0/1
$$r{"keys"}{'db' . ($$o{"db"} // 0)} // 0
$$r{"keys"}{'db' . ($$o{"db"} // 0)}
MC/DC0%0/1
$$o{"db"} // 0
$$o{"db"}
MC/DC0%0/1
$$o{"db"} // 0
$$o{"db"}
Truth table0%0/2
A
A= $$r{"flushed"}
Aresult
11
00
Truth table0%0/2
A
A= $$r{"keys"}{'db' . ($$o{"db"} // 0)}
Aresult
11
00
Truth table0%0/2
A
A= $$o{"db"}
Aresult
11
00
Truth table0%0/2
A
A= $$o{"db"}
Aresult
11
00
396 # Daten: SET/GET/DEL/EXISTS/INCR/EXPIRE/TTL an einem kleinen Bestand (data); Schreiben ist bei
397 # gescheiterter Sicherung gesperrt (MISCONF), bei voller Grenze ohne Verdraengung (OOM)
398 30 ▶ if ( $cmd =~ /\A(?:SET|SETEX|DEL|INCR|EXPIRE|HSET|LPUSH|RPUSH)\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /\A(?:SET|SETEX|DEL|INCR|EXPIRE|HSET|LPUSH|RPUSH)\z/) 3 27 30
399 3 ▶ return _err("ERR wrong number of arguments for '" . lc($cmd) . "' command") unless @w;
Branch: 1 branch
BranchTrueFalseTotal
unless @w 0 3 3
400 return _err("READONLY You can't write against a read only replica.")
401 3 ▶ if _replica_of($dev) && ( $run->{'replica-read-only'} // 'yes' ) eq 'yes';
Branch: 1 branch
BranchTrueFalseTotal
if _replica_of($dev) and ($$run{"replica-read-only"} // "yes") eq "yes" 1 2 3
Condition60%3/5
_replica_of($dev) and ($$run{"replica-read-only"} // "yes") eq "yes"
!ll&&!rl&&r
201
$$run{"replica-read-only"} // "yes"
l!l
10
MC/DC50%1/2
_replica_of($dev) and ($$run{"replica-read-only"} // "yes") eq "yes"
_replica_of($dev) $$run{"replica-read-only"}
Truth table66%2/3
A and B
A= _replica_of($dev)B= $$run{"replica-read-only"}
ABresult
0X0
100
111
402 2 ▶ if ( !( $r->{rdb_ok} // 1 ) && ( $run->{'stop-writes-on-bgsave-error'} // 'yes' ) eq 'yes' && ( $run->{save} // '' ) ne '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $$r{"rdb_ok"} // 1 and ($$run{"stop-writes-on-bgsave-error"} // "yes") eq "yes" and ($$run{"save"} // "") ne "") 1 1 2
Condition58%7/12
not $$r{"rdb_ok"} // 1 and ($$run{"stop-writes-on-bgsave-error"} // "yes") eq "yes" and ($$run{"save"} // "") ne ""
!ll&&!rl&&r
101
not $$r{"rdb_ok"} // 1 and ($$run{"stop-writes-on-bgsave-error"} // "yes") eq "yes"
!ll&&!rl&&r
101
$$r{"rdb_ok"} // 1
l!l
20
$$run{"stop-writes-on-bgsave-error"} // "yes"
l!l
10
$$run{"save"} // ""
l!l
10
MC/DC0%0/3
not $$r{"rdb_ok"} // 1 and ($$run{"stop-writes-on-bgsave-error"} // "yes") eq "yes" and ($$run{"save"} // "") ne ""
$$r{"rdb_ok"} $$run{"stop-writes-on-bgsave-error"} $$run{"save"}
Truth table25%1/4
not(A) and B and C
A= $$r{"rdb_ok"}B= $$run{"stop-writes-on-bgsave-error"}C= $$run{"save"}
ABCresult
1XX0
00X0
0100
0111
403 1 return _err('MISCONF Redis is configured to save RDB snapshots, but it\'s currently unable to persist to disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.');
404 }
405 1 ▶ if ( ( $run->{maxmemory} // 0 ) > 0 && ( $r->{used_memory} // 0 ) >= $run->{maxmemory} && $run->{'maxmemory-policy'} eq 'noeviction' && $cmd ne 'DEL' && $cmd ne 'EXPIRE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($$run{"maxmemory"} // 0) > 0 and ($$r{"used_memory"} // 0) >= $$run{"maxmemory"} and $$run{"maxmemory-policy"} eq "noeviction" and $cmd ne "DEL" and $cmd ne "EXPIRE") 0 1 1
Condition37%6/16
($$run{"maxmemory"} // 0) > 0 and ($$r{"used_memory"} // 0) >= $$run{"maxmemory"} and $$run{"maxmemory-policy"} eq "noeviction" and $cmd ne "DEL" and $cmd ne "EXPIRE"
!ll&&!rl&&r
100
($$run{"maxmemory"} // 0) > 0 and ($$r{"used_memory"} // 0) >= $$run{"maxmemory"} and $$run{"maxmemory-policy"} eq "noeviction" and $cmd ne "DEL"
!ll&&!rl&&r
100
($$run{"maxmemory"} // 0) > 0 and ($$r{"used_memory"} // 0) >= $$run{"maxmemory"} and $$run{"maxmemory-policy"} eq "noeviction"
!ll&&!rl&&r
100
($$run{"maxmemory"} // 0) > 0 and ($$r{"used_memory"} // 0) >= $$run{"maxmemory"}
!ll&&!rl&&r
010
$$run{"maxmemory"} // 0
l!l
10
$$r{"used_memory"} // 0
l!l
10
MC/DC0%0/5
($$run{"maxmemory"} // 0) > 0 and ($$r{"used_memory"} // 0) >= $$run{"maxmemory"} and $$run{"maxmemory-policy"} eq "noeviction" and $cmd ne "DEL" and $cmd ne "EXPIRE"
$$run{"maxmemory"} $$r{"used_memory"} $$run{"maxmemory-policy"} eq "noeviction" $cmd ne "DEL" $cmd ne "EXPIRE"
Truth table0%0/6
A and B and C and D and E
A= $$run{"maxmemory"}B= $$r{"used_memory"}C= $$run{"maxmemory-policy"} eq "noeviction"D= $cmd ne "DEL"E= $cmd ne "EXPIRE"
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
406 0 return _err("OOM command not allowed when used memory > 'maxmemory'.");
407 }
408 1 ▶ my $db = 'db' . ( $o->{db} // 0 );
Condition50%1/2
$$o{"db"} // 0
l!l
01
MC/DC0%0/1
$$o{"db"} // 0
$$o{"db"}
Truth table50%1/2
A
A= $$o{"db"}
Aresult
11
00
409 1 ▶ my $d = $r->{data} //= {};
Condition50%1/2
$$r{"data"} //= {}
l!l
01
MC/DC0%0/1
$$r{"data"} //= {}
$$r{"data"}
Truth table50%1/2
A
A= $$r{"data"}
Aresult
11
00
410 1 ▶ if ( $cmd eq 'DEL' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "DEL") 0 1 1
411 0 my $n = grep { delete $d->{$_} } @w;
412 0 $r->{keys}{$db}-- , $r->{deleted}++ for 1 .. $n;
413 0 ▶ return ( ( $raw ? '' : '(integer) ' ) . $n, 1 );
Branch: 1 branch
BranchTrueFalseTotal
$raw ? : 0 0 0
414 }
415 0 ▶ if ( $cmd eq 'EXPIRE' ) { return ( ( $raw ? '' : '(integer) ' ) . ( exists $d->{ $w[0] } ? 1 : 0 ), 1 ) }
Branch: 3 branches
BranchTrueFalseTotal
if ($cmd eq "EXPIRE") 0 1 1
$raw ? : 0 0 0
exists $$d{$w[0]} ? : 0 0 0
416 1 my $new = !exists $d->{ $w[0] };
417 1 ▶ $d->{ $w[0] } = $cmd eq 'INCR' ? ( $d->{ $w[0] } // 0 ) + 1 : $cmd eq 'SETEX' ? $w[2] // '' : $w[1] // '';
Branch: 2 branches
BranchTrueFalseTotal
$cmd eq 'INCR' ? : 0 1 1
$cmd eq 'SETEX' ? : 0 1 1
Condition16%1/6
$$d{$w[0]} // 0
l!l
00
$w[2] // ""
l!l
00
$w[1] // ""
l!l
10
MC/DC0%0/1
$$d{$w[0]} // 0
$$d{$w[0]}
MC/DC0%0/1
$w[2] // ""
$w[2]
MC/DC0%0/1
$w[1] // ""
$w[1]
Truth table0%0/2
A
A= $$d{$w[0]}
Aresult
11
00
Truth table0%0/2
A
A= $w[2]
Aresult
11
00
Truth table50%1/2
A
A= $w[1]
Aresult
11
00
418 1 ▶ $r->{keys}{$db}++ if $new;
Branch: 1 branch
BranchTrueFalseTotal
if $new 1 0 1
419 1 ▶ $r->{rdb_changes} = ( $r->{rdb_changes} // 0 ) + 1;
Condition50%1/2
$$r{"rdb_changes"} // 0
l!l
10
MC/DC0%0/1
$$r{"rdb_changes"} // 0
$$r{"rdb_changes"}
Truth table50%1/2
A
A= $$r{"rdb_changes"}
Aresult
11
00
420 1 ▶ return ( $cmd eq 'INCR' ? ( $raw ? '' : '(integer) ' ) . $d->{ $w[0] } : $cmd =~ /PUSH|HSET/ ? ( $raw ? '' : '(integer) ' ) . 1 : 'OK', 1 );
Branch: 4 branches
BranchTrueFalseTotal
$cmd eq 'INCR' ? : 0 1 1
$raw ? : 0 0 0
$cmd =~ /PUSH|HSET/ ? : 0 1 1
$raw ? : 0 0 0
421 }
422 27 ▶ if ( $cmd =~ /\A(?:GET|EXISTS|TTL|TYPE)\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /\A(?:GET|EXISTS|TTL|TYPE)\z/) 1 26 27
423 1 ▶ my $v = ( $r->{data} || {} )->{ $w[0] // '' };
Condition50%2/4
$$r{'data'} || {}
l!l
10
$w[0] // ""
l!l
10
MC/DC0%0/1
$$r{'data'} || {}
$$r{'data'}
MC/DC0%0/1
$w[0] // ""
$w[0]
Truth table50%1/2
A
A= $$r{'data'}
Aresult
11
00
Truth table50%1/2
A
A= $w[0]
Aresult
11
00
424 1 ▶ return ( ( $raw ? '' : '(integer) ' ) . ( defined $v ? 1 : 0 ), 1 ) if $cmd eq 'EXISTS';
Branch: 3 branches
BranchTrueFalseTotal
if $cmd eq "EXISTS" 0 1 1
$raw ? : 0 0 0
defined $v ? : 0 0 0
425 1 ▶ return ( ( $raw ? '' : '(integer) ' ) . ( defined $v ? -1 : -2 ), 1 ) if $cmd eq 'TTL';
Branch: 3 branches
BranchTrueFalseTotal
if $cmd eq "TTL" 0 1 1
$raw ? : 0 0 0
defined $v ? : 0 0 0
426 1 ▶ return ( defined $v ? 'string' : 'none', 1 ) if $cmd eq 'TYPE';
Branch: 2 branches
BranchTrueFalseTotal
if $cmd eq "TYPE" 0 1 1
defined $v ? : 0 0 0
427 1 ▶ return ( defined $v ? ( $raw ? $v : qq{"$v"} ) : $raw ? '' : '(nil)', 1 );
Branch: 3 branches
BranchTrueFalseTotal
defined $v ? : 1 0 1
$raw ? : 0 1 1
$raw ? : 0 0 0
428 }
429 26 ▶ if ( $cmd eq 'SHUTDOWN' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "SHUTDOWN") 0 26 26
430 0 ▶ my $svc = $dev->{services}{ $r->{service} // 'redis-server' };
Condition0%0/2
$$r{"service"} // "redis-server"
l!l
00
MC/DC0%0/1
$$r{"service"} // "redis-server"
$$r{"service"}
Truth table0%0/2
A
A= $$r{"service"}
Aresult
11
00
431 0 ▶ if ( $svc && $svc->{active} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($svc and $$svc{"active"}) 0 0 0
Condition0%0/3
$svc and $$svc{"active"}
!ll&&!rl&&r
000
MC/DC0%0/2
$svc and $$svc{"active"}
$svc $$svc{"active"}
Truth table0%0/3
A and B
A= $svcB= $$svc{"active"}
ABresult
0X0
100
111
432 0 my $nosave = grep { uc $_ eq 'NOSAVE' } @w;
433 0 ▶ _bgsave($dev) unless $nosave;
Branch: 1 branch
BranchTrueFalseTotal
unless $nosave 0 0 0
434 0 $svc->{active} = JSON::MaybeXS::false();
435 0 ▶ $svc->{restarts} = ( $svc->{restarts} // 0 ) + 1;
Condition0%0/2
$$svc{"restarts"} // 0
l!l
00
MC/DC0%0/1
$$svc{"restarts"} // 0
$$svc{"restarts"}
Truth table0%0/2
A
A= $$svc{"restarts"}
Aresult
11
00
436 }
437 0 return ( '', 1 );
438 }
439 # DEBUG SLEEP s: der Befehl dauert s Sekunden; ab slowlog-log-slower-than (µs, >= 0)
440 # ein Eintrag im Slowlog (Laufzeitspur _slowlog, hoechstens slowlog-max-len)
441 26 ▶ if ( $cmd eq 'DEBUG' && uc( $w[0] // '' ) eq 'SLEEP' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "DEBUG" and uc($w[0] // "") eq "SLEEP") 5 21 26
Condition60%3/5
$cmd eq "DEBUG" and uc($w[0] // "") eq "SLEEP"
!ll&&!rl&&r
2105
$w[0] // ""
l!l
50
MC/DC50%1/2
$cmd eq "DEBUG" and uc($w[0] // "") eq "SLEEP"
$cmd eq "DEBUG" $w[0]
Truth table66%2/3
A and B
A= $cmd eq "DEBUG"B= $w[0]
ABresult
0X0
100
111
442 5 ▶ my $s = $w[1] // '';
Condition50%1/2
$w[1] // ""
l!l
50
MC/DC0%0/1
$w[1] // ""
$w[1]
Truth table50%1/2
A
A= $w[1]
Aresult
11
00
443 5 ▶ return _err("ERR value is not a valid float") unless $s =~ /\A\d+(?:\.\d+)?\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $s =~ /\A\d+(?:\.\d+)?\z/ 0 5 5
444 5 my $us = int( $s * 1e6 ) + 12;
445 5 ▶ my $lim = $run->{'slowlog-log-slower-than'} // 10000;
Condition50%1/2
$$run{"slowlog-log-slower-than"} // 10000
l!l
50
MC/DC0%0/1
$$run{"slowlog-log-slower-than"} // 10000
$$run{"slowlog-log-slower-than"}
Truth table50%1/2
A
A= $$run{"slowlog-log-slower-than"}
Aresult
11
00
446 5 ▶ if ( $lim =~ /\A\d+\z/ && $us >= $lim ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lim =~ /\A\d+\z/ and $us >= $lim) 3 2 5
Condition100%3/3
$lim =~ /\A\d+\z/ and $us >= $lim
!ll&&!rl&&r
113
MC/DC100%2/2
$lim =~ /\A\d+\z/ and $us >= $lim
$lim =~ /\A\d+\z/ $us >= $lim
Truth table100%3/3
A and B
A= $lim =~ /\A\d+\z/B= $us >= $lim
ABresult
0X0
100
111
447 3 ▶ my $now = defined $dev->{clock} ? do { Langertha::Holmgang::Sim::Linux::_part('Monitoring'); Langertha::Holmgang::Sim::Linux::Monitoring::now_epoch($dev) } : 1792821600;
Branch: 1 branch
BranchTrueFalseTotal
defined $$dev{'clock'} ? : 3 0 3
448 3 ▶ my $id = $r->{_slowlog_next} // 0;
Condition100%2/2
$$r{"_slowlog_next"} // 0
l!l
21
MC/DC100%1/1
$$r{"_slowlog_next"} // 0
$$r{"_slowlog_next"}
Truth table100%2/2
A
A= $$r{"_slowlog_next"}
Aresult
11
00
449 3 unshift @{ $r->{_slowlog} }, { id => $id, ts => $now, us => $us, args => [ 'DEBUG', 'SLEEP', $s ], client => '127.0.0.1:' . ( 43210 + $id ) };
450 3 $r->{_slowlog_next} = $id + 1;
451 3 ▶ my $max = $run->{'slowlog-max-len'} // 128;
Condition50%1/2
$$run{"slowlog-max-len"} // 128
l!l
30
MC/DC0%0/1
$$run{"slowlog-max-len"} // 128
$$run{"slowlog-max-len"}
Truth table50%1/2
A
A= $$run{"slowlog-max-len"}
Aresult
11
00
452 3 ▶ splice @{ $r->{_slowlog} }, $max if $max =~ /\A\d+\z/ && @{ $r->{_slowlog} } > $max;
Branch: 1 branch
BranchTrueFalseTotal
if $max =~ /\A\d+\z/ and @{$$r{"_slowlog"};} > $max 1 2 3
Condition66%2/3
$max =~ /\A\d+\z/ and @{$$r{"_slowlog"};} > $max
!ll&&!rl&&r
021
MC/DC50%1/2
$max =~ /\A\d+\z/ and @{$$r{"_slowlog"};} > $max
$max =~ /\A\d+\z/ @{$$r{"_slowlog"};} > $max
Truth table66%2/3
A and B
A= $max =~ /\A\d+\z/B= @{$$r{"_slowlog"};} > $max
ABresult
0X0
100
111
453 }
454 5 return ( 'OK', 1 );
455 }
456 21 ▶ if ( $cmd eq 'SLOWLOG' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "SLOWLOG") 11 10 21
457 11 ▶ my $sub = uc( $w[0] // '' );
Condition50%1/2
$w[0] // ""
l!l
110
MC/DC0%0/1
$w[0] // ""
$w[0]
Truth table50%1/2
A
A= $w[0]
Aresult
11
00
458 11 ▶ my @e = @{ $r->{_slowlog} || [] };
Condition100%2/2
$$r{'_slowlog'} || []
l!l
83
MC/DC100%1/1
$$r{'_slowlog'} || []
$$r{'_slowlog'}
Truth table100%2/2
A
A= $$r{'_slowlog'}
Aresult
11
00
459 11 ▶ return ( ( $raw ? '' : '(integer) ' ) . scalar(@e), 1 ) if $sub eq 'LEN';
Branch: 2 branches
BranchTrueFalseTotal
if $sub eq "LEN" 6 5 11
$raw ? : 0 6 6
460 5 ▶ if ( $sub eq 'RESET' ) { $r->{_slowlog} = []; return ( 'OK', 1 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "RESET") 1 4 5
461 4 ▶ return _err("ERR unknown subcommand '" . lc( $w[0] // '' ) . "'. Try SLOWLOG HELP.") unless $sub eq 'GET';
Branch: 1 branch
BranchTrueFalseTotal
unless $sub eq "GET" 0 4 4
Condition0%0/2
$w[0] // ""
l!l
00
MC/DC0%0/1
$w[0] // ""
$w[0]
Truth table0%0/2
A
A= $w[0]
Aresult
11
00
462 4 ▶ my $n = $w[1] // 10;
Condition100%2/2
$w[1] // 10
l!l
22
MC/DC100%1/1
$w[1] // 10
$w[1]
Truth table100%2/2
A
A= $w[1]
Aresult
11
00
463 4 ▶ @e = @e[ 0 .. $n - 1 ] if $n =~ /\A\d+\z/ && @e > $n;
Branch: 1 branch
BranchTrueFalseTotal
if $n =~ /\A\d+\z/ and @e > $n 1 3 4
Condition66%2/3
$n =~ /\A\d+\z/ and @e > $n
!ll&&!rl&&r
031
MC/DC50%1/2
$n =~ /\A\d+\z/ and @e > $n
$n =~ /\A\d+\z/ @e > $n
Truth table66%2/3
A and B
A= $n =~ /\A\d+\z/B= @e > $n
ABresult
0X0
100
111
464 4 ▶ return ( $raw ? '' : '(empty array)', 1 ) unless @e;
Branch: 2 branches
BranchTrueFalseTotal
unless @e 1 3 4
$raw ? : 0 1 1
465 3 ▶ if ($raw) { return ( join( "\n", map { ( $_->{id}, $_->{ts}, $_->{us}, @{ $_->{args} }, $_->{client}, '' ) } @e ), 1 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($raw) 1 2 3
466 2 my @l;
467 2 my $i = 0;
468 2 for my $x (@e) {
469 3 $i++;
470 3 my $p = "$i) ";
471 3 my $ind = ' ' x length $p;
472 3 my $j = 0;
473 3 ▶ my @args = map { $j++; ( $j == 1 ? '' : "$ind " ) . "$j) \"$_\"" } @{ $x->{args} };
Branch: 1 branch
BranchTrueFalseTotal
$j == 1 ? : 3 6 9
474 3 push @l, "${p}1) (integer) $x->{id}", "${ind}2) (integer) $x->{ts}", "${ind}3) (integer) $x->{us}",
475 "${ind}4) $args[0]", @args[ 1 .. $#args ], "${ind}5) \"$x->{client}\"", "${ind}6) \"\"";
476 }
477 2 return ( join( "\n", @l ), 1 );
478 }
479 10 ▶ if ( $cmd eq 'CONFIG' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "CONFIG") 9 1 10
480 9 ▶ my $sub = uc( shift(@w) // '' );
Condition50%1/2
shift @w // ""
l!l
90
MC/DC0%0/1
shift @w // ""
shift @w
Truth table50%1/2
A
A= shift @w
Aresult
11
00
481 9 ▶ if ( $sub eq 'GET' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "GET") 2 7 9
482 2 ▶ return _err("ERR wrong number of arguments for 'config|get' command") unless @w;
Branch: 1 branch
BranchTrueFalseTotal
unless @w 0 2 2
483 2 my @out;
484 2 for my $pat (@w) {
485 2 ▶ my $re = _glob_re( $ALIAS{ lc $pat } // $pat );
Condition33%1/3
$Langertha::Holmgang::Sim::Linux::Redis::ALIAS{lc $pat} // $pat
l!l&&r!l&&!r
020
MC/DC0%0/2
$Langertha::Holmgang::Sim::Linux::Redis::ALIAS{lc $pat} // $pat
$Langertha::Holmgang::Sim::Linux::Redis::ALIAS{lc $pat} $pat
Truth table33%1/3
A // B
A= $Langertha::Holmgang::Sim::Linux::Redis::ALIAS{lc $pat}B= $pat
ABresult
1X1
011
000
486 2 for my $k ( sort keys %$run ) {
487 64 ▶ next unless $k =~ $re;
Branch: 1 branch
BranchTrueFalseTotal
unless $k =~ /$re/ 62 2 64
488 2 ▶ push @out, $k, $run->{$k} // '';
Condition50%1/2
$$run{$k} // ""
l!l
20
MC/DC0%0/1
$$run{$k} // ""
$$run{$k}
Truth table50%1/2
A
A= $$run{$k}
Aresult
11
00
489 }
490 }
491 2 return ( _fmt_bulk_list( $raw, @out ), 1 );
492 }
493 7 ▶ if ( $sub eq 'SET' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "SET") 6 1 7
494 6 ▶ return _err("ERR wrong number of arguments for 'config|set' command") unless @w && @w % 2 == 0;
Branch: 1 branch
BranchTrueFalseTotal
unless @w and @w % 2 == 0 0 6 6
Condition33%1/3
@w and @w % 2 == 0
!ll&&!rl&&r
006
MC/DC0%0/2
@w and @w % 2 == 0
@w @w % 2 == 0
Truth table33%1/3
A and B
A= @wB= @w % 2 == 0
ABresult
0X0
100
111
495 6 my %new;
496 6 ▶ while (@w) {
Branch: 1 branch
BranchTrueFalseTotal
if (@w) 6 3 9
497 6 my ( $k, $v ) = ( lc shift @w, shift @w );
498 6 ▶ $k = $ALIAS{$k} // $k;
Condition33%1/3
$Langertha::Holmgang::Sim::Linux::Redis::ALIAS{$k} // $k
l!l&&r!l&&!r
060
MC/DC0%0/2
$Langertha::Holmgang::Sim::Linux::Redis::ALIAS{$k} // $k
$Langertha::Holmgang::Sim::Linux::Redis::ALIAS{$k} $k
Truth table33%1/3
A // B
A= $Langertha::Holmgang::Sim::Linux::Redis::ALIAS{$k}B= $k
ABresult
1X1
011
000
499 6 ▶ return _err("ERR Unknown option or number of arguments for CONFIG SET - '$k'") unless exists $DEFAULT{$k} || $k eq 'replicaof';
Branch: 1 branch
BranchTrueFalseTotal
unless exists $Langertha::Holmgang::Sim::Linux::Redis::DEFAULT{$k} or $k eq "replicaof" 0 6 6
Condition33%1/3
exists $Langertha::Holmgang::Sim::Linux::Redis::DEFAULT{$k} or $k eq "replicaof"
l!l&&r!l&&!r
600
MC/DC0%0/2
exists $Langertha::Holmgang::Sim::Linux::Redis::DEFAULT{$k} or $k eq "replicaof"
exists $Langertha::Holmgang::Sim::Linux::Redis::DEFAULT{$k} $k eq "replicaof"
Truth table33%1/3
A or B
A= exists $Langertha::Holmgang::Sim::Linux::Redis::DEFAULT{$k}B= $k eq "replicaof"
ABresult
1X1
011
000
500 6 ▶ return _err("ERR CONFIG SET failed (possibly related to argument '$k') - can't set immutable config") if $IMMUTABLE{$k};
Branch: 1 branch
BranchTrueFalseTotal
if $Langertha::Holmgang::Sim::Linux::Redis::IMMUTABLE{$k} 1 5 6
501 5 ▶ return _err("ERR Unknown option or number of arguments for CONFIG SET - '$k'") if $k eq 'replicaof';
Branch: 1 branch
BranchTrueFalseTotal
if $k eq "replicaof" 0 5 5
502 5 my ( $x, $e ) = _check_value( $k, $v );
503 5 ▶ return _err("ERR CONFIG SET failed (possibly related to argument '$k') - $e") unless defined $x;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $x 1 4 5
504 4 ▶ if ( $k eq 'bind' ) { # jede Adresse muss gueltig und eine des Servers sein
Branch: 1 branch
BranchTrueFalseTotal
if ($k eq "bind") 1 3 4
505 0 ▶ my %own = map { s{/\d+\z}{}r => 1 } map { @{ $_->{addr} || [] } } values %{ $dev->{interfaces} || {} };
Condition25%1/4
$$_{'addr'} || []
l!l
00
$$dev{'interfaces'} || {}
l!l
01
MC/DC0%0/1
$$_{'addr'} || []
$$_{'addr'}
MC/DC0%0/1
$$dev{'interfaces'} || {}
$$dev{'interfaces'}
Truth table0%0/2
A
A= $$_{'addr'}
Aresult
11
00
Truth table50%1/2
A
A= $$dev{'interfaces'}
Aresult
11
00
506 1 $own{'127.0.0.1'} = $own{'::1'} = 1;
507 1 for my $a ( split /\s+/, $x ) {
508 1 ( my $b = $a ) =~ s/\A-//;
509 1 ▶ next if $b eq '*' || $b eq '0.0.0.0' || $b eq '::' || $own{$b};
Branch: 1 branch
BranchTrueFalseTotal
if $b eq "*" or $b eq "0.0.0.0" or $b eq "::" or $own{$b} 0 1 1
Condition33%3/9
$b eq "*" or $b eq "0.0.0.0" or $b eq "::" or $own{$b}
l!l&&r!l&&!r
001
$b eq "*" or $b eq "0.0.0.0" or $b eq "::"
l!l&&r!l&&!r
001
$b eq "*" or $b eq "0.0.0.0"
l!l&&r!l&&!r
001
MC/DC0%0/4
$b eq "*" or $b eq "0.0.0.0" or $b eq "::" or $own{$b}
$b eq "*" $b eq "0.0.0.0" $b eq "::" $own{$b}
Truth table20%1/5
A or B or C or D
A= $b eq "*"B= $b eq "0.0.0.0"C= $b eq "::"D= $own{$b}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
510 1 return _err("ERR CONFIG SET failed (possibly related to argument 'bind') - Failed to bind to specified addresses.");
511 }
512 }
513 3 $new{$k} = $x;
514 }
515 3 $run->{$_} = $new{$_} for keys %new;
516 3 return ( 'OK', 1 );
517 }
518 1 ▶ if ( $sub eq 'REWRITE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "REWRITE") 1 0 1
519 1 ▶ return _rewrite($dev) ? ( 'OK', 1 ) : _err("ERR Rewriting config file: No such file or directory");
Branch: 1 branch
BranchTrueFalseTotal
_rewrite($dev) ? : 1 0 1
520 }
521 0 ▶ if ( $sub eq 'RESETSTAT' ) { $r->{stats} = {}; return ( 'OK', 1 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "RESETSTAT") 0 0 0
522 0 return _err("ERR unknown subcommand '" . lc($sub) . "'. Try CONFIG HELP.");
523 }
524 # echter Redis-Befehl ohne Nachbildung: Luecke; sonst wie Redis: unbekannter Befehl
525 1 ▶ if ( !$REAL_CMD{$cmd} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Langertha::Holmgang::Sim::Linux::Redis::REAL_CMD{$cmd}) 1 0 1
526 1 ▶ my $args = join ' ', map {"'$_'"} @w[ 0 .. ( $#w < 2 ? $#w : 2 ) ];
Branch: 1 branch
BranchTrueFalseTotal
$#w < 2 ? : 1 0 1
527 1 ▶ return _err( "ERR unknown command '" . lc($cmd) . "', with args beginning with: " . ( length $args ? "$args " : '' ) );
Branch: 1 branch
BranchTrueFalseTotal
length $args ? : 1 0 1
528 }
529 0 push @GAPS, 'redis-cli ' . join( ' ', $cmd, @w );
530 0 return ( '', 0 );
531 }
532  
533 4 %REAL_CMD = map { $_ => 1 } qw( APPEND BITCOUNT BLPOP BRPOP COPY DECR DECRBY DUMP ECHO EVAL EVALSHA EXPIREAT GETDEL GETEX GETRANGE GETSET HDEL HEXISTS HGET
534 HGETALL HINCRBY HKEYS HLEN HMGET HMSET HSCAN HVALS INCRBY INFO KEYS LINDEX LLEN LPOP LRANGE LREM MEMORY MGET MONITOR MOVE MSET OBJECT PERSIST PEXPIRE PTTL
535 PUBLISH RANDOMKEY RENAME RPOP SADD SCAN SCARD SCRIPT SELECT SETNX SISMEMBER SLOWLOG SMEMBERS SREM STRLEN SUBSCRIBE SWAPDB TIME TOUCH UNLINK WAIT XADD XLEN
536 XRANGE ZADD ZCARD ZRANGE ZREM ZSCORE LATENCY MODULE COMMAND DEBUG FAILOVER PSYNC SYNC LASTSAVE CLUSTER READONLY READWRITE RESET HELLO QUIT
537 MULTI EXEC DISCARD WATCH UNWATCH PFADD PFCOUNT GEOADD );
538  
539  
540 47 ▶sub redis_cli {
Subroutine redis_cli: called CC=49 SCAR=50.3
Pod documented
541 47 my ( $dev, $av, $ctx, $stdin ) = @_;
542 47 my @a = @$av;
543 47 my %o = ( host => '127.0.0.1', port => undef );
544 47 my @cmd;
545 47 ▶ while (@a) {
Branch: 1 branch
BranchTrueFalseTotal
if (@a) 54 1 55
546 54 my $x = shift @a;
547 54 ▶ if ( $x eq '-h' ) { $o{host} = shift @a }
Branch: 10 branches
BranchTrueFalseTotal
if ($x eq '-h') { } 1 53 54
elsif ($x eq '-p') { } 0 53 53
elsif ($x eq '-a' or $x eq '--pass') { } 3 50 53
elsif ($x =~ /\A-a(.+)\z/) { } 0 50 50
elsif ($x eq '--user') { } 0 50 50
elsif ($x eq '-n') { } 0 50 50
elsif ($x eq '--raw') { } 2 48 50
elsif ($x eq '--no-auth-warning' or $x eq '--no-raw' or $x eq '-e') { } 2 46 48
elsif ($x eq '-u') { } 0 46 46
elsif ($x =~ /\A--(?:stat|bigkeys|memkeys|latency|scan|pipe|rdb|eval|cluster|ldb)/ or $x eq '-i' or $x eq '-r' or $x eq '-x') { } 1 45 46
548 0 elsif ( $x eq '-p' ) { $o{port} = shift @a }
549 3 ▶ elsif ( $x eq '-a' || $x eq '--pass' ) { $o{pass} = shift @a }
Condition66%2/3
$x eq "-a" or $x eq "--pass"
l!l&&r!l&&!r
3050
MC/DC50%1/2
$x eq "-a" or $x eq "--pass"
$x eq "-a" $x eq "--pass"
Truth table66%2/3
A or B
A= $x eq "-a"B= $x eq "--pass"
ABresult
1X1
011
000
550 0 elsif ( $x =~ /\A-a(.+)\z/ ) { $o{pass} = $1 }
551 0 elsif ( $x eq '--user' ) { shift @a }
552 0 elsif ( $x eq '-n' ) { $o{db} = shift @a }
553 2 elsif ( $x eq '--raw' ) { $o{raw} = 1 }
554 ▶ elsif ( $x eq '--no-auth-warning' || $x eq '--no-raw' || $x eq '-e' ) { }
Condition66%4/6
$x eq "--no-auth-warning" or $x eq "--no-raw" or $x eq "-e"
l!l&&r!l&&!r
2046
$x eq "--no-auth-warning" or $x eq "--no-raw"
l!l&&r!l&&!r
2046
MC/DC33%1/3
$x eq "--no-auth-warning" or $x eq "--no-raw" or $x eq "-e"
$x eq "--no-auth-warning" $x eq "--no-raw" $x eq "-e"
Truth table50%2/4
A or B or C
A= $x eq "--no-auth-warning"B= $x eq "--no-raw"C= $x eq "-e"
ABCresult
1XX1
01X1
0011
0000
555 elsif ( $x eq '-u' ) {
556 0 ▶ my $u = shift @a // '';
Condition0%0/2
shift @a // ""
l!l
00
MC/DC0%0/1
shift @a // ""
shift @a
Truth table0%0/2
A
A= shift @a
Aresult
11
00
557 0 ▶ if ( $u =~ m{\Aredis://(?:[^:@]*:([^@]*)@)?([^:/]+)(?::(\d+))?(?:/(\d+))?} ) { $o{pass} = $1; $o{host} = $2; $o{port} = $3; $o{db} = $4 }
Branch: 1 branch
BranchTrueFalseTotal
if ($u =~ m[\Aredis://(?:[^:\@]*:([^\@]*)@)?([^:/]+)(?::(\d+))?(?:/(\d+))?]) 0 0 0
558 }
559 ▶ elsif ( $x =~ /\A--(?:stat|bigkeys|memkeys|latency|scan|pipe|rdb|eval|cluster|ldb)/ || $x eq '-i' || $x eq '-r' || $x eq '-x' ) {
Condition66%6/9
$x =~ /\A--(?:stat|bigkeys|memkeys|latency|scan|pipe|rdb|eval|cluster|ldb)/ or $x eq "-i" or $x eq "-r" or $x eq "-x"
l!l&&r!l&&!r
1045
$x =~ /\A--(?:stat|bigkeys|memkeys|latency|scan|pipe|rdb|eval|cluster|ldb)/ or $x eq "-i" or $x eq "-r"
l!l&&r!l&&!r
1045
$x =~ /\A--(?:stat|bigkeys|memkeys|latency|scan|pipe|rdb|eval|cluster|ldb)/ or $x eq "-i"
l!l&&r!l&&!r
1045
MC/DC25%1/4
$x =~ /\A--(?:stat|bigkeys|memkeys|latency|scan|pipe|rdb|eval|cluster|ldb)/ or $x eq "-i" or $x eq "-r" or $x eq "-x"
$x =~ /\A--(?:stat|bigkeys|memkeys|latency|scan|pipe|rdb|eval|cluster|ldb)/ $x eq "-i" $x eq "-r" $x eq "-x"
Truth table40%2/5
A or B or C or D
A= $x =~ /\A--(?:stat|bigkeys|memkeys|latency|scan|pipe|rdb|eval|cluster|ldb)/B= $x eq "-i"C= $x eq "-r"D= $x eq "-x"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
560 1 push @GAPS, join( ' ', 'redis-cli', @$av );
561 1 return ( '', 0 );
562 }
563 45 else { @cmd = ( $x, @a ); last }
564 }
565 46 my $r = $dev->{redis};
566 46 ▶ return ( 'Could not connect to Redis at ' . $o{host} . ':' . ( $o{port} // 6379 ) . ': Connection refused', 1 ) unless $r && _active($dev);
Branch: 1 branch
BranchTrueFalseTotal
unless $r and _active($dev) 1 45 46
Condition60%3/5
$r and _active($dev)
!ll&&!rl&&r
0145
$o{"port"} // 6379
l!l
01
MC/DC50%1/2
$r and _active($dev)
$r _active($dev)
MC/DC0%0/1
$o{"port"} // 6379
$o{"port"}
Truth table66%2/3
A and B
A= $rB= _active($dev)
ABresult
0X0
100
111
Truth table50%1/2
A
A= $o{"port"}
Aresult
11
00
567 45 my $run = _running($dev);
568 45 ▶ $o{port} //= $run->{port};
Condition33%1/3
$o{"port"} //= $$run{"port"}
l!l&&r!l&&!r
0450
MC/DC0%0/2
$o{"port"} //= $$run{"port"}
$o{"port"} $$run{"port"}
Truth table33%1/3
A //= B
A= $o{"port"}B= $$run{"port"}
ABresult
1X1
011
000
569 return ( "Could not connect to Redis at $o{host}:$o{port}: Connection refused", 1 )
570 45 ▶ unless $o{port} eq $run->{port} && ( _bound_to( $dev, $o{host} ) || ( $ctx->{host} // '' ) eq $o{host} && _bound_to( $dev, '127.0.0.1' ) );
Branch: 1 branch
BranchTrueFalseTotal
unless $o{"port"} eq $$run{"port"} and _bound_to($dev, $o{"host"}) || ($$ctx{"host"} // "") eq $o{"host"} && _bound_to($dev, "127.0.0.1") 0 45 45
Condition18%2/11
$o{"port"} eq $$run{"port"} and _bound_to($dev, $o{"host"}) || ($$ctx{"host"} // "") eq $o{"host"} && _bound_to($dev, "127.0.0.1")
!ll&&!rl&&r
0045
_bound_to($dev, $o{"host"}) or ($$ctx{"host"} // "") eq $o{"host"} and _bound_to($dev, "127.0.0.1")
l!l&&r!l&&!r
4500
($$ctx{"host"} // "") eq $o{"host"} and _bound_to($dev, "127.0.0.1")
!ll&&!rl&&r
000
$$ctx{"host"} // ""
l!l
00
MC/DC0%0/4
$o{"port"} eq $$run{"port"} and _bound_to($dev, $o{"host"}) || ($$ctx{"host"} // "") eq $o{"host"} && _bound_to($dev, "127.0.0.1")
$o{"port"} eq $$run{"port"} _bound_to($dev, $o{"host"}) $$ctx{"host"} _bound_to($dev, "127.0.0.1")
Truth table20%1/5
A and B or C and D
A= $o{"port"} eq $$run{"port"}B= _bound_to($dev, $o{"host"})C= $$ctx{"host"}D= _bound_to($dev, "127.0.0.1")
ABCDresult
0XXX0
100X0
10100
11XX1
10111
571 45 my $quiet = grep { $_ eq '--no-auth-warning' } @$av;
572 45 ▶ my @warn = defined $o{pass} && !$quiet
Branch: 1 branch
BranchTrueFalseTotal
defined $o{'pass'} && !$quiet ? : 1 44 45
Condition100%3/3
defined $o{"pass"} and not $quiet
!ll&&!rl&&r
4221
MC/DC100%2/2
defined $o{"pass"} and not $quiet
defined $o{"pass"} not $quiet
Truth table100%3/3
A and not(B)
A= defined $o{"pass"}B= not $quiet
ABresult
0X0
100
111
573 ? ('Warning: Using a password with \'-a\' or \'-u\' option on the command line interface may not be safe.') : ();
574 45 ▶ if ( defined $o{pass} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $o{"pass"}) 3 42 45
575 3 ▶ my $rp = $run->{requirepass} // '';
Condition50%1/2
$$run{"requirepass"} // ""
l!l
30
MC/DC0%0/1
$$run{"requirepass"} // ""
$$run{"requirepass"}
Truth table50%1/2
A
A= $$run{"requirepass"}
Aresult
11
00
576 3 ▶ if ( $rp ne '' && $o{pass} eq $rp ) { $o{authed} = 1 }
Branch: 2 branches
BranchTrueFalseTotal
if ($rp ne '' and $o{'pass'} eq $rp) { } 3 0 3
elsif ($rp ne '') { } 0 0 0
Condition33%1/3
$rp ne "" and $o{"pass"} eq $rp
!ll&&!rl&&r
003
MC/DC0%0/2
$rp ne "" and $o{"pass"} eq $rp
$rp ne "" $o{"pass"} eq $rp
Truth table33%1/3
A and B
A= $rp ne ""B= $o{"pass"} eq $rp
ABresult
0X0
100
111
577 0 elsif ( $rp ne '' ) { return ( join( "\n", @warn, 'AUTH failed: WRONGPASS invalid username-password pair or user is disabled.' ), 1 ) }
578 }
579 # nach einer gescheiterten Sicherung versucht Redis es selbst alle paar Sekunden neu
580 45 ▶ _bgsave($dev) if !( $r->{rdb_ok} // 1 ) && ( $run->{save} // '' ) ne '' && !_need_failing( $dev, $r->{bgsave_needs} ) && !_need_failing( $dev, $r->{fork_needs} );
Branch: 1 branch
BranchTrueFalseTotal
if not $$r{"rdb_ok"} // 1 and ($$run{"save"} // "") ne "" and not _need_failing($dev, $$r{"bgsave_needs"}) and not _need_failing($dev, $$r{"fork_needs"}) 1 44 45
Condition76%10/13
not $$r{"rdb_ok"} // 1 and ($$run{"save"} // "") ne "" and not _need_failing($dev, $$r{"bgsave_needs"}) and not _need_failing($dev, $$r{"fork_needs"})
!ll&&!rl&&r
4401
not $$r{"rdb_ok"} // 1 and ($$run{"save"} // "") ne "" and not _need_failing($dev, $$r{"bgsave_needs"})
!ll&&!rl&&r
4221
not $$r{"rdb_ok"} // 1 and ($$run{"save"} // "") ne ""
!ll&&!rl&&r
4203
$$r{"rdb_ok"} // 1
l!l
936
$$run{"save"} // ""
l!l
30
MC/DC0%0/4
not $$r{"rdb_ok"} // 1 and ($$run{"save"} // "") ne "" and not _need_failing($dev, $$r{"bgsave_needs"}) and not _need_failing($dev, $$r{"fork_needs"})
$$r{"rdb_ok"} $$run{"save"} not _need_failing($dev, $$r{"bgsave_needs"}) not _need_failing($dev, $$r{"fork_needs"})
Truth table20%1/5
not(A) and B and not(C) and not(D)
A= $$r{"rdb_ok"}B= $$run{"save"}C= not _need_failing($dev, $$r{"bgsave_needs"})D= not _need_failing($dev, $$r{"fork_needs"})
ABCDresult
1XXX0
00XX0
010X0
01100
01111
581 45 ▶ my @lines = @cmd ? ( [@cmd] ) : map { [ grep { !ref } Langertha::Holmgang::Shell::shell_words($_) ] } grep {/\S/} split /\n/, $stdin // '';
Branch: 1 branch
BranchTrueFalseTotal
@cmd ? : 44 1 45
Condition50%1/2
$stdin // ""
l!l
10
MC/DC0%0/1
$stdin // ""
$stdin
Truth table50%1/2
A
A= $stdin
Aresult
11
00
582 0 ▶ if ( !@lines ) { push @GAPS, 'redis-cli (interaktiv)'; return ( '', 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
unless (@lines) 0 45 45
583 45 my @out = @warn;
584 45 for my $l (@lines) {
585 45 my ( $t, $k ) = _command( $dev, $l, \%o );
586 45 ▶ push @out, $t if defined $t && length $t;
Branch: 1 branch
BranchTrueFalseTotal
if defined $t and length $t 45 0 45
Condition33%1/3
defined $t and length $t
!ll&&!rl&&r
0045
MC/DC0%0/2
defined $t and length $t
defined $t length $t
Truth table33%1/3
A and B
A= defined $tB= length $t
ABresult
0X0
100
111
587 45 ▶ return ( join( "\n", @out ), 0 ) unless $k;
Branch: 1 branch
BranchTrueFalseTotal
unless $k 0 45 45
588 }
589 45 return ( join( "\n", @out ), 1 );
590 }
591  
592 4 1;
593  
594 __END__
« blib/lib/Langertha/Holmgang/Sim/Linux/MariaDB.pm ↑ Summary blib/lib/Langertha/Holmgang/Sim/Linux/Kubernetes.pm »