Revolyssup commented on code in PR #10138:
URL: https://github.com/apache/apisix/pull/10138#discussion_r1315443994
##########
t/plugin/proxy-cache/memory.t:
##########
@@ -661,3 +661,57 @@ GET /hello
--- more_headers
Cache-Control: only-if-cached
--- error_code: 504
+
+
+
+=== TEST 36: configure plugin without memory_cache zone
+--- 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": {
+ "proxy-cache": {
+ "cache_strategy": "memory",
+ "cache_key":["$host","$uri"],
+ "cache_bypass": ["$arg_bypass"],
+ "cache_control": true,
+ "cache_method": ["GET"],
+ "cache_ttl": 10,
+ "cache_http_status": [200]
+ }
+ },
+ "upstream": {
+ "nodes": {
+ "127.0.0.1:1986": 1
+ },
+ "type": "roundrobin"
+ },
+ "uri": "/hello"
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ end
+ ngx.say(body)
+ }
+ }
+--- request
+GET /t
+--- error_code: 200
+--- response_body
+passed
+
+
+
+=== TEST 37: hit route
+--- request
+GET /hello
+--- grep_error_log eval
+qr/no cache_zone provided/
+--- grep_error_log_out
+no cache_zone provided
+no cache_zone provided
Review Comment:
@kayx23 That internal server error takes place when the requests are
received and not when plugin is configured in admin API.
Now instead of 500 internal server error, the error logs will point out the
fact that cache_zone is not configured so proxy-cache won't work as expected.
The requests still pass through.
I think your suggestion is more in line with, rejecting the configuration
during schema validation if cache_zone is explicitly not provided while
cache_strategy is `memory`
--
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]