Mercurial > hg > nginx-tests
comparison stream_limit_rate.t @ 634:40675bfad7d3
Tests: fixed stream limit rate tests.
Relaxed time error values to make tests safe on slow hosts.
author | Andrey Zelenkov <zelenkov@nginx.com> |
---|---|
date | Tue, 21 Jul 2015 15:41:55 +0300 |
parents | c8d6f816e094 |
children | 443848f28a73 |
comparison
equal
deleted
inserted
replaced
633:cf89559cd558 | 634:40675bfad7d3 |
---|---|
69 } | 69 } |
70 | 70 |
71 server { | 71 server { |
72 listen 127.0.0.1:8085; | 72 listen 127.0.0.1:8085; |
73 proxy_pass 127.0.0.1:8080; | 73 proxy_pass 127.0.0.1:8080; |
74 proxy_download_rate 500; | 74 proxy_download_rate 250; |
75 } | 75 } |
76 | 76 |
77 server { | 77 server { |
78 listen 127.0.0.1:8086; | 78 listen 127.0.0.1:8086; |
79 proxy_pass 127.0.0.1:8090; | 79 proxy_pass 127.0.0.1:8090; |
80 proxy_upload_rate 500; | 80 proxy_upload_rate 250; |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 EOF | 84 EOF |
85 | 85 |
113 %r = stream_get($str, peer => '127.0.0.1:8084'); | 113 %r = stream_get($str, peer => '127.0.0.1:8084'); |
114 is($r{'data'}, '1', 'upload - one byte'); | 114 is($r{'data'}, '1', 'upload - one byte'); |
115 | 115 |
116 } | 116 } |
117 | 117 |
118 # Three chunks are split with two 1s delays + 1s error: | 118 # Five chunks are split with four 1s delays + 2s error: |
119 # the first two chunks are halfs of test string | 119 # the first two chunks are halfs of test string |
120 # and the third one is some extra data from backend. | 120 # and the third one is some extra data from backend. |
121 | 121 |
122 %r = stream_get($str, peer => '127.0.0.1:8085'); | 122 %r = stream_get($str, peer => '127.0.0.1:8085'); |
123 my $diff = time() - $r{'time'}; | 123 my $diff = time() - $r{'time'}; |
124 cmp_ok(abs($diff - 2), '<=', 1, 'download - time'); | 124 cmp_ok(abs($diff - 4), '<=', 2, 'download - time'); |
125 is($r{'data'}, $str, 'download - data'); | 125 is($r{'data'}, $str, 'download - data'); |
126 | 126 |
127 my $time = time(); | 127 my $time = time(); |
128 %r = stream_get($str . 'close', peer => '127.0.0.1:8086'); | 128 %r = stream_get($str . 'close', peer => '127.0.0.1:8086'); |
129 $diff = time() - $time; | 129 $diff = time() - $time; |
130 cmp_ok(abs($diff - 2), '<=', 1, 'upload - time'); | 130 cmp_ok(abs($diff - 4), '<=', 2, 'upload - time'); |
131 is($r{'data'}, $str . 'close', 'upload - data'); | 131 is($r{'data'}, $str . 'close', 'upload - data'); |
132 | 132 |
133 ############################################################################### | 133 ############################################################################### |
134 | 134 |
135 sub stream_get { | 135 sub stream_get { |