From dbc9e8a730aab282bad90a453d1a10162f1220b5 Mon Sep 17 00:00:00 2001 From: Qi Date: Fri, 17 Jan 2025 10:09:45 +0800 Subject: [PATCH] tests(correlation-id): fix flaky test (#14176) KAG-6207 --- .../11-correlation-id/02-schema_spec.lua | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/spec/03-plugins/11-correlation-id/02-schema_spec.lua b/spec/03-plugins/11-correlation-id/02-schema_spec.lua index e5aa7c3035e5..0dae3607c482 100644 --- a/spec/03-plugins/11-correlation-id/02-schema_spec.lua +++ b/spec/03-plugins/11-correlation-id/02-schema_spec.lua @@ -102,9 +102,9 @@ describe("Plugin: correlation-id (schema) #a [#" .. strategy .."]", function() }, } local sql = render([[ - UPDATE plugins SET route_id='$(ROUTE_ID)', - protocols=ARRAY['grpc','grpcs','http','https'], - cache_key='$(CACHE_KEY)' + UPDATE plugins SET route_id='$(ROUTE_ID)', + protocols=ARRAY['grpc','grpcs','http','https'], + cache_key='$(CACHE_KEY)' WHERE id='$(ID)'; COMMIT; ]], { @@ -174,16 +174,19 @@ describe("Plugin: correlation-id (schema) #a [#" .. strategy .."]", function() assert.equals("uuid#counter", res.config.generator) local proxy_client = helpers.proxy_client(20000, 9002, "127.0.0.1") - res = assert(proxy_client:send { - method = "GET", - path = "/", - headers = { - ["Host"] = "example.com", - } - }) - assert.res_status(200, res) - assert.is_not_nil(res.headers["Kong-Request-ID"]) + helpers.pwait_until(function() + res = assert(proxy_client:send { + method = "GET", + path = "/", + headers = { + ["Host"] = "example.com", + } + }) + assert.res_status(200, res) + assert.is_not_nil(res.headers["Kong-Request-ID"]) + end, 10) proxy_client:close() + end) end) end -- for rpc_sync