Skip to content

Commit

Permalink
internal/civisibility: test with efd enabled disable atr for that test
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyredondo committed Oct 30, 2024
1 parent 0bd0a8c commit 844a72a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
25 changes: 13 additions & 12 deletions internal/civisibility/integrations/gotesting/instrumentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,15 @@ func applyAdditionalFeaturesToTestFunc(f func(*testing.T), testInfo *commonInfo)
// Target function
targetFunc := f

// Flaky test retries
if settings.FlakyTestRetriesEnabled {
targetFunc = applyFlakyTestRetriesAdditionalFeature(targetFunc)
}

// Early flake detection
var earlyFlakeDetectionApplied bool
if settings.EarlyFlakeDetection.Enabled {
targetFunc = applyEarlyFlakeDetectionAdditionalFeature(testInfo, targetFunc, settings)
targetFunc, earlyFlakeDetectionApplied = applyEarlyFlakeDetectionAdditionalFeature(testInfo, targetFunc, settings)
}

// Flaky test retries (only if EFD was not applied and if the feature is enabled)
if !earlyFlakeDetectionApplied && settings.FlakyTestRetriesEnabled {
targetFunc, _ = applyFlakyTestRetriesAdditionalFeature(targetFunc)
}

// Register the instrumented func as an internal instrumented func (to avoid double instrumentation)
Expand All @@ -178,7 +179,7 @@ func applyAdditionalFeaturesToTestFunc(f func(*testing.T), testInfo *commonInfo)
}

// applyFlakyTestRetriesAdditionalFeature applies the flaky test retries feature as a wrapper of a func(*testing.T)
func applyFlakyTestRetriesAdditionalFeature(targetFunc func(*testing.T)) func(*testing.T) {
func applyFlakyTestRetriesAdditionalFeature(targetFunc func(*testing.T)) (func(*testing.T), bool) {
flakyRetrySettings := integrations.GetFlakyRetriesSettings()

// If the retry count per test is > 1 and if we still have remaining total retry count
Expand Down Expand Up @@ -235,13 +236,13 @@ func applyFlakyTestRetriesAdditionalFeature(targetFunc func(*testing.T)) func(*t
},
execMetaAdjust: nil, // No execMetaAdjust needed
})
}
}, true
}
return targetFunc
return targetFunc, false
}

// applyEarlyFlakeDetectionAdditionalFeature applies the early flake detection feature as a wrapper of a func(*testing.T)
func applyEarlyFlakeDetectionAdditionalFeature(testInfo *commonInfo, targetFunc func(*testing.T), settings *net.SettingsResponseData) func(*testing.T) {
func applyEarlyFlakeDetectionAdditionalFeature(testInfo *commonInfo, targetFunc func(*testing.T), settings *net.SettingsResponseData) (func(*testing.T), bool) {
earlyFlakeDetectionData := integrations.GetEarlyFlakeDetectionSettings()
if earlyFlakeDetectionData != nil &&
len(earlyFlakeDetectionData.Tests) > 0 {
Expand Down Expand Up @@ -327,10 +328,10 @@ func applyEarlyFlakeDetectionAdditionalFeature(testInfo *commonInfo, targetFunc
execMeta.isANewTest = true
},
})
}
}, true
}
}
return targetFunc
return targetFunc, false
}

// runTestWithRetry encapsulates the common retry logic for test functions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,8 @@ func runFlakyTestRetriesWithEarlyFlakyTestDetectionTests(m *testing.M) {
// 1 TestSkip
// 1 TestRetryWithPanic + 3 retry tests from testing_test.go
// 1 TestRetryWithFail + 3 retry tests from testing_test.go
// 1 TestRetryAlwaysFail + 10 retry tests from testing_test.go
// 1 TestNormalPassingAfterRetryAlwaysFail
// 11 TestEarlyFlakeDetection + 10 retries
// 1 TestEarlyFlakeDetection + 10 EFD retries
// 2 normal spans from testing_test.go

// check spans by resource name
Expand All @@ -294,19 +293,19 @@ func runFlakyTestRetriesWithEarlyFlakyTestDetectionTests(m *testing.M) {
checkSpansByResourceName(finishedSpans, "testing_test.go.TestRetryWithPanic", 4)
checkSpansByResourceName(finishedSpans, "testing_test.go.TestRetryWithFail", 4)
checkSpansByResourceName(finishedSpans, "testing_test.go.TestNormalPassingAfterRetryAlwaysFail", 1)
checkSpansByResourceName(finishedSpans, "testing_test.go.TestEarlyFlakeDetection", 21)
checkSpansByResourceName(finishedSpans, "testing_test.go.TestEarlyFlakeDetection", 11)

// check spans by tag
checkSpansByTagName(finishedSpans, constants.TestIsNew, 21)
checkSpansByTagName(finishedSpans, constants.TestIsRetry, 26)
checkSpansByTagName(finishedSpans, constants.TestIsNew, 11)
checkSpansByTagName(finishedSpans, constants.TestIsRetry, 16)

// check spans by type
checkSpansByType(finishedSpans,
48,
38,
1,
1,
2,
44,
34,
0)

fmt.Println("All tests passed.")
Expand Down

0 comments on commit 844a72a

Please sign in to comment.