This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 1f27b7220 change: change the default router from radixtree uri to 
radixtree hos… (#9047)
1f27b7220 is described below

commit 1f27b72206a3a33517110cc1b6070e1a138e2e46
Author: Liu Wei <[email protected]>
AuthorDate: Fri Mar 17 10:18:49 2023 +0800

    change: change the default router from radixtree uri to radixtree hos… 
(#9047)
---
 apisix/http/router/radixtree_host_uri.lua |  7 ++++-
 apisix/plugins/ai.lua                     |  1 +
 conf/config-default.yaml                  |  2 +-
 docs/en/latest/terminology/router.md      | 10 +++++--
 docs/zh/latest/terminology/router.md      | 11 ++++++--
 t/config-center-yaml/route.t              | 12 --------
 t/node/route-status.t                     | 11 --------
 t/plugin/ai5.t                            | 16 +++++------
 t/router/radixtree-host-uri-priority.t    | 12 +++++---
 t/router/radixtree-host-uri.t             | 23 ++++++---------
 t/router/radixtree-host-uri2.t            | 16 +++++------
 t/router/radixtree-host-uri3.t            |  6 ++--
 t/router/radixtree-method.t               | 11 ++++++++
 t/router/radixtree-sni.t                  | 47 ++++++-------------------------
 t/router/radixtree-sni2.t                 | 37 ++++++------------------
 t/router/radixtree-uri-host.t             | 15 ++++++++++
 t/router/radixtree-uri-keep-end-slash.t   | 13 +++++++--
 t/router/radixtree-uri-multiple.t         | 15 ++++++++++
 t/router/radixtree-uri-priority.t         | 14 +++++++++
 t/router/radixtree-uri-sanity.t           | 17 +++++++++++
 t/router/radixtree-uri-vars.t             | 16 +++++++++++
 21 files changed, 177 insertions(+), 135 deletions(-)

diff --git a/apisix/http/router/radixtree_host_uri.lua 
b/apisix/http/router/radixtree_host_uri.lua
index 70919763c..532576e53 100644
--- a/apisix/http/router/radixtree_host_uri.lua
+++ b/apisix/http/router/radixtree_host_uri.lua
@@ -17,6 +17,7 @@
 local require = require
 local router = require("apisix.utils.router")
 local core = require("apisix.core")
+local event = require("apisix.core.event")
 local get_services = require("apisix.http.service").services
 local service_fetch = require("apisix.http.service").get
 local ipairs = ipairs
@@ -104,8 +105,9 @@ local function create_radixtree_router(routes)
     local host_routes = {}
     local only_uri_routes = {}
     host_router = nil
+    routes = routes or {}
 
-    for _, route in ipairs(routes or {}) do
+    for _, route in ipairs(routes) do
         local status = core.table.try_read_attr(route, "value", "status")
         -- check the status
         if not status or status == 1 then
@@ -128,6 +130,9 @@ local function create_radixtree_router(routes)
             end
         })
     end
+
+    event.push(event.CONST.BUILD_ROUTER, routes)
+
     if #host_router_routes > 0 then
         host_router = router.new(host_router_routes)
     end
diff --git a/apisix/plugins/ai.lua b/apisix/plugins/ai.lua
index 3195b4bae..b46249a9a 100644
--- a/apisix/plugins/ai.lua
+++ b/apisix/plugins/ai.lua
@@ -163,6 +163,7 @@ local function routes_analyze(routes)
 
     local route_flags = core.table.new(0, 16)
     local route_up_flags = core.table.new(0, 12)
+
     for _, route in ipairs(routes) do
         if type(route) == "table" then
             for key, value in pairs(route.value) do
diff --git a/conf/config-default.yaml b/conf/config-default.yaml
index c043ce2de..2765afe9c 100755
--- a/conf/config-default.yaml
+++ b/conf/config-default.yaml
@@ -75,7 +75,7 @@ apisix:
   # Turn this option on if you want to be compatible with servlet when 
matching URI path.
   normalize_uri_like_servlet: false
   router:
-    http: radixtree_uri         # radixtree_uri: match route by uri(base on 
radixtree)
+    http: radixtree_host_uri      # radixtree_uri: match route by uri(base on 
radixtree)
                                   # radixtree_host_uri: match route by host + 
uri(base on radixtree)
                                   # radixtree_uri_with_parameter: like 
radixtree_uri but match uri with parameters,
                                   #   see 
https://github.com/api7/lua-resty-radixtree/#parameters-in-path for
diff --git a/docs/en/latest/terminology/router.md 
b/docs/en/latest/terminology/router.md
index 804514f12..0eb49f117 100644
--- a/docs/en/latest/terminology/router.md
+++ b/docs/en/latest/terminology/router.md
@@ -38,13 +38,19 @@ A Router can have the following configurations:
 
 - `apisix.router.http`: The HTTP request route. It can take the following 
values:
 
-  - `radixtree_uri`: (Default) Only use the `uri` as the primary index. To 
learn more about the support for full and deep prefix matching, check [How to 
use router-radixtree](../router-radixtree.md).
+  - `radixtree_uri`: Only use the `uri` as the primary index. To learn more 
about the support for full and deep prefix matching, check [How to use 
router-radixtree](../router-radixtree.md).
     - `Absolute match`: Match completely with the given `uri` (`/foo/bar`, 
`/foo/glo`).
     - `Prefix match`: Match with the given prefix. Use `*` to represent the 
given `uri` for prefix matching. For example, `/foo*` can match with `/foo/`, 
`/foo/a` and `/foo/b`.
     - `match priority`: First try an absolute match, if it didn't match, try 
prefix matching.
     - `Any filter attribute`: This allows you to specify any Nginx built-in 
variable as a filter, such as URL request parameters, request headers, and 
cookies.
   - `radixtree_uri_with_parameter`: Like `radixtree_uri` but also supports 
parameter match.
-  - `radixtree_host_uri`: Matches both host and URI of the request. Use `host 
+ uri` as the primary index (based on the `radixtree` engine).
+  - `radixtree_host_uri`: (Default) Matches both host and URI of the request. 
Use `host + uri` as the primary index (based on the `radixtree` engine).
+
+:::note
+
+In version 3.2 and earlier, APISIX used `radixtree_uri` as the default Router. 
`radixtree_uri` has better performance than `radixtree_host_uri`, so if you 
have higher performance requirements and can live with the fact that 
`radixtree_uri` only use the `uri` as the primary index, consider continuing to 
use `radixtree_uri` as the default Router.
+
+:::
 
 - `apisix.router.ssl`: SSL loads the matching route.
   - `radixtree_sni`: (Default) Use `SNI` (Server Name Indication) as the 
primary index (based on the radixtree engine).
diff --git a/docs/zh/latest/terminology/router.md 
b/docs/zh/latest/terminology/router.md
index 3bfaf4256..43cf809c0 100644
--- a/docs/zh/latest/terminology/router.md
+++ b/docs/zh/latest/terminology/router.md
@@ -38,13 +38,20 @@ Router 具有以下配置:
 
 - `apisix.router.http`: HTTP 请求路由。
 
-  - `radixtree_uri`:(默认)只使用 `uri` 作为主索引。基于 `radixtree` 
引擎,支持全量和深前缀匹配,更多信息请参考[如何使用 
router-radixtree](../../../en/latest/router-radixtree.md)。
+  - `radixtree_uri`:只使用 `uri` 作为主索引。基于 `radixtree` 引擎,支持全量和深前缀匹配,更多信息请参考[如何使用 
router-radixtree](../../../en/latest/router-radixtree.md)。
     - `绝对匹配`:完整匹配给定的 `uri` ,比如 `/foo/bar`,`/foo/glo`。
     - `前缀匹配`:末尾使用 `*` 代表给定的 `uri` 是前缀匹配。比如 `/foo*`,则允许匹配 
`/foo/`、`/foo/a`和`/foo/b`等。
     - `匹配优先级`:优先尝试绝对匹配,若无法命中绝对匹配,再尝试前缀匹配。
     - `任意过滤属性`:允许指定任何 Nginx 内置变量作为过滤条件,比如 URL 请求参数、请求头、cookie 等。
   - `radixtree_uri_with_parameter`:同 `radixtree_uri` 但额外有参数匹配的功能。
-  - `radixtree_host_uri`:使用 `host + uri` 作为主索引(基于 `radixtree` 引擎),对当前请求会同时匹配 
`host` 和 `uri`,支持的匹配条件与 `radixtree_uri` 基本一致。
+  - `radixtree_host_uri`:(默认)使用 `host + uri` 作为主索引(基于 `radixtree` 
引擎),对当前请求会同时匹配 `host` 和 `uri`,支持的匹配条件与 `radixtree_uri` 基本一致。
+
+::: 注意
+
+在3.2及之前版本,APISIX 使用 `radixtree_uri` 作为默认路由,`radixtree_uri` 比 
`radixtree_host_uri` 拥有更好的性能,如果你对性能有更高的要求,并且能够接受 `radixtree_uri` 只使用 `uri` 
作为主索引的特点,可以考虑继续使用 `radixtree_uri` 作为默认路由
+
+:::
+
 
 - `apisix.router.ssl`:SSL 加载匹配路由。
   - `radixtree_sni`:(默认)使用 `SNI` (Server Name Indication) 作为主索引(基于 radixtree 
引擎)。
diff --git a/t/config-center-yaml/route.t b/t/config-center-yaml/route.t
index fa2fc6713..2da1397da 100644
--- a/t/config-center-yaml/route.t
+++ b/t/config-center-yaml/route.t
@@ -145,10 +145,6 @@ hello world
 
 === TEST 6: route with bad plugin, radixtree_host_uri
 --- yaml_config
-apisix:
-    node_listen: 1984
-    router:
-        http: "radixtree_host_uri"
 deployment:
     role: data_plane
     role_data_plane:
@@ -176,10 +172,6 @@ property "uri" validation failed
 
 === TEST 7: fix route with default value
 --- yaml_config
-apisix:
-    node_listen: 1984
-    router:
-        http: "radixtree_host_uri"
 deployment:
     role: data_plane
     role_data_plane:
@@ -206,10 +198,6 @@ GET /hello
 
 === TEST 8: invalid route, bad vars operator
 --- yaml_config
-apisix:
-    node_listen: 1984
-    router:
-        http: "radixtree_host_uri"
 deployment:
     role: data_plane
     role_data_plane:
diff --git a/t/node/route-status.t b/t/node/route-status.t
index 1f14a0263..434afa07d 100644
--- a/t/node/route-status.t
+++ b/t/node/route-status.t
@@ -22,13 +22,6 @@ worker_connections(256);
 no_root_location();
 no_shuffle();
 
-our $yaml_config = <<_EOC_;
-apisix:
-    node_listen: 1984
-    router:
-        http: 'radixtree_host_uri'
-_EOC_
-
 run_tests();
 
 __DATA__
@@ -133,7 +126,6 @@ GET /hello
             ngx.say(body)
         }
     }
---- yaml_config eval: $::yaml_config
 --- request
 GET /t
 --- response_body
@@ -144,7 +136,6 @@ passed
 === TEST 6: hit route
 --- request
 GET /hello
---- yaml_config eval: $::yaml_config
 --- more_headers
 Host: foo.com
 --- response_body
@@ -172,7 +163,6 @@ hello world
             ngx.say(body)
         }
     }
---- yaml_config eval: $::yaml_config
 --- request
 GET /t
 --- response_body
@@ -183,7 +173,6 @@ passed
 === TEST 8: route not found, failed by disable
 --- request
 GET /hello
---- yaml_config eval: $::yaml_config
 --- more_headers
 Host: foo.com
 --- error_code: 404
diff --git a/t/plugin/ai5.t b/t/plugin/ai5.t
index 24282c4cb..93ee8bbd3 100644
--- a/t/plugin/ai5.t
+++ b/t/plugin/ai5.t
@@ -171,11 +171,11 @@ done
 qr/route match mode: \S[^,]+/
 --- grep_error_log_out
 route match mode: ai_match
-route match mode: radixtree_uri
-route match mode: radixtree_uri
-route match mode: radixtree_uri
+route match mode: radixtree_host_uri
+route match mode: radixtree_host_uri
+route match mode: radixtree_host_uri
 route match mode: ai_match
-route match mode: radixtree_uri
+route match mode: radixtree_host_uri
 
 
 
@@ -263,8 +263,8 @@ done
 --- grep_error_log eval
 qr/route match mode: \S[^,]+/
 --- grep_error_log_out
-route match mode: radixtree_uri
-route match mode: radixtree_uri
+route match mode: radixtree_host_uri
+route match mode: radixtree_host_uri
 route match mode: ai_match
-route match mode: radixtree_uri
-route match mode: radixtree_uri
+route match mode: radixtree_host_uri
+route match mode: radixtree_host_uri
diff --git a/t/router/radixtree-host-uri-priority.t 
b/t/router/radixtree-host-uri-priority.t
index 50e5ff81e..a2bb56c85 100644
--- a/t/router/radixtree-host-uri-priority.t
+++ b/t/router/radixtree-host-uri-priority.t
@@ -34,12 +34,19 @@ deployment:
         config_provider: yaml
 _EOC_
 
+add_block_preprocessor(sub {
+    my ($block) = @_;
+
+    if (!defined $block->yaml_config) {
+        $block->set_value("yaml_config", $yaml_config);
+    }
+});
+
 run_tests();
 
 __DATA__
 
 === TEST 1: hit routes(priority: 1 + priority: 2)
---- yaml_config eval: $::yaml_config
 --- apisix_yaml
 routes:
   -
@@ -72,7 +79,6 @@ use config_provider: yaml
 
 
 === TEST 2: hit routes(priority: 2 + priority: 1)
---- yaml_config eval: $::yaml_config
 --- apisix_yaml
 routes:
   -
@@ -105,7 +111,6 @@ use config_provider: yaml
 
 
 === TEST 3: hit routes(priority: default_value + priority: 1)
---- yaml_config eval: $::yaml_config
 --- apisix_yaml
 routes:
   -
@@ -137,7 +142,6 @@ use config_provider: yaml
 
 
 === TEST 4: hit routes(priority: 1 + priority: default_value)
---- yaml_config eval: $::yaml_config
 --- apisix_yaml
 routes:
   -
diff --git a/t/router/radixtree-host-uri.t b/t/router/radixtree-host-uri.t
index a65df25a3..be29464d5 100644
--- a/t/router/radixtree-host-uri.t
+++ b/t/router/radixtree-host-uri.t
@@ -29,6 +29,14 @@ apisix:
         http: 'radixtree_host_uri'
 _EOC_
 
+add_block_preprocessor(sub {
+    my ($block) = @_;
+
+    if (!defined $block->yaml_config) {
+        $block->set_value("yaml_config", $yaml_config);
+    }
+});
+
 run_tests();
 
 __DATA__
@@ -58,7 +66,6 @@ __DATA__
             ngx.say(body)
         }
     }
---- yaml_config eval: $::yaml_config
 --- request
 GET /t
 --- response_body
@@ -69,7 +76,6 @@ passed
 === TEST 2: /not_found
 --- request
 GET /not_found
---- yaml_config eval: $::yaml_config
 --- error_code: 404
 --- response_body
 {"error_msg":"404 Route Not Found"}
@@ -79,7 +85,6 @@ GET /not_found
 === TEST 3: /not_found
 --- request
 GET /hello
---- yaml_config eval: $::yaml_config
 --- error_code: 404
 --- response_body
 {"error_msg":"404 Route Not Found"}
@@ -89,7 +94,6 @@ GET /hello
 === TEST 4: /not_found
 --- request
 GET /hello
---- yaml_config eval: $::yaml_config
 --- more_headers
 Host: not_found.com
 --- error_code: 404
@@ -101,7 +105,6 @@ Host: not_found.com
 === TEST 5: hit routes
 --- request
 GET /hello
---- yaml_config eval: $::yaml_config
 --- more_headers
 Host: foo.com
 --- response_body
@@ -112,7 +115,6 @@ hello world
 === TEST 6: hit routes
 --- request
 GET /hello
---- yaml_config eval: $::yaml_config
 --- more_headers
 Host: foo.com
 --- response_body
@@ -144,7 +146,6 @@ hello world
             ngx.say(body)
         }
     }
---- yaml_config eval: $::yaml_config
 --- request
 GET /t
 --- response_body
@@ -155,7 +156,6 @@ passed
 === TEST 8: /not_found
 --- request
 GET /hello
---- yaml_config eval: $::yaml_config
 --- error_code: 404
 --- response_body
 {"error_msg":"404 Route Not Found"}
@@ -165,7 +165,6 @@ GET /hello
 === TEST 9: hit routes
 --- request
 GET /server_port
---- yaml_config eval: $::yaml_config
 --- more_headers
 Host: anydomain.com
 --- response_body_like eval
@@ -197,7 +196,6 @@ qr/1981/
             ngx.say(body)
         }
     }
---- yaml_config eval: $::yaml_config
 --- request
 GET /t
 --- response_body
@@ -208,7 +206,6 @@ passed
 === TEST 11: /not_found
 --- request
 GET /hello2
---- yaml_config eval: $::yaml_config
 --- error_code: 404
 --- response_body
 {"error_msg":"404 Route Not Found"}
@@ -218,7 +215,6 @@ GET /hello2
 === TEST 12: hit routes
 --- request
 GET /hello
---- yaml_config eval: $::yaml_config
 --- more_headers
 Host: anydomain.com
 --- response_body
@@ -241,7 +237,6 @@ hello world
             ngx.say(body)
         }
     }
---- yaml_config eval: $::yaml_config
 --- request
 GET /t
 --- response_body
@@ -274,7 +269,6 @@ passed
             ngx.say(body)
         }
     }
---- yaml_config eval: $::yaml_config
 --- request
 GET /t
 --- response_body
@@ -285,7 +279,6 @@ passed
 === TEST 15: hit routes
 --- request
 GET /hello
---- yaml_config eval: $::yaml_config
 --- more_headers
 Host: www.foo.com
 --- response_body
diff --git a/t/router/radixtree-host-uri2.t b/t/router/radixtree-host-uri2.t
index 7be88f82d..2a6aa42f0 100644
--- a/t/router/radixtree-host-uri2.t
+++ b/t/router/radixtree-host-uri2.t
@@ -34,12 +34,19 @@ deployment:
         config_provider: yaml
 _EOC_
 
+add_block_preprocessor(sub {
+    my ($block) = @_;
+
+    if (!defined $block->yaml_config) {
+        $block->set_value("yaml_config", $yaml_config);
+    }
+});
+
 run_tests();
 
 __DATA__
 
 === TEST 1: test.com
---- yaml_config eval: $::yaml_config
 --- apisix_yaml
 routes:
   -
@@ -69,7 +76,6 @@ use config_provider: yaml
 
 
 === TEST 2: *.test.com + uri
---- yaml_config eval: $::yaml_config
 --- apisix_yaml
 routes:
   -
@@ -99,7 +105,6 @@ use config_provider: yaml
 
 
 === TEST 3: *.test.com + /*
---- yaml_config eval: $::yaml_config
 --- apisix_yaml
 routes:
   -
@@ -129,7 +134,6 @@ use config_provider: yaml
 
 
 === TEST 4: filter_func(not match)
---- yaml_config eval: $::yaml_config
 --- apisix_yaml
 routes:
   -
@@ -160,7 +164,6 @@ use config_provider: yaml
 
 
 === TEST 5: filter_func(match)
---- yaml_config eval: $::yaml_config
 --- apisix_yaml
 routes:
   -
@@ -318,7 +321,6 @@ Host: t.com
 
 
 === TEST 12: request host with uppercase
---- yaml_config eval: $::yaml_config
 --- apisix_yaml
 routes:
   -
@@ -337,7 +339,6 @@ Host: tEst.com
 
 
 === TEST 13: configure host with uppercase
---- yaml_config eval: $::yaml_config
 --- apisix_yaml
 routes:
   -
@@ -356,7 +357,6 @@ Host: test.com
 
 
 === TEST 14: inherit hosts from services
---- yaml_config eval: $::yaml_config
 --- apisix_yaml
 services:
   - id: 1
diff --git a/t/router/radixtree-host-uri3.t b/t/router/radixtree-host-uri3.t
index 2db4bb437..0d57788a2 100644
--- a/t/router/radixtree-host-uri3.t
+++ b/t/router/radixtree-host-uri3.t
@@ -26,12 +26,14 @@ _EOC_
 add_block_preprocessor(sub {
     my ($block) = @_;
 
-    $block->set_value("yaml_config", $yaml_config);
-
     if (!$block->request) {
         $block->set_value("request", "GET /t");
     }
 
+    if (!defined $block->yaml_config) {
+        $block->set_value("yaml_config", $yaml_config);
+    }
+
     if (!$block->error_log && !$block->no_error_log &&
         (defined $block->error_code && $block->error_code != 502))
     {
diff --git a/t/router/radixtree-method.t b/t/router/radixtree-method.t
index 30a51c218..f17826e57 100644
--- a/t/router/radixtree-method.t
+++ b/t/router/radixtree-method.t
@@ -16,9 +16,20 @@
 #
 use t::APISIX 'no_plan';
 
+our $yaml_config = <<_EOC_;
+apisix:
+    node_listen: 1984
+    router:
+        http: 'radixtree_uri'
+_EOC_
+
 add_block_preprocessor(sub {
     my ($block) = @_;
 
+    if (!defined $block->yaml_config) {
+        $block->set_value("yaml_config", $yaml_config);
+    }
+
     if (!defined $block->request) {
         $block->set_value("request", "GET /t");
     }
diff --git a/t/router/radixtree-sni.t b/t/router/radixtree-sni.t
index 57f9ed360..9a28e3d78 100644
--- a/t/router/radixtree-sni.t
+++ b/t/router/radixtree-sni.t
@@ -21,6 +21,15 @@ no_root_location();
 
 $ENV{TEST_NGINX_HTML_DIR} ||= html_dir();
 
+add_block_preprocessor(sub {
+    my ($block) = @_;
+
+    if (!$block->request) {
+        $block->set_value("request", "GET /t");
+    }
+
+});
+
 run_tests;
 
 __DATA__
@@ -51,8 +60,6 @@ location /t {
         ngx.say(body)
     }
 }
---- request
-GET /t
 --- response_body
 passed
 
@@ -82,8 +89,6 @@ passed
             ngx.say(body)
         }
     }
---- request
-GET /t
 --- response_body
 passed
 
@@ -144,8 +149,6 @@ location /t {
         -- collectgarbage()
     }
 }
---- request
-GET /t
 --- response_body eval
 qr{connected: 1
 ssl handshake: true
@@ -195,8 +198,6 @@ location /t {
         end
     }
 }
---- request
-GET /t
 --- response_body
 connected: 1
 failed to do SSL handshake: handshake failed
@@ -231,8 +232,6 @@ location /t {
         ngx.say(body)
     }
 }
---- request
-GET /t
 --- response_body
 passed
 
@@ -293,8 +292,6 @@ location /t {
         -- collectgarbage()
     }
 }
---- request
-GET /t
 --- response_body eval
 qr{connected: 1
 ssl handshake: true
@@ -340,8 +337,6 @@ location /t {
         ngx.say(body)
     }
 }
---- request
-GET /t
 --- response_body
 passed
 
@@ -402,8 +397,6 @@ location /t {
         -- collectgarbage()
     }
 }
---- request
-GET /t
 --- response_body eval
 qr{connected: 1
 ssl handshake: true
@@ -449,8 +442,6 @@ location /t {
         ngx.say(body)
     }
 }
---- request
-GET /t
 --- response_body
 passed
 
@@ -489,8 +480,6 @@ location /t {
         -- collectgarbage()
     }
 }
---- request
-GET /t
 --- response_body_like
 connected: 1
 failed to do SSL handshake: 18: self[- ]signed certificate
@@ -535,8 +524,6 @@ location /t {
         -- collectgarbage()
     }
 }
---- request
-GET /t
 --- response_body
 connected: 1
 failed to do SSL handshake: handshake failed
@@ -572,8 +559,6 @@ location /t {
         ngx.say(body)
     }
 }
---- request
-GET /t
 --- response_body
 passed
 
@@ -612,8 +597,6 @@ location /t {
         -- collectgarbage()
     }
 }
---- request
-GET /t
 --- response_body
 connected: 1
 failed to do SSL handshake: handshake failed
@@ -648,8 +631,6 @@ location /t {
         ngx.say(body)
     }
 }
---- request
-GET /t
 --- response_body
 passed
 
@@ -688,8 +669,6 @@ location /t {
         -- collectgarbage()
     }
 }
---- request
-GET /t
 --- response_body_like
 connected: 1
 failed to do SSL handshake: 18: self[- ]signed certificate
@@ -727,8 +706,6 @@ location /t {
         ngx.say(body)
     }
 }
---- request
-GET /t
 --- response_body
 passed
 
@@ -767,8 +744,6 @@ location /t {
         -- collectgarbage()
     }
 }
---- request
-GET /t
 --- response_body_like
 connected: 1
 failed to do SSL handshake: 18: self[- ]signed certificate
@@ -813,8 +788,6 @@ location /t {
         -- collectgarbage()
     }
 }
---- request
-GET /t
 --- response_body
 connected: 1
 failed to do SSL handshake: handshake failed
@@ -846,8 +819,6 @@ location /t {
         ngx.print(body)
     }
 }
---- request
-GET /t
 --- response_body
 {"error_msg":"failed to decrypt previous encrypted key"}
 --- error_code: 400
diff --git a/t/router/radixtree-sni2.t b/t/router/radixtree-sni2.t
index 1c910198a..b34d0b725 100644
--- a/t/router/radixtree-sni2.t
+++ b/t/router/radixtree-sni2.t
@@ -21,6 +21,15 @@ no_root_location();
 
 $ENV{TEST_NGINX_HTML_DIR} ||= html_dir();
 
+add_block_preprocessor(sub {
+    my ($block) = @_;
+
+    if (!$block->request) {
+        $block->set_value("request", "GET /t");
+    }
+
+});
+
 run_tests;
 
 __DATA__
@@ -59,8 +68,6 @@ location /t {
         ngx.say(body)
     }
 }
---- request
-GET /t
 --- response_body
 passed
 
@@ -100,8 +107,6 @@ location /t {
         -- collectgarbage()
     }
 }
---- request
-GET /t
 --- response_body
 connected: 1
 ssl handshake: true
@@ -143,8 +148,6 @@ location /t {
         -- collectgarbage()
     }
 }
---- request
-GET /t
 --- response_body
 connected: 1
 ssl handshake: true
@@ -177,8 +180,6 @@ location /t {
         ngx.say(body)
     }
 }
---- request
-GET /t
 --- response_body
 passed
 
@@ -222,8 +223,6 @@ location /t {
         -- collectgarbage()
     }
 }
---- request
-GET /t
 --- response_body eval
 qr{connected: 1
 ssl handshake: true
@@ -269,8 +268,6 @@ location /t {
         ngx.print(body)
     }
 }
---- request
-GET /t
 --- error_code: 400
 --- response_body
 {"error_msg":"failed to handle cert-key pair[1]: failed to decrypt previous 
encrypted key"}
@@ -299,8 +296,6 @@ location /t {
         ngx.print(body)
     }
 }
---- request
-GET /t
 --- response_body
 {"error_msg":"failed to parse cert: PEM_read_bio_X509_AUX() failed"}
 --- error_code: 400
@@ -338,8 +333,6 @@ location /t {
         -- collectgarbage()
     }
 }
---- request
-GET /t
 --- response_body
 failed to do SSL handshake: handshake failed
 --- error_log
@@ -384,8 +377,6 @@ location /t {
         -- collectgarbage()
     }
 }
---- request
-GET /t
 --- response_body
 ssl handshake: true
 
@@ -411,8 +402,6 @@ location /t {
         ngx.say(body)
     }
 }
---- request
-GET /t
 --- response_body
 passed
 
@@ -445,8 +434,6 @@ location /t {
         -- collectgarbage()
     }
 }
---- request
-GET /t
 --- response_body
 ssl handshake: true
 
@@ -472,8 +459,6 @@ location /t {
         ngx.say(body)
     }
 }
---- request
-GET /t
 --- response_body
 passed
 
@@ -506,8 +491,6 @@ location /t {
         -- collectgarbage()
     }
 }
---- request
-GET /t
 --- response_body
 ssl handshake: true
 
@@ -553,8 +536,6 @@ location /t {
         ngx.log(ngx.WARN, "release table ", name)
         return old_release(name, ...)
     end
---- request
-GET /t
 --- response_body
 ssl handshake: true
 --- grep_error_log eval
diff --git a/t/router/radixtree-uri-host.t b/t/router/radixtree-uri-host.t
index e6a16a6c7..b9f290141 100644
--- a/t/router/radixtree-uri-host.t
+++ b/t/router/radixtree-uri-host.t
@@ -22,6 +22,21 @@ worker_connections(256);
 no_root_location();
 no_shuffle();
 
+our $yaml_config = <<_EOC_;
+apisix:
+    node_listen: 1984
+    router:
+        http: 'radixtree_uri'
+_EOC_
+
+add_block_preprocessor(sub {
+    my ($block) = @_;
+
+    if (!defined $block->yaml_config) {
+        $block->set_value("yaml_config", $yaml_config);
+    }
+});
+
 run_tests();
 
 __DATA__
diff --git a/t/router/radixtree-uri-keep-end-slash.t 
b/t/router/radixtree-uri-keep-end-slash.t
index 533b480f0..910ef99b0 100644
--- a/t/router/radixtree-uri-keep-end-slash.t
+++ b/t/router/radixtree-uri-keep-end-slash.t
@@ -25,9 +25,19 @@ no_shuffle();
 our $yaml_config = <<_EOC_;
 apisix:
     node_listen: 1984
+    router:
+        http: 'radixtree_uri'
     delete_uri_tail_slash: true
 _EOC_
 
+add_block_preprocessor(sub {
+    my ($block) = @_;
+
+    if (!defined $block->yaml_config) {
+        $block->set_value("yaml_config", $yaml_config);
+    }
+});
+
 run_tests();
 
 __DATA__
@@ -56,7 +66,6 @@ __DATA__
             ngx.say(body)
         }
     }
---- yaml_config eval: $::yaml_config
 --- request
 GET /t
 --- response_body
@@ -67,7 +76,6 @@ passed
 === TEST 2: hit route
 --- request
 GET /hello
---- yaml_config eval: $::yaml_config
 --- response_body
 hello world
 
@@ -76,5 +84,4 @@ hello world
 === TEST 3: hit route
 --- request
 GET /hello/
---- yaml_config eval: $::yaml_config
 --- error_code: 404
diff --git a/t/router/radixtree-uri-multiple.t 
b/t/router/radixtree-uri-multiple.t
index 001d97080..8f124fe44 100644
--- a/t/router/radixtree-uri-multiple.t
+++ b/t/router/radixtree-uri-multiple.t
@@ -22,6 +22,21 @@ worker_connections(256);
 no_root_location();
 no_shuffle();
 
+our $yaml_config = <<_EOC_;
+apisix:
+    node_listen: 1984
+    router:
+        http: 'radixtree_uri'
+_EOC_
+
+add_block_preprocessor(sub {
+    my ($block) = @_;
+
+    if (!defined $block->yaml_config) {
+        $block->set_value("yaml_config", $yaml_config);
+    }
+});
+
 run_tests();
 
 __DATA__
diff --git a/t/router/radixtree-uri-priority.t 
b/t/router/radixtree-uri-priority.t
index 865b341f6..93c2464ca 100644
--- a/t/router/radixtree-uri-priority.t
+++ b/t/router/radixtree-uri-priority.t
@@ -22,6 +22,20 @@ worker_connections(256);
 no_root_location();
 no_shuffle();
 
+our $yaml_config = <<_EOC_;
+apisix:
+    node_listen: 1984
+    router:
+        http: 'radixtree_uri'
+_EOC_
+
+add_block_preprocessor(sub {
+    my ($block) = @_;
+
+    if (!defined $block->yaml_config) {
+        $block->set_value("yaml_config", $yaml_config);
+    }
+});
 
 run_tests();
 
diff --git a/t/router/radixtree-uri-sanity.t b/t/router/radixtree-uri-sanity.t
index c61721df8..5d36a3db1 100644
--- a/t/router/radixtree-uri-sanity.t
+++ b/t/router/radixtree-uri-sanity.t
@@ -25,9 +25,26 @@ no_shuffle();
 our $servlet_yaml_config = <<_EOC_;
 apisix:
     node_listen: 1984
+    router:
+        http: 'radixtree_uri'
     normalize_uri_like_servlet: true
 _EOC_
 
+our $yaml_config = <<_EOC_;
+apisix:
+    node_listen: 1984
+    router:
+        http: 'radixtree_uri'
+_EOC_
+
+add_block_preprocessor(sub {
+    my ($block) = @_;
+
+    if (!defined $block->yaml_config) {
+        $block->set_value("yaml_config", $yaml_config);
+    }
+});
+
 run_tests();
 
 __DATA__
diff --git a/t/router/radixtree-uri-vars.t b/t/router/radixtree-uri-vars.t
index f9b3e2af1..6e4b78712 100644
--- a/t/router/radixtree-uri-vars.t
+++ b/t/router/radixtree-uri-vars.t
@@ -22,6 +22,22 @@ worker_connections(256);
 no_root_location();
 no_shuffle();
 
+our $yaml_config = <<_EOC_;
+apisix:
+    node_listen: 1984
+    router:
+        http: 'radixtree_uri'
+_EOC_
+
+add_block_preprocessor(sub {
+    my ($block) = @_;
+
+    if (!defined $block->yaml_config) {
+        $block->set_value("yaml_config", $yaml_config);
+    }
+
+});
+
 run_tests();
 
 __DATA__

Reply via email to