Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests(ai-plugins): fix flaky latency assertion (part 2) #13560

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

flrgh
Copy link
Contributor

@flrgh flrgh commented Aug 23, 2024

Applies the same fix as 58c580f (#13558) to similar tests.

KAG-5251

@github-actions github-actions bot added the cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee label Aug 23, 2024
@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is these any possible equal to 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This latency is calculated with ngx.now() and not any monotonic time source, so it's always possible for it to be 0, especially in tests where things are mocked/no actual proxying happens.

kong.ctx.plugin[start_time_key] = ngx.now()

local llm_latency = math.floor((ngx.now() - kong.ctx.plugin[start_time_key]) * 1000)

Applies the same fix as 58c580f to similar tests.
@Hayk-S Hayk-S merged commit a631c3f into master Aug 23, 2024
29 checks passed
@Hayk-S Hayk-S deleted the tests/ai-plugin-latency branch August 23, 2024 19:06
github-actions bot pushed a commit that referenced this pull request Aug 23, 2024
Applies the same fix as 58c580f to similar tests.

(cherry picked from commit a631c3f)
@team-gateway-bot
Copy link
Collaborator

Successfully created backport PR for release/3.8.x:

@team-gateway-bot
Copy link
Collaborator

Successfully created cherry-pick PR for master:

flrgh added a commit that referenced this pull request Aug 23, 2024
)

Applies the same fix as 58c580f to similar tests.

(cherry picked from commit a631c3f)

Co-authored-by: Michael Martin <flrgh@protonmail.com>
curiositycasualty pushed a commit that referenced this pull request Oct 15, 2024
Applies the same fix as 58c580f to similar tests.

(cherry picked from commit a631c3f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport release/3.8.x cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee size/XS skip-changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants