« blib/lib/Langertha/Holmgang/Sim/Linux/Calendar.pm
↑ Summary
blib/lib/Langertha/Holmgang/Batch.pm »
| 1 | package Langertha::Holmgang::Haystack; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Long, deterministic operational data for long-context cases, generated from a short spec | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 41 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 41 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 41 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 41 | ▶ | use JSON::MaybeXS (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 41 | ▶ | use Langertha::Holmgang::Error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 41 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 41 | ▶ | use Time::Local (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 41 | our $VERSION = '0.001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 41 | ▶ | use constant CHARS_PER_TOKEN => 3.5; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 41 | my @KINDS = qw( journal syslog nginx-access postgres-log ini-config k8s-manifests runbooks ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 41 | my %LOG = map { $_ => 1 } qw( journal syslog nginx-access postgres-log ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 41 | my %SEP = ( 'ini-config' => "\n\n", runbooks => "\n\n", 'k8s-manifests' => "\n---\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 41 | my @KEYS = qw( kind tokens seed start hours tz host hosts units upstreams database title namespace exclude insert ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 41 | has chars_per_token => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | builder => '_build_chars_per_token', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 21 | ▶ | sub _build_chars_per_token { CHARS_PER_TOKEN } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_chars_per_token: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | has _cache => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 89 | ▶ | default => sub { {} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 41 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 41 | has _json => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | builder => '_build__json', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 23 | ▶ | sub _build__json { JSON::MaybeXS->new( canonical => 1, convert_blessed => 1, utf8 => 1 ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build__json: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # A refusal names the field first, then the reason. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 23 | ▶ | sub _refuse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_refuse: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | my ( $self, $field, $reason ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_refuse: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | Langertha::Holmgang::Error->throw( $field, $reason ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 6 | ▶ | sub kinds { @KINDS } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
kinds: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 13 | ▶ | sub estimate_tokens { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
estimate_tokens: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 13 | my ( $self, $text ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 13 | ▶ | return 0 unless defined $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 12 | ▶ | my $cpt = blessed $self ? $self->chars_per_token : CHARS_PER_TOKEN; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 12 | return int( length($text) / $cpt + 0.5 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | #### Random | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # xorshift32: the same on every perl with 64-bit integers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 104 | ▶ | sub _rng { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rng: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 104 | my ( $self, $seed ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 104 | my $s = ( ( $seed * 2654435761 ) + 0x9E3779B9 ) & 0xFFFFFFFF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 104 | ▶ | $s ||= 0x12345678; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$s ||= 305419896
MC/DC0%0/1
$s ||= 305419896
$s
Truth table50%1/2
A
A= $s
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 64069 | ▶ | my $r = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 64069 | $s ^= ( $s << 13 ) & 0xFFFFFFFF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 64069 | $s ^= $s >> 17; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 64069 | $s ^= ( $s << 5 ) & 0xFFFFFFFF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 64069 | return $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 104 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 104 | $r->() for 1 .. 8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 104 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 15018 | ▶ | sub _int { my ( $self, $r, $lo, $hi ) = @_; return $lo + $r->() % ( $hi - $lo + 1 ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_int: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 21618 | ▶ | sub _pick { my ( $self, $r, $l ) = @_; return $l->[ $r->() % @$l ] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pick: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 440 | ▶ | sub _hex { my ( $self, $r, $n ) = @_; return join '', map { sprintf '%x', $r->() % 16 } 1 .. $n } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hex: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | #### Vocabulary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 41 | my @UNITS = qw( belegimport lieferschein rechnungsversand mahnlauf kundenportal-api lagerdienst ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 41 | my @DBHOST = map { 'db'.$_.'.example.invalid' } 1 .. 3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 41 | my @QUEUE = qw( auftraege belege rueckmeldungen versand inventur ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 41 | my @TASK = ( 'Tagesabschluss', 'Bestandsabgleich', 'Belegarchiv', 'Preisliste', 'Mahnvorschlag', 'Lieferavis', 'Kontenabgleich' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 41 | my @LOCK = qw( stapel-export kunden-index belegnummern lager-reservierung ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 41 | my @MAND = qw( nord sued west ost zentrale ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 41 | my @PFAD = qw( auftraege belege artikel kunden lager versand status ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 41 | my @TAB = qw( artikel bestellung bestellposition kunde lagerbestand rechnung versandauftrag ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # messages of the invented services (German); placeholders in <...> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 41 | my @APP = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 'Auftrag <n6> verarbeitet in <ms> ms', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 'Beleg <n6> übernommen (Mandant <mand>, <n2> Positionen)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 'Verbindung zur Datenbank <db> hergestellt (Pool <n1>/<n2>)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 'Gesundheitsprüfung erfolgreich (<ms> ms)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 'Zwischenspeicher bereinigt: <n4> Einträge entfernt, <n4> behalten', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 'Stapel <n5> abgeschlossen: <n3> Datensätze, <n1> übersprungen', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 'Nachricht <hex8> aus Warteschlange <queue> bestätigt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 'Hintergrundaufgabe »<task>« gestartet', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 'Hintergrundaufgabe »<task>« beendet nach <n2> s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 'Anfrage GET /intern/<pfad>/<n5> beantwortet: 200 in <ms> ms', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 'Sitzungsschlüssel erneuert, gültig bis <hh>:<mm>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 'Metriken an mon1.example.invalid übertragen (<n3> Werte)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 'Konfiguration unverändert, kein Neuladen nötig', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 'Datei /srv/archiv/<pfad>/<n6>.json.gz archiviert (<n3> KB)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 'Export <n5> nach sftp://ablage.example.invalid/<pfad>/ übertragen', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 'Neuer Arbeitsauftrag aus <queue>: <n2> Elemente', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 'Prüfsumme für Paket <n5> stimmt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 'Abgleich mit Lagerbestand: <n3> Artikel aktualisiert', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 'Wiederholung <n1>/5 für Nachricht <hex8> erfolgreich', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 'Speicher: <n3> MB belegt, <n3> MB frei', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 'Sperre »<lock>« erhalten nach <ms> ms', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 'Sperre »<lock>« freigegeben', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 'Planlauf »<task>« übersprungen: letzter Lauf vor <n2> min', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 'Benachrichtigung an lager-<n2>@example.invalid versendet', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 'Warteschlange <queue>: <n2> offen, <n3> erledigt in der letzten Minute', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 'Antwortzeit <db>: Median <ms> ms, 95. Perzentil <ms> ms', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 'Druckauftrag <n5> an drucker-<n2>.example.invalid übergeben', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 'Kunde <n6>: Adresse geprüft, keine Änderung', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 'Zeitplan geladen: nächster Lauf »<task>« um <hh>:<mm>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 'Verbindung zu <db> nach Leerlauf geschlossen', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 41 | my @SYSTEMD = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 'Starting <svc>.service - <desc>...', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 'Started <svc>.service - <desc>.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 'Finished <svc>.service - <desc>.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | '<svc>.service: Deactivated successfully.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | '<svc>.service: Consumed <n1>.<n3>s CPU time.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 41 | my %SYSUNIT = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | logrotate => 'Rotate log files', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 'apt-daily' => 'Daily apt download activities', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 'man-db' => 'Daily man-db regeneration', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | sysstat => 'system activity accounting tool', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 'systemd-tmpfiles-clean' => 'Cleanup of Temporary Directories', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | #### Time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 41 | my @MON = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 4159 | ▶ | sub _ts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ts: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 4159 | my ( $self, $kind, $epoch, $us, $tz ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 4159 | my ( $s, $m, $h, $d, $mo, $y ) = gmtime $epoch; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 4159 | $y += 1900; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 4159 | ▶ | my $off = $tz eq 'CEST' ? '+02:00' : '+01:00'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 4159 | ▶ | return sprintf '%s %02d %02d:%02d:%02d', $MON[$mo], $d, $h, $m, $s if $kind eq 'journal'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 2092 | ▶ | return sprintf '%04d-%02d-%02dT%02d:%02d:%02d.%06d%s', $y, $mo + 1, $d, $h, $m, $s, $us, $off if $kind eq 'syslog'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1072 | ▶ | return sprintf '%02d/%s/%04d:%02d:%02d:%02d %s', $d, $MON[$mo], $y, $h, $m, $s, $off =~ s/://r if $kind eq 'nginx-access'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 667 | return sprintf '%04d-%02d-%02d %02d:%02d:%02d.%03d %s', $y, $mo + 1, $d, $h, $m, $s, int( $us / 1000 ), $tz; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | #### Filler per kind | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | # Every kind yields line templates with the mark \0 for the timestamp. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 4657 | ▶ | sub _fill_app { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fill_app: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 4657 | my ( $self, $r, $t ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | my %v = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 387 | ▶ | n1 => sub { $self->_int( $r, 1, 9 ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 1308 | ▶ | n2 => sub { $self->_int( $r, 2, 60 ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 595 | ▶ | n3 => sub { $self->_int( $r, 10, 900 ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 288 | ▶ | n4 => sub { $self->_int( $r, 100, 9800 ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 447 | ▶ | n5 => sub { $self->_int( $r, 10000, 99999 ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 293 | ▶ | n6 => sub { $self->_int( $r, 100000, 999999 ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 511 | ▶ | ms => sub { $self->_int( $r, 2, 480 ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 184 | ▶ | hex8 => sub { $self->_hex( $r, 8 ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 156 | ▶ | mand => sub { $self->_pick( $r, \@MAND ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 289 | ▶ | db => sub { $self->_pick( $r, \@DBHOST ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 282 | ▶ | queue => sub { $self->_pick( $r, \@QUEUE ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 321 | ▶ | task => sub { $self->_pick( $r, \@TASK ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 163 | ▶ | lock => sub { $self->_pick( $r, \@LOCK ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 240 | ▶ | pfad => sub { $self->_pick( $r, \@PFAD ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 169 | ▶ | hh => sub { sprintf '%02d', $self->_int( $r, 0, 23 ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 169 | ▶ | mm => sub { sprintf '%02d', $self->_int( $r, 0, 59 ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 4657 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 4657 | ▶ | $t =~ s/<(\w+)>/$v{$1} ? $v{$1}->() : '<'.$1.'>'/ge; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 4657 | return $t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | # system line (English, as Debian writes it): ( prog, pid, text ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 592 | ▶ | sub _sys_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sys_line: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 592 | my ( $self, $r, $host ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 592 | my $x = $r->() % 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 592 | ▶ | if ( $x < 4 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 253 | my $svc = $self->_pick( $r, [ sort keys %SYSUNIT ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 253 | my $t = $self->_pick( $r, \@SYSTEMD ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 253 | $t =~ s/<svc>/$svc/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 253 | $t =~ s/<desc>/$SYSUNIT{$svc}/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 253 | $t =~ s/<n1>/$self->_int( $r, 0, 3 )/ge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 253 | $t =~ s/<n3>/sprintf '%03d', $self->_int( $r, 0, 999 )/ge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 253 | return ( 'systemd', 1, $t ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 339 | ▶ | if ( $x < 7 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 197 | return ( 'CRON', $self->_int( $r, 20000, 60000 ), $self->_pick( $r, [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 'pam_unix(cron:session): session opened for user root(uid=0) by (uid=0)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | '(root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 'pam_unix(cron:session): session closed for user root', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | ] ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 142 | ▶ | if ( $x < 9 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 96 | my $ip = '10.20.0.'.$self->_int( $r, 5, 9 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 96 | return ( 'sshd', $self->_int( $r, 20000, 60000 ), $self->_pick( $r, [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 'Accepted publickey for deploy from '.$ip.' port '.$self->_int( $r, 32768, 60999 ).' ssh2: ED25519 SHA256:'.$self->_hex( $r, 16 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 'pam_unix(sshd:session): session opened for user deploy(uid=1100) by (uid=0)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 'pam_unix(sshd:session): session closed for user deploy', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | ] ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 46 | ▶ | return ( 'systemd-timesyncd', $self->_int( $r, 400, 900 ), 'Initial synchronization to time server 10.20.0.1:123 (ntp1.example.invalid).' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | if $r->() % 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 17 | return ( 'kernel', undef, 'nft-drop: IN=eth0 OUT= SRC=192.0.2.'.$self->_int( $r, 2, 250 ).' DST=10.20.0.'.$self->_int( $r, 10, 90 ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | .' PROTO=TCP SPT='.$self->_int( $r, 1024, 65000 ).' DPT='.$self->_pick( $r, [ 23, 445, 3389, 5900 ] ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | # PID per host and service, fixed for the whole text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 77 | ▶ | sub _pids { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pids: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 77 | my ( $self, $r, $hosts, $units ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 77 | my %p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 77 | for my $h (@$hosts) { $p{ $h.'/'.$_ } = $self->_int( $r, 900, 4800 ) for @$units } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 77 | return \%p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 3232 | ▶ | sub _log_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_log_line: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 3232 | my ( $self, $r, $o, $host ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 3232 | my ( $prog, $pid, $text ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 3232 | ▶ | if ( $r->() % 100 < 82 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 2640 | $prog = $self->_pick( $r, $o->{units} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 2640 | $pid = $o->{_pids}{ $host.'/'.$prog }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 2640 | $text = $self->_fill_app( $r, $self->_pick( $r, \@APP ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 592 | else { ( $prog, $pid, $text ) = $self->_sys_line( $r, $host ) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 3232 | ▶ | return "\0 ".$host.' '.( defined $pid ? $prog.'['.$pid.']' : $prog ).': '.$text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 41 | my @UA = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 'Mozilla/5.0 (X11; Linux x86_64; rv:131.0) Gecko/20100101 Firefox/131.0', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 'lagerscanner/4.2 (Android 14)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 'kassensystem/2.8.1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 41 | my @SUCHE = qw( schrauben duebel winkel kabelbinder spannband palette regal kiste etikett klebeband ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 385 | ▶ | sub _nginx_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_nginx_line: called CC=17 SCAR=28.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 385 | my ( $self, $r, $o ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 385 | ▶ | my $ip = $r->() % 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | ? '10.20.'.$self->_int( $r, 4, 7 ).'.'.$self->_int( $r, 2, 254 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | : $self->_pick( $r, [ '192.0.2.', '198.51.100.', '203.0.113.' ] ).$self->_int( $r, 2, 254 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 385 | my $x = $r->() % 100; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 385 | my ( $req, $up, $st, $bytes, $ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 385 | ▶ | if ( $x < 22 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 80 | $req = 'GET /static/'.$self->_pick( $r, [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 'css/haupt.'.$self->_hex( $r, 8 ).'.css', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 'js/app.'.$self->_hex( $r, 8 ).'.js', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 'img/logo.svg', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 'img/artikel/'.$self->_int( $r, 1000, 9999 ).'.webp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 80 | ▶ | ( $up, $st ) = ( '-', $r->() % 4 ? 200 : 304 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 80 | ▶ | $bytes = $st == 304 ? 0 : $self->_int( $r, 800, 90000 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 305 | ▶ | my $m = $r->() % 6 ? 'GET' : 'POST'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 305 | ▶ | my $p = $m eq 'POST' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | ? $self->_pick( $r, [ '/api/warenkorb', '/api/bestellung', '/konto/anmelden', '/api/lager/reservierung' ] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | : $self->_pick( $r, [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | '/', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | '/artikel/'.$self->_int( $r, 10000, 99999 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | '/api/artikel/'.$self->_int( $r, 10000, 99999 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | '/suche?q='.$self->_pick( $r, \@SUCHE ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | '/konto/bestellungen', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | '/api/lager/'.$self->_int( $r, 100, 999 ).'/bestand', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | '/kategorie/'.$self->_pick( $r, \@SUCHE ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 305 | $req = $m.' '.$p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 305 | my $y = $r->() % 1000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 305 | ▶ | $st = $y < 900 ? 200 : $y < 940 ? ( $m eq 'POST' ? 201 : 304 ) : $y < 975 ? 404 : $y < 990 ? 301 : $y < 997 ? 499 : 403; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 305 | $up = $self->_pick( $r, $o->{upstreams} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 305 | ▶ | $bytes = $st == 304 || $st == 499 ? 0 : $self->_int( $r, 180, 48000 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$st == 304 or $st == 499
MC/DC100%2/2
$st == 304 or $st == 499
$st == 304
$st == 499
Truth table100%3/3
A or B
A= $st == 304B= $st == 499
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 385 | ▶ | $ref = $r->() % 3 ? '"https://shop.example.invalid/"' : '"-"'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 385 | my $rt = sprintf '%.3f', $self->_int( $r, 1, 900 ) / 1000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 385 | ▶ | my $us = $up eq '-' ? '-' : $st; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 385 | return $ip.' - - ['."\0".'] "'.$req.' HTTP/1.1" '.$st.' '.$bytes.' '.$ref.' "'.$self->_pick( $r, \@UA ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | .'" rt='.$rt.' ua="'.$up.'" us="'.$us.'"'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 41 | my @PGUSER = qw( shop bericht lager replikator ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 647 | ▶ | sub _pg_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pg_line: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 647 | my ( $self, $r, $o ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 647 | my $pid = $self->_int( $r, 10000, 99999 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 647 | my $u = $self->_pick( $r, \@PGUSER ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 647 | my $db = $o->{database}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 647 | my $ip = '10.20.1.'.$self->_int( $r, 10, 60 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 647 | my $port = $self->_int( $r, 32768, 60999 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 647 | my $x = $r->() % 100; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 647 | my $pre = "\0 [".$pid.'] '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 647 | my $who = $u.'@'.$db; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 647 | ▶ | return $pre.'LOG: Verbindung empfangen: Host='.$ip.' Port='.$port if $x < 18; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 532 | ▶ | return $pre.$who.' LOG: Verbindung autorisiert: Benutzer='.$u.' Datenbank='.$db.' Anwendungsname=' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | .$self->_pick( $r, [ 'shop-web', 'lagerdienst', 'berichte', 'psql' ] ) if $x < 36; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 431 | ▶ | return $pre.$who.' LOG: Verbindungsende: Sitzungszeit: 0:00:'.sprintf( '%02d.%03d', $self->_int( $r, 0, 59 ), $self->_int( $r, 0, 999 ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | .' Benutzer='.$u.' Datenbank='.$db.' Host='.$ip.' Port='.$port if $x < 52; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 345 | my $tab = $self->_pick( $r, \@TAB ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 345 | ▶ | if ( $x < 76 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 189 | my $q = $self->_pick( $r, [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 'SELECT * FROM '.$tab.' WHERE id = '.$self->_int( $r, 1000, 999999 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 'SELECT count(*) FROM '.$tab." WHERE erstellt_am > now() - interval '1 day'", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 'UPDATE '.$tab.' SET geaendert_am = now() WHERE id = '.$self->_int( $r, 1000, 999999 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 'SELECT a.id, a.bezeichnung, l.menge FROM artikel a JOIN lagerbestand l ON l.artikel_id = a.id WHERE l.lager = '.$self->_int( $r, 1, 12 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 189 | return $pre.$who.' LOG: Dauer: '.$self->_int( $r, 250, 4800 ).'.'.sprintf( '%03d', $self->_int( $r, 0, 999 ) ).' ms Anweisung: '.$q; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 156 | ▶ | return $pre.'LOG: Checkpoint beginnt: time' if $x < 82; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 114 | ▶ | return $pre.'LOG: Checkpoint komplett: '.$self->_int( $r, 100, 9000 ).' Puffer geschrieben ('.$self->_int( $r, 0, 9 ).','.$self->_int( $r, 0, 9 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | .'%); 0 WAL-Datei(en) hinzugefügt, 0 entfernt, '.$self->_int( $r, 1, 9 ).' wiederverwendet; Schreiben='.$self->_int( $r, 10, 269 ).','.$self->_int( $r, 100, 999 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | .' s, Sync=0,0'.$self->_int( $r, 10, 99 ).' s, gesamt='.$self->_int( $r, 10, 270 ).','.$self->_int( $r, 100, 999 ).' s' if $x < 88; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 82 | ▶ | return $pre.'LOG: automatisches Vacuum der Tabelle »'.$db.'.public.'.$tab.'«: Index-Scans: 1' if $x < 93; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 42 | ▶ | return $pre.'LOG: automatisches Analyze der Tabelle »'.$db.'.public.'.$tab.'«' if $x < 97; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 18 | return $pre.$who.' LOG: temporäre Datei: Pfad »base/pgsql_tmp/pgsql_tmp'.$pid.'.'.$self->_int( $r, 0, 40 ).'«, Größe '.$self->_int( $r, 100000, 90000000 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 41 | my @INI_SEC = ( 'zone_lager', 'export_kanal', 'drucker', 'schnittstelle_erp', 'scanner_station', 'versandart', 'mandant', 'etikett_vorlage' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 41 | my @INI_COMMENT = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | '# Zone <n2>: Hochregallager, Gang <n1> bis <n2>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | '# geändert für die Inventur — nicht ohne Rücksprache mit der Logistik zurücksetzen', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | '# Wert in Sekunden', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | '# Ansprechpartner: Team Lager (lager-<n2>@example.invalid)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | '# gilt nur für den Standort <mand>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | '# Übergangsweise bis zur Umstellung auf das neue Etikettenformat', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | '# Grenzwerte abgestimmt mit der Fachabteilung', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | '# leer lassen = Vorgabe des Programms', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | # [ key, value ], the value drawn by $value->( $self, $r ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | my @INI_KEY = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 179 | ▶ | [ aktiv => sub { $_[0]->_pick( $_[1], [qw( ja ja ja nein )] ) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 173 | ▶ | [ intervall_s => sub { $_[0]->_pick( $_[1], [ 15, 30, 60, 120, 300, 900 ] ) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 175 | ▶ | [ ziel => sub { 'sftp://ablage.example.invalid/'.$_[0]->_pick( $_[1], \@PFAD ).'/' } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 148 | ▶ | [ wiederholungen => sub { $_[0]->_int( $_[1], 1, 8 ) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 192 | ▶ | [ protokoll_stufe => sub { $_[0]->_pick( $_[1], [qw( info info warnung fehler )] ) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 158 | ▶ | [ zeitzone => sub { 'Europe/Berlin' } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 144 | ▶ | [ zeichensatz => sub { $_[0]->_pick( $_[1], [qw( UTF-8 UTF-8 ISO-8859-15 )] ) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 170 | ▶ | [ puffer_kb => sub { $_[0]->_pick( $_[1], [ 64, 128, 256, 512 ] ) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 157 | ▶ | [ beschreibung => sub { $_[0]->_pick( $_[1], [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 'Wareneingang Halle '.$_[0]->_int( $_[1], 1, 6 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 'Kommissionierung Süd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 'Rückläufer und Retouren', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 'Versand Paketdienst', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 'Sperrlager (Qualitätsprüfung)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 'Kühlbereich Tor '.$_[0]->_int( $_[1], 1, 9 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | ] ) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 169 | ▶ | [ freigabe_gruppe => sub { $_[0]->_pick( $_[1], [qw( lager-leitung schichtfuehrung versand qs )] ) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 161 | ▶ | [ drucker => sub { 'drucker-'.$_[0]->_int( $_[1], 2, 60 ).'.example.invalid' } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 179 | ▶ | [ format => sub { $_[0]->_pick( $_[1], [qw( csv json edifact xml )] ) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 176 | ▶ | [ max_positionen => sub { $_[0]->_pick( $_[1], [ 50, 100, 250, 999 ] ) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 152 | ▶ | [ sperrzeit_min => sub { $_[0]->_int( $_[1], 1, 90 ) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 168 | ▶ | [ standort => sub { $_[0]->_pick( $_[1], \@MAND ) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 536 | ▶ | sub _ini_block { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ini_block: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 536 | my ( $self, $r, $o, $n ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 536 | my @l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 536 | ▶ | push @l, $self->_fill_app( $r, $self->_pick( $r, \@INI_COMMENT ) ) if $r->() % 3 == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 536 | push @l, '['.$self->_pick( $r, \@INI_SEC ).'_'.$n.']'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 536 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 536 | for ( 1 .. $self->_int( $r, 3, 8 ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 2954 | my $k = $self->_pick( $r, \@INI_KEY ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 2954 | ▶ | next if $seen{ $k->[0] }++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 2501 | ▶ | push @l, $self->_fill_app( $r, $self->_pick( $r, \@INI_COMMENT ) ) if $r->() % 7 == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 2501 | push @l, $k->[0].' = '.$k->[1]->( $self, $r ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 536 | return join "\n", @l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | #### Kubernetes manifests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 41 | my @K8S_A = qw( artikel auftrag bestand beleg druck etikett faktura inventur kasse katalog kunden lager liefer | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | mahn pack preis rabatt reklamation scan schicht spedition tarif touren versand waren zoll ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 41 | my @K8S_B = qw( api dienst export gateway import index planer portal pruefer rechner sammler sync worker abgleich ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 41 | my @K8S_TEAM = qw( lager versand kasse einkauf plattform finanzen ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | my @K8S_ENV = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 80 | ▶ | [ PROTOKOLL_STUFE => sub { $_[0]->_pick( $_[1], [qw( info info warnung )] ) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 104 | ▶ | [ DB_POOL_MAX => sub { $_[0]->_pick( $_[1], [ 10, 20, 40 ] ) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 92 | ▶ | [ WARTESCHLANGE => sub { 'amqp://mq'.$_[0]->_int( $_[1], 1, 3 ).'.example.invalid:5672/'.$_[0]->_pick( $_[1], \@QUEUE ) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 85 | ▶ | [ ZEITZONE => sub { 'Europe/Berlin' } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 85 | ▶ | [ CACHE_TTL_S => sub { $_[0]->_pick( $_[1], [ 30, 60, 300 ] ) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 147 | ▶ | sub _k8s_block { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_k8s_block: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 147 | my ( $self, $r, $o, $n ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 147 | my $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 147 | for ( 1 .. 50 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 159 | $name = $self->_pick( $r, \@K8S_A ).'-'.$self->_pick( $r, \@K8S_B ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 159 | ▶ | last unless $o->{_names}{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 147 | ▶ | $name .= '-'.$n if $o->{_names}{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 147 | $o->{_names}{$name} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 147 | my $ns = $o->{namespace}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 147 | my $team = $self->_pick( $r, \@K8S_TEAM ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 147 | my $port = $self->_pick( $r, [ 8080, 8080, 8000, 8081, 9000, 3000 ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 147 | my $named = $r->() % 3 == 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 147 | my $ver = join '.', $self->_int( $r, 1, 4 ), $self->_int( $r, 0, 19 ), $self->_int( $r, 0, 30 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 147 | my @env = grep { $r->() % 2 } @K8S_ENV; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 147 | my @docs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | push @docs, join "\n", '# Quelle: apps/'.$name.'/configmap.yaml', 'apiVersion: v1', 'kind: ConfigMap', 'metadata:', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | ' name: '.$name.'-einstellungen', ' namespace: '.$ns, 'data:', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 147 | ▶ | map { ' '.$_->[0].': "'.$_->[1]->( $self, $r ).'"' } grep { $r->() % 2 } @K8S_ENV | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | if $r->() % 4 == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | push @docs, join "\n", '# Quelle: apps/'.$name.'/deployment.yaml', 'apiVersion: apps/v1', 'kind: Deployment', 'metadata:', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | ' name: '.$name, ' namespace: '.$ns, ' labels:', ' app: '.$name, ' team: '.$team, 'spec:', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | ' replicas: '.$self->_int( $r, 1, 6 ), ' selector:', ' matchLabels:', ' app: '.$name, ' template:', ' metadata:', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | ' labels:', ' app: '.$name, ' team: '.$team, ' spec:', ' containers:', ' - name: '.$name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | ' image: registry.example.invalid/'.$team.'/'.$name.':'.$ver, ' ports:', ' - name: http', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | ' containerPort: '.$port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 147 | ▶ | ( @env ? ( ' env:', map { ( ' - name: '.$_->[0], ' value: "'.$_->[1]->( $self, $r ).'"' ) } @env ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | ' resources:', ' requests:', ' cpu: '.$self->_pick( $r, [qw( 50m 100m 250m 500m )] ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | ' memory: '.$self->_pick( $r, [qw( 128Mi 256Mi 512Mi )] ), ' limits:', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | ' memory: '.$self->_pick( $r, [qw( 512Mi 1Gi )] ), ' readinessProbe:', ' httpGet:', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | ' path: /bereit', ' port: http'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 147 | ▶ | push @docs, join "\n", '# Quelle: apps/'.$name.'/service.yaml', 'apiVersion: v1', 'kind: Service', 'metadata:', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | ' name: '.$name, ' namespace: '.$ns, 'spec:', ' selector:', ' app: '.$name, ' ports:', ' - name: http', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | ' port: 80', ' targetPort: '.( $named ? 'http' : $port ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 147 | return join "\n---\n", @docs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | #### Runbooks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 41 | my @RB_SVC = qw( lagerdienst belegimport lieferschein rechnungsversand mahnlauf kundenportal-api versand-gateway | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | etikettendruck scanner-hub preisdienst ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 41 | my @RB_HOST = qw( app3 app5 app7 lb2 mq1 mq2 db2 db3 druck1 ftp2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 41 | my @RB_TOPIC = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 'Dienst nach Wartung wieder anfahren', 'Warteschlange leeren', 'Zertifikat erneuern', 'Platte erweitern', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 'Replikat neu aufsetzen', 'Protokollstufe vorübergehend erhöhen', 'Verbindungspool anpassen', 'Sicherung prüfen', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 'Benutzerkonto sperren', 'Logrotation anpassen', 'Zeitplan verschieben', 'Drucker-Warteschlange zurücksetzen', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 41 | my @RB_ANLASS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 'Der Dienst meldet nach dem nächtlichen Wartungsfenster keine Gesundheitsprüfung.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 'Die Überwachung meldet einen Rückstau von mehr als <n4> Nachrichten.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 'Das Zertifikat läuft in weniger als <n2> Tagen ab.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 'Die Fachabteilung braucht für <n2> Tage ausführlichere Protokolle.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 'Der Verbindungspool ist zu Lastspitzen erschöpft.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 'Planmäßige Prüfung, einmal im Monat.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 'Ein Mitarbeiter hat das Unternehmen verlassen.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 41 | my @RB_STEP = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 'Auf <host> mit `systemctl status <svc>` prüfen, ob der Dienst läuft.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 'Mit `journalctl -u <svc> -n 200` die letzten Meldungen ansehen.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 'In /etc/<svc>/<svc>.conf den Wert `<key> = <val>` setzen.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 'Danach `systemctl reload <svc>` — der Dienst liest die Datei neu, laufende Aufträge bleiben.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 'Danach `systemctl restart <svc>` (nur außerhalb der Kernzeit, 07:00–19:00).', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 'Im Ticket vermerken, wer was wann geändert hat.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 'Mit `curl -s http://127.0.0.1:<port>/bereit` die Bereitschaft prüfen; erwartet wird `ok`.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 'Wenn der Rückstau nach <n2> Minuten nicht sinkt: Bereitschaft Team <team> anrufen.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 'Die Änderung nach <n2> Tagen wieder zurücknehmen (Erinnerung im Kalender anlegen).', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 'Freien Platz mit `df -h /srv` prüfen; unter <n2> % frei nicht fortfahren.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 41 | my @RB_NOTE = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 'Ältere Fassungen dieser Seite gelten nicht mehr; maßgeblich ist das Stand-Datum.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 'Bei Unklarheiten nicht raten, sondern die Bereitschaft fragen.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 'Änderungen an Konfigurationen gehen danach als Merge-Request ins Konfigurations-Repository.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 'Gilt sinngemäß auch für die Testumgebung.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | my @RB_KEY = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 30 | ▶ | [ protokoll_stufe => sub { $_[0]->_pick( $_[1], [qw( info debug warnung )] ) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 40 | ▶ | [ max_verbindungen => sub { $_[0]->_pick( $_[1], [ 16, 32, 64, 128 ] ) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 40 | ▶ | [ wiederholungen => sub { $_[0]->_int( $_[1], 1, 8 ) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 43 | ▶ | [ zeitfenster => sub { sprintf '%02d:00-%02d:00', $_[0]->_int( $_[1], 0, 5 ), $_[0]->_int( $_[1], 6, 9 ) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 45 | ▶ | [ puffer_kb => sub { $_[0]->_pick( $_[1], [ 128, 256, 512 ] ) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 260 | ▶ | sub _runbook_block { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_runbook_block: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 260 | my ( $self, $r, $o, $n ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 260 | my $svc = $self->_pick( $r, \@RB_SVC ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 260 | my $host = $self->_pick( $r, \@RB_HOST ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 260 | my $team = $self->_pick( $r, \@K8S_TEAM ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 260 | my $date = sprintf '%04d-%02d-%02d', $self->_int( $r, 2023, 2026 ), $self->_int( $r, 1, 12 ), $self->_int( $r, 1, 28 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 260 | my $topic = $self->_pick( $r, \@RB_TOPIC ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 1210 | ▶ | my $fill = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 1210 | my ($t) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 1210 | my $k = $self->_pick( $r, \@RB_KEY ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 1210 | $t =~ s/<svc>/$svc/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 1210 | $t =~ s/<host>/$host/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 1210 | $t =~ s/<team>/$team/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 1210 | $t =~ s/<key>/$k->[0]/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 1210 | $t =~ s/<val>/$k->[1]->( $self, $r )/ge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 1210 | $t =~ s/<port>/$self->_pick( $r, [ 8080, 8081, 9000 ] )/ge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 1210 | return $self->_fill_app( $r, $t ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 260 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | # sequence: check, maybe change and apply, check again, record (no duplicates) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 260 | my @steps = ( $fill->( $RB_STEP[ $self->_int( $r, 0, 1 ) ] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 260 | ▶ | if ( $r->() % 4 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 198 | push @steps, $fill->( $RB_STEP[2] ), $fill->( $RB_STEP[ 3 + $r->() % 2 ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 260 | my %seen = map { $_ => 1 } @steps; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 260 | for my $x ( map { $RB_STEP[$_] } grep { $r->() % 3 == 0 } 6 .. $#RB_STEP ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 294 | my $t = $fill->($x); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 294 | ▶ | push @steps, $t unless $seen{$t}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 260 | push @steps, $fill->( $RB_STEP[5] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 260 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | return join "\n", '## Runbook: '.$svc.' — '.$topic, '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 'Seite '.$n.' · Stand: '.$date.' · Verantwortlich: Team '.$team.' · Gilt für: '.$host, '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 'Anlass: '.$self->_fill_app( $r, $self->_pick( $r, \@RB_ANLASS ) ), '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 260 | ▶ | ( map { ++$i.'. '.$_ } @steps ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | ( $r->() % 3 == 0 ? ( '', 'Hinweis: '.$self->_pick( $r, \@RB_NOTE ) ) : () ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | #### Checking the spec | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 92 | ▶ | sub _check { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check: called CC=45 SCAR=43.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 92 | my ( $self, $s, $f ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 92 | ▶ | $self->_refuse( $f, 'spec (hash) expected' ) unless ref $s eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 91 | my %ok = map { $_ => 1 } @KEYS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 91 | ▶ | $ok{$_} or $self->_refuse( $f.'.'.$_, 'unknown key ('.join( ', ', @KEYS ).')' ) for sort keys %$s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 89 | ▶ | my $kind = $s->{kind} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$s->{"kind"} // ""
MC/DC0%0/1
$s->{"kind"} // ""
$s->{"kind"}
Truth table50%1/2
A
A= $s->{"kind"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 89 | ▶ | $self->_refuse( $f.'.kind', 'kind must be one of '.join( ', ', @KINDS ) ) unless !ref $kind && grep { $kind eq $_ } @KINDS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not ref $kind and grep {$kind eq $_;} @KINDS
MC/DC50%1/2
not ref $kind and grep {$kind eq $_;} @KINDS
not ref $kind
grep {$kind eq $_;} @KINDS
Truth table66%2/3
not(A) and B
A= not ref $kindB= grep {$kind eq $_;} @KINDS
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 255 | ▶ | my $num = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=21.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 255 | my ( $k, $min, $max, $def ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 255 | ▶ | my $v = $s->{$k} // $def; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$s->{$k} // $def
MC/DC0%0/2
$s->{$k} // $def
$s->{$k}
$def
Truth table66%2/3
A // B
A= $s->{$k}B= $def
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 255 | ▶ | $self->_refuse( $f.'.'.$k, 'number '.$min.'..'.$max ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%6/12
not defined $v or ref $v or not $v =~ /\A\d+(?:\.\d+)?\z/ or $v < $min or $v > $max
not defined $v or ref $v or not $v =~ /\A\d+(?:\.\d+)?\z/ or $v < $min
not defined $v or ref $v or not $v =~ /\A\d+(?:\.\d+)?\z/
not defined $v or ref $v
MC/DC20%1/5
not defined $v or ref $v or not $v =~ /\A\d+(?:\.\d+)?\z/ or $v < $min or $v > $max
not defined $v
ref $v
not $v =~ /\A\d+(?:\.\d+)?\z/
$v < $min
$v > $max
Truth table33%2/6
not(A) or B or not(C) or D or E
A= not defined $vB= ref $vC= not $v =~ /\A\d+(?:\.\d+)?\z/D= $v < $minE= $v > $max
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | if !defined $v || ref $v || $v !~ /\A\d+(?:\.\d+)?\z/ || $v < $min || $v > $max; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 252 | return 0 + $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 87 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 87 | my %o = ( kind => $kind ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 87 | $o{tokens} = int $num->( 'tokens', 1000, 200_000 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 84 | $o{seed} = int $num->( 'seed', 0, 2**31, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 84 | $o{hours} = $num->( 'hours', 0.5, 72, 8 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 84 | ▶ | my $start = $s->{start} // '2026-10-28 22:00:00'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$s->{"start"} // "2026-10-28 22:00:00"
MC/DC100%1/1
$s->{"start"} // "2026-10-28 22:00:00"
$s->{"start"}
Truth table100%2/2
A
A= $s->{"start"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 84 | ▶ | my @t = !ref $start ? $start =~ /\A(\d{4})-(\d\d)-(\d\d)[ T](\d\d):(\d\d):(\d\d)\z/ : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 84 | ▶ | $self->_refuse( $f.'.start', 'time like "2026-10-28 22:00:00"' ) unless @t; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 83 | ▶ | $o{start} = eval { Time::Local::timegm( $t[5], $t[4], $t[3], $t[2], $t[1] - 1, $t[0] ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
eval {
do {
Time::Local::timegm($t[5], $t[4], $t[3], $t[2], $t[1] - 1, $t[0])
}
} // $self->_refuse($f . '.start', "not a valid time")
MC/DC0%0/2
eval {
do {
Time::Local::timegm($t[5], $t[4], $t[3], $t[2], $t[1] - 1, $t[0])
}
} // $self->_refuse($f . '.start', "not a valid time")
eval {
do {
Time::Local::timegm($t[5], $t[4], $t[3], $t[2], $t[1] - 1, $t[0])
}
}
$self->_refuse($f . '.start', "not a valid time")
Truth table33%1/3
A // B
A= eval {
do {
Time::Local::timegm($t[5], $t[4], $t[3], $t[2], $t[1] - 1, $t[0])
}
}B= $self->_refuse($f . '.start', "not a valid time")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | // $self->_refuse( $f.'.start', 'not a valid time' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 83 | ▶ | $o{tz} = $s->{tz} // 'CET'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$s->{"tz"} // "CET"
MC/DC100%1/1
$s->{"tz"} // "CET"
$s->{"tz"}
Truth table100%2/2
A
A= $s->{"tz"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 83 | ▶ | $self->_refuse( $f.'.tz', 'CET or CEST' ) unless !ref $o{tz} && $o{tz} =~ /\ACES?T\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not ref $o{"tz"} and $o{"tz"} =~ /\ACES?T\z/
MC/DC50%1/2
not ref $o{"tz"} and $o{"tz"} =~ /\ACES?T\z/
not ref $o{"tz"}
$o{"tz"} =~ /\ACES?T\z/
Truth table66%2/3
not(A) and B
A= not ref $o{"tz"}B= $o{"tz"} =~ /\ACES?T\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 245 | ▶ | my $names = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=21.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 245 | my ( $k, $def, $re ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 245 | ▶ | my $v = $s->{$k} // $def; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$s->{$k} // $def
MC/DC0%0/2
$s->{$k} // $def
$s->{$k}
$def
Truth table66%2/3
A // B
A= $s->{$k}B= $def
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 245 | ▶ | $self->_refuse( $f.'.'.$k, 'list of names' ) unless ref $v eq 'ARRAY' && @$v && !grep { !defined || ref || !/$re/ } @$v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%6/12
ref $v eq "ARRAY" and @$v and not grep({not defined $_ or ref $_ or not /$re/;} @$v)
ref $v eq "ARRAY" and @$v
!defined($_) || ref $_ || !/$re/
not defined $_ or ref $_
MC/DC33%1/3
ref $v eq "ARRAY" and @$v and not grep({not defined $_ or ref $_ or not /$re/;} @$v)
ref $v eq "ARRAY"
@$v
not grep({not defined $_ or ref $_ or not /$re/;} @$v)
MC/DC0%0/3
!defined($_) || ref $_ || !/$re/
not defined $_
ref $_
!/$re/
Truth table50%2/4
A and B and not(C)
A= ref $v eq "ARRAY"B= @$vC= not grep({not defined $_ or ref $_ or not /$re/;} @$v)
Truth table25%1/4
not(A) or B || not(C)
A= not defined $_B= ref $_C= !/$re/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 244 | return [ map { "$_" } @$v ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 82 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 82 | my $name = qr/\A[a-z0-9][a-z0-9.@-]{0,62}\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 82 | ▶ | my $title = $kind eq 'k8s-manifests' ? 'release' : $kind eq 'runbooks' ? 'Betriebshandbuch' : 'lager.ini'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 82 | my %one = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | host => [ 'srv1', $name ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | database => [ 'shop', $name ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | namespace => [ 'shop', $name ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | title => [ $title, qr/\A[^\n]{1,80}\z/ ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 82 | for my $k ( sort keys %one ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 328 | ▶ | my $v = $s->{$k} // $one{$k}[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$s->{$k} // $one{$k}[0]
MC/DC0%0/2
$s->{$k} // $one{$k}[0]
$s->{$k}
$one{$k}[0]
Truth table66%2/3
A // B
A= $s->{$k}B= $one{$k}[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 328 | ▶ | $self->_refuse( $f.'.'.$k, 'name' ) if ref $v || $v !~ $one{$k}[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $v or not $v =~ /$one{$k}[1]/
MC/DC0%0/2
ref $v or not $v =~ /$one{$k}[1]/
ref $v
not $v =~ /$one{$k}[1]/
Truth table33%1/3
A or not(B)
A= ref $vB= not $v =~ /$one{$k}[1]/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 328 | $o{$k} = "$v"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 82 | $o{hosts} = $names->( 'hosts', [qw( web1 web2 web3 )], $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 82 | $o{units} = $names->( 'units', \@UNITS, $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 81 | $o{upstreams} = $names->( 'upstreams', [ map { '10.20.2.'.$_.':8080' } 11 .. 14 ], qr/\A[a-z0-9.:-]+\z/ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 81 | ▶ | my $ex = $s->{exclude} // []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$s->{"exclude"} // []
MC/DC100%1/1
$s->{"exclude"} // []
$s->{"exclude"}
Truth table100%2/2
A
A= $s->{"exclude"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 81 | ▶ | $self->_refuse( $f.'.exclude', 'list of patterns' ) unless ref $ex eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | $o{exclude} = [ map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 81 | my $x = $ex->[$_]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 35 | ▶ | $self->_refuse( $f.'.exclude['.$_.']', 'pattern (text)' ) if !defined $x || ref $x || !length $x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $x or ref $x or not length $x
not defined $x or ref $x
MC/DC0%0/3
not defined $x or ref $x or not length $x
not defined $x
ref $x
not length $x
Truth table25%1/4
not(A) or B or not(C)
A= not defined $xB= ref $xC= not length $x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 35 | ▶ | my $re = eval { qr/$x/m } or $self->_refuse( $f.'.exclude['.$_.']', 'invalid regular expression' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 34 | $re; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } 0 .. $#$ex ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 80 | ▶ | my $in = $s->{insert} // []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$s->{"insert"} // []
MC/DC100%1/1
$s->{"insert"} // []
$s->{"insert"}
Truth table100%2/2
A
A= $s->{"insert"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 80 | ▶ | $self->_refuse( $f.'.insert', 'list' ) unless ref $in eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 80 | ▶ | $self->_refuse( $f.'.exclude', 'inserts need exclude (the needle patterns the filler must never contain)' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@$in and not @$ex
MC/DC100%2/2
@$in and not @$ex
@$in
not @$ex
Truth table100%3/3
A and not(B)
A= @$inB= not @$ex
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | if @$in && !@$ex; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 79 | my @ins; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 79 | for my $i ( 0 .. $#$in ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 51 | my ( $x, $xf ) = ( $in->[$i], $f.'.insert['.$i.']' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 51 | ▶ | $self->_refuse( $xf, 'hash expected' ) unless ref $x eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 51 | ▶ | my %k = map { $_ => 1 } exists $x->{at} ? qw( at text ) : qw( from to count text ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 51 | ▶ | $k{$_} or $self->_refuse( $xf.'.'.$_, 'unknown key (at, text or from, to, count, text)' ) for sort keys %$x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 51 | ▶ | $self->_refuse( $xf.'.text', 'text missing' ) if !defined $x->{text} || ref $x->{text} || !length $x->{text}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $x->{"text"} or ref $x->{"text"} or not length $x->{"text"}
not defined $x->{"text"} or ref $x->{"text"}
MC/DC0%0/3
not defined $x->{"text"} or ref $x->{"text"} or not length $x->{"text"}
not defined $x->{"text"}
ref $x->{"text"}
not length $x->{"text"}
Truth table25%1/4
not(A) or B or not(C)
A= not defined $x->{"text"}B= ref $x->{"text"}C= not length $x->{"text"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 74 | ▶ | my $frac = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 74 | my ($k) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 74 | my $v = $x->{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 74 | ▶ | $self->_refuse( $xf.'.'.$k, 'number 0..1' ) if !defined $v || ref $v || $v !~ /\A\d*\.?\d+\z/ || $v > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition44%4/9
not defined $v or ref $v or not $v =~ /\A\d*\.?\d+\z/ or $v > 1
not defined $v or ref $v or not $v =~ /\A\d*\.?\d+\z/
not defined $v or ref $v
MC/DC25%1/4
not defined $v or ref $v or not $v =~ /\A\d*\.?\d+\z/ or $v > 1
not defined $v
ref $v
not $v =~ /\A\d*\.?\d+\z/
$v > 1
Truth table40%2/5
not(A) or B or not(C) or D
A= not defined $vB= ref $vC= not $v =~ /\A\d*\.?\d+\z/D= $v > 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 73 | return 0 + $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 51 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 51 | ▶ | if ( exists $x->{at} ) { push @ins, { at => $frac->('at'), text => "$x->{text}", n => $i } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 23 | my ( $from, $to ) = ( $frac->('from'), $frac->('to') ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 23 | ▶ | $self->_refuse( $xf.'.to', 'must lie after from' ) unless $to > $from; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 22 | my $c = $x->{count}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 22 | ▶ | $self->_refuse( $xf.'.count', 'integer 1..500' ) if !defined $c || ref $c || $c !~ /\A\d+\z/ || $c < 1 || $c > 500; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%4/12
not defined $c or ref $c or not $c =~ /\A\d+\z/ or $c < 1 or $c > 500
not defined $c or ref $c or not $c =~ /\A\d+\z/ or $c < 1
not defined $c or ref $c or not $c =~ /\A\d+\z/
not defined $c or ref $c
MC/DC0%0/5
not defined $c or ref $c or not $c =~ /\A\d+\z/ or $c < 1 or $c > 500
not defined $c
ref $c
not $c =~ /\A\d+\z/
$c < 1
$c > 500
Truth table16%1/6
not(A) or B or not(C) or D or E
A= not defined $cB= ref $cC= not $c =~ /\A\d+\z/D= $c < 1E= $c > 500
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 22 | push @ins, map { { at => $from + ( $to - $from ) * ( $_ + 0.5 ) / $c, text => "$x->{text}", n => $i } } 0 .. $c - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 77 | $o{insert} = \@ins; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 77 | return \%o; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | #### Generating | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 130 | ▶ | sub generate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 130 | my ( $self, $spec, $f ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 130 | ▶ | $f //= 'generate'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$f //= "generate"
MC/DC100%1/1
$f //= "generate"
$f
Truth table100%2/2
A
A= $f
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 130 | my $key = eval { $self->_json->encode($spec) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 130 | my $cache = $self->_cache; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 130 | ▶ | return $cache->{$key} if defined $key && exists $cache->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $key and exists $cache->{$key}
MC/DC50%1/2
defined $key and exists $cache->{$key}
defined $key
exists $cache->{$key}
Truth table66%2/3
A and B
A= defined $keyB= exists $cache->{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 92 | my $text = $self->_build( $self->_check( $spec, $f ), $f ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 73 | ▶ | $cache->{$key} = $text if defined $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 73 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 77 | ▶ | sub _build { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build: called CC=34 SCAR=35.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 77 | my ( $self, $o, $f ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 77 | my $r = $self->_rng( $o->{seed} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 77 | my $kind = $o->{kind}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 77 | my $target = $o->{tokens} * $self->chars_per_token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 77 | ▶ | my @hosts = $kind eq 'journal' ? ( $o->{host} ) : @{ $o->{hosts} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 77 | $o->{_pids} = $self->_pids( $r, [ @hosts, $o->{host} ], $o->{units} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 77 | ▶ | my $tslen = $LOG{$kind} ? length $self->_ts( $kind, $o->{start}, 0, $o->{tz} ) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | # filler: templates (line or block) up to the target size, excluded ones drawn again | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 77 | my ( @fill, $len ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 77 | my $head = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 77 | ▶ | if ( $kind eq 'ini-config' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 8 | $head = '# '.$o->{title}." — Hauptkonfiguration\n# Verwaltet im Konfigurations-Repository; Änderungen nur mit Ticket.\n" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | .'# Abschnitte dürfen mehrfach vorkommen; bei doppeltem Schlüssel gilt die letzte Zuweisung.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | elsif ( $kind eq 'k8s-manifests' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 8 | $head = '# Gerendertes Bündel '.$o->{title}.' (Namespace '.$o->{namespace}."), erzeugt von der CI aus apps/*/\n" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | .'# Reihenfolge wie im Repository; kommt ein Objekt mehrfach vor, gilt das letzte (wie bei kubectl apply).'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | elsif ( $kind eq 'runbooks' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 8 | $head = '# '.$o->{title}." — Export aus dem Wiki (Bereich Betrieb)\n\n" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | .'Jedes Runbook trägt sein Stand-Datum. Der Export ist nach Seiten-ID sortiert, nicht nach Datum.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 77 | ▶ | my $sep = $SEP{$kind} // "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$SEP{$kind} // "\n"
MC/DC100%1/1
$SEP{$kind} // "\n"
$SEP{$kind}
Truth table100%2/2
A
A= $SEP{$kind}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 77 | $len = length $head; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 77 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 77 | ▶ | while ( $len < $target ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 4994 | my $t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 4994 | for my $try ( 1 .. 200 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | $t = $kind eq 'journal' ? $self->_log_line( $r, $o, $o->{host} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 5207 | ▶ | : $kind eq 'syslog' ? $self->_log_line( $r, $o, $self->_pick( $r, \@hosts ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | : $kind eq 'nginx-access' ? $self->_nginx_line( $r, $o ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | : $kind eq 'postgres-log' ? $self->_pg_line( $r, $o ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | : $kind eq 'k8s-manifests' ? $self->_k8s_block( $r, $o, ++$n ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | : $kind eq 'runbooks' ? $self->_runbook_block( $r, $o, ++$n ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | : $self->_ini_block( $r, $o, ++$n ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 5207 | ▶ | last unless grep { ( $t =~ s/\0//r ) =~ $_ } @{ $o->{exclude} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 214 | $t = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 4994 | ▶ | $self->_refuse( $f.'.exclude', 'excludes almost all of the filler' ) unless defined $t; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 4993 | push @fill, [ $t, $r->() % 1_000_000 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 4993 | ▶ | $len += length($t) + ( $t =~ /\0/ ? $tslen - 1 : 0 ) + length $sep; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | # large blocks (manifests, runbooks): drop the last one when the size without it is closer to the target | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 76 | ▶ | if ( $kind eq 'k8s-manifests' || $kind eq 'runbooks' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$kind eq "k8s-manifests" or $kind eq "runbooks"
MC/DC100%2/2
$kind eq "k8s-manifests" or $kind eq "runbooks"
$kind eq "k8s-manifests"
$kind eq "runbooks"
Truth table100%3/3
A or B
A= $kind eq "k8s-manifests"B= $kind eq "runbooks"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 16 | my $last = length( $fill[-1][0] ) + length $sep; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 16 | ▶ | if ( @fill > 1 && $len - $target > $target - ( $len - $last ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@fill > 1 and $len - $target > $target - ($len - $last)
MC/DC50%1/2
@fill > 1 and $len - $target > $target - ($len - $last)
@fill > 1
$len - $target > $target - ($len - $last)
Truth table66%2/3
A and B
A= @fill > 1B= $len - $target > $target - ($len - $last)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 9 | pop @fill; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 9 | $len -= $last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | # time: even over hours, monotonic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 76 | my $span = $o->{hours} * 3600; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 76 | my $N = @fill; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 76 | my @ts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 76 | for my $i ( 0 .. $N - 1 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 4984 | my $u = ( $r->() % 1000 ) / 1000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 4984 | push @ts, [ $o->{start} + int( $span * ( $i + $u ) / $N ), $fill[$i][1] ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 4143 | ▶ | my $stamp = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 4143 | my ($i) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 4143 | ▶ | $i = $N - 1 if $i >= $N; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 4143 | ▶ | return $LOG{$kind} ? $self->_ts( $kind, @{ $ts[$i] }, $o->{tz} ) : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 76 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 76 | my @out = map { $fill[$_][0] =~ s/\0/$stamp->($_)/er } 0 .. $N - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | # the filler gives nothing away — not through its timestamps either | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 76 | ▶ | my $plain = join $sep, ( length $head ? $head : () ), @out; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 76 | for my $j ( 0 .. $#{ $o->{exclude} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | $self->_refuse( $f.'.exclude['.$j.']', 'matches the filler (its timestamps, say) — make the pattern tighter' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 31 | ▶ | if $plain =~ $o->{exclude}[$j]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 75 | ▶ | return $plain."\n" unless @{ $o->{insert} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | # inserts go before the line at their position, with its timestamp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 27 | my $ri = $self->_rng( $o->{seed} + 7919 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 27 | my %at; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 27 | for my $x ( @{ $o->{insert} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 93 | my $i = int( $x->{at} * $N + 0.5 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 93 | my $t = $x->{text}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 93 | $t =~ s/\n+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 93 | my $ts = $stamp->($i); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 255 | ▶ | my $ph = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 255 | my ( $w, $unit ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 255 | ▶ | return $ts if $w eq 'ts'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 228 | ▶ | return $o->{host} if $w eq 'host'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 201 | ▶ | return $self->_int( $ri, 1000, 99999 ) if $w eq 'num'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 175 | ▶ | return '10.20.'.$self->_int( $ri, 4, 7 ).'.'.$self->_int( $ri, 2, 254 ) if $w eq 'ip'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 154 | ▶ | return $self->_int( $ri, 3, 900 ) if $w eq 'ms'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 154 | ▶ | return $self->_int( $ri, 32768, 60999 ) if $w eq 'port'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 91 | ▶ | my $k = $unit =~ m{/} ? $unit : $o->{host}.'/'.$unit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | return $o->{_pids}{$k} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 91 | ▶ | // $self->_refuse( $f.'.insert['.$x->{n}.'].text', '{pid:'.$unit.'}: no service of that name (units, host/hosts)' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$o->{"_pids"}{$k} // $self->_refuse($f . '.insert[' . $x->{"n"} . '].text', '{pid:' . $unit . '}: no service of that name (units, host/hosts)')
MC/DC0%0/2
$o->{"_pids"}{$k} // $self->_refuse($f . '.insert[' . $x->{"n"} . '].text', '{pid:' . $unit . '}: no service of that name (units, host/hosts)')
$o->{"_pids"}{$k}
$self->_refuse($f . '.insert[' . $x->{"n"} . '].text', '{pid:' . $unit . '}: no service of that name (units, host/hosts)')
Truth table33%1/3
A // B
A= $o->{"_pids"}{$k}B= $self->_refuse($f . '.insert[' . $x->{"n"} . '].text', '{pid:' . $unit . '}: no service of that name (units, host/hosts)')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 93 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 93 | $t =~ s/\{(ts|host|num|ip|ms|port|pid:([^\}]+))\}/my ( $w, $u ) = ( $1, $2 ); $ph->( $w =~ s{:.*}{}sr, $u )/ge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 92 | push @{ $at{$i} }, $t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 26 | for my $j ( 0 .. $#{ $o->{exclude} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 27 | my $re = $o->{exclude}[$j]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | $self->_refuse( $f.'.exclude['.$j.']', 'matches no insert — the needle would not stand where the case puts it' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 27 | ▶ | unless grep { $_ =~ $re } map { @{ $at{$_} } } sort { $a <=> $b } keys %at; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 25 | my @all; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 25 | for my $i ( 0 .. $N ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 1645 | ▶ | push @all, @{ $at{$i} } if $at{$i}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 1645 | ▶ | push @all, $out[$i] if $i < $N; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 25 | ▶ | return join( $sep, ( length $head ? $head : () ), @all )."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 125 | ▶ | sub resolve { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 125 | my ( $self, $v, $f ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 125 | ▶ | if ( ref $v eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 48 | ▶ | $self->_refuse( $f, 'only generate: { ... } (or text, or a list of parts)' ) unless exists $v->{generate} && keys %$v == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $v->{"generate"} and keys %$v == 1
MC/DC50%1/2
exists $v->{"generate"} and keys %$v == 1
exists $v->{"generate"}
keys %$v == 1
Truth table66%2/3
A and B
A= exists $v->{"generate"}B= keys %$v == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 47 | return $self->generate( $v->{generate}, $f.'.generate' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 77 | ▶ | return $v unless ref $v eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 75 | ▶ | $self->_refuse( $f, 'empty list' ) unless @$v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | return join '', map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 74 | my $p = $v->[$_]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 142 | ▶ | ref $p eq 'HASH' ? $self->resolve( $p, $f.'['.$_.']' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
not defined $p or ref $p
MC/DC50%1/2
not defined $p or ref $p
not defined $p
ref $p
Truth table66%2/3
not(A) or B
A= not defined $pB= ref $p
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | : !defined $p || ref $p ? $self->_refuse( $f.'['.$_.']', 'part: text or generate: { ... }' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | : "$p"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | } 0 .. $#$v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 41 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||