comparison proxy_limit_rate.t @ 628:0940773278c7

Tests: backed out previous change, adjusted general timeouts. The previous timeout values are commonly not enough when making mass-building.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 09 Jul 2015 14:09:27 +0300
parents cb35a9ec4428
children a53c310c695d
comparison
equal deleted inserted replaced
627:cb35a9ec4428 628:0940773278c7
56 $t->write_file('data', 'X' x 40000); 56 $t->write_file('data', 'X' x 40000);
57 $t->run(); 57 $t->run();
58 58
59 ############################################################################### 59 ###############################################################################
60 60
61 my $s = http_get('/', start => 1); 61 my $r = http_get('/');
62 my $r = http_end_gentle($s);
63 62
64 my ($t1) = $r =~ /X-Msec: (\d+)/; 63 my ($t1) = $r =~ /X-Msec: (\d+)/;
65 my $diff = time() - $t1; 64 my $diff = time() - $t1;
66 65
67 # four chunks are split with three 1s delays + 1s error 66 # four chunks are split with three 1s delays + 1s error
68 67
69 cmp_ok(abs($diff - 3), '<=', 1, 'proxy_limit_rate'); 68 cmp_ok(abs($diff - 3), '<=', 1, 'proxy_limit_rate');
70 like($r, qr/^(XXXXXXXXXX){4000}\x0d?\x0a?$/m, 'response body'); 69 like($r, qr/^(XXXXXXXXXX){4000}\x0d?\x0a?$/m, 'response body');
71 70
72 ############################################################################### 71 ###############################################################################
73
74 sub http_end_gentle {
75 my ($s) = @_;
76 my $reply;
77
78 eval {
79 local $SIG{ALRM} = sub { die "timeout\n" };
80 local $SIG{PIPE} = sub { die "sigpipe\n" };
81 alarm(8);
82
83 local $/;
84 $reply = $s->getline();
85
86 alarm(0);
87 };
88 alarm(0);
89 if ($@) {
90 log_in("died: $@");
91 return undef;
92 }
93
94 log_in($reply);
95 return $reply;
96 }
97
98 ###############################################################################