13 verify-distlookup-cutipassfail.pl distv ...
21 my @opt = <<'=back' =~ /B<--(\S+)>/g;
27 =item B<--repairnth=i>
29 Defaults to 18, meaning every 18th record is subject to a zero run,
32 cnntp-solver.pl --cpanstats_distrofacts_zero=...
34 Setting this to 0 disables automatic repair.
38 Defaults to 2, meaning after every repair we sleep for 2 seconds.
44 distv arguments are optional. without such you get all
45 pass/pass/fail/fail data, that have deviating numbers for lastcalc
46 according to slvdv vs DB.
48 B<Probably a script of small utility>, but we keep it because it
49 helped us to find a missing record in the database.
51 Sind aber distv argumente gegeben, dann werden die Vergleiche fuer
54 Die wahre Zahl der PASS und FAIL der letzten Calc findet man in der
55 .slvdv.gz Datei unter meta:ok in der verwegenen Struktur
69 Die Datei ist in json. Prove:
71 % zcat /home/andreas/data/cnntp-solver-2009/workdir/solved/MIME-tools-5.505.slvdv.gz | perl -le '
72 my $j = do {local $/; <STDIN>};
74 my $h = JSON::XS->new->decode($j);
75 warn join ",", map { $_ => $h->{"meta:ok"}{$_}{$_} } qw(PASS FAIL NA)'
76 PASS,1411,FAIL,37,NA,1 at -e line 5, <STDIN> line 1.
78 lc_pass und lc_fail wurde lange Zeit und wird noch immer falsch
79 geschrieben. Sobald das in cnntp-solver.pl gefixt ist, sollte diese
80 Liste automatisch kuerzer werden, aber wer weiss. Die confusion about
81 lastcalc, lc_*, passfail_overview, timestamp bug, etc. ist enorm, da
82 muss etwas reduziert werden: canonische verbindliche Adressen fuer
83 primaerdaten und fuer gecachetes Material.
89 use lib
"$FindBin::Bin/../lib";
95 use File
::Basename
qw(dirname);
96 use File
::Path
qw(mkpath);
101 use Hash
::Util
qw(lock_keys);
104 lock_keys
%Opt, map { /([^=|!]+)/ } @opt;
111 $Opt{repairnth
} //= 18;
113 use CPAN
::Blame
::Config
::Cnntp
;
115 use Algorithm
::Numerical
::Shuffle qw
/shuffle/;
119 my($workdir,$cpan_home,$ext_src);
121 $workdir = File
::Spec
->catdir
122 ($CPAN::Blame
::Config
::Cnntp
::Config
->{solver_vardir
},
124 $cpan_home = $CPAN::Blame
::Config
::Cnntp
::Config
->{cpan_home
};
125 $ext_src = $CPAN::Blame
::Config
::Cnntp
::Config
->{ext_src
};
128 my $dbi = DBI
->connect ("dbi:Pg:dbname=analysis");
129 my $sql = "SELECT lc_pass, lc_fail FROM distlookup WHERE distv=?";
130 my $sth = $dbi->prepare($sql);
131 my $slvdir = "$workdir/solved";
132 opendir my $dh, $slvdir or die;
133 my %argv = map {($_ => 1)} @ARGV;
134 my $headerwritten = 0;
136 my @dirent = shuffle
grep {/slvdv\.gz$/} readdir $dh;
137 DIRENT
: for my $dirent (@dirent) {
138 my($distv) = $dirent =~ /(.+)\.slvdv\.gz$/ or next;
142 $wantsee = "u"; # unconditionally
147 $wantsee = "g"; # slv is greater
148 # $wantsee = "d"; # any diff
150 my $abs = "$slvdir/$dirent";
151 my $j = do {local $/; open my $fh, "-|", zcat
=> $abs; <$fh> };
152 my $h = eval { JSON
::XS
->new->decode($j); };
153 if ($@
or !defined $h) {
154 warn "error while decoding $abs: $@";
157 my %slv = map { $_ => $h->{"meta:ok"}{$_}{$_} } qw(PASS FAIL NA);
158 $sth->execute($distv);
159 next unless $sth->rows >= 1;
160 my(@row) = $sth->fetchrow_array();
161 next unless defined $row[0] or defined $row[1];
164 my @stat = stat $abs;
165 if ($wantsee eq "d") {
166 no warnings
'uninitialized';
167 my $iseq = $slv{PASS
}==$row[0] && $slv{FAIL
}==$row[1];
169 } elsif ($wantsee eq "g") {
170 no warnings
'uninitialized';
171 my $isslvgt = $slv{PASS
}>$row[0] || $slv{FAIL
}>$row[1];
172 next unless $isslvgt;
173 } elsif ($wantsee eq "u") {
174 # no next, we want to see everything
176 die "illegal value for wantsee: $wantsee";
178 #my $smalldiff = abs($slv{PASS}-$row[0]) + abs($slv{FAIL}-$row[1]) <= 4;
180 unless ($headerwritten++) {
181 print "|distv========|=pass-per-slv |=pass-per-db |=fail-per-slv |=fail-per-db\n";
184 my $time = Time
::Moment
->from_epoch($stat[9])->at_utc->strftime("%FT%T%Z");
185 $time =~ s/:[0-9][0-9]Z/z/;
187 no warnings
'uninitialized';
188 warn sprintf "%d/%d %-31s %4d %4d %4d %4d %s\n", $line, scalar @dirent, $distv, $slv{PASS
}, $row[0], $slv{FAIL
}, $row[1], $time;
190 if ($Opt{repairnth
}) {
191 unless ($line % $Opt{repairnth
}) {
192 system "$^X bin/cnntp-solver.pl --cpanstats_distrofacts_zero=$distv";
193 sleep $Opt{sleep} if $Opt{sleep};
200 # cperl-indent-level: 4