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 27b84116a3c8..5f96f2738506 100644 --- a/spec/02-integration/09-hybrid_mode/01-sync_spec.lua +++ b/spec/02-integration/09-hybrid_mode/01-sync_spec.lua @@ -260,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()