feat(xds): using data written by xds to control dp behavior #6759
Conversation
|
I want to write some test cases, such as without any keys, json with wrong format, json that does not conform to the route's json scheme, etc., but I don't know how to control the data passed with libxds.so in the test cases. But I can write data to shdict directly in the test case, which seems more convenient than writing data with libxds.so, is this acceptable way of testing. |
| } | ||
| --- error_code: 404 | ||
| --- no_error_log | ||
| [alert] |
There was a problem hiding this comment.
Why should we check the alert log? Is there any alert log in the path?
There was a problem hiding this comment.
because this test case throws an error level log, but the above defines
if (!$block->no_error_log) {
$block->set_value("no_error_log", "[error]\n[alert]");
}
so I need to override the above definition with the --- no_error_log statement, and I need to verify that the error level log.
There was a problem hiding this comment.
@tzssangglass
We can check like this?
Line 40 in 97bcb56
There was a problem hiding this comment.
We can safely remove it, right?
|
|
||
| require("apisix.debug").init_worker() | ||
|
|
||
| if core.config == require("apisix.core.config_xds") then |
There was a problem hiding this comment.
Can we just put all the init_worker together?
There was a problem hiding this comment.
For config_xds, I need it to run before route, service is initialised. So do I need to advance config_yaml to the same level as config_xds?
| } | ||
| --- error_code: 404 | ||
| --- no_error_log | ||
| [alert] |
There was a problem hiding this comment.
We can safely remove it, right?
|
|
||
| if not keys or #keys <= 0 then | ||
| -- xds did not write any data to shdict | ||
| return true, "no keys" |
There was a problem hiding this comment.
| return true, "no keys" | |
| return false, "no keys" |
| end | ||
|
|
||
| -- v1 version we only support route/upstream | ||
| local capacity = math_ceil(#keys / 2) |
There was a problem hiding this comment.
ngx.shared["xds-config"] stores all routes, upstreams, here I estimate the capacity of the route by using the total capacity / 2.
There was a problem hiding this comment.
Route and upstream are not 1:1.
Maybe we can use #keys directly
|
|
||
| -- blocking until xds completes initial configuration | ||
| while true do | ||
| fetch_version() |
There was a problem hiding this comment.
ngx.sleep can not used in init_worker_by_lua, is there another way?
|
|
||
|
|
||
| local function sync_data(self) | ||
| if not latest_version then |
There was a problem hiding this comment.
As we already block for the version, we can skip this check?
|
|
||
| local sync_data | ||
| local latest_version | ||
| sync_data = function(self) |
There was a problem hiding this comment.
Why not use local function xxx?
|
|
||
| -- blocking until xds completes initial configuration | ||
| while true do | ||
| fetch_version() |
Description
This PR is designed to mock the behavior of xds writing data and reading it from ngx.shared.DICT to complete the request proxy.
It needs to accomplish the following functions:
Fixes # (issue)
Checklist