test

package
v0.0.0-...-1a56975 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Eventually

func Eventually(t *testing.T, name string, cond Condition)

Eventually polls cond until it completes (returns true) or times out (resulting in a test failure).

func JoinConfigs

func JoinConfigs(parts ...string) string

JoinConfigs merges the given config snippets together

func ReadConfigFile

func ReadConfigFile(filepath string) (string, error)

func SplitConfigs

func SplitConfigs(cfg string) []string

SplitConfigs splits config into chunks, based on the "---" separator.

Types

type Condition

type Condition func() bool

A Condition is a function that returns true when a test condition is satisfied.

type EventualOpts

type EventualOpts struct {
	// contains filtered or unexported fields
}

EventualOpts defines a polling strategy for operations that must eventually succeed. A new EventualOpts must be provided for each invocation of Eventually (or call Reset on a previously completed set of options).

func NewEventualOpts

func NewEventualOpts(interval, deadline time.Duration) *EventualOpts

NewEventualOpts constructs an EventualOpts instance with the provided polling interval and deadline. EventualOpts will perform randomized exponential backoff using the starting interval, and will stop polling (and therefore fail) after deadline time as elapsed from calling Eventually.

Note: we always backoff with a randomization of 0.5 (50%), a multiplier of 1.5, and a max interval of one minute.

func (EventualOpts) Eventually

func (e EventualOpts) Eventually(t *testing.T, name string, cond Condition)

Eventually polls cond until it succeeds (returns true) or we exceed the deadline. Eventually performs backoff while polling cond.

name is printed as part of the test failure message when we exceed the deadline to help identify the test case failing. cond does not need to be thread-safe: it is only called from the current goroutine. cond itself can also fail the test early using t.Fatal.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL