Mercurial > hg > nginx-tests
comparison stream_udp_wildcard.t @ 1164:cdd44ff602db
Tests: stream udp test with wildcard address.
The test ensures that the source address used for outgoing UDP datagrams
is the same as the one used for the incoming datagram.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 18 Apr 2017 17:51:00 +0300 |
parents | |
children | 97c8280de681 |
comparison
equal
deleted
inserted
replaced
1163:bd1cf0a80b28 | 1164:cdd44ff602db |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for stream proxy module with datagrams, source address selection. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
16 | |
17 use lib 'lib'; | |
18 use Test::Nginx; | |
19 use Test::Nginx::Stream qw/ dgram /; | |
20 | |
21 ############################################################################### | |
22 | |
23 select STDERR; $| = 1; | |
24 select STDOUT; $| = 1; | |
25 | |
26 plan(skip_all => '127.0.0.2 local address required') | |
27 unless defined IO::Socket::INET->new( LocalAddr => '127.0.0.2' ); | |
28 | |
29 plan(skip_all => 'listen on wildcard address') | |
30 unless $ENV{TEST_NGINX_UNSAFE}; | |
31 | |
32 my $t = Test::Nginx->new()->has(qw/stream stream_return udp/)->plan(1) | |
33 ->write_file_expand('nginx.conf', <<'EOF'); | |
34 | |
35 %%TEST_GLOBALS%% | |
36 | |
37 daemon off; | |
38 | |
39 events { | |
40 } | |
41 | |
42 stream { | |
43 server { | |
44 listen %%PORT_8999_UDP%% udp; | |
45 return $server_addr; | |
46 } | |
47 } | |
48 | |
49 EOF | |
50 | |
51 $t->run(); | |
52 | |
53 ############################################################################### | |
54 | |
55 my $s = dgram( | |
56 LocalAddr => '127.0.0.1', | |
57 PeerAddr => '127.0.0.2:' . port(8999) | |
58 ); | |
59 | |
60 TODO: { | |
61 local $TODO = 'not yet' unless $t->has_version('1.13.0'); | |
62 | |
63 is($s->io('test'), '127.0.0.2', 'stream udp wildcard'); | |
64 | |
65 } | |
66 | |
67 ############################################################################### |