line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: ResponseTimeTest.pm,v 1.7 2003/03/02 11:52:09 m_ilya Exp $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package HTTP::WebTest::Plugin::ResponseTimeTest; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
HTTP::WebTest::Plugin::ResponseTimeTest - Tests for response time |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Not Applicable |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
This plugin supports web server response time tests. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
10
|
|
|
10
|
|
86
|
use strict; |
|
10
|
|
|
|
|
26
|
|
|
10
|
|
|
|
|
410
|
|
20
|
|
|
|
|
|
|
|
21
|
10
|
|
|
10
|
|
58
|
use base qw(HTTP::WebTest::Plugin); |
|
10
|
|
|
|
|
26
|
|
|
10
|
|
|
|
|
3658
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 TEST PARAMETERS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=for pod_merge copy params |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 min_rtime |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Minimum web server response time (seconds) expected. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head3 Allowed values |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Any number less than C (if C is specified). |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 max_rtime |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Maximum web server response time (seconds) expected. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head3 Allowed values |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Any number greater that zero and greater than C (if |
42
|
|
|
|
|
|
|
C is specified). |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub param_types { |
47
|
190
|
|
|
190
|
1
|
2178
|
return q(min_rtime scalar |
48
|
|
|
|
|
|
|
max_rtime scalar); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub check_response { |
52
|
190
|
|
|
190
|
0
|
425
|
my $self = shift; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# response time |
55
|
190
|
|
|
|
|
797
|
my $rtime = $self->webtest->current_response_time; |
56
|
|
|
|
|
|
|
|
57
|
190
|
|
|
|
|
1059
|
$self->validate_params(qw(min_rtime max_rtime)); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# response time limits |
60
|
190
|
|
|
|
|
841
|
my $min_rtime = $self->test_param('min_rtime'); |
61
|
190
|
|
|
|
|
660
|
my $max_rtime = $self->test_param('max_rtime'); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# test results |
64
|
190
|
|
|
|
|
586
|
my @results = (); |
65
|
190
|
|
|
|
|
359
|
my @ret = (); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# check minimal size |
68
|
190
|
100
|
|
|
|
534
|
if(defined $min_rtime) { |
69
|
4
|
|
|
|
|
13
|
my $ok = $rtime >= $min_rtime; |
70
|
4
|
|
|
|
|
11
|
my $comment = 'Response time ('; |
71
|
4
|
|
|
|
|
63
|
$comment .= sprintf '%6.2f', $rtime; |
72
|
4
|
|
|
|
|
9
|
$comment .= ' ) is > or ='; |
73
|
4
|
|
|
|
|
17
|
$comment .= sprintf '%6.2f', $min_rtime; |
74
|
4
|
|
|
|
|
15
|
$comment .= ' ?'; |
75
|
|
|
|
|
|
|
|
76
|
4
|
|
|
|
|
24
|
push @results, $self->test_result($ok, $comment); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# check maximal size |
80
|
190
|
100
|
|
|
|
587
|
if(defined $max_rtime) { |
81
|
7
|
|
|
|
|
25
|
my $ok = $rtime <= $max_rtime; |
82
|
7
|
|
|
|
|
16
|
my $comment = 'Response time ('; |
83
|
7
|
|
|
|
|
80
|
$comment .= sprintf '%6.2f', $rtime; |
84
|
7
|
|
|
|
|
19
|
$comment .= ' ) is < or ='; |
85
|
7
|
|
|
|
|
32
|
$comment .= sprintf '%6.2f', $max_rtime; |
86
|
7
|
|
|
|
|
18
|
$comment .= ' ?'; |
87
|
|
|
|
|
|
|
|
88
|
7
|
|
|
|
|
28
|
push @results, $self->test_result($ok, $comment); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
190
|
100
|
|
|
|
541
|
push @ret, [ 'Response time check', @results ] if @results; |
92
|
|
|
|
|
|
|
|
93
|
190
|
|
|
|
|
804
|
return @ret; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 COPYRIGHT |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Copyright (c) 2000-2001 Richard Anderson. All rights reserved. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Copyright (c) 2001-2003 Ilya Martynov. All rights reserved. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
103
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 SEE ALSO |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
L |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
L |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
L |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
L |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |