Merge branch 'master' of ssh://git.indexdata.com:222/home/git/pub/irspy
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Test / Search / Bib1.pm
1
2 # See the "Main" test package for documentation
3
4 package ZOOM::IRSpy::Test::Search::Bib1;
5
6 use 5.008;
7 use strict;
8 use warnings;
9
10 use ZOOM::IRSpy::Test;
11 our @ISA = qw(ZOOM::IRSpy::Test);
12
13
14 sub start {
15     my $class = shift();
16     my($conn) = @_;
17     my @attrs = ( 1..63, 1000..1036,            # Bib-1
18                   1037..1096, 1185..1209,       # Extended Bib-1
19                   1097..1111,                   # Dublin-Core
20                   1112..1184                    # GILS
21                 );
22
23     foreach my $attr (@attrs) {
24         $conn->irspy_search_pqf("\@attr 1=$attr mineral",
25                                 {'attr' => $attr}, {},
26                                 ZOOM::Event::ZEND, \&found,
27                                 exception => \&error);
28     }
29 }
30
31
32 sub found {
33     my($conn, $task, $test_args, $event) = @_;
34     my $attr = $test_args->{'attr'};
35
36     my $n = $task->{rs}->size();
37     $task->{rs}->destroy();
38     $conn->log("irspy_test", "search on access-point $attr found $n record",
39                $n==1 ? "" : "s");
40     update($conn, $attr, 1);
41
42     return ZOOM::IRSpy::Status::TASK_DONE;
43 }
44
45
46 sub error {
47     my($conn, $task, $test_args, $exception) = @_;
48     my $attr = $test_args->{'attr'};
49
50     $task->{rs}->destroy();
51     $conn->log("irspy_test", "search on access-point $attr had error: ",
52                $exception);
53     update($conn, $attr, 0);
54     zoom_error_timeout_update($conn, $exception);
55
56 # Commented out because TEST_BAD causes sibling tests to be skipped.
57 #    return ZOOM::IRSpy::Status::TEST_BAD
58 #       if ($exception->code() == 1 || # permanent system error
59 #           $exception->code() == 235 || # Database does not exist
60 #           $exception->code() == 109); # Database unavailable
61
62     return ZOOM::IRSpy::Status::TASK_DONE;
63 }
64
65
66 sub update {
67     my ($conn, $attr, $ok) = @_;
68     $conn->record()->store_result('search', 'set'       => 'bib-1',
69                                             'ap'        => $attr,
70                                             'ok'        => $ok);
71 }
72
73 1;