test: add comprehensive integration tests for label mapping validation#135
Merged
test: add comprehensive integration tests for label mapping validation#135
Conversation
Add integration tests that would have caught the label mapping issues we
experienced. These tests verify:
1. **Full Integration Test**: Tests the complete collection flow with mock
GHCR API responses to ensure metrics are created with correct labels
without panicking.
2. **Label Consistency Test**: Tests all metrics individually to verify
that the labels used in With(prometheus.Labels{}) calls match the
metric definitions exactly.
3. **Error Handling Test**: Tests error scenarios to ensure they don't
cause label mapping panics.
These tests would have caught the 'repo' vs 'name' label mapping bug
that caused the panic: label name "repo" missing in label map
The tests use testutil.ToFloat64() to verify metrics are created
successfully, which will panic if labels don't match metric definitions.
This provides a safety net for future refactoring and ensures label
mapping issues are caught before deployment.
53683b6 to
43d929d
Compare
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.
Add integration tests that would have caught the label mapping issues we experienced. These tests verify:
Full Integration Test: Tests the complete collection flow with mock GHCR API responses to ensure metrics are created with correct labels without panicking.
Label Consistency Test: Tests all metrics individually to verify that the labels used in With(prometheus.Labels{}) calls match the metric definitions exactly.
Error Handling Test: Tests error scenarios to ensure they don't cause label mapping panics.
These tests would have caught the 'repo' vs 'name' label mapping bug that caused the panic: label name "repo" missing in label map
The tests use testutil.ToFloat64() to verify metrics are created successfully, which will panic if labels don't match metric definitions.
This provides a safety net for future refactoring and ensures label mapping issues are caught before deployment.