@@ -792,10 +792,9 @@ qr/runtime error: content_by_lua\(nginx\.conf:\d+\):13: bad request/
792
792
else
793
793
ngx. say (" peer set" )
794
794
end
795
-
796
795
local function f()
797
796
local sock = test. get_sock()
798
- sock: send( " a " )
797
+ sock: close( )
799
798
end
800
799
ngx. timer. at(0 , f)
801
800
ngx. sleep (0.001 )
@@ -818,73 +817,71 @@ end
818
817
peer set
819
818
820
819
-- - error_log eval
821
- qr/ runtime error: content_by_lua\(nginx\. conf: \d+ \): 13 : bad request/
820
+ qr/ runtime error: content_by_lua\(nginx\. conf: \d+ \): 12 : bad request/
822
821
823
822
-- - no_error_log
824
823
[alert]
825
824
826
825
827
826
828
- === TEST 17 : bad request tries to receive
827
+ === TEST 17 : the upper bound of port range should be 2 ^ 16 - 1
829
828
-- - stream_config eval
830
829
" lua_package_path '$::HtmlDir/?.lua;./?.lua;;';"
831
830
-- - stream_server_config
832
831
content_by_lua_block {
833
- local test = require " test"
834
- local sock = test. new_sock()
835
- local ok , err = sock: setpeername(" 127.0.0.1" , $ TEST_NGINX_MEMCACHED_PORT )
832
+ local sock = ngx. socket. udp()
833
+ local ok , err = sock: setpeername(" 127.0.0.1" , 65536 )
836
834
if not ok then
837
- ngx. say (" failed to set peer: " , err)
838
- else
839
- ngx. say (" peer set" )
840
- end
841
- function f()
842
- local sock = test. get_sock()
843
- sock: close()
835
+ ngx. say (" failed to connect: " , err)
844
836
end
845
- ngx. timer. at(0 , f)
846
- ngx. sleep (0.001 )
847
837
}
848
- -- - user_files
849
- >>> test. lua
850
- module(" test" , package. seeall)
851
-
852
- local sock
853
-
854
- function new_sock()
855
- sock = ngx. socket. udp()
856
- return sock
857
- end
858
-
859
- function get_sock()
860
- return sock
861
- end
862
838
-- - stream_response
863
- peer set
864
-
865
- -- - error_log eval
866
- qr/ runtime error: content_by_lua\(nginx\. conf: \d+ \): 12 : bad request/
867
-
839
+ failed to connect : bad port number: 65536
868
840
-- - no_error_log
869
- [alert ]
841
+ [error ]
870
842
871
843
872
844
873
- === TEST 18 : the upper bound of port range should be 2 ^ 16 - 1
874
- -- - stream_config eval
875
- " lua_package_path '$::HtmlDir/?.lua;./?.lua;;';"
845
+ === TEST 18 : send boolean and nil
876
846
-- - stream_server_config
877
847
content_by_lua_block {
878
- local sock = ngx. socket. udp()
879
- local ok , err = sock: setpeername(" 127.0.0.1" , 65536 )
848
+ local socket = ngx. socket
849
+ local udp = socket. udp()
850
+ local port = ngx. var. port
851
+ udp: settimeout(1000 ) -- 1 sec
852
+
853
+ local ok , err = udp: setpeername(" 127.0.0.1" , $ TEST_NGINX_MEMCACHED_PORT )
880
854
if not ok then
881
855
ngx. say (" failed to connect: " , err)
856
+ return
882
857
end
858
+
859
+ local function send(data)
860
+ local bytes , err = udp: send(data)
861
+ if not bytes then
862
+ ngx. say (" failed to send: " , err)
863
+ return
864
+ end
865
+ ngx. say (" sent ok" )
866
+ end
867
+
868
+ send(true)
869
+ send(false)
870
+ send(nil)
883
871
}
884
872
-- - stream_response
885
- failed to connect : bad port number: 65536
873
+ sent ok
874
+ sent ok
875
+ sent ok
886
876
-- - no_error_log
887
877
[error]
878
+ -- - grep_error_log eval
879
+ qr/ sendto: fd: \d+ \d+ of \d+/
880
+ -- - grep_error_log_out eval
881
+ qr/ sendto: fd: \d+ 4 of 4
882
+ sendto: fd: \d+ 5 of 5
883
+ sendto: fd: \d+ 3 of 3 /
884
+ -- - log_level: debug
888
885
889
886
890
887
0 commit comments