complete error timeout handling for all tests
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Test.pm
1
2 package ZOOM::IRSpy::Test;
3
4 use 5.008;
5 use strict;
6 use warnings;
7
8 use Scalar::Util;
9
10 use Exporter 'import';
11 our @EXPORT = qw(zoom_error_timeout_update zoom_error_timeout_check); 
12
13 =head1 NAME
14
15 ZOOM::IRSpy::Test - base class for tests in IRSpy
16
17 =head1 SYNOPSIS
18
19  ## To follow
20
21 =head1 DESCRIPTION
22
23 I<## To follow>
24
25 =cut
26
27
28 sub subtests { () }
29
30 sub timeout { undef }
31
32 sub start {
33     my $class = shift();
34     my($conn) = @_;
35
36     die "can't start the base-class test";
37 }
38
39
40 our $max_timeout_errors = $ZOOM::IRSpy::max_timeout_errors;
41
42 sub zoom_error_timeout_update {
43     my ($conn, $exception) = @_;
44
45     if ($exception =~ /Timeout/i) {
46         $conn->record->zoom_error->{TIMEOUT}++;
47         $conn->log("irspy_test", "Increase timeout error counter to: " .
48                 $conn->record->zoom_error->{TIMEOUT});
49     }
50 }
51
52 sub zoom_error_timeout_check {
53     my $conn = shift;
54
55     if ($conn->record->zoom_error->{TIMEOUT} >= $max_timeout_errors) {
56         $conn->log("irspy_test", "Got $max_timeout_errors or more timeouts, give up...");
57         return  1;
58     }
59
60     return 0;
61 }
62
63 =head1 SEE ALSO
64
65 ZOOM::IRSpy
66
67 =head1 AUTHOR
68
69 Mike Taylor, E<lt>mike@indexdata.comE<gt>
70
71 =head1 COPYRIGHT AND LICENSE
72
73 Copyright (C) 2006 by Index Data ApS.
74
75 This library is free software; you can redistribute it and/or modify
76 it under the same terms as Perl itself, either Perl version 5.8.7 or,
77 at your option, any later version of Perl 5 you may have available.
78
79 =cut
80
81 1;