spacewander commented on a change in pull request #4808:
URL: https://github.com/apache/apisix/pull/4808#discussion_r687683718
##########
File path: t/plugin/limit-conn2.t
##########
@@ -228,3 +228,91 @@ GET /hello1
qr/request latency is nil/
--- grep_error_log_out
request latency is nil
+
+
+
+=== TEST 7: invalid route: wrong rejected_msg type
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin").test
+ local code, body = t('/apisix/admin/routes/1',
+ ngx.HTTP_PUT,
+ [[{
+ "plugins": {
+ "limit-conn": {
+ "conn": 1,
+ "burst": 1,
+ "default_conn_delay": 0.1,
+ "rejected_code": 503,
+ "key": "remote_addr",
+ "rejected_msg": true
+ }
+ },
+ "upstream": {
+ "nodes": {
+ "127.0.0.1:1980": 1
+ },
+ "type": "roundrobin"
+ },
+ "uri": "/limit_conn"
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ end
+ ngx.print(body)
+ }
+ }
+--- request
+GET /t
Review comment:
We don't need to set request and error_log. They are set in
https://github.com/apache/apisix/blob/05fc2306b5f005799e908273cfe11bd5f830459f/t/plugin/limit-conn2.t#L38
##########
File path: t/plugin/limit-count.t
##########
@@ -1371,3 +1371,63 @@ GET /t
qr/property \"time_window\" validation failed: expected 0 to be strictly
greater than 0/
--- no_error_log
[error]
+
+
+
+=== TEST 43: set route, with rejected_msg
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin").test
+ local code, body = t('/apisix/admin/routes/1',
+ ngx.HTTP_PUT,
+ [[{
+ "uri": "/hello",
+ "plugins": {
+ "limit-count": {
+ "count": 1,
+ "time_window": 600,
+ "rejected_code": 503,
+ "rejected_msg": "Requests are too frequent, please
try again later.",
+ "key": "remote_addr"
+ }
+ },
+ "upstream": {
+ "nodes": {
+ "127.0.0.1:1980": 1
+ },
+ "type": "roundrobin"
+ }
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ end
+ ngx.say(body)
+ }
+ }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 44: rejected_msg, request normal
+--- request
+GET /hello
+--- response_body
+hello world
+
+
+
+=== TEST 45: rejected_msg, request frequent
+--- request
+GET /hello
+--- error_code eval
Review comment:
```suggestion
--- error_code: 503
```
##########
File path: t/plugin/limit-count.t
##########
@@ -1371,3 +1371,63 @@ GET /t
qr/property \"time_window\" validation failed: expected 0 to be strictly
greater than 0/
--- no_error_log
[error]
+
+
+
+=== TEST 43: set route, with rejected_msg
Review comment:
Let's move the test to the new test file. See
https://github.com/apache/apisix/blob/master/CONTRIBUTING.md#check-code-style-and-test-case-style
> When the test file is too large, for example > 800 lines, you should split
it to a new file. Please take a look at t/plugin/limit-conn.t and
t/plugin/limit-conn2.t
--
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]