spacewander commented on a change in pull request #6759:
URL: https://github.com/apache/apisix/pull/6759#discussion_r841039554
##########
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:
@tzssangglass
We can check like this?
https://github.com/apache/apisix/blob/97bcb565075e59372842973844216c129af5d812/t/plugin/gzip.t#L40
--
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]