-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: testsets failing because of noisy fields with skip-app-restart flag #3300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v2
Are you sure you want to change the base?
Conversation
…app-restart flag Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a critical bug where test sets were failing due to mutation of the global noise configuration when the skip-app-restart flag is enabled. The issue occurred because the LeftJoinNoise function was modifying the original globalNoise map, causing noise configurations to accumulate across test sets.
Key Changes:
- Refactored
LeftJoinNoiseto perform deep copying of the global noise configuration before merging test-set specific noise - Added debug logging in
CompareHTTPRespandCompareGRPCRespto track noise configuration application - Improved code readability by extracting intermediate variables in comparison functions
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/service/replay/utils.go | Implements deep copy logic in LeftJoinNoise to prevent mutation of the original global noise configuration |
| pkg/service/replay/replay.go | Refactors noise configuration handling with clearer variable names and adds debug logging for troubleshooting |
Comments suppressed due to low confidence (1)
pkg/service/replay/utils.go:69
- This function has been refactored to fix a critical bug with global noise mutation, but there are no unit tests covering this behavior. Consider adding tests that verify:
- The returned noise config doesn't share references with the input globalNoise or tsNoise
- Multiple calls with the same globalNoise don't affect each other
- The merge behavior works correctly (test-set noise overrides global noise)
This would prevent regression of the bug this PR fixes.
func LeftJoinNoise(globalNoise config.GlobalNoise, tsNoise config.GlobalNoise) config.GlobalNoise {
// Create a deep copy of globalNoise to avoid mutating the original config
noise := make(config.GlobalNoise)
// Deep copy the body map
if bodyMap, ok := globalNoise["body"]; ok {
noise["body"] = make(map[string][]string)
for field, regexArr := range bodyMap {
// Copy the slice to avoid sharing references
noise["body"][field] = append([]string{}, regexArr...)
}
} else {
noise["body"] = make(map[string][]string)
}
// Deep copy the header map
if headerMap, ok := globalNoise["header"]; ok {
noise["header"] = make(map[string][]string)
for field, regexArr := range headerMap {
// Copy the slice to avoid sharing references
noise["header"][field] = append([]string{}, regexArr...)
}
} else {
noise["header"] = make(map[string][]string)
}
// Merge test-set specific noise (overwrites global noise for matching fields)
if tsNoiseBody, ok := tsNoise["body"]; ok {
for field, regexArr := range tsNoiseBody {
noise["body"][field] = regexArr
}
}
if tsNoiseHeader, ok := tsNoise["header"]; ok {
for field, regexArr := range tsNoiseHeader {
noise["header"][field] = regexArr
}
}
return noise
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if tsNoiseBody, ok := tsNoise["body"]; ok { | ||
| for field, regexArr := range tsNoiseBody { | ||
| noise["body"][field] = regexArr | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test-set specific noise slices are directly assigned without deep copying. This means the returned noise config still shares slice references with tsNoise, which could lead to the same mutation issues this PR aims to fix.
Consider copying the slices when merging test-set noise:
if tsNoiseBody, ok := tsNoise["body"]; ok {
for field, regexArr := range tsNoiseBody {
noise["body"][field] = append([]string{}, regexArr...)
}
}The same applies to the header section below (lines 62-66).
Describe the changes that are made
This PR fixes a critical bug where test sets were failing due to mutation of the global noise configuration when the skip-app-restart flag is enabled. The issue occurred because the
LeftJoinNoisefunction was modifying the originalglobalNoisemap, causing noise configurations to accumulate across test sets.Key Changes:
LeftJoinNoiseto perform deep copying of the global noise configuration before merging test-set specific noiseCompareHTTPRespandCompareGRPCRespto track noise configuration applicationLinks & References
Closes: #3299
🔗 Related PRs
🐞 Related Issues
📄 Related Documents
What type of PR is this? (check all applicable)
Added e2e test pipeline?
Added comments for hard-to-understand areas?
Added to documentation?
Are there any sample code or steps to test the changes?
Self Review done?
Any relevant screenshots, recordings or logs?
🧠 Semantics for PR Title & Branch Name
Please ensure your PR title and branch name follow the Keploy semantics:
📌 PR Semantics Guide
📌 Branch Semantics Guide
Examples:
fix: patch MongoDB document update bugfeat/#1-login-flow(You may skip mentioning the issue number in the branch name if the change is small and the PR description clearly explains it.)Additional checklist: