Documentation ¶
Index ¶
- Constants
- func ExpectConsistOf(actual interface{}, extra interface{}, explain ...interface{})
- func ExpectEmpty(actual interface{}, explain ...interface{})
- func ExpectEqual(actual interface{}, extra interface{}, explain ...interface{})
- func ExpectError(err error, explain ...interface{})
- func ExpectHaveKey(actual interface{}, key interface{}, explain ...interface{})
- func ExpectNoError(err error, explain ...interface{})
- func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{})
- func ExpectNotEqual(actual interface{}, extra interface{}, explain ...interface{})
- func Fail(msg string, callerSkip ...int)
- func Failf(format string, args ...interface{})
- func HandleWaitingAPIError(err error, retryNotFound bool, taskFormat string, taskArgs ...interface{}) (bool, error)
- func IsTimeout(err error) bool
- func Logf(format string, args ...interface{})
- func MaybeTimeoutError(err error, taskFormat string, taskArgs ...interface{}) error
- func PrunedStack(skip int) []byte
- func RegisterCommonFlags(flags *flag.FlagSet)
- func RemoveCleanupAction(p CleanupActionHandle)
- func RunCleanupActions()
- func TimeoutError(msg string, observedObjects ...interface{}) error
- type AfterEachActionFunc
- type CleanupActionHandle
- type Framework
- type TestContextType
- type TimeoutContext
Constants ¶
const ( // Poll is how often to poll clusters. Poll = 15 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func ExpectConsistOf ¶
func ExpectConsistOf(actual interface{}, extra interface{}, explain ...interface{})
ExpectConsistOf expects actual contains precisely the extra elements. The ordering of the elements does not matter.
func ExpectEmpty ¶
func ExpectEmpty(actual interface{}, explain ...interface{})
ExpectEmpty expects actual is empty
func ExpectEqual ¶
func ExpectEqual(actual interface{}, extra interface{}, explain ...interface{})
ExpectEqual expects the specified two are the same, otherwise an exception raises
func ExpectError ¶
func ExpectError(err error, explain ...interface{})
ExpectError expects an error happens, otherwise an exception raises
func ExpectHaveKey ¶
func ExpectHaveKey(actual interface{}, key interface{}, explain ...interface{})
ExpectHaveKey expects the actual map has the key in the keyset
func ExpectNoError ¶
func ExpectNoError(err error, explain ...interface{})
ExpectNoError checks if "err" is set, and if so, fails assertion while logging the error.
func ExpectNoErrorWithOffset ¶
ExpectNoErrorWithOffset checks if "err" is set, and if so, fails assertion while logging the error at "offset" levels above its caller (for example, for call chain f -> g -> ExpectNoErrorWithOffset(1, ...) error would be logged for "f").
func ExpectNotEqual ¶
func ExpectNotEqual(actual interface{}, extra interface{}, explain ...interface{})
ExpectNotEqual expects the specified two are not the same, otherwise an exception raises
func Fail ¶
Fail is a replacement for ginkgo.Fail which logs the problem as it occurs together with a stack trace and then calls ginkgowrapper.Fail.
func Failf ¶
func Failf(format string, args ...interface{})
Failf logs the fail info, including a stack trace starts at 2 levels above its caller (for example, for call chain f -> g -> Failf("foo", ...) error would be logged for "f").
func HandleWaitingAPIError ¶ added in v1.3.1
func HandleWaitingAPIError(err error, retryNotFound bool, taskFormat string, taskArgs ...interface{}) (bool, error)
HandleWaitingAPIError handles an error from an API request in the context of a Wait function. If the error is retryable, sleep the recommended delay and ignore the error. If the erorr is terminal, return it.
func MaybeTimeoutError ¶ added in v1.3.1
MaybeTimeoutError returns a TimeoutError if err is a timeout. Otherwise, wrap err. taskFormat and taskArgs should be the task being performed when the error occurred, e.g. "waiting for pod to be running".
func PrunedStack ¶
PrunedStack is a wrapper around debug.Stack() that removes information about the current goroutine and optionally skips some of the initial stack entries. With skip == 0, the returned stack will start with the caller of PruneStack. From the remaining entries it automatically filters out useless ones like entries coming from Ginkgo.
This is a modified copy of PruneStack in https://github.com/onsi/ginkgo/blob/f90f37d87fa6b1dd9625e2b1e83c23ffae3de228/internal/codelocation/code_location.go#L25:
- simplified API and thus renamed (calls debug.Stack() instead of taking a parameter)
- source code filtering updated to be specific to Kubernetes
- optimized to use bytes and in-place slice filtering from https://github.com/golang/go/wiki/SliceTricks#filter-in-place
func RegisterCommonFlags ¶
func RemoveCleanupAction ¶
func RemoveCleanupAction(p CleanupActionHandle)
RemoveCleanupAction removes a function that was installed by AddCleanupAction.
func RunCleanupActions ¶
func RunCleanupActions()
RunCleanupActions runs all functions installed by AddCleanupAction. It does not remove them (see RemoveCleanupAction) but it does run unlocked, so they may remove themselves.
func TimeoutError ¶ added in v1.3.1
Types ¶
type AfterEachActionFunc ¶
AfterEachActionFunc is a function that can be called after each test
type CleanupActionHandle ¶
type CleanupActionHandle *int
CleanupActionHandle is an integer pointer type for handling cleanup action
func AddCleanupAction ¶
func AddCleanupAction(fn func()) CleanupActionHandle
AddCleanupAction installs a function that will be called in the event of the whole test being terminated. This allows arbitrary pieces of the overall test to hook into SynchronizedAfterSuite(). The hooks are called in last-in-first-out order.
type Framework ¶
type Framework struct { BaseName string // Timeouts contains the custom timeouts used during the test execution. Timeouts *TimeoutContext Context *TestContextType // contains filtered or unexported fields }
func NewDefaultFramework ¶
NewDefaultFramework makes a new framework and sets up a BeforeEach/AfterEach for you (you can write additional before/after each functions).
func NewFramework ¶
NewFramework creates a test framework.
func NewFrameworkWithCustomTimeouts ¶
func NewFrameworkWithCustomTimeouts(baseName string, timeouts *TimeoutContext) *Framework
NewFrameworkWithCustomTimeouts makes a framework with with custom timeouts.
func (*Framework) AddAfterEach ¶
func (f *Framework) AddAfterEach(name string, fn AfterEachActionFunc)
AddAfterEach is a way to add a function to be called after every test. The execution order is intentionally random to avoid growing dependencies. If you register the same name twice, it is a coding error and will panic.
type TestContextType ¶
type TestContextType struct { Host string LocalRegistry string Username string Password string Client *kc.Client }
var TestContext TestContextType
TestContext should be used by all tests to access common context data.
type TimeoutContext ¶
type TimeoutContext struct { // ClusterInstall is how long to wait for the pod to be started. // Use it in create ha cluster case ClusterInstall time.Duration // ClusterInstallShort is same as `ClusterInstall`, but shorter. // Use it in create aio cluster case ClusterInstallShort time.Duration // ClusterDelete is how long to wait for the cluster to be deleted. ClusterDelete time.Duration CommonTimeout time.Duration }
TimeoutContext contains timeout settings for several actions.
func NewTimeoutContextWithDefaults ¶
func NewTimeoutContextWithDefaults() *TimeoutContext
NewTimeoutContextWithDefaults returns a TimeoutContext with default values.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package ginkgowrapper wraps Ginkgo Fail and Skip functions to panic with structured data instead of a constant string.
|
Package ginkgowrapper wraps Ginkgo Fail and Skip functions to panic with structured data instead of a constant string. |