Mercurial > hg > nginx-tests
annotate stream_udp_stream.t @ 1983:c7315caf2110
Tests: optimized processing of large QUIC packets with padding.
Path MTU discovery packets might contain a lot of padding, and creating
a copy of the whole buffer for each PADDING frame, which is just one
byte with type 0, consumes lots of resources. This was seen to result
in flapping of at least h3_keepalive.t and h3_ssl_early_data.t tests.
Fix is to copy at most 8 bytes for parse_int() calls when parsing
frame types.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 03 Jun 2024 04:17:28 +0300 |
parents | f3ba4c74de31 |
children |
rev | line source |
---|---|
1335 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Nginx, Inc. | |
4 | |
5 # Tests for UDP stream. | |
6 | |
7 ############################################################################### | |
8 | |
9 use warnings; | |
10 use strict; | |
11 | |
12 use Test::More; | |
13 | |
14 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
15 | |
16 use lib 'lib'; | |
17 use Test::Nginx; | |
18 use Test::Nginx::Stream qw/ dgram /; | |
19 | |
20 ############################################################################### | |
21 | |
22 select STDERR; $| = 1; | |
23 select STDOUT; $| = 1; | |
24 | |
25 my $t = Test::Nginx->new()->has(qw/stream stream_return udp/)->plan(8) | |
26 ->write_file_expand('nginx.conf', <<'EOF'); | |
27 | |
28 %%TEST_GLOBALS%% | |
29 | |
30 daemon off; | |
31 | |
32 events { | |
33 } | |
34 | |
35 stream { | |
1609
f3ba4c74de31
Tests: added TEST_GLOBALS_STREAM variable support.
Andrei Belov <defan@nginx.com>
parents:
1535
diff
changeset
|
36 %%TEST_GLOBALS_STREAM%% |
f3ba4c74de31
Tests: added TEST_GLOBALS_STREAM variable support.
Andrei Belov <defan@nginx.com>
parents:
1535
diff
changeset
|
37 |
1437
2fc21bdd6f0d
Tests: adjusted stream_udp_stream.t for slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1372
diff
changeset
|
38 proxy_timeout 1s; |
1335 | 39 |
40 server { | |
41 listen 127.0.0.1:%%PORT_8980_UDP%% udp; | |
42 proxy_pass 127.0.0.1:%%PORT_8981_UDP%%; | |
43 } | |
44 | |
45 server { | |
46 listen 127.0.0.1:%%PORT_8981_UDP%% udp; | |
47 return $remote_port; | |
48 } | |
49 } | |
50 | |
51 EOF | |
52 | |
53 $t->run(); | |
54 | |
55 ############################################################################### | |
56 | |
57 my $s = dgram('127.0.0.1:' . port(8980)); | |
58 my $data = $s->io('1', read_timeout => 0.5); | |
59 isnt($data, '', 'udp_stream response 1'); | |
60 | |
61 my $s2 = dgram('127.0.0.1:' . port(8980)); | |
62 my $data2 = $s2->io('1', read_timeout => 0.5); | |
63 isnt($data2, '', 'udp_stream response 2'); | |
64 | |
65 isnt($data, $data2, 'udp_stream two sessions'); | |
66 | |
67 is($s->io('1'), $data, 'udp_stream session 1'); | |
68 is($s->io('1'), $data, 'udp_stream session 2'); | |
69 | |
70 is($s2->io('1'), $data2, 'udp_stream another session 1'); | |
71 is($s2->io('1'), $data2, 'udp_stream another session 2'); | |
72 | |
1437
2fc21bdd6f0d
Tests: adjusted stream_udp_stream.t for slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1372
diff
changeset
|
73 select undef, undef, undef, 1.1; |
1335 | 74 |
75 isnt($s->io('1'), $data, 'udp_stream new session'); | |
1372 | 76 |
77 ############################################################################### |