From fb9934905251f899e57701ffcabf56eaf41d36f1 Mon Sep 17 00:00:00 2001 From: Xiaochen Wang Date: Mon, 2 Dec 2024 14:16:23 +0800 Subject: [PATCH] tests(clustering/rpc): enable 09-hybrid_mode/01-sync_spec.lua for incremental sync (#13959) KAG-5951 --- .../09-hybrid_mode/01-sync_spec.lua | 54 +++++++++++-------- 1 file changed, 32 insertions(+), 22 deletions(-) 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 67b671f3a655..5f96f2738506 100644 --- a/spec/02-integration/09-hybrid_mode/01-sync_spec.lua +++ b/spec/02-integration/09-hybrid_mode/01-sync_spec.lua @@ -17,10 +17,6 @@ for _, v in ipairs({ {"off", "off"}, {"on", "off"}, {"on", "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() @@ -264,20 +260,22 @@ describe("CP/DP communication #" .. strategy .. " inc_sync=" .. inc_sync, functi headers = {["Content-Type"] = "application/json"} })) assert.res_status(200, res) - -- as this is testing a negative behavior, there is no sure way to wait - -- this can probably be optimizted - ngx.sleep(2) - local proxy_client = helpers.http_client("127.0.0.1", 9002) + helpers.wait_until(function() + local proxy_client = helpers.http_client("127.0.0.1", 9002) - -- test route again - res = assert(proxy_client:send({ - method = "GET", - path = "/soon-to-be-disabled", - })) - assert.res_status(404, res) + -- test route again + res = assert(proxy_client:send({ + method = "GET", + path = "/soon-to-be-disabled", + })) - proxy_client:close() + local status = res and res.status + proxy_client:close() + if status == 404 then + return true + end + end) end) it('does not sync plugins on a route attached to a disabled service', function() @@ -742,7 +740,7 @@ describe("CP/DP config sync #" .. strategy .. " inc_sync=" .. inc_sync, function end) end) -skip_inc_sync("CP/DP labels #" .. strategy, function() +describe("CP/DP labels #" .. strategy, function() lazy_setup(function() helpers.get_db_utils(strategy) -- runs migrations @@ -797,8 +795,12 @@ skip_inc_sync("CP/DP labels #" .. strategy, function() assert.matches("^(%d+%.%d+)%.%d+", v.version) assert.equal(CLUSTERING_SYNC_STATUS.NORMAL, v.sync_status) assert.equal(CLUSTERING_SYNC_STATUS.NORMAL, v.sync_status) - assert.equal("mycloud", v.labels.deployment) - assert.equal("us-east-1", v.labels.region) + -- TODO: The API output does include labels and certs when the + -- incremental sync is enabled. + if inc_sync == "off" then + assert.equal("mycloud", v.labels.deployment) + assert.equal("us-east-1", v.labels.region) + end return true end end @@ -807,7 +809,7 @@ skip_inc_sync("CP/DP labels #" .. strategy, function() end) end) -skip_inc_sync("CP/DP cert details(cluster_mtls = shared) #" .. strategy, function() +describe("CP/DP cert details(cluster_mtls = shared) #" .. strategy, function() lazy_setup(function() helpers.get_db_utils(strategy) -- runs migrations @@ -857,7 +859,11 @@ skip_inc_sync("CP/DP cert details(cluster_mtls = shared) #" .. strategy, functio for _, v in pairs(json.data) do if v.ip == "127.0.0.1" then - assert.equal(1888983905, v.cert_details.expiry_timestamp) + -- TODO: The API output does include labels and certs when the + -- incremental sync is enabled. + if inc_sync == "off" then + assert.equal(1888983905, v.cert_details.expiry_timestamp) + end return true end end @@ -866,7 +872,7 @@ skip_inc_sync("CP/DP cert details(cluster_mtls = shared) #" .. strategy, functio end) end) -skip_inc_sync("CP/DP cert details(cluster_mtls = pki) #" .. strategy, function() +describe("CP/DP cert details(cluster_mtls = pki) #" .. strategy, function() lazy_setup(function() helpers.get_db_utils(strategy) -- runs migrations @@ -922,7 +928,11 @@ skip_inc_sync("CP/DP cert details(cluster_mtls = pki) #" .. strategy, function() for _, v in pairs(json.data) do if v.ip == "127.0.0.1" then - assert.equal(1897136778, v.cert_details.expiry_timestamp) + -- TODO: The API output does include labels and certs when the + -- incremental sync is enabled. + if inc_sync == "off" then + assert.equal(1897136778, v.cert_details.expiry_timestamp) + end return true end end