istio: istio.io/istio/tests/util Index | Files | Directories

package util

import "istio.io/istio/tests/util"

Index

Package Files

common_utils.go compare_utils.go retry.go

func Backoff Uses

func Backoff(baseDelay, maxDelay time.Duration, retries int) time.Duration

Backoff returns a random value in [0, maxDelay] that increases exponentially with retries, starting from baseDelay. It is the Go equivalent to C++'s //util/time/backoff.cc.

func Compare Uses

func Compare(out, model []byte) error

Compare compares two byte slices. It returns an error with a contextual diff if they are not equal.

func RandomString Uses

func RandomString(n int) string

RandomString returns a random string of size n (letters only)

type Break Uses

type Break struct {
    Err error
}

Break the retry loop if the error returned is of this type.

func (Break) Error Uses

func (e Break) Error() string

type Retrier Uses

type Retrier struct {
    // BaseDelay is the minimum delay between retry attempts.
    BaseDelay time.Duration
    // MaxDelay is the maximum delay allowed between retry attempts.
    MaxDelay time.Duration
    // MaxDuration is the maximum cumulative duration allowed for all retries
    MaxDuration time.Duration
    // Retries defines number of retry attempts
    Retries int
}

Retrier contains the retry configuration parameters.

func (Retrier) Retry Uses

func (r Retrier) Retry(ctx context.Context, fn func(ctx context.Context, retryIndex int) error) (int, error)

Retry calls the given function a number of times, unless it returns a nil or a Break

Directories

PathSynopsis
leakleak checks for goroutine leaks in tests This is (heavily) inspired by https://github.com/grpc/grpc-go/blob/master/internal/leakcheck/leakcheck.go and https://github.com/fortytw2/leaktest
sanitycheck

Package util imports 7 packages (graph). Updated 2021-01-09. Refresh now. Tools for package owners.