annotate proxy_limit_rate.t @ 1021:ebdf239722b9

Tests: relaxed proxy_cache_lock.t nolock tests to fix on Solaris. Assumed that the order of responses being arrived in nolock case may be ignored. An important part of such case is that the only last response should be cached.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 02 Sep 2016 12:17:35 +0300
parents 516070bada7d
children b113eeca94ad
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
482
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6 # Tests for the proxy_limit_rate directive.
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8 ###############################################################################
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10 use warnings;
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use strict;
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13 use Test::More;
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17 use lib 'lib';
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 use Test::Nginx;
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20 ###############################################################################
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22 select STDERR; $| = 1;
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 select STDOUT; $| = 1;
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24
568
907e89fba9c3 Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents: 536
diff changeset
25 my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(2);
482
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
26
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
27 $t->write_file_expand('nginx.conf', <<'EOF');
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29 %%TEST_GLOBALS%%
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31 daemon off;
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33 events {
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34 }
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36 http {
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37 %%TEST_GLOBALS_HTTP%%
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
40 listen 127.0.0.1:8080;
482
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
41 server_name localhost;
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43 location / {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
44 proxy_pass http://127.0.0.1:8080/data;
981
516070bada7d Tests: unbreak proxy_limit_rate.t on hosts with larger page sizes.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
45 proxy_buffer_size 4k;
482
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46 proxy_limit_rate 12000;
536
c2481c6b748f Tests: adjusted proxy_limit_rate test.
Sergey Kandaurov <pluknet@nginx.com>
parents: 482
diff changeset
47 add_header X-Msec $msec;
482
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48 }
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50 location /data {
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51 }
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52 }
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53 }
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55 EOF
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57 $t->write_file('data', 'X' x 40000);
568
907e89fba9c3 Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents: 536
diff changeset
58 $t->run();
482
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60 ###############################################################################
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61
628
0940773278c7 Tests: backed out previous change, adjusted general timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents: 627
diff changeset
62 my $r = http_get('/');
482
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63
536
c2481c6b748f Tests: adjusted proxy_limit_rate test.
Sergey Kandaurov <pluknet@nginx.com>
parents: 482
diff changeset
64 my ($t1) = $r =~ /X-Msec: (\d+)/;
482
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
65 my $diff = time() - $t1;
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
66
787
a53c310c695d Tests: relaxed limit_rate tests timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents: 628
diff changeset
67 # four chunks are split with three 1s delays
482
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
68
787
a53c310c695d Tests: relaxed limit_rate tests timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents: 628
diff changeset
69 cmp_ok($diff, '>=', 3, 'proxy_limit_rate');
482
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
70 like($r, qr/^(XXXXXXXXXX){4000}\x0d?\x0a?$/m, 'response body');
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
71
6d35acdf9a61 Tests: proxy_limit_rate simple test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
72 ###############################################################################