Skip to content

fix: fixing flaky test for debugtelemetry#722

Open
dietb wants to merge 2 commits intogoogle:mainfrom
dietb:fix/flaky-telemetry-tests
Open

fix: fixing flaky test for debugtelemetry#722
dietb wants to merge 2 commits intogoogle:mainfrom
dietb:fix/flaky-telemetry-tests

Conversation

@dietb
Copy link
Copy Markdown

@dietb dietb commented Apr 10, 2026

Problem:
Tests in adk/server/adkrest/internal/services around the debug telemetry are flaky due to non-deterministic (map-based) ordering.

Solution:
Added deterministic sorting to both cases before test assertions. Now both the expected (tt.wantSessionSpans/tt.wantEventSpans) and actual (gotSessionSpans/gotEventSpans) results are sorted by name before comparison.

Testing Plan

go test ./... -count=5?

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.
=== RUN   TestDebugTelemetryGetSpansBySessionID
=== RUN   TestDebugTelemetryGetSpansBySessionID/root_span_with_conversation_id
=== RUN   TestDebugTelemetryGetSpansBySessionID/child_span_with_conversation_id
=== RUN   TestDebugTelemetryGetSpansBySessionID/multiple_traces_with_same_session_id
=== RUN   TestDebugTelemetryGetSpansBySessionID/trace_with_spans_with_mixed_session_ids_session-1
=== RUN   TestDebugTelemetryGetSpansBySessionID/trace_with_spans_with_mixed_session_ids_session-2
=== RUN   TestDebugTelemetryGetSpansBySessionID/no_matching_session_id
=== RUN   TestDebugTelemetryGetSpansBySessionID/log_without_span
--- PASS: TestDebugTelemetryGetSpansBySessionID (0.00s)
    --- PASS: TestDebugTelemetryGetSpansBySessionID/root_span_with_conversation_id (0.00s)
    --- PASS: TestDebugTelemetryGetSpansBySessionID/child_span_with_conversation_id (0.00s)
    --- PASS: TestDebugTelemetryGetSpansBySessionID/multiple_traces_with_same_session_id (0.00s)
    --- PASS: TestDebugTelemetryGetSpansBySessionID/trace_with_spans_with_mixed_session_ids_session-1 (0.00s)
    --- PASS: TestDebugTelemetryGetSpansBySessionID/trace_with_spans_with_mixed_session_ids_session-2 (0.00s)
    --- PASS: TestDebugTelemetryGetSpansBySessionID/no_matching_session_id (0.00s)
    --- PASS: TestDebugTelemetryGetSpansBySessionID/log_without_span (0.00s)
=== RUN   TestDebugTelemetryGetSpansByEventID
=== RUN   TestDebugTelemetryGetSpansByEventID/single_span_and_log
=== RUN   TestDebugTelemetryGetSpansByEventID/multiple_spans
=== RUN   TestDebugTelemetryGetSpansByEventID/no_matching_span
=== RUN   TestDebugTelemetryGetSpansByEventID/log_without_span
--- PASS: TestDebugTelemetryGetSpansByEventID (0.00s)
    --- PASS: TestDebugTelemetryGetSpansByEventID/single_span_and_log (0.00s)
    --- PASS: TestDebugTelemetryGetSpansByEventID/multiple_spans (0.00s)
    --- PASS: TestDebugTelemetryGetSpansByEventID/no_matching_span (0.00s)
    --- PASS: TestDebugTelemetryGetSpansByEventID/log_without_span (0.00s)
=== RUN   TestDebugTelemetryLRU
--- PASS: TestDebugTelemetryLRU (0.00s)
PASS

Manual End-to-End (E2E) Tests:

This PR is for test cases only.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant