Skip to content

fix(googlecloudcommon): use 1m timeout context and assert on expiration in TestLogFetcherImpl_FetchLogs - #1006

Merged
kyasbal merged 1 commit into
GoogleCloudPlatform:mainfrom
kyasbal:push-syqsqpzxpxzl
Sep 15, 2026
Merged

kyasbal merged 1 commit into
GoogleCloudPlatform:mainfrom
kyasbal:push-syqsqpzxpxzl

Conversation

@kyasbal

@kyasbal kyasbal commented Sep 15, 2026

Copy link
Copy Markdown
Member

Summary

In pkg/task/inspection/googlecloudcommon/contract/logfetcher_test.go, increases the timeout in TestLogFetcherImpl_FetchLogs to 1 minute via context.WithTimeout and adds an explicit assertion on context expiration to avoid false-positive passes and prevent test flakiness in CI.

Details

  1. Replaced the arbitrary 20-second timer and context.WithCancel with context.WithTimeout(t.Context(), 1*time.Minute). A 1-minute window provides a generous margin for transient Cloud Logging latency in CI environments while still failing promptly without waiting for the 10-minute test runner timeout.
  2. In the receiver goroutine, case <-ctx.Done(): explicitly calls t.Errorf("no logs returned before context timeout: %v", ctx.Err()) so the test fails deterministically if no log entry is received before the timeout.
  3. Updated the error check on fetcher.FetchLogs to ignore context.DeadlineExceeded in addition to context.Canceled, preventing duplicate redundant error reports when the receiver goroutine's timeout assertion triggers.

Verification

  • go test -v ./pkg/task/inspection/googlecloudcommon/contract -run TestLogFetcherImpl_FetchLogs passed cleanly.
  • go test -race ./pkg/task/inspection/googlecloudcommon/contract -run TestLogFetcherImpl_FetchLogs passed with 0 data races.
  • make test-go passed across backend.
  • make lint-go passed with 0 issues.
  • make pre-commit passed cleanly.
  • Subagent review suite (khi-go-reviewer, khi-naming-reviewer, khi-deadcode-reviewer, khi-test-reviewer) all approved with 0 findings.
@kyasbal kyasbal added type:bug Something isn't working as expected area:backend-parser Log parsers and log timeline mapper tasks labels Sep 15, 2026
@kyasbal
kyasbal requested review from K53 and renamoo as code owners September 15, 2026 08:12

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates the TestLogFetcherImpl_FetchLogs test in logfetcher_test.go to use a context with a 1-minute timeout instead of a manual 20-second timeout channel. It refactors the select block to listen to ctx.Done() and updates the error checking to ignore context.DeadlineExceeded in addition to context.Canceled. There are no review comments, and I have no feedback to provide.

@kyasbal
kyasbal enabled auto-merge September 15, 2026 08:16
@kyasbal
kyasbal added this pull request to the merge queue Sep 15, 2026
Merged via the queue into GoogleCloudPlatform:main with commit 513082e Sep 15, 2026
17 checks passed
@kyasbal
kyasbal deleted the push-syqsqpzxpxzl branch September 15, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend-parser Log parsers and log timeline mapper tasks type:bug Something isn't working as expected

1 participant