Mercurial > hg > nginx-tests
annotate stream_limit_conn_complex.t @ 1328:a682c219af45
Tests: updated ssl_engine_keys.t test.
After merge with libp11, pkcs11 engine shared object was renamed
from "engine_pkcs11.so" to "pkcs11.so". Changed configuration
accordingly.
Additionally, changed "init" to "1" in the engine configuration. This
keeps pkcs11 engine loaded and prevents segmentation faults observed
during nginx shutdown.
While here, restored correct order of ssl_certificate and ssl_certificate_key.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 22 May 2018 17:46:59 +0300 |
parents | 766bcbb632ee |
children | f3ba4c74de31 |
rev | line source |
---|---|
966
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Andrey Zelenkov |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for stream limit_conn module. |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
1020
196d33c2bb45
Tests: removed TODO and try_run() checks for legacy versions.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
974
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http stream stream_limit_conn/) |
966
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 ->write_file_expand('nginx.conf', <<'EOF'); |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 %%TEST_GLOBALS%% |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 daemon off; |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 events { |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 } |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 stream { |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 limit_conn_zone $binary_remote_addr$server_port zone=zone:1m; |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
966
diff
changeset
|
39 listen 127.0.0.1:8080; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
966
diff
changeset
|
40 proxy_pass 127.0.0.1:8084; |
966
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 limit_conn zone 1; |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 } |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
966
diff
changeset
|
45 listen 127.0.0.1:8081; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
966
diff
changeset
|
46 proxy_pass 127.0.0.1:8084; |
966
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 limit_conn zone 1; |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 } |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 } |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 http { |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 %%TEST_GLOBALS_HTTP%% |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
966
diff
changeset
|
55 listen 127.0.0.1:8084; |
966
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 server_name localhost; |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 location / { } |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 } |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 } |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 EOF |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 $t->write_file('index.html', ''); |
1251
766bcbb632ee
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
65 $t->run()->plan(4); |
966
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 ############################################################################### |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
966
diff
changeset
|
69 like(get(port(8080)), qr/200 OK/, 'passed'); |
966
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 my $s = http(<<EOF, start => 1, sleep => 0.2); |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 GET / HTTP/1.0 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 EOF |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 ok($s, 'long connection'); |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
966
diff
changeset
|
77 is(get(port(8080)), undef, 'rejected same key'); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
966
diff
changeset
|
78 like(get(port(8081)), qr/200 OK/, 'passed different key'); |
966
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 ############################################################################### |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 sub get { |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 my $port = shift; |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 my $s = IO::Socket::INET->new( |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 Proto => 'tcp', |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 PeerAddr => "127.0.0.1:$port" |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 ) |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 or die "Can't connect to nginx: $!\n"; |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 my $r = http_get('/', socket => $s); |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 if (!$r) { |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 $r = undef; |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 } |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 return $r; |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 } |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 |
3ac72d59430b
Tests: stream limit_conn tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 ############################################################################### |