Skip to content

test(intake): derive chat-completions fixture created from now#321

Merged
svvarom merged 2 commits into
mainfrom
fix-chat-completions-ingest-test-lookback/smuley
Jun 12, 2026
Merged

test(intake): derive chat-completions fixture created from now#321
svvarom merged 2 commits into
mainfrom
fix-chat-completions-ingest-test-lookback/smuley

Conversation

@svvarom

@svvarom svvarom commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

What

Replace the fixed created: 1778698885 (2026-05-13T19:01:25Z) in the chat-completions ingest test factory with int(time.time()).

Why

The ingest endpoint maps response.created to span started_at, and the spans/traces list endpoints default started_at_gte to now−30d. At 2026-06-12T19:01Z the fixture crossed that boundary and every list read-back in the file started returning empty — 8 of 16 tests failing (IndexError on data[0] or length asserts). The one read-back test without a created field kept passing because ingest falls back to ingested_at.

Same failure class as #174. That PR pinned reads with an explicit filter[started_at][gte] because ATIF step timestamps are part of the payload format under test; here created is incidental (no assertion reads it back), so deriving it from now is a one-line fix and keeps the tests exercising the default read path. The OTLP conftest in this suite already derives span times from now().

Dedupe/hash-fallback tests are unaffected: each reuses a single body dict within the test, so both POSTs carry the same created.

Verification

uv run --frozen pytest services/intake/tests/integration/spans/test_chat_completions_ingest.py -v — 16 passed (8 failed before).

Swept intake tests for other fixed timestamps exposed to the lookback: test_evaluator_results_atif.py reads back via the evaluator-results endpoint (no lookback default); test_atif_ingest.py reads were already pinned by #174.

Summary by CodeRabbit

  • Tests
    • Updated integration test data generation to ensure test spans remain within expected lookback windows.

The _openai_response() factory hardcoded created=1778698885
(2026-05-13T19:01:25Z). Ingest maps response.created to span started_at,
and the spans/traces list endpoints default to a 30-day lookback, so on
2026-06-12T19:01Z the fixture aged out and every list read-back in the
file returned empty — 8 of 16 tests failing. Same class of breakage as
PR #174.

Derive created from time.time() so spans always land inside the lookback.

Signed-off-by: Swarom Muley <smuley@nvidia.com>
@svvarom
svvarom requested review from a team as code owners June 12, 2026 21:37
@github-actions github-actions Bot added the test conventional-commit type label Jun 12, 2026
@svvarom svvarom changed the title test(intake): stabilize chat-completions ingest tests against the 30-day read lookback test(intake): derive chat-completions fixture created from now Jun 12, 2026
@svvarom svvarom self-assigned this Jun 12, 2026
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 99047239-e109-4915-b7dc-3fa82680c74e

📥 Commits

Reviewing files that changed from the base of the PR and between fc132aa and 6fea13e.

📒 Files selected for processing (1)
  • services/intake/tests/integration/spans/test_chat_completions_ingest.py

📝 Walkthrough

Walkthrough

The OpenAI chat completions integration test fixture now generates its mocked response created timestamp dynamically using current time instead of a fixed historical value. This prevents derived span start times from being filtered out by the spans/traces list endpoints' default lookback window during test execution.

Changes

Test Fixture Timestamp Correction

Layer / File(s) Summary
Dynamic timestamp in OpenAI mock fixture
services/intake/tests/integration/spans/test_chat_completions_ingest.py
Import time module and update mocked OpenAI response fixture to set created to int(time.time()) with inline comments explaining the relationship between created, derived span start times, and list endpoint lookback aging.

Suggested reviewers

  • BrianNewsom
  • matthewgrossman
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title precisely describes the main change: replacing a fixed timestamp with a dynamic one to stabilize tests against the 30-day read lookback window.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-chat-completions-ingest-test-lookback/smuley

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 19033/25227 75.4% 61.4%
Integration Tests 11027/23999 46.0% 20.4%

@svvarom
svvarom added this pull request to the merge queue Jun 12, 2026
Merged via the queue into main with commit 3c35ea4 Jun 12, 2026
46 of 47 checks passed
@svvarom
svvarom deleted the fix-chat-completions-ingest-test-lookback/smuley branch June 12, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test conventional-commit type

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants