Skip to content

test(metrics): wait for observation after image job completion - #285

Open
excniesNIED wants to merge 1 commit into
astaxie:mainfrom
excniesNIED:fix/image-metrics-flaky-test
Open

test(metrics): wait for observation after image job completion#285
excniesNIED wants to merge 1 commit into
astaxie:mainfrom
excniesNIED:fix/image-metrics-flaky-test

Conversation

@excniesNIED

@excniesNIED excniesNIED commented Aug 22, 2026

Copy link
Copy Markdown

Summary

Fixes an intermittent flake in TestMetricsImageJobAttributesAttempts observed in CI.

CompleteImageJob commits the completed status to the store before observeGatewayCall publishes the request counters. The test polled only the job status and asserted the metrics immediately, so under CI load it could observe completed while the counters were still zero and fail with expected the image request to be counted once, got 0. The wait loop now also waits for the overhead series, the last one ObserveGatewayCall writes, so the assertions run after publication.

Related Issue

N/A (observed in CI on the implicit-TLS SMTP PR #271; split out to keep that PR scoped to notification channels)

Changes

  • TestMetricsImageJobAttributesAttempts now breaks the polling loop only when the job is completed and the overhead metrics series is published
  • Failed jobs still fail fast

Type of Change

  • Bug fix
  • Refactor or maintenance
  • Documentation
  • Deployment or configuration

Verification

  • go test ./internal/server/ -run TestMetricsImageJobAttributesAttempts -count=10 — passes
  • go test ./internal/server/ -race -run TestMetricsImageJobAttributesAttempts -count=8 — passes
  • go vet ./internal/server/ — clean
  • git diff --check — clean

Compatibility, Security, and Operations

None.

Checklist

  • The PR title and body are written in English.
  • Tests were added or updated for behavior changes, or the reason they are unnecessary is documented.
  • No credentials, local .env files, databases, backups, or runtime logs are included.
  • Environment variable changes are synchronized across examples, Compose, start.sh, and deployment documentation where applicable.
  • Shared user-facing behavior is documented consistently in English, Simplified Chinese, and Japanese where applicable.
  • data/model-catalog.yaml remains tracked and catalog changes were reviewed where applicable.
  • git diff --check passes.

CompleteImageJob commits the completed status before observeGatewayCall
publishes the counters, so polling only the job status raced the metrics
assertion and failed intermittently under CI load (got 0). Also wait for
the overhead series, the last one ObserveGatewayCall writes, so the
assertions run after publication.
Copilot AI balanced review requested due to automatic review settings August 22, 2026 07:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@astaxie astaxie left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Reviewed the complete diff at exact head 3678c56ffea200386b7c375474edf3e0f3f778c1. The test fix is focused and technically sound: it waits for the last collector written by ObserveGatewayCall after job completion while preserving immediate failure handling. The focused test passed 10 normal runs and 3 race-enabled runs locally; go vet ./internal/server/, git diff --check, and all GitHub CI checks are green.

Approval is blocked by the PR body not preserving .github/pull_request_template.md, as required by AGENTS.md. It currently omits Related Issue, Changes, Type of Change, Compatibility, Security, and Operations, and Checklist. Please restore every template section, mark this as a test/maintenance change, record the no-runtime-impact compatibility assessment, and complete the checklist (using explicit N/A explanations where appropriate).

@excniesNIED

Copy link
Copy Markdown
Author

PR body rewritten to follow .github/pull_request_template.md — all sections (Summary, Related Issue, Changes, Type of Change, Verification, Compatibility/Security/Operations, Checklist) restored, marked as refactor/maintenance with the checklist completed.

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.

3 participants