@@ -4,7 +4,7 @@ use Test::Nginx::Socket::Lua::Stream;
4
4
5
5
repeat_each(2 );
6
6
7
- plan tests => repeat_each() * 191 ;
7
+ plan tests => repeat_each() * 196 ;
8
8
9
9
our $ HtmlDir = html_dir;
10
10
@@ -3074,7 +3074,65 @@ failed to setkeepalive: closed
3074
3074
3075
3075
3076
3076
3077
- === TEST 57: TEST 62: the upper bound of port range should be 2^ 16 - 1
3077
+ === TEST 57: options_table is nil
3078
+ --- stream_server_config
3079
+ content_by_lua_block {
3080
+ local sock = ngx. socket. tcp()
3081
+ local port = $ TEST_NGINX_SERVER_PORT
3082
+
3083
+ local ok , err = sock: connect(" 127.0.0.1" , port, nil)
3084
+ if not ok then
3085
+ ngx. say (" failed to connect: " , err)
3086
+ return
3087
+ end
3088
+
3089
+ ngx. say (" connected: " , ok )
3090
+
3091
+ ok , err = sock: close()
3092
+ ngx. say (" close: " , ok , " " , err)
3093
+ }
3094
+ --- stream_response
3095
+ connected: 1
3096
+ close: 1 nil
3097
+ --- no_error_log
3098
+ [error]
3099
+
3100
+
3101
+
3102
+ === TEST 58: resolver send query failing immediately in connect()
3103
+ this case did not clear coctx->cleanup properly and would lead to memory invalid accesses.
3104
+
3105
+ this test case requires the following iptables rule to work properly:
3106
+
3107
+ sudo iptables -I OUTPUT 1 -p udp --dport 10086 -j REJECT
3108
+
3109
+ --- stream_server_config
3110
+ resolver 127. 0. 0. 1:10086 ipv6=off;
3111
+ resolver_timeout 10ms;
3112
+
3113
+ content_by_lua_block {
3114
+ local sock = ngx. socket. tcp()
3115
+
3116
+ for i = 1 , 3 do -- retry
3117
+ local ok , err = sock: connect(" www.google.com" , 80 )
3118
+ if not ok then
3119
+ ngx. say (" failed to connect: " , err)
3120
+ end
3121
+ end
3122
+
3123
+ ngx. say (" hello!" )
3124
+ }
3125
+ --- stream_response_body_like
3126
+ failed to connect: www. google. com could not be resolved(? : \(\d + : Operation timed out\))?
3127
+ failed to connect: www. google. com could not be resolved(? : \(\d + : Operation timed out\))?
3128
+ failed to connect: www. google. com could not be resolved(? : \(\d + : Operation timed out\))?
3129
+ hello!
3130
+ --- error_log eval
3131
+ qr{ \[alert\] .*? send\(\) failed \(\d+: Operation not permitted\) while resolving}
3132
+
3133
+
3134
+
3135
+ === TEST 59: the upper bound of port range should be 2^ 16 - 1
3078
3136
--- stream_server_config
3079
3137
content_by_lua_block {
3080
3138
local sock, err = ngx. socket. connect (" 127.0.0.1" , 65536 )
@@ -3090,7 +3148,7 @@ failed to connect: bad port number: 65536
3090
3148
3091
3149
3092
3150
3093
- === TEST 58 : TCP socket GC'ed in preread phase without Lua content phase
3151
+ === TEST 60 : TCP socket GC'ed in preread phase without Lua content phase
3094
3152
--- stream_server_config
3095
3153
lua_socket_connect_timeout 1s;
3096
3154
resolver $TEST_NGINX_RESOLVER ipv6=off;
0 commit comments