tzssangglass commented on a change in pull request #6759:
URL: https://github.com/apache/apisix/pull/6759#discussion_r841056621
##########
File path: t/xds-library/config_xds_2.t
##########
@@ -76,3 +76,166 @@ __DATA__
}
--- response_body
hello world
+
+
+
+=== TEST 2: proxy request using data written by xds(id = 2, upstream_id = 1)
+--- config
+ location /t {
+ content_by_lua_block {
+ local http = require "resty.http"
+ local httpc = http.new()
+ local uri = "http://127.0.0.1:" .. ngx.var.server_port .. "/hello1"
+ local res, err = httpc:request_uri(uri, { method = "GET"})
+
+ if not res then
+ ngx.say(err)
+ return
+ end
+ ngx.print(res.body)
+ }
+ }
+--- response_body
+hello1 world
+
+
+
+=== TEST 3: proxy request using data written by xds(id = 3, upstream_id = 2)
+--- config
+ location /t {
+ content_by_lua_block {
+ ngx.sleep(1.5)
+ local core = require("apisix.core")
+ local value = ngx.shared["xds-config"]:flush_all()
+ ngx.sleep(1.5)
+ local http = require "resty.http"
+ local httpc = http.new()
+ local uri = "http://127.0.0.1:" .. ngx.var.server_port .. "/hello"
+ local res, err = httpc:request_uri(uri, { method = "GET"})
+
+ if not res then
+ ngx.say(err)
+ return
+ end
+ ngx.print(res.body)
+ }
+ }
+--- response_body
+hello world
+
+
+
+=== TEST 4: flush all keys in xds config
+--- config
+ location /t {
+ content_by_lua_block {
+ local core = require("apisix.core")
+ ngx.shared["xds-config"]:flush_all()
+ ngx.update_time()
+ ngx.shared["xds-conf-version"]:set("version", ngx.now())
+ ngx.sleep(1.5)
+
+ local http = require "resty.http"
+ local httpc = http.new()
+ local uri = "http://127.0.0.1:" .. ngx.var.server_port .. "/hello"
+ local res, err = httpc:request_uri(uri, { method = "GET"})
+
+ if not res then
+ ngx.say(err)
+ return
+ end
+ ngx.status = res.status
+ ngx.print(res.body)
+ }
+ }
+--- error_code: 404
+--- response_body
+{"error_msg":"404 Route Not Found"}
+
+
+
+=== TEST 5: bad format json
+--- config
+ location /t {
+ content_by_lua_block {
+ local data = [[{
+ upstream = {
+ type = "roundrobin"
+ nodes = {
+ ["127.0.0.1:1980"] = 1,
+ }
+ },
+ uri = "/bad_json"
+ }]]
+ ngx.shared["xds-config"]:set("/routes/3", data)
+ ngx.update_time()
+ ngx.shared["xds-conf-version"]:set("version", ngx.now())
+ ngx.sleep(1.5)
+
+ local http = require "resty.http"
+ local httpc = http.new()
+ local uri = "http://127.0.0.1:" .. ngx.var.server_port ..
"/bad_json"
+ local res, err = httpc:request_uri(uri, { method = "GET"})
+
+ if not res then
+ ngx.say(err)
+ return
+ end
+ ngx.status = res.status
+ }
+ }
+--- error_code: 404
+--- no_error_log
+[alert]
Review comment:
update
##########
File path: apisix/cli/ngx_tpl.lua
##########
@@ -244,7 +244,8 @@ http {
{% end %}
{% if config_center == "xds" then %}
- lua_shared_dict xds-route-config 10m;
+ lua_shared_dict xds-config 10m;
+ lua_shared_dict xds-conf-version 1m;
Review comment:
update
##########
File path: t/APISIX.pm
##########
@@ -509,7 +509,8 @@ _EOC_
lua_shared_dict ext-plugin 1m;
lua_shared_dict kubernetes 1m;
lua_shared_dict tars 1m;
- lua_shared_dict xds-route-config 1m;
+ lua_shared_dict xds-config 1m;
+ lua_shared_dict xds-conf-version 1m;
Review comment:
update
--
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]