Skip to content

Commit

Permalink
internal/civisibility: changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyredondo committed Oct 3, 2024
1 parent 868acf4 commit de7d8da
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
11 changes: 8 additions & 3 deletions internal/civisibility/integrations/civisibility_features.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import (
"gopkg.in/DataDog/dd-trace-go.v1/internal/log"
)

const (
DefaultFlakyRetryCount = 5
DefaultFlakyTotalRetryCount = 1_000
)

type (
// FlakyRetriesSetting struct to hold all the settings related to flaky tests retries
FlakyRetriesSetting struct {
Expand All @@ -27,7 +32,7 @@ var (
// additionalFeaturesInitializationOnce ensures we do the additional features initialization just once
additionalFeaturesInitializationOnce sync.Once

// ciVisibilityRapidClient contains the http rapid client to do CI Visibility querys and upload to the rapid backend
// ciVisibilityRapidClient contains the http rapid client to do CI Visibility queries and upload to the rapid backend
ciVisibilityClient net.Client

// ciVisibilitySettings contains the CI Visibility settings for this session
Expand Down Expand Up @@ -72,9 +77,9 @@ func ensureAdditionalFeaturesInitialization(serviceName string) {
if ciVisibilitySettings.FlakyTestRetriesEnabled {
flakyRetryEnabledByEnv := internal.BoolEnv(constants.CIVisibilityFlakyRetryEnabledEnvironmentVariable, true)
if flakyRetryEnabledByEnv {
totalRetriesCount := (int64)(internal.IntEnv(constants.CIVisibilityTotalFlakyRetryCountEnvironmentVariable, 1_000))
totalRetriesCount := (int64)(internal.IntEnv(constants.CIVisibilityTotalFlakyRetryCountEnvironmentVariable, DefaultFlakyTotalRetryCount))
ciVisibilityFlakyRetriesSettings = FlakyRetriesSetting{
RetryCount: (int64)(internal.IntEnv(constants.CIVisibilityFlakyRetryCountEnvironmentVariable, 5)),
RetryCount: (int64)(internal.IntEnv(constants.CIVisibilityFlakyRetryCountEnvironmentVariable, DefaultFlakyRetryCount)),
TotalRetryCount: totalRetriesCount,
RemainingTotalRetryCount: totalRetriesCount,
}
Expand Down
15 changes: 8 additions & 7 deletions internal/civisibility/integrations/gotesting/reflections.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ func getFieldPointerFromValue(value reflect.Value, fieldName string) (unsafe.Poi

// copyFieldUsingPointers copies a private field value from one struct to another of the same type
func copyFieldUsingPointers[V any](source any, target any, fieldName string) error {
if sourcePtr, err := getFieldPointerFrom(source, fieldName); err == nil {
if targetPtr, err := getFieldPointerFrom(target, fieldName); err == nil {
*(*V)(targetPtr) = *(*V)(sourcePtr)
} else {
return err
}
} else {
sourcePtr, err := getFieldPointerFrom(source, fieldName)
if err != nil {
return err
}
targetPtr, err := getFieldPointerFrom(target, fieldName)
if err != nil {
return err
}

*(*V)(targetPtr) = *(*V)(sourcePtr)
return nil
}

Expand Down

0 comments on commit de7d8da

Please sign in to comment.