framework

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
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

func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{})

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

func Fail(msg string, callerSkip ...int)

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 IsTimeout added in v1.3.1

func IsTimeout(err error) bool

func Logf

func Logf(format string, args ...interface{})

Logf logs the info.

func MaybeTimeoutError added in v1.3.1

func MaybeTimeoutError(err error, taskFormat string, taskArgs ...interface{}) error

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

func PrunedStack(skip int) []byte

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:

func RegisterCommonFlags

func RegisterCommonFlags(flags *flag.FlagSet)

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

func TimeoutError(msg string, observedObjects ...interface{}) error

Types

type AfterEachActionFunc

type AfterEachActionFunc func(f *Framework, failed bool)

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

func NewDefaultFramework(baseName string) *Framework

NewDefaultFramework makes a new framework and sets up a BeforeEach/AfterEach for you (you can write additional before/after each functions).

func NewFramework

func NewFramework(baseName string) *Framework

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.

func (*Framework) AfterEach

func (f *Framework) AfterEach()

AfterEach deletes the resource, after reading its events.

func (*Framework) BeforeEach

func (f *Framework) BeforeEach()

BeforeEach gets a client

func (*Framework) KcClient added in v1.3.1

func (f *Framework) KcClient() *kc.Client

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.

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.

Jump to

Keyboard shortcuts

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