From 776d837f27ce39b70e471635ba5c91ce235cb641 Mon Sep 17 00:00:00 2001 From: xumin Date: Thu, 31 Oct 2024 17:30:35 +0800 Subject: [PATCH] fix(rpc): dao hooks of `*_by` are missed --- kong/clustering/services/sync/hooks.lua | 15 ++++++++++++ .../09-hybrid_mode/01-sync_spec.lua | 23 ++++++++++--------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/kong/clustering/services/sync/hooks.lua b/kong/clustering/services/sync/hooks.lua index 8ae44ca062b7..929f02f028c2 100644 --- a/kong/clustering/services/sync/hooks.lua +++ b/kong/clustering/services/sync/hooks.lua @@ -180,6 +180,21 @@ function _M:register_dao_hooks() ["dao:upsert:pre"] = pre_hook_func, ["dao:upsert:fail"] = fail_hook_func, ["dao:upsert:post"] = post_hook_writer_func, + + -- dao:upsert_by + ["dao:upsert_by:pre"] = pre_hook_func, + ["dao:upsert_by:fail"] = fail_hook_func, + ["dao:upsert_by:post"] = post_hook_writer_func, + + -- dao:delete_by + ["dao:delete_by:pre"] = pre_hook_func, + ["dao:delete_by:fail"] = fail_hook_func, + ["dao:delete_by:post"] = post_hook_delete_func, + + -- dao:update_by + ["dao:update_by:pre"] = pre_hook_func, + ["dao:update_by:fail"] = fail_hook_func, + ["dao:update_by:post"] = post_hook_writer_func, } for ev, func in pairs(dao_hooks) do diff --git a/spec/02-integration/09-hybrid_mode/01-sync_spec.lua b/spec/02-integration/09-hybrid_mode/01-sync_spec.lua index f434f7c37531..283ed430c02a 100644 --- a/spec/02-integration/09-hybrid_mode/01-sync_spec.lua +++ b/spec/02-integration/09-hybrid_mode/01-sync_spec.lua @@ -12,9 +12,13 @@ local uuid = require("kong.tools.uuid").uuid local KEY_AUTH_PLUGIN -for _, inc_sync in ipairs { "on", "off" } do +for _, inc_sync in ipairs { "on" } do for _, strategy in helpers.each_strategy() do +--- XXX FIXME: enable inc_sync = on +-- skips the rest of the tests. We will fix them in a follow-up PR +local skip_inc_sync = inc_sync == "on" and pending or describe + describe("CP/DP communication #" .. strategy .. " inc_sync=" .. inc_sync, function() lazy_setup(function() @@ -623,11 +627,7 @@ describe("CP/DP #version check #" .. strategy, function() end) end) ---- XXX FIXME: enable inc_sync = on --- skips the rest of the tests. We will fix them in a follow-up PR -local skip_inc_sync = inc_sync == "on" and pending or describe - -skip_inc_sync("CP/DP config sync #" .. strategy, function() +describe("CP/DP config sync #" .. strategy, function() lazy_setup(function() helpers.get_db_utils(strategy) -- runs migrations @@ -776,14 +776,15 @@ skip_inc_sync("CP/DP labels #" .. strategy, function() describe("status API", function() it("shows DP status", function() - helpers.wait_until(function() - local admin_client = helpers.admin_client() - finally(function() - admin_client:close() - end) + local admin_client = helpers.admin_client() + finally(function() + admin_client:close() + end) + helpers.wait_until(function() local res = assert(admin_client:get("/clustering/data-planes")) local body = assert.res_status(200, res) + print(body) local json = cjson.decode(body) for _, v in pairs(json.data) do