comparison proxy_limit_rate.t @ 536:c2481c6b748f

Tests: adjusted proxy_limit_rate test. Start time is now taken from nginx for greater accuracy.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 17 Mar 2015 16:27:00 +0300
parents 6d35acdf9a61
children 907e89fba9c3
comparison
equal deleted inserted replaced
535:ee7a6a144437 536:c2481c6b748f
41 server_name localhost; 41 server_name localhost;
42 42
43 location / { 43 location / {
44 proxy_pass http://127.0.0.1:8080/data; 44 proxy_pass http://127.0.0.1:8080/data;
45 proxy_limit_rate 12000; 45 proxy_limit_rate 12000;
46 add_header X-Msec $msec;
46 } 47 }
47 48
48 location /data { 49 location /data {
49 } 50 }
50 } 51 }
55 $t->write_file('data', 'X' x 40000); 56 $t->write_file('data', 'X' x 40000);
56 $t->try_run('no proxy_limit_rate')->plan(2); 57 $t->try_run('no proxy_limit_rate')->plan(2);
57 58
58 ############################################################################### 59 ###############################################################################
59 60
60 my $t1 = time();
61
62 my $r = http_get('/'); 61 my $r = http_get('/');
63 62
63 my ($t1) = $r =~ /X-Msec: (\d+)/;
64 my $diff = time() - $t1; 64 my $diff = time() - $t1;
65 65
66 # four chunks are split with three 1s delays + 1s error 66 # four chunks are split with three 1s delays + 1s error
67 67
68 cmp_ok(abs($diff - 3), '<=', 1, 'proxy_limit_rate'); 68 cmp_ok(abs($diff - 3), '<=', 1, 'proxy_limit_rate');