test(debuginfo): add unit tests for debug info store and upload reader#4896
Merged
korniltsev-grafanista merged 7 commits intoMar 13, 2026
Conversation
Cover the store logic (ValidateGnuBuildID, validateInit, NewStore, shouldInitiateUpload, uploadIsStale, fetchMetadata, writeMetadata, ObjectPath, MetadataObjectPath) and the chunked upload reader (Read, Size, context cancellation) with ~43 test cases across two new test files. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The base branch (debuginfo-upload) uses GnuBuildId and FileMetadata_TYPE_* naming in the generated protobuf, while this worktree had a divergent proto with GNU and DEBUGINFO_TYPE_* names. Align the test file with the base branch so CI compiles correctly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Align struct field formatting to pass gofmt check in CI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add TestUploadE2E with three subtests that exercise the full Upload bidi streaming RPC over a real HTTP/2 test server with connect client: - full upload flow: init -> chunks -> verify stored data and metadata - already uploaded: pre-populate metadata, verify service declines upload - disabled service: verify service returns ReasonDisabled Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
BidiStream requires HTTP/2. Switch from h2c (cleartext) to TLS via StartTLS() which negotiates HTTP/2 through ALPN. Remove unused h2c and http2 imports. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…d state bug - Align store.go with base branch protobuf field names (GnuBuildId, TYPE_EXECUTABLE_FULL/NO_TEXT) and use connect.NewError instead of grpc status.Error - Add missing md.State = STATE_UPLOADED after successful upload - Fix e2e test to wait for server handler completion by calling Receive() after CloseRequest() before checking bucket contents Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
korniltsev-grafanista
approved these changes
Mar 13, 2026
afe536a
into
grafana:debuginfo-upload
22 of 24 checks passed
korniltsev-grafanista
added a commit
that referenced
this pull request
Mar 13, 2026
* parca symbol upload * test: add symbolizer test for parca bucket debuginfo source Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add debug logging to debuginfo upload Add debug-level logging to help troubleshoot debuginfo upload issues: - Log ShouldInitiateUpload results (build_id, decision, reason) - Log Upload gRPC results (success with size, or failure with error) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Remove debuginfod support from parca/debuginfo package Debuginfod fetching is now handled in the symbolizer instead of in the parca debuginfo store. This removes the debuginfod client implementation, related tests, and test fixtures from the parca/debuginfo package. Also removes tenant ID handling from the debuginfo store since it's not needed for this use case. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: use HTTP/2 with AuthenticateUser middleware in debuginfo store test Refactor the store test to use an HTTP/2 server with h2c and the util.AuthenticateUser middleware instead of a direct gRPC server. This better reflects the production setup where requests go through HTTP middleware for tenant authentication. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * make go/mod * make fmt * Update pkg/parca/debuginfo/metadata.go Co-authored-by: Marc Sanmiquel <marcsanmiquel@gmail.com> * remove writepath options from the new debuginfo handlers * level.Error * cleanup * remove cache * init * add gopclntab * integrate lidia * add test for gopclntab-only symbol resolution Test creates a lidia table from /proc/self/exe using only gopclntab (symtab disabled), then resolves the test function's own address and verifies the name matches. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * lint * disable unused linter for pclntab.go Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * new file name for lidia files with gopclntab support * improve error logging * increase upload size * dont use parca * dont use parca * generate * generate * revert changes * revert changes * revert changes * revert changes * todo * revert change * fix symbolizer tests after New() signature change Remove parcaBucket parameter from test helper and all callers after the symbolizer was refactored to use a single bucket for both lidia and parca debug info storage. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * rename debuginfo API package to v1alpha1 to mark as experimental Move proto package from debuginfo.v1 to debuginfo.v1alpha1 and update all generated code and consumer imports accordingly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * revert lidia change * address PR review comments: proto naming, state bug, error type, rename - Rename proto fields to snake_case (gnu_build_id, go_build_id, otel_file_id) - Rename enum DebuginfoType → Type, add TYPE_UNSPECIFIED, fix prefix - Fix bug: set STATE_UPLOADED after upload completes - Replace gRPC status.Error with connect.NewError for consistency - Rename fetchFromParca → fetchFromUploadedDebugInfo - Revert ProcessELFData back to private method on Symbolizer Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * cleanup * test(debuginfo): add unit tests for debug info store and upload reader (#4896) * add unit tests for debuginfo service Cover the store logic (ValidateGnuBuildID, validateInit, NewStore, shouldInitiateUpload, uploadIsStale, fetchMetadata, writeMetadata, ObjectPath, MetadataObjectPath) and the chunked upload reader (Read, Size, context cancellation) with ~43 test cases across two new test files. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix store_test.go to use base branch protobuf field names The base branch (debuginfo-upload) uses GnuBuildId and FileMetadata_TYPE_* naming in the generated protobuf, while this worktree had a divergent proto with GNU and DEBUGINFO_TYPE_* names. Align the test file with the base branch so CI compiles correctly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix gofmt alignment in store_test.go Align struct field formatting to pass gofmt check in CI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * add end-to-end connect client tests for debuginfo Upload RPC Add TestUploadE2E with three subtests that exercise the full Upload bidi streaming RPC over a real HTTP/2 test server with connect client: - full upload flow: init -> chunks -> verify stored data and metadata - already uploaded: pre-populate metadata, verify service declines upload - disabled service: verify service returns ReasonDisabled Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * remove unused net/http import from store_test.go Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix e2e test to use TLS for HTTP/2 bidi streaming BidiStream requires HTTP/2. Switch from h2c (cleartext) to TLS via StartTLS() which negotiates HTTP/2 through ALPN. Remove unused h2c and http2 imports. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix store.go and e2e test: align with base branch protobuf, fix upload state bug - Align store.go with base branch protobuf field names (GnuBuildId, TYPE_EXECUTABLE_FULL/NO_TEXT) and use connect.NewError instead of grpc status.Error - Add missing md.State = STATE_UPLOADED after successful upload - Fix e2e test to wait for server handler completion by calling Receive() after CloseRequest() before checking bucket contents Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix proto formatting (buf format) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address remaining PR review comments - Fix wrong error messages: "init.FileData" → "init.File" to match actual field name - Enforce MaxUploadSize in UploadReader to prevent unlimited chunked uploads - Tenant-isolate lidia cache paths to prevent cross-tenant cache poisoning Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address Cursor BugBot review comments - Use path.Join instead of filepath.Join in lidiaObjectPath for OS-independent object storage keys - Restore tenant-scoped not-found cache in getLidiaBytes to reduce redundant object storage lookups for unknown build IDs - Extract MaxSizeReader from UploadReader into a composable wrapper - Handle simultaneous data+EOF in UploadReader.Read per io.Reader contract - Revert debug-specific IDE run configuration changes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: remove MaxSizeReader, enforce size limits at upload and read sites - Remove MaxSizeReader wrapper; check r.Size() after upload and delete oversized objects in store.go - Remove duplicate not-found cache in symbolizer (debuginfod client already caches not-found build IDs) - Bound io.ReadAll in fetchLidiaFromDebuginfod with readAllWithLimit to enforce SymbolizerMaxSymbolSizeBytes for uploaded debug-info files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Marc Sanmiquel <marcsanmiquel@gmail.com> Co-authored-by: Tolya Korniltsev YOLO vibecoder <anatoly.korniltsev+githubvibecoder@grafana.com>
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
Adds comprehensive unit tests for the new debug info service (
pkg/debuginfo/), which previously had zero test coverage.pkg/debuginfo/store_test.go— 9 test functions (~30 subtests) covering the store logicpkg/debuginfo/reader/reader_test.go— 4 test functions (~13 subtests) covering the chunked upload readerWhat's Tested
Store (
store_test.go)ValidateGnuBuildID— regex boundary validation (min/max length, valid/invalid hex chars)validateInit— init message validation (nil checks, debuginfo type validation, build ID propagation)NewStore— constructor validation (bucket required when enabled, optional when disabled)ObjectPath/MetadataObjectPath— path construction for object storageshouldInitiateUpload— full state machine coverage (first-time, stale upload retry, in-progress, already exists, unknown state error)uploadIsStale— staleness threshold boundary cases (startedAt + MaxUploadDuration + 2min)fetchMetadata— bucket reads (not-found → nil, valid protojson, corrupt data → error)writeMetadata— bucket writes and write-then-fetch round-tripUpload Reader (
reader/reader_test.go)Read— single/multiple chunks, empty streams, small buffers, error propagationSize— incremental byte trackingio.ReadAllintegrationApproach
memory.NewInMemBucket()(in-memory object storage) for real bucket behavior rather than mockst.Parallel()and table-driven patterns per project conventionsUpload()streaming handler is not directly tested since it takes a concrete*connect.BidiStreamtype; instead, all its constituent helper functions are tested individually🤖 Generated with Claude Code
Note
Medium Risk
Mostly adds tests, but it also changes the
Store.Uploadpath (error type, proto field names, and explicitly marking metadataSTATE_UPLOADED), which could affect client-visible behavior and upload state transitions.Overview
Adds extensive new test coverage for the debug info subsystem, including unit tests for the chunked
UploadReader(chunk boundaries, buffering, size tracking, and context cancellation) and forStorehelpers (build-id/init validation, staleness decisions, object paths, and metadata read/write).Updates
Store.Uploadto use the renamed proto fields/enums (GnuBuildId,FileMetadata_TYPE_*), returnconnect.NewError(connect.CodeInternal, ...)instead of gRPCstatuserrors, and to set uploaded metadata toSTATE_UPLOADEDafter a successful bucket upload.Written by Cursor Bugbot for commit df0e8eb. This will update automatically on new commits. Configure here.