Skip to content

Commit

Permalink
internal/civisibility: auto test retries max retries fix (#2947)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyredondo authored Oct 24, 2024
1 parent 7f5a7c9 commit bca85bc
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions internal/civisibility/integrations/gotesting/instrumentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,14 @@ func applyFlakyTestRetriesAdditionalFeature(targetFunc func(*testing.T)) func(*t
initialRetryCount: flakyRetrySettings.RetryCount,
adjustRetryCount: nil, // No adjustRetryCount
shouldRetry: func(ptrToLocalT *testing.T, executionIndex int, remainingRetries int64) bool {
remainingTotalRetries := atomic.AddInt64(&flakyRetrySettings.RemainingTotalRetryCount, -1)
// Decide whether to retry
return ptrToLocalT.Failed() && remainingRetries >= 0 && remainingTotalRetries >= 0
return ptrToLocalT.Failed() && remainingRetries >= 0 && atomic.LoadInt64(&flakyRetrySettings.RemainingTotalRetryCount) >= 0
},
perExecution: func(ptrToLocalT *testing.T, executionIndex int, duration time.Duration) {
if executionIndex > 0 {
atomic.AddInt64(&flakyRetrySettings.RemainingTotalRetryCount, -1)
}
},
perExecution: nil, // No perExecution needed
onRetryEnd: func(t *testing.T, executionIndex int, lastPtrToLocalT *testing.T) {
// Update original `t` with results from last execution
tCommonPrivates := getTestPrivateFields(t)
Expand Down Expand Up @@ -223,11 +226,11 @@ func applyFlakyTestRetriesAdditionalFeature(targetFunc func(*testing.T)) func(*t
}

fmt.Printf(" [ %v after %v retries by Datadog's auto test retries ]\n", status, executionIndex)
}

// Check if total retry count was exceeded
if flakyRetrySettings.RemainingTotalRetryCount < 1 {
fmt.Println(" the maximum number of total retries was exceeded.")
// Check if total retry count was exceeded
if atomic.LoadInt64(&flakyRetrySettings.RemainingTotalRetryCount) < 1 {
fmt.Println(" the maximum number of total retries was exceeded.")
}
}
},
execMetaAdjust: nil, // No execMetaAdjust needed
Expand Down

0 comments on commit bca85bc

Please sign in to comment.