1 # See the "Main" test package for documentation
3 ### Too much common code with Fetch.pm: need to refactor
5 package ZOOM::IRSpy::Test::Record::OPAC;
11 use ZOOM::IRSpy::Test;
12 our @ISA = qw(ZOOM::IRSpy::Test);
16 "\@attr 1=4 computer",
17 "\@attr 1=44 mineral", # Smithsonian doesn't support AP 4!
18 "\@attr 1=1016 water", # Connector Framework only does 1016
19 ### We can add more queries here
22 # We'd like to use this temporary-options hash to set
23 # preferredRecordSyntax, as well But that doesn't work because the
24 # same value needs to be in force later on when we make the
25 # record_immediate() call, otherwise it misses its cache.
29 # preferredRecordSyntax => "opac"
36 $conn->option(preferredRecordSyntax => "opac");
37 $conn->irspy_search_pqf($queries[0], { queryindex => 0 }, \%options,
38 ZOOM::Event::ZEND, \&completed_search,
39 exception => \&completed_search);
43 sub completed_search {
44 my($conn, $task, $udata, $event) = @_;
46 my $n = $task->{rs}->size();
47 $conn->log("irspy_test", "OPAC test search (", $task->render_query(), ") ",
48 ref $event && $event->isa("ZOOM::Exception") ?
49 "failed: $event" : "found $n records (event=$event)");
51 # remember how often a target record hit a timeout
52 if (ref $event && $event->isa("ZOOM::Exception")) {
53 if ($event =~ /Timeout/i) {
54 $conn->record->zoom_error->{TIMEOUT}++;
55 $conn->log("irspy_test", "Increase timeout error counter to: " .
56 $conn->record->zoom_error->{TIMEOUT});
61 $task->{rs}->destroy();
62 my $qindex = $udata->{queryindex}+1;
63 my $q = $queries[$qindex];
64 return ZOOM::IRSpy::Status::TEST_SKIPPED
65 if !defined $q || $conn->record->zoom_error->{TIMEOUT} >= $ZOOM::IRSpy::max_timeout_errors;
67 $conn->log("irspy_test", "Trying another search ...");
68 $conn->irspy_search_pqf($queries[$qindex], { queryindex => $qindex }, \%options,
69 ZOOM::Event::ZEND, \&completed_search,
70 exception => \&completed_search);
71 return ZOOM::IRSpy::Status::TASK_DONE;
74 # We have a result-set of three of more records, and we requested
75 # that those records be included in the Search Response using
76 # piggybacking. Was it done?
77 my $rec = $task->{rs}->record_immediate(2);
78 my $ok = defined $rec;
80 $task->{rs}->destroy();
81 $conn->record()->store_result('multiple_opac', 'ok' => $ok);
82 return $ok ? ZOOM::IRSpy::Status::TEST_GOOD : ZOOM::IRSpy::Status::TEST_BAD;