Repository navigation
fix(googlecloudcommon): use 1m timeout context and assert on expiration in TestLogFetcherImpl_FetchLogs - #1006
Merged
Conversation
…on in TestLogFetcherImpl_FetchLogs
Contributor
There was a problem hiding this comment.
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
enabled auto-merge
September 15, 2026 08:16
Merged
via the queue into
GoogleCloudPlatform:main
with commit Sep 15, 2026
513082e
17 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In
pkg/task/inspection/googlecloudcommon/contract/logfetcher_test.go, increases the timeout inTestLogFetcherImpl_FetchLogsto 1 minute viacontext.WithTimeoutand adds an explicit assertion on context expiration to avoid false-positive passes and prevent test flakiness in CI.Details
context.WithCancelwithcontext.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.case <-ctx.Done():explicitly callst.Errorf("no logs returned before context timeout: %v", ctx.Err())so the test fails deterministically if no log entry is received before the timeout.fetcher.FetchLogsto ignorecontext.DeadlineExceededin addition tocontext.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_FetchLogspassed cleanly.go test -race ./pkg/task/inspection/googlecloudcommon/contract -run TestLogFetcherImpl_FetchLogspassed with 0 data races.make test-gopassed across backend.make lint-gopassed with 0 issues.make pre-commitpassed cleanly.khi-go-reviewer,khi-naming-reviewer,khi-deadcode-reviewer,khi-test-reviewer) all approved with 0 findings.