Skip to content

Add streaming support for trlp metric tests#793

Merged
emmaaroche merged 1 commit intoKuadrant:mainfrom
emmaaroche:trlp-metrics-stream-support
Oct 17, 2025
Merged

Add streaming support for trlp metric tests#793
emmaaroche merged 1 commit intoKuadrant:mainfrom
emmaaroche:trlp-metrics-stream-support

Conversation

@emmaaroche
Copy link
Copy Markdown
Contributor

@emmaaroche emmaaroche commented Oct 16, 2025

Description

This PR adds a new module (test_trlp_metrics_stream.py) to validate trlp metrics when using streaming (stream=True).
The tests mirror the existing non-streaming ones and verify that metrics such as authorized_hits, authorized_calls, and limited_calls are correctly emitted and labeled for streaming requests.

Why tests are in a separate module?
Although the logic is the same, streaming and non-streaming tests can’t be safely parameterized together because Prometheus counters are cumulative, and running both modes in parametrized tests caused inconsistent token counts and cross-test interference, leading to test failures.

Change Summary

  • Added test_trlp_metrics_stream.py with streaming request handling (parse_streaming_usage, extract_usage_tokens)
  • Added theUSERS and MODEL_NAME variables and theuser_data fixture to conftest as it is now shared across both tests

Closes Kuadrant/kuadrant-operator#1627

Signed-off-by: emmaaroche <eroche@redhat.com>
@emmaaroche emmaaroche requested a review from trepel October 16, 2025 08:15
@emmaaroche emmaaroche self-assigned this Oct 16, 2025
@emmaaroche emmaaroche added enhancement Improvement to existing test Test case New test case labels Oct 16, 2025
Copy link
Copy Markdown
Contributor

@trepel trepel left a comment

Choose a reason for hiding this comment

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

Nice work! LGTM, just two questions, but it's for me to explain rather than suggestions to change something.

@emmaaroche emmaaroche merged commit fb27809 into Kuadrant:main Oct 17, 2025
3 checks passed
@emmaaroche emmaaroche deleted the trlp-metrics-stream-support branch October 17, 2025 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improvement to existing test Test case New test case

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add stream request support to the TRLP metric tests

2 participants