framework

package
v0.0.310 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Using the same interval as integration should be fine given the
	// minimal load that the apiserver is likely to be under.
	PollInterval = 50 * time.Millisecond
	// How long to try single API calls (like 'get' or 'list'). Used to prevent
	// transient failures from failing tests.
	DefaultSingleCallTimeout = 30 * time.Second
)

Variables

This section is empty.

Functions

func CreateTestWorkSpace

func CreateTestWorkSpace(client client.Client, baseName string) string

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.

func FailfWithOffset

func FailfWithOffset(offset int, format string, args ...interface{})

FailfWithOffset calls "Fail" and logs the error with a stack trace that starts at "offset" levels above its caller (for example, for call chain f -> g -> FailfWithOffset(1, ...) error would be logged for "f").

func Logf

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

Logf logs the info.

func ParseFlags

func ParseFlags()

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:

Types

type Framework

type Framework struct {
	BaseName   string
	Workspace  string
	Namespaces []string
	Scheme     *runtime.Scheme
}

func (*Framework) AfterEach

func (f *Framework) AfterEach()

AfterEach

func (*Framework) BeforeEach

func (f *Framework) BeforeEach()

BeforeEach

func (*Framework) CreateNamespace

func (f *Framework) CreateNamespace(name string) string

func (*Framework) GenericClient

func (f *Framework) GenericClient(userAgent string) client.Client

func (*Framework) GetNamespaceNames

func (f *Framework) GetNamespaceNames() []string

func (*Framework) GetScheme

func (f *Framework) GetScheme() *runtime.Scheme

func (*Framework) KubeSphereSystemNamespace

func (f *Framework) KubeSphereSystemNamespace() string

func (*Framework) RestClient

func (f *Framework) RestClient(userAgent string) *restclient.RestClient

func (*Framework) TestWorkSpaceName

func (f *Framework) TestWorkSpaceName() string

type KubeSphereFramework

type KubeSphereFramework interface {
	GenericClient(userAgent string) client.Client
	RestClient(userAgent string) *restclient.RestClient
	KubeSphereSystemNamespace() string

	// Name of the workspace for the current test to target
	TestWorkSpaceName() string

	// Create a Namespace under current Worksapce
	CreateNamespace(name string) string
	// Get Names of the namespaces for the current test to target
	GetNamespaceNames() []string

	GetScheme() *runtime.Scheme
}

KubeSphereFramework provides an interface to a test control plane so that the implementation can vary without affecting tests.

func NewKubeSphereFramework

func NewKubeSphereFramework(baseName string) KubeSphereFramework

type TestContextType

type TestContextType struct {
	Host         string
	InMemoryTest bool
	Username     string
	Password     string
}
var TestContext *TestContextType = &TestContextType{}

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