From e967fe2d9277626e9e7416b774ecce3cd4275d08 Mon Sep 17 00:00:00 2001 From: Kong Team Gateway Bot <98048765+team-gateway-bot@users.noreply.github.com> Date: Fri, 23 Aug 2024 21:49:27 +0200 Subject: [PATCH] tests(ai-plugins): fix flaky latency assertion (part 2) (#13560) (#13569) Applies the same fix as 58c580f420 to similar tests. (cherry picked from commit a631c3f2731890633668cedb50978d15064a7039) Co-authored-by: Michael Martin --- spec/03-plugins/38-ai-proxy/02-openai_integration_spec.lua | 6 +++--- .../39-ai-request-transformer/02-integration_spec.lua | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/03-plugins/38-ai-proxy/02-openai_integration_spec.lua b/spec/03-plugins/38-ai-proxy/02-openai_integration_spec.lua index d62e9de9fe..3e2e98829d 100644 --- a/spec/03-plugins/38-ai-proxy/02-openai_integration_spec.lua +++ b/spec/03-plugins/38-ai-proxy/02-openai_integration_spec.lua @@ -833,7 +833,7 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then first_got.usage.time_per_token = 1 assert.same(first_expected, first_got) - assert.is_true(actual_llm_latency > 0) + assert.is_true(actual_llm_latency >= 0) assert.same(actual_time_per_token, time_per_token) end) @@ -1409,7 +1409,7 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then }, body = pl_file.read("spec/fixtures/ai-proxy/openai/llm-v1-chat/requests/good_multi_modal.json"), }) - + -- validate that the request succeeded, response status 200 local body = assert.res_status(200 , r) local json = cjson.decode(body) @@ -1444,7 +1444,7 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then first_got.usage.time_per_token = 1 assert.same(first_expected, first_got) - assert.is_true(actual_llm_latency > 0) + assert.is_true(actual_llm_latency >= 0) assert.same(actual_time_per_token, time_per_token) end) diff --git a/spec/03-plugins/39-ai-request-transformer/02-integration_spec.lua b/spec/03-plugins/39-ai-request-transformer/02-integration_spec.lua index 9598bab7f5..40989e3522 100644 --- a/spec/03-plugins/39-ai-request-transformer/02-integration_spec.lua +++ b/spec/03-plugins/39-ai-request-transformer/02-integration_spec.lua @@ -307,7 +307,7 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then log_message.ai["ai-request-transformer"].usage.time_per_token = 1 assert.same(_EXPECTED_CHAT_STATS, log_message.ai) - assert.is_true(actual_llm_latency > 0) + assert.is_true(actual_llm_latency >= 0) assert.same(actual_time_per_token, time_per_token) end)