my $conn = $copy_conn[$i0];
#print "connection $i0 of $nconn/", scalar(@conn), " is $conn\n";
next if !defined $conn;
+
if (!$conn->current_task()) {
if (!$conn->next_task()) {
# Out of tasks: we need a new test
$conn->log("irspy_test",
"checking for next test after '$address'");
$nextaddr = $this->_next_test($address);
- if ($nextaddr && $conn->record->zoom_error->{TIMEOUT} >= $max_timeout_errors) {
- $conn->log("irspy", "Got to many timeouts, stop testing: " . $conn->record->zoom_error->{TIMEOUT});
- $nextaddr = "";
- }
}
+
+ if (ZOOM::IRSpy::Test::zoom_error_timeout_check($conn)) {
+ $conn->log("irspy", "Got to many timeouts, stop testing");
+ undef $nextaddr;
+ }
+
if (!defined $nextaddr) {
$conn->log("irspy", "has no more tests: removing");
$this->_rewrite_irspy_record($conn);
my $task = $conn->next_task();
die "no next task queued for $conn" if !defined $task;
+
+ # do not run the next task if we got too many timeouts
+ if (ZOOM::IRSpy::Test::zoom_error_timeout_check($conn)) {
+ $conn->log("irspy_task", "Got to many timeouts for this target, do not start a new task");
+ next;
+ }
+
$conn->log("irspy_task", "preparing task $task");
$conn->next_task(0);
$conn->current_task($task);
use Scalar::Util;
+use Exporter 'import';
+our @EXPORT = qw(zoom_error_timeout_update zoom_error_timeout_check);
+
=head1 NAME
ZOOM::IRSpy::Test - base class for tests in IRSpy
=cut
+
sub subtests { () }
sub timeout { undef }
}
+our $max_timeout_errors = $ZOOM::IRSpy::max_timeout_errors;
+
+sub zoom_error_timeout_update {
+ my ($conn, $exception) = @_;
+
+ if ($exception =~ /Timeout/i) {
+ $conn->record->zoom_error->{TIMEOUT}++;
+ $conn->log("irspy_test", "Increase timeout error counter to: " .
+ $conn->record->zoom_error->{TIMEOUT});
+ }
+}
+
+sub zoom_error_timeout_check {
+ my $conn = shift;
+
+ if ($conn->record->zoom_error->{TIMEOUT} >= $max_timeout_errors) {
+ $conn->log("irspy_test", "Got $max_timeout_errors or more timeouts, give up...");
+ return 1;
+ }
+
+ return 0;
+}
+
=head1 SEE ALSO
ZOOM::IRSpy
my($conn, $task, $test_args, $exception) = @_;
$conn->log("irspy_test", "Named resultset check failed:", $exception);
+ zoom_error_timeout_update($conn, $exception);
return ZOOM::IRSpy::Status::TASK_DONE;
}
$conn->log("irspy_test", "search on access-point $attr had error: ",
$exception);
update($conn, $attr, 0);
+ zoom_error_timeout_update($conn, $exception);
return ZOOM::IRSpy::Status::TEST_BAD
if ($exception->code() == 1 || # permanent system error
'ok' => $ok);
}
-
1;
$conn->log("irspy_test", "search using boolean operator ", $operator,
" had error: ", $exception);
update($conn, $operator, 0);
+ zoom_error_timeout_update($conn, $exception);
return ZOOM::IRSpy::Status::TASK_DONE;
}
$task->{rs}->destroy();
$conn->log("irspy_test", "CQL search on '$index' had error: $exception");
$conn->record()->store_result("search_cql", index => $index, ok => 0);
+ zoom_error_timeout_update($conn, $exception);
return ZOOM::IRSpy::Status::TEST_BAD
if $exception->code() == 11; # Unsupported query type
my $rec = $conn->record();
$rec->append_entry("irspy:status", "<irspy:search_dbdate ok='0'>" .
isodate(time()) . "</irspy:search_dbdate>");
+ zoom_error_timeout_update($conn, $exception);
return ZOOM::IRSpy::Status::TEST_BAD;
}
$conn->log("irspy_test", "search on access-point $attr had error: ",
$exception);
update($conn, $attr, 0);
+ zoom_error_timeout_update($conn, $exception);
### How about TEST_BAD if $exception->code() == 121?
return ZOOM::IRSpy::Status::TASK_DONE;
$task->{rs}->destroy();
$conn->log("irspy_test", "Explain category lookup failed: ", $exception);
update($conn, $category, 0);
+ zoom_error_timeout_update($conn, $exception);
return ZOOM::IRSpy::Status::TEST_BAD
if ($exception->code() == 109 || # Database unavailable
my $rec = $conn->record();
$rec->append_entry("irspy:status", "<irspy:search_title ok='0'>" .
isodate(time()) . "</irspy:search_title>");
+ zoom_error_timeout_update($conn, $exception);
return ZOOM::IRSpy::Status::TEST_BAD;
}