.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Required to disable full justification in groff 1.23.0. .if n .ds AD l .\" ======================================================================== .\" .IX Title "Test::Nginx::Socket::Lua::Dgram 3pm" .TH Test::Nginx::Socket::Lua::Dgram 3pm 2026-08-04 "perl v5.42.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Test::Nginx::Socket::Lua::Dgram \- Subclass of Test::Nginx::Socket::Lua to test NGINX udp stream modules .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 3 \& === TEST 1: simple test for ngx_stream_echo_module \& \-\-\- dgram_server_config \& echo "Hello, stream echo!"; \& \& \-\-\- dgram_response \& Hello, stream echo! \& \& \-\-\- no_error_log \& [error] \& [alert] .Ve .SH Description .IX Header "Description" This module subclasses Test::Nginx::Socket::Lua to provide handy abstractions for testing NGINX UDP stream\-typed modules like ngx_stream_echo_module. .PP By default, the stream server listens on the port number N + 1 where N is the value of the environment \f(CW\*(C`TEST_NGINX_SERVER_PORT\*(C'\fR or \f(CW\*(C`TEST_NGINX_PORT\*(C'\fR (both default to 1984). One can explicitly specify the default stream server\*(Aqs listening port via the \f(CW\*(C`TEST_NGINX_DGRAM_PORT\*(C'\fR environment. .SH "Sections supported" .IX Header "Sections supported" All the existing sections of Test::Nginx::Socket::Lua are automatically inherited. .PP The following new test sections are supported: .SS dgram_config .IX Subsection "dgram_config" Specifies custom content in the default \f(CW\*(C`stream {}\*(C'\fR configuration block. .SS dgram_server_config .IX Subsection "dgram_server_config" Specifies custom content in the default \f(CW\*(C`server {}\*(C'\fR configuration block (inside \f(CW\*(C`stream {}\*(C'\fR) in \fInginx.conf\fR. .PP For example, .PP .Vb 2 \& \-\-\- dgram_server_config \& echo "hello"; .Ve .PP will generate something like below in \fInginx.conf\fR: .PP .Vb 6 \& stream { \& server { \& listen 1985 udp; \& echo "Hello, stream echo!"; \& } \& } .Ve .SS dgram_server_config2 .IX Subsection "dgram_server_config2" Specifies a second stream server which listens on the port used by the first default server plus one. .SS dgram_server_config3 .IX Subsection "dgram_server_config3" Specifies a third stream server which listens on the port used by the first default server plus two. .SS dgram_request .IX Subsection "dgram_request" Specifies the request data sent to the first default stream server (defined by \f(CW\*(C`dgram_server_config\*(C'\fR. .SS dgram_request2 .IX Subsection "dgram_request2" Specifies the request data sent to the second default stream server (defined by \f(CW\*(C`dgram_server_config2\*(C'\fR. .SS dgram_request3 .IX Subsection "dgram_request3" Specifies the request data sent to the third default stream server (defined by \f(CW\*(C`dgram_server_config3\*(C'\fR. .SS dgram_response .IX Subsection "dgram_response" Specifies expected response content sent from the default stream servers. For example, .PP .Vb 3 \& === TEST 1: simple echo \& \-\-\- dgram_server_config \& echo "Hello, stream echo!"; \& \& \-\-\- dgram_response \& Hello, stream echo! .Ve .PP When multiple default stream servers are specified (i.e., via \f(CW\*(C`dgram_server_config2\*(C'\fR and \&\f(CW\*(C`dgram_server_config3\*(C'\fR, the responses from all these stream servers are concatenated together in the order of their specifications. .SS dgram_response_like .IX Subsection "dgram_response_like" Specifies the regex pattern used to test the response data from the default stream servers. .SS log_dgram_response .IX Subsection "log_dgram_response" Print out the stream response to the nginx error log with the "info" level instead of sending it out to the stream client directly. .SH AUTHOR .IX Header "AUTHOR" Yichun "agentzh" Zhang (章亦春) \f(CW\*(C`\*(C'\fR, OpenResty Inc. .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright (c) 2016 ~ 2025, Yichun Zhang \f(CW\*(C`\*(C'\fR, OpenResty Inc. .PP This module is licensed under the terms of the BSD license. .PP Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: .IP \(bu 4 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. .IP \(bu 4 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. .IP \(bu 4 Neither the name of the authors nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. .PP THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .SH "SEE ALSO" .IX Header "SEE ALSO" Test::Nginx::Socket::Lua, Test::Base.