Documentation
¶
Index ¶
- func ConvertToAuthSecret(auth client.Auth) (secret corev1.Secret)
- func DurationToFloat(dur time.Duration) float64
- func GetConfigFromContext(ctx context.Context) interface{}
- func GetDefaultEnv(key string, defaultValue string) string
- func GetPluginAddress(client *resty.Client, plugin client.Interface) (address *duckv1.Addressable, err error)
- func MustGetPluginAddress(client *resty.Client, plugin client.Interface) (address *duckv1.Addressable)
- func MustRollback(testCtx *TestContext, obj client.Object, opts ...client.DeleteOption)
- func NewConfigCondition(configName string, obj interface{}) *configCondition
- func NewTestConfigMap(name, namespace string, data map[string]string) *v1.ConfigMap
- func RequestWrapAuthMeta(req *resty.Request, auth client.Auth, meta client.Meta) *resty.Request
- func ResourceTopConditionIsReadyEventually(ctx *TestContext, obj client.Object, readyFuncs ...IsReadyCheckFunc) func(g Gomega) error
- func WaitRollback(testCtx *TestContext, obj client.Object)
- type Condition
- type ConditionFunc
- type Framework
- type IsReadyCheckFunc
- type NamespaceCondition
- type Options
- type Poller
- type ReconcileCondition
- type ServicePortForward
- type TestCaseBuilder
- func (b *TestCaseBuilder) Cluster() *TestCaseBuilder
- func (b *TestCaseBuilder) Do() bool
- func (b *TestCaseBuilder) DoFunc(f TestFunction) bool
- func (b *TestCaseBuilder) Namespaced() *TestCaseBuilder
- func (b *TestCaseBuilder) P0() *TestCaseBuilder
- func (b *TestCaseBuilder) P1() *TestCaseBuilder
- func (b *TestCaseBuilder) P2() *TestCaseBuilder
- func (b *TestCaseBuilder) P3() *TestCaseBuilder
- func (b *TestCaseBuilder) WithCondition(funcs ...Condition) *TestCaseBuilder
- func (b *TestCaseBuilder) WithFunc(tc TestFunction) *TestCaseBuilder
- func (b *TestCaseBuilder) WithLabels(labels ...string) *TestCaseBuilder
- func (b *TestCaseBuilder) WithPriority(prior TestCasePriority) *TestCaseBuilder
- func (b *TestCaseBuilder) WithTestContextOptions(options ...TestContextOption) *TestCaseBuilder
- type TestCaseLabel
- type TestCasePriority
- type TestCaseScope
- type TestConfig
- type TestContext
- type TestContextOption
- type TestFunction
- type TestNamespaceCondition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertToAuthSecret ¶ added in v0.7.0
ConvertToAuthSecret convert auth
func DurationToFloat ¶
DurationToFloat converts a duration into a float64 seconds, useful for Ginkgo methods
func GetConfigFromContext ¶ added in v0.7.0
GetConfigFromContext get the config information from context
func GetDefaultEnv ¶ added in v0.7.0
GetDefaultEnv get the parameter from env, if not set it use the defaultValue instead
func GetPluginAddress ¶ added in v0.7.0
func GetPluginAddress(client *resty.Client, plugin client.Interface) (address *duckv1.Addressable, err error)
GetPluginAddress get the base url of the plugin
func MustGetPluginAddress ¶ added in v0.7.0
func MustGetPluginAddress(client *resty.Client, plugin client.Interface) (address *duckv1.Addressable)
MustGetPluginAddress get the base url or panics if the parse fails.
func MustRollback ¶ added in v0.7.0
func MustRollback(testCtx *TestContext, obj client.Object, opts ...client.DeleteOption)
MustRollback delete an object and wait for completion
func NewConfigCondition ¶ added in v0.7.0
func NewConfigCondition(configName string, obj interface{}) *configCondition
NewConfigCondition construct an configCondition object `obj` is a pointer which used to unmarshal configuration to
func NewTestConfigMap ¶ added in v0.7.0
NewTestConfigMap helper function for constructing a new configmap
func RequestWrapAuthMeta ¶ added in v0.7.0
RequestWrapAuthMeta wrap auth and meta information into http request
func ResourceTopConditionIsReadyEventually ¶ added in v0.7.0
func ResourceTopConditionIsReadyEventually(ctx *TestContext, obj client.Object, readyFuncs ...IsReadyCheckFunc) func(g Gomega) error
ResourceTopConditionIsReadyEventually generic function to check if a resource is ready resource type must implement GetTopLevelCondition() *apis.Condition function
func WaitRollback ¶ added in v0.7.0
func WaitRollback(testCtx *TestContext, obj client.Object)
WaitRollback Wait for the delete object behavior to complete
Types ¶
type Condition ¶ added in v0.7.0
type Condition interface {
Condition(testCtx *TestContext) error
}
Condition describe the conditions which the test must match
func NewNamespaceCondition ¶ added in v0.7.0
NewNamespaceCondition construct a namespace condition
type ConditionFunc ¶ added in v0.7.0
type ConditionFunc func(testCtx *TestContext) error
ConditionFunc helper function to wrapping condition
func (ConditionFunc) Condition ¶ added in v0.7.0
func (c ConditionFunc) Condition(testCtx *TestContext) error
Condition implement the Condition interface
type Framework ¶
type Framework struct { Name string Config *rest.Config Scheme *runtime.Scheme Context context.Context *zap.SugaredLogger Output io.Writer InitTimeout time.Duration sync.Once }
Framework base framework for running automated test cases
func (*Framework) SynchronizedAfterSuite ¶
SynchronizedAfterSuite destroys the whole environment
func (*Framework) SynchronizedBeforeSuite ¶
SynchronizedBeforeSuite basic before suite initialization
type IsReadyCheckFunc ¶ added in v0.7.0
IsReadyCheckFunc additional function to check if object is ready in an Eventually context
example: ``` func(g Gomega, obj client.Object) error { if obj.GetName() == "" { fmt.Errorf("should have a name") } // or use g.Expect instead g.Expect(obj.GetName()).To(Equal("")) return nil } ```
type NamespaceCondition ¶ added in v0.7.0
type NamespaceCondition struct {
Namespace string
}
NamespaceCondition generate namespace for testing
func (*NamespaceCondition) Condition ¶ added in v0.7.0
func (t *NamespaceCondition) Condition(testCtx *TestContext) error
Condition implement the Condition interface Delete the namespace when it already exists, then create a new one. After the testing is completed, delete the namespace as well.
type Options ¶
type Options struct { // Name oof the test case Name string // Priority of the test case Priority TestCasePriority // Scope defines what kind of permissions this test case needs Scope TestCaseScope // Labels used to filter test cases when executing testing Labels []string // Condition used to check condition before testing Conditions []Condition // TestContextOptions used to setup TestContext TestContextOptions []TestContextOption }
Options options for TestCase
type Poller ¶ added in v0.7.0
Poller describe the configuration of Poller Interval: Indicates the inspection interval Timeout: Indicates the maximum time the check will last
type ReconcileCondition ¶ added in v0.7.0
type ReconcileCondition struct { *Poller // contains filtered or unexported fields }
ReconcileCondition check if a controller is available
func NewReconcileCondition ¶ added in v0.7.0
func NewReconcileCondition(obj client.Object, objCheckFun func(obj client.Object) bool) *ReconcileCondition
NewReconcileCondition helper function for constructing a `ReconcileCondition` object
func (*ReconcileCondition) Condition ¶ added in v0.7.0
func (n *ReconcileCondition) Condition(testCtx *TestContext) error
Condition implement the Condition interface Apply an object and wait for reconciliation, then check the status via `objCheckFun`
func (*ReconcileCondition) WithPoller ¶ added in v0.7.0
func (n *ReconcileCondition) WithPoller(interval, timeout time.Duration) *ReconcileCondition
WithPoller customize poller settings
type ServicePortForward ¶ added in v0.7.0
type ServicePortForward struct { Namespace string ServiceName string ServicePortFilter func(ports []v1.ServicePort) int32 // contains filtered or unexported fields }
ServicePortForward describe the configuration of port forwarding
func NewServicePortForward ¶ added in v0.7.0
func NewServicePortForward(ns string, serviceName string) *ServicePortForward
NewServicePortForward construct a new ServicePortForward object
func (*ServicePortForward) Close ¶ added in v0.7.0
func (s *ServicePortForward) Close()
Close will stop the forwarder
func (*ServicePortForward) Forward ¶ added in v0.7.0
func (s *ServicePortForward) Forward(testCtx *TestContext) (restyClient *resty.Client, err error)
Forward setting a forwarder
type TestCaseBuilder ¶
type TestCaseBuilder struct {
// contains filtered or unexported fields
}
TestCaseBuilder builder for TestCases helps provide methods to construct
func (*TestCaseBuilder) Cluster ¶
func (b *TestCaseBuilder) Cluster() *TestCaseBuilder
Cluster set the scope of the testcase as a cluster scoped
func (*TestCaseBuilder) DoFunc ¶ added in v0.7.0
func (b *TestCaseBuilder) DoFunc(f TestFunction) bool
DoFunc build and return the test case, just like the Do function
func (*TestCaseBuilder) Namespaced ¶
func (b *TestCaseBuilder) Namespaced() *TestCaseBuilder
Namespaced set the scope of the testcase as namespaced
func (*TestCaseBuilder) WithCondition ¶ added in v0.7.0
func (b *TestCaseBuilder) WithCondition(funcs ...Condition) *TestCaseBuilder
WithCondition sets conditions
func (*TestCaseBuilder) WithFunc ¶
func (b *TestCaseBuilder) WithFunc(tc TestFunction) *TestCaseBuilder
WithFunc replaces the function with another given function
func (*TestCaseBuilder) WithLabels ¶ added in v0.7.0
func (b *TestCaseBuilder) WithLabels(labels ...string) *TestCaseBuilder
WithLabels sets labels
func (*TestCaseBuilder) WithPriority ¶
func (b *TestCaseBuilder) WithPriority(prior TestCasePriority) *TestCaseBuilder
WithPriority sets priorities
func (*TestCaseBuilder) WithTestContextOptions ¶ added in v0.7.0
func (b *TestCaseBuilder) WithTestContextOptions(options ...TestContextOption) *TestCaseBuilder
WithTestContextOptions sets options of TestContext
type TestCaseLabel ¶ added in v0.7.0
type TestCaseLabel = string
TestCaseLabel label for test case
const ( ControllerLabel TestCaseLabel = "controller" WebhookLabel TestCaseLabel = "webhook" WebServiceLabel TestCaseLabel = "webservice" CliLabel TestCaseLabel = "cli" )
type TestCasePriority ¶
type TestCasePriority uint16
TestCasePriority priority for the testcase
const ( // P0 critical priority test case P0 TestCasePriority = 0 // P1 high priority test case P1 TestCasePriority = 1 // P2 medium priority test case P2 TestCasePriority = 2 // P3 low priority test case P3 TestCasePriority = 3 )
type TestCaseScope ¶
type TestCaseScope string
TestCaseScope scope for test case
const ( // ClusterScoped cluster test case scope ClusterScoped TestCaseScope = "Cluster" // NamespaceScoped test case scoped for a Namespace NamespaceScoped TestCaseScope = "Namespaced" )
type TestConfig ¶ added in v0.7.0
TestConfig Provide a unified way to get configuration from configmap
func NewE2EConfig ¶ added in v0.7.0
func NewE2EConfig(cmName string) *TestConfig
NewE2EConfig construct a `TestConfig` with special configmap name
type TestContext ¶
type TestContext struct { Context context.Context Config *rest.Config Client client.Client MultiClusterClient multicluster.Interface *zap.SugaredLogger Namespace string Scheme *runtime.Scheme }
TestContext a test context
type TestContextOption ¶ added in v0.7.0
type TestContextOption func(*TestContext)
TestContextOption options for TestContext
func NamespaceOption ¶ added in v0.7.0
func NamespaceOption(ns string) TestContextOption
NamespaceOption customize the namespace name
func NamespacePrefixOption ¶ added in v0.7.0
func NamespacePrefixOption(prefix string) TestContextOption
NamespacePrefixOption customize the prefix of the namespace name
type TestNamespaceCondition ¶ added in v0.7.0
type TestNamespaceCondition struct{}
TestNamespaceCondition generate namespace for testing
func (*TestNamespaceCondition) Condition ¶ added in v0.7.0
func (t *TestNamespaceCondition) Condition(testCtx *TestContext) error
Condition implement the Condition interface Delete the namespace when it already exists, then create a new one. After the testing is completed, delete the namespace as well.