complete error timeout handling for all tests
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Test / Search / CQL.pm
1
2 # See the "Main" test package for documentation
3
4 package ZOOM::IRSpy::Test::Search::CQL;
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
18     ### More indexes could be added here
19     my @indexes = qw(cql.serverChoice cql.anywhere cql.allRecords
20                      rec.id
21                      net.host net.port
22                      dc.title dc.creator dc.description
23                      zeerex.numberOfRecords zeerex.set
24                      );
25
26     foreach my $index (@indexes) {
27         $conn->irspy_search(cql => "$index=mineral",
28                             { index => $index }, {},
29                             ZOOM::Event::ZEND, \&found,
30                             exception => \&error);
31     }
32 }
33
34
35 sub found {
36     my($conn, $task, $udata, $event) = @_;
37     my $index = $udata->{"index"};
38
39     my $n = $task->{rs}->size();
40     $task->{rs}->destroy();
41     $conn->log("irspy_test",
42                "CQL search on '$index' found $n record", $n==1 ? "" : "s");
43     $conn->record()->store_result("search_cql", index => $index, ok => 1);
44     return ZOOM::IRSpy::Status::TASK_DONE;
45 }
46
47
48 sub error {
49     my($conn, $task, $udata, $exception) = @_;
50     my $index = $udata->{"index"};
51
52     $task->{rs}->destroy();
53     $conn->log("irspy_test", "CQL search on '$index' had error: $exception");
54     $conn->record()->store_result("search_cql", index => $index, ok => 0);
55     zoom_error_timeout_update($conn, $exception);
56     return ZOOM::IRSpy::Status::TEST_BAD
57         if $exception->code() == 11; # Unsupported query type
58
59     return ZOOM::IRSpy::Status::TASK_DONE;
60 }
61
62
63 1;