Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: init clean_handlers when add new item from etcd. #1412

Merged
merged 1 commit into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]