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

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


The following commit(s) were added to refs/heads/master by this push:
     new 0f33105  bugfix: init `clean_handlers` when add new item from etcd. 
(#1412)
0f33105 is described below

commit 0f3310562c1a117f9519b8b022c6ede282cf670b
Author: YuanSheng Wang <membp...@gmail.com>
AuthorDate: Tue Apr 28 16:01:04 2020 +0800

    bugfix: init `clean_handlers` when add new item from etcd. (#1412)
    
    fix #1384
---
 apisix/core/config_etcd.lua |  1 +
 t/node/healthcheck.t        | 68 +++++++++++++++++++++++++++++++++++++++------
 2 files changed, 60 insertions(+), 9 deletions(-)

diff --git a/apisix/core/config_etcd.lua b/apisix/core/config_etcd.lua
index 484e6ef..dd0a548 100644
--- a/apisix/core/config_etcd.lua
+++ b/apisix/core/config_etcd.lua
@@ -285,6 +285,7 @@ local function sync_data(self)
         end
 
     elseif res.value then
+        res.clean_handlers = {}
         insert_tab(self.values, res)
         self.values_hash[key] = #self.values
         res.value.id = key
diff --git a/t/node/healthcheck.t b/t/node/healthcheck.t
index 22e8b08..96ff4f4 100644
--- a/t/node/healthcheck.t
+++ b/t/node/healthcheck.t
@@ -14,15 +14,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-BEGIN {
-    if ($ENV{TEST_NGINX_CHECK_LEAK}) {
-        $SkipReason = "unavailable for the hup tests";
-
-    } else {
-        $ENV{TEST_NGINX_USE_HUP} = 1;
-        undef $ENV{TEST_NGINX_USE_STAP};
-    }
-}
 
 use t::APISIX 'no_plan';
 
@@ -498,3 +489,62 @@ qr{.*http://127.0.0.1:1960/server_port.*
 .*http://127.0.0.1:1961/server_port.*
 .*http://127.0.0.1:1961/server_port.*}
 --- timeout: 10
+
+
+
+=== TEST 11: add new routh with healthcheck attribute
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            for i = 1, 3 do
+                t('/apisix/admin/routes/' .. i,
+                    ngx.HTTP_PUT,
+                    [[{
+                        "uri": "/server_port",
+                        "upstream": {
+                            "type": "roundrobin",
+                            "nodes": {
+                                "127.0.0.1:1980": 1
+                            },
+                            "checks": {
+                                "active": {
+                                    "http_path": "/status",
+                                    "host": "foo.com",
+                                    "healthy": {
+                                        "interval": 1,
+                                        "successes": 1
+                                    },
+                                    "unhealthy": {
+                                        "interval": 1,
+                                        "http_failures": 2
+                                    }
+                                }
+                            }
+                        }
+                    }]]
+                )
+
+                ngx.sleep(0.1)
+
+                local code, body = t('/server_port', ngx.HTTP_GET)
+                ngx.say("code: ", code, " body: ", body)
+
+                code, body = t('/apisix/admin/routes/' .. i, ngx.HTTP_DELETE)
+                ngx.say("delete code: ", code)
+
+                ngx.sleep(0.1)
+            end
+        }
+    }
+--- request
+GET /t
+--- response_body
+code: 200 body: passed
+delete code: 200
+code: 200 body: passed
+delete code: 200
+code: 200 body: passed
+delete code: 200
+--- no_error_log
+[error]

Reply via email to