Skip to content

Commit

Permalink
bugfix: init clean_handlers when add new item from etcd. (#1412)
Browse files Browse the repository at this point in the history
fix #1384
  • Loading branch information
membphis authored Apr 28, 2020
1 parent 50d2957 commit 0f33105
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 9 deletions.
1 change: 1 addition & 0 deletions apisix/core/config_etcd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
68 changes: 59 additions & 9 deletions t/node/healthcheck.t
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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]

0 comments on commit 0f33105

Please sign in to comment.