nic-6443 commented on code in PR #13402:
URL: https://github.com/apache/apisix/pull/13402#discussion_r3278171543
##########
t/stream-plugin/syslog.t:
##########
@@ -349,7 +349,123 @@ sending a batch logs to 127.0.0.1:5045
-=== TEST 8: log format in plugin
+=== TEST 8: check service plugin configuration updating
+--- stream_conf_enable
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin").test
+ local code, body1 = t('/apisix/admin/services/1',
+ ngx.HTTP_PUT,
+ [[{
+ "plugins": {
+ "syslog": {
+ "host" : "127.0.0.1",
+ "port" : 5044,
+ "batch_max_size": 1
+ }
+ },
+ "upstream": {
+ "nodes": {
+ "127.0.0.1:1995": 1
+ },
+ "type": "roundrobin"
+ }
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ ngx.say("fail")
+ return
+ end
+
+ local code, body2 = t('/apisix/admin/stream_routes/1',
+ ngx.HTTP_PUT,
+ [[{
+ "service_id": "1"
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ ngx.say("fail")
+ return
+ end
+
+ ngx.sleep(0.5)
+
+ local sock = ngx.socket.tcp()
+ local ok, err = sock:connect("127.0.0.1", 1985)
+ if not ok then
+ ngx.status = code
+ ngx.say("fail")
+ return
+ end
+
+ assert(sock:send("mmm"))
+ local body3 = assert(sock:receive("*a"))
+
Review Comment:
Good catch. The test now closes the cosocket after receive, and closes it on
send failure too.
##########
t/stream-plugin/syslog.t:
##########
@@ -349,7 +349,123 @@ sending a batch logs to 127.0.0.1:5045
-=== TEST 8: log format in plugin
+=== TEST 8: check service plugin configuration updating
+--- stream_conf_enable
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin").test
+ local code, body1 = t('/apisix/admin/services/1',
+ ngx.HTTP_PUT,
+ [[{
+ "plugins": {
+ "syslog": {
+ "host" : "127.0.0.1",
+ "port" : 5044,
+ "batch_max_size": 1
+ }
+ },
+ "upstream": {
+ "nodes": {
+ "127.0.0.1:1995": 1
+ },
+ "type": "roundrobin"
+ }
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ ngx.say("fail")
+ return
+ end
+
+ local code, body2 = t('/apisix/admin/stream_routes/1',
+ ngx.HTTP_PUT,
+ [[{
+ "service_id": "1"
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ ngx.say("fail")
+ return
+ end
+
+ ngx.sleep(0.5)
+
+ local sock = ngx.socket.tcp()
+ local ok, err = sock:connect("127.0.0.1", 1985)
+ if not ok then
+ ngx.status = code
+ ngx.say("fail")
+ return
+ end
+
+ assert(sock:send("mmm"))
+ local body3 = assert(sock:receive("*a"))
+
+ local code, body4 = t('/apisix/admin/services/1',
+ ngx.HTTP_PUT,
+ [[{
+ "plugins": {
+ "syslog": {
+ "host" : "127.0.0.1",
+ "port" : 5045,
+ "batch_max_size": 1
+ }
+ },
+ "upstream": {
+ "nodes": {
+ "127.0.0.1:1995": 1
+ },
+ "type": "roundrobin"
+ }
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ ngx.say("fail")
+ return
+ end
+
+ ngx.sleep(0.5)
+
+ local sock = ngx.socket.tcp()
+ local ok, err = sock:connect("127.0.0.1", 1985)
+ if not ok then
+ ngx.status = code
+ ngx.say("fail")
+ return
+ end
Review Comment:
Good catch. Updated the helper to return 500 and print the socket error
instead of reusing the previous Admin API status.
##########
t/stream-plugin/syslog.t:
##########
@@ -349,7 +349,123 @@ sending a batch logs to 127.0.0.1:5045
-=== TEST 8: log format in plugin
+=== TEST 8: check service plugin configuration updating
+--- stream_conf_enable
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin").test
+ local code, body1 = t('/apisix/admin/services/1',
+ ngx.HTTP_PUT,
+ [[{
+ "plugins": {
+ "syslog": {
+ "host" : "127.0.0.1",
+ "port" : 5044,
+ "batch_max_size": 1
+ }
+ },
+ "upstream": {
+ "nodes": {
+ "127.0.0.1:1995": 1
+ },
+ "type": "roundrobin"
+ }
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ ngx.say("fail")
+ return
+ end
+
+ local code, body2 = t('/apisix/admin/stream_routes/1',
+ ngx.HTTP_PUT,
+ [[{
+ "service_id": "1"
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ ngx.say("fail")
+ return
+ end
+
+ ngx.sleep(0.5)
+
+ local sock = ngx.socket.tcp()
+ local ok, err = sock:connect("127.0.0.1", 1985)
+ if not ok then
+ ngx.status = code
+ ngx.say("fail")
Review Comment:
Good catch. Updated the helper to return 500 and print the socket error
instead of reusing the previous Admin API status.
##########
t/stream-plugin/syslog.t:
##########
@@ -349,7 +349,123 @@ sending a batch logs to 127.0.0.1:5045
-=== TEST 8: log format in plugin
+=== TEST 8: check service plugin configuration updating
+--- stream_conf_enable
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin").test
+ local code, body1 = t('/apisix/admin/services/1',
+ ngx.HTTP_PUT,
+ [[{
+ "plugins": {
+ "syslog": {
+ "host" : "127.0.0.1",
+ "port" : 5044,
+ "batch_max_size": 1
+ }
+ },
+ "upstream": {
+ "nodes": {
+ "127.0.0.1:1995": 1
+ },
+ "type": "roundrobin"
+ }
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ ngx.say("fail")
+ return
+ end
+
+ local code, body2 = t('/apisix/admin/stream_routes/1',
+ ngx.HTTP_PUT,
+ [[{
+ "service_id": "1"
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ ngx.say("fail")
+ return
+ end
+
+ ngx.sleep(0.5)
+
+ local sock = ngx.socket.tcp()
+ local ok, err = sock:connect("127.0.0.1", 1985)
+ if not ok then
+ ngx.status = code
+ ngx.say("fail")
+ return
+ end
+
+ assert(sock:send("mmm"))
+ local body3 = assert(sock:receive("*a"))
+
+ local code, body4 = t('/apisix/admin/services/1',
+ ngx.HTTP_PUT,
+ [[{
+ "plugins": {
+ "syslog": {
+ "host" : "127.0.0.1",
+ "port" : 5045,
+ "batch_max_size": 1
+ }
+ },
+ "upstream": {
+ "nodes": {
+ "127.0.0.1:1995": 1
+ },
+ "type": "roundrobin"
+ }
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ ngx.say("fail")
+ return
+ end
+
+ ngx.sleep(0.5)
+
+ local sock = ngx.socket.tcp()
+ local ok, err = sock:connect("127.0.0.1", 1985)
+ if not ok then
+ ngx.status = code
+ ngx.say("fail")
+ return
+ end
+
+ assert(sock:send("mmm"))
+ local body5 = assert(sock:receive("*a"))
+
Review Comment:
Good catch. The test now closes the cosocket after receive, and closes it on
send failure too.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]