Documentation ¶
Index ¶
- Variables
- func CreateTestingNS(baseName string, c clientset.Interface, labels map[string]string) (*v1.Namespace, error)
- func DeleteNamespaces(c clientset.Interface, deleteFilter, skipFilter []string) ([]string, error)
- 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 LoadClientset() (*clientset.Clientset, error)
- func LoadConfig() (config *restclient.Config, err error)
- func Logf(format string, args ...interface{})
- func PrunedStack(skip int) []byte
- func RandomSuffix() string
- func RegisterFlags(flags *flag.FlagSet)
- func RemoveCleanupAction(p CleanupActionHandle)
- func RunCleanupActions()
- func WaitForNamespacesDeleted(c clientset.Interface, namespaces []string, timeout time.Duration) error
- type CleanupActionHandle
- type FailurePanic
- type Framework
- type Options
Constants ¶
This section is empty.
Variables ¶
var RunID = uuid.NewUUID()
RunID is a unique identifier of the e2e run. Beware that this ID is not the same for all tests in the e2e run, because each Ginkgo node creates it separately.
var TestContext testContext
Functions ¶
func CreateTestingNS ¶
func CreateTestingNS(baseName string, c clientset.Interface, labels map[string]string) (*v1.Namespace, error)
CreateTestingNS should be used by every test, note that we append a common prefix to the provided test name. Please see NewFramework instead of using this directly.
func DeleteNamespaces ¶
DeleteNamespaces deletes all namespaces that match the given delete and skip filters. Filter is by simple strings.Contains; first skip filter, then delete filter. Returns the list of deleted namespaces or an error.
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 LoadClientset ¶
LoadClientset returns clientset for connecting to kubernetes clusters.
func LoadConfig ¶
func LoadConfig() (config *restclient.Config, err error)
LoadConfig returns a config for a rest client with the UserAgent set to include the current test name.
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 RandomSuffix ¶
func RandomSuffix() string
RandomSuffix provides a random sequence to append to pods,services,rcs.
func RegisterFlags ¶
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.
Types ¶
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 FailurePanic ¶
type FailurePanic struct { Message string // The failure message passed to Fail Filename string // The filename that is the source of the failure Line int // The line number of the filename that is the source of the failure FullStackTrace string // A full stack trace starting at the source of the failure }
FailurePanic is the value that will be panicked from Fail.
func (FailurePanic) String ¶
func (FailurePanic) String() string
String makes FailurePanic look like the old Ginkgo panic when printed.
type Framework ¶
type Framework struct { BaseName string // Set together with creating the ClientSet and the namespace. // Guaranteed to be unique in the cluster even when running the same // test multiple times in parallel. UniqueName string SednaClientSet sednaclientset.Interface ClientSet clientset.Interface SkipNamespaceCreation bool // Whether to skip creating a namespace Namespace *v1.Namespace // Every test has at least one namespace unless creation is skipped // configuration for framework's client Options Options AfterEachActions []func() // contains filtered or unexported fields }
Framework supports common operations used by e2e tests; it will keep a client & a namespace for you. Eventual goal is to merge this with integration test framework.
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 makes a new framework and sets up a BeforeEach/AfterEach
func (*Framework) AddNamespacesToDelete ¶
AddNamespacesToDelete adds one or more namespaces to be deleted when the test completes.
func (*Framework) AfterEach ¶
func (f *Framework) AfterEach()
AfterEach deletes the namespace, after reading its events.
func (*Framework) BeforeEach ¶
func (f *Framework) BeforeEach()
BeforeEach gets a client and makes a namespace.