refactor: rewrite staging API tester in Go - #5897
Open
michaelkedar wants to merge 3 commits into
Open
Conversation
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.
This PR migrates the
staging_api_testservice from Python (gcp/workers/staging_api_test/) to Go (go/cmd/staging_api_test/), aligning it with the ongoing Python-to-Go migration across the repository.Key Changes
Go Implementation (
go/cmd/staging_api_test/):loader.go: Downloads and directly processesall.zip(from GCS or local path) in memory/stream, extracting lightweight records (SimpleVuln) and partitioning query pools (VulnQueryIDs,PackageQueryIDs, andLargeBatchQueryIDs)without creating temporary JSON shards on disk.
generator.go: High-performance, concurrent traffic generator with:/v1/vulns/{id},/v1/query(package, version, PURL), and standard/large/v1/querybatchrequests.http.Transportwith HTTP/2, connection pooling, and response body draining.GeneratorStats).main.go: CLI flags with environment variable fallbacks, signal-based graceful shutdown (SIGINT/SIGTERM), and structured logging.loader_test.goandgenerator_test.gocovering payload builders, zip extraction, edge cases, and traffic generator lifecycles.Build & Deployment:
go/Dockerfile: Addedstaging-api-testmulti-stage build target using distroless Debian 12.deployment/build-and-stage.yaml: Updated Cloud Build steps to buildstaging-api-testfromgo/Dockerfileusing BuildKit with--build-context bindings=../bindings.gcp/workers/staging_api_test/.Verification
go test -race -v ./cmd/staging_api_test/...make go-testspoetry run tools/lint_and_format.shagy
gemini sure is wordy...