Stabilize the pod-count test (#94)#105
Open
e-300 wants to merge 2 commits into
Open
Conversation
Signed-off-by: Ebad Shahid <ebad@ebad.dev>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR rewrites the integration test for comparing pod counts between the Allocation API and Prometheus. It replaces a simple count comparison with a Jaccard overlap-based approach that includes retry logic, absolute time windows, and improved filtering.
Changes:
- Replaced strict pod-count equality checks with Jaccard overlap comparison (exact-match for small namespaces, ratio threshold for larger ones)
- Added retry logic (
maxResampleAttempts) with re-anchored absolute time windows to handle transient churn - Improved synthetic pod filtering from a hardcoded allowlist to suffix-based matching (
-unmounted-pvcs)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
19
to
+20
| ) | ||
| const ( |
Comment on lines
+75
to
+76
| endTime = time.Now().UTC().Truncate(time.Hour).Unix() | ||
| startTime = endTime - 86400 |
Member
Author
There was a problem hiding this comment.
Implemented single duration time window from tc.window
Comment on lines
+182
to
+187
| intersection := 0 | ||
| for _, p := range apiAgg.Pods { | ||
| if slices.Contains(promAgg.Pods, p) { | ||
| intersection++ | ||
| } | ||
| } |
Signed-off-by: Ebad Shahid <ebad@ebad.dev>
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.
Description
The pod-count test (
test/integration/query/count/allocation_running_pods_test.go) compares running pods per namespace from two independent sources (allocation API and Prometheus).The issue in the previous code was that both sources sampled the cluster at two different time windows.
Changes
endTimeis computed per attempt at a completed hour boundary; the API now uses an absolutewindow=start,end(verified to resolve to the exact requested interval) instead of the relative24hform that drifted to the request-processing instant. Prometheus continues to query at the sameendTime.overlapThreshold = 0.80) instead of exact counts. Namespaces below a size floor (minNamespacePods = 3) require sets to be equal. A namespace present in only one namespace would cause the test to fail.Related issues
Testing
Passed against the demo cluster, all namespaces with both sources sharing one window (e.g. kube-system 149/149).
Local k3d run is blocked (404 on
/allocation, no workloads).