Skip to content

chore: speed up Go tests and fix Datastore emulator leaks - #6231

Merged
michaelkedar merged 1 commit into
google:masterfrom
michaelkedar:chore/go-test-improvements
Oct 26, 2026
Merged

michaelkedar merged 1 commit into
google:masterfrom
michaelkedar:chore/go-test-improvements

Conversation

@michaelkedar

Copy link
Copy Markdown
Member

Speeds up local and CI Go test execution and fixes leaked Datastore emulator processes:

  • Fix Datastore emulator lifecycle and process leaks (go/testutils/datastore.go):
    • Previously, StartDatastoreEmulator(t) registered t.Cleanup inside sync.Once, which ran after the first test function finished and only killed the parent gcloud Python process—leaving the child bash wrapper and java CloudFirestore emulator running as orphaned background processes after go test exited.
    • Replaced StartDatastoreEmulator(t) with RunWithDatastoreEmulator(m *testing.M) (called from TestMain in cmd/relations, internal/database/datastore, and internal/recoverer), running the emulator in its own process group (Setpgid: true) so the entire process tree is cleanly terminated when the package tests finish.
    • Switched the readiness check from raw TCP net.DialTimeout to HTTP GET / (200 OK) and added a request timeout to resetEmulator so POST /reset cannot hang before Jetty's HTTP handler is ready.
  • Remove dead go/internal/repos package:
    • go/internal/repos was unused across the codebase and was the sole importer of github.com/go-git/go-git/v6 (and 9 transitive dependencies) in go/go.mod.
  • Disable go-vcr replay latency simulation:
    • Added recorder.WithSkipRequestLatency(true) in go/testutils/vcr.go and vulnfeeds/internal/testutils/testutils.go so VCR cassette tests don't sleep for recorded HTTP response durations during replay (dropping go/osv/ecosystem from ~6.8s to ~0.17s).
  • Speed up Cloud Build Go test runners:
    • Set machineType: E2_HIGHCPU_8 in go/cloudbuild.yaml and vulnfeeds/cloudbuild.yaml (matching osv/cloudbuild.yaml) instead of the default 1-vCPU e2-medium VM.
    • Bumped docker/ci/install_go.sh to go1.27.1 to match go.mod.

agy

@michaelkedar
michaelkedar requested review from a team and Ly-Joey October 26, 2026 04:55
@michaelkedar
michaelkedar merged commit 3792aef into google:master Oct 26, 2026
24 checks passed
@michaelkedar
michaelkedar deleted the chore/go-test-improvements branch October 26, 2026 04:58
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.

2 participants