Documentation ¶
Index ¶
- Constants
- Variables
- func AwaitForAll(log *zap.SugaredLogger) error
- func CreateNamespaceWithRetry(client *Client, namespace string) error
- func CreateRBACPodsEventsGetListWatch(client *Client, name string)
- func CreateRBACPodsGetEventsAll(client *Client, name string)
- func DeleteNameSpace(client *Client) error
- func EventingTypeMeta(kind string) *metav1.TypeMeta
- func ExportLogs(systemLogsDir, systemNamespace string)
- func FlowsTypeMeta(kind string) *metav1.TypeMeta
- func GetNextNamespaceId() int
- func InterestingHeaders() []string
- func MessagingTypeMeta(kind string) *metav1.TypeMeta
- func NextNamespace() string
- func SetupPullSecret(t *testing.T, client *Client)
- func SetupServiceAccount(t *testing.T, client *Client)
- func TearDown(client *Client)
- func WaitFor(name string, routine AwaitRoutine)
- func WaitForReadiness(port int, log *zap.SugaredLogger) error
- func WithService(name string) func(*corev1.Pod, *Client) error
- type AwaitRoutine
- type Client
- func (c *Client) Cleanup(f func())
- func (c *Client) CreateApiServerSourceV1OrFail(apiServerSource *sourcesv1.ApiServerSource)
- func (c *Client) CreateBrokerConfigMapOrFail(name string, channel *metav1.TypeMeta) *duckv1.KReference
- func (c *Client) CreateBrokerOrFail(name string, options ...resources.BrokerOption) *eventingv1.Broker
- func (c *Client) CreateChannelOrFail(name string, channelTypeMeta *metav1.TypeMeta)
- func (c *Client) CreateChannelWithDefaultOrFail(channel *messagingv1.Channel)
- func (c *Client) CreateChannelsOrFail(names []string, channelTypeMeta *metav1.TypeMeta)
- func (c *Client) CreateClusterRoleBindingOrFail(saName, crName, crbName string)
- func (c *Client) CreateClusterRoleOrFail(cr *rbacv1.ClusterRole)
- func (c *Client) CreateConfigMapOrFail(name, namespace string, data map[string]string) *corev1.ConfigMap
- func (c *Client) CreateContainerSourceV1OrFail(containerSource *sourcesv1.ContainerSource)
- func (c *Client) CreateCronJobOrFail(cronjob *batchv1.CronJob, options ...func(*batchv1.CronJob, *Client) error)
- func (c *Client) CreateDeploymentOrFail(deploy *appsv1.Deployment, options ...func(*appsv1.Deployment, *Client) error)
- func (c *Client) CreateFlowsParallelOrFail(parallel *flowsv1.Parallel)
- func (c *Client) CreateFlowsSequenceOrFail(sequence *flowsv1.Sequence)
- func (c *Client) CreatePingSourceV1Beta2OrFail(pingSource *sourcesv1beta2.PingSource)
- func (c *Client) CreatePingSourceV1OrFail(pingSource *sourcesv1.PingSource)
- func (c *Client) CreatePodOrFail(pod *corev1.Pod, options ...func(*corev1.Pod, *Client) error)
- func (c *Client) CreateRoleBindingOrFail(saName, rKind, rName, rbName, rbNamespace string)
- func (c *Client) CreateRoleOrFail(r *rbacv1.Role)
- func (c *Client) CreateServiceAccountOrFail(saName string)
- func (c *Client) CreateServiceOrFail(svc *corev1.Service) *corev1.Service
- func (c *Client) CreateSinkBindingV1OrFail(sb *sourcesv1.SinkBinding)
- func (c *Client) CreateSubscriptionOrFail(name, channelName string, channelTypeMeta *metav1.TypeMeta, ...) *messagingv1.Subscription
- func (c *Client) CreateSubscriptionsOrFail(names []string, channelName string, channelTypeMeta *metav1.TypeMeta, ...)
- func (c *Client) CreateTriggerOrFail(name string, options ...resources.TriggerOption) *eventingv1.Trigger
- func (c *Client) ExportLogs(dir string) error
- func (c *Client) GetAddressableURI(addressableName string, typeMeta *metav1.TypeMeta) (string, error)
- func (c *Client) GetServiceHost(podName string) string
- func (c *Client) LabelNamespace(labels map[string]string) error
- func (c *Client) RetryWebhookErrors(updater func(int) error) error
- func (c *Client) SendEvent(ctx context.Context, senderName string, uri string, event cloudevents.Event, ...)
- func (c *Client) SendEventToAddressable(ctx context.Context, senderName, addressableName string, ...)
- func (c *Client) SendRequest(ctx context.Context, senderName string, uri string, headers map[string]string, ...)
- func (c *Client) SendRequestToAddressable(ctx context.Context, senderName, addressableName string, ...)
- func (c *Client) WaitForAllTestResourcesReady(ctx context.Context) error
- func (c *Client) WaitForAllTestResourcesReadyOrFail(ctx context.Context)
- func (c *Client) WaitForResourceReadyOrFail(name string, typemeta *metav1.TypeMeta)
- func (c *Client) WaitForResourcesReadyOrFail(typemeta *metav1.TypeMeta)
- func (c *Client) WaitForServiceEndpointsOrFail(ctx context.Context, svcName string, numberOfExpectedEndpoints int)
- type ComponentsTestRunner
- func (tr *ComponentsTestRunner) AddComponentSetupClientOption(component metav1.TypeMeta, options ...SetupClientOption)
- func (tr *ComponentsTestRunner) RunTests(t *testing.T, feature Feature, ...)
- func (tr *ComponentsTestRunner) RunTestsWithComponentOptions(t *testing.T, feature Feature, strict bool, ...)
- type EventHandler
- type EventListener
- type Feature
- type ResourceDeleter
- type SetupClientOption
- type Tracker
Constants ¶
const ( // Default Event values DefaultEventSource = "http://knative.test" DefaultEventType = "dev.knative.test.event" SystemLogsDir = "knative-eventing-logs" )
const ( MaxNamespaceSkip = 200 MaxRetries = 5 RetrySleepDuration = 2 * time.Second )
const (
RoleKind = "Role"
)
Variables ¶
var ApiServerSourceTypeMeta = metav1.TypeMeta{ APIVersion: resources.SourcesV1APIVersion, Kind: resources.ApiServerSourceKind, }
var BrokerFeatureMap = map[metav1.TypeMeta][]Feature{ *BrokerTypeMeta: {FeatureBasic}, }
var BrokerTypeMeta = EventingTypeMeta(resources.BrokerKind)
BrokerTypeMeta is the TypeMeta ref for Broker.
var ChannelFeatureMap = map[metav1.TypeMeta][]Feature{ InMemoryChannelTypeMeta: {FeatureBasic}, MessagingChannelTypeMeta: {FeatureBasic}, }
ComponentFeatureMap saves the channel-features mapping. Each pair means the channel support the list of features.
var ChannelTypeMeta = MessagingTypeMeta(resources.ChannelKind)
ChannelTypeMeta is the TypeMeta ref for Channel.
var DefaultChannel = InMemoryChannelTypeMeta
DefaultChannel is the default channel we will run tests against.
var FlowsParallelTypeMeta = FlowsTypeMeta(resources.FlowsParallelKind)
FlowsParallelTypeMeta is the TypeMeta ref for Parallel (in flows.knative.dev).
var FlowsSequenceTypeMeta = FlowsTypeMeta(resources.FlowsSequenceKind)
FlowsSequenceTypeMeta is the TypeMeta ref for Sequence (in flows.knative.dev).
var InMemoryChannelTypeMeta = metav1.TypeMeta{ APIVersion: resources.MessagingAPIVersion, Kind: resources.InMemoryChannelKind, }
InMemoryChannelTypeMeta is the metav1.TypeMeta for InMemoryChannel.
var MessagingChannelTypeMeta = metav1.TypeMeta{ APIVersion: resources.MessagingAPIVersion, Kind: resources.ChannelKind, }
MessagingChannelTypeMeta is the metav1.TypeMeta for messaging.Channel.
var ParallelTypeMeta = MessagingTypeMeta(resources.ParallelKind)
ParallelTypeMeta is the TypeMeta ref for Parallel.
var PingSourceTypeMeta = metav1.TypeMeta{ APIVersion: resources.SourcesV1A2APIVersion, Kind: resources.PingSourceKind, }
var (
ReuseNamespace bool
)
var SequenceTypeMeta = MessagingTypeMeta(resources.SequenceKind)
SequenceTypeMeta is the TypeMeta ref for Sequence.
var SourceFeatureMap = map[metav1.TypeMeta][]Feature{ ApiServerSourceTypeMeta: {FeatureBasic, FeatureLongLiving}, PingSourceTypeMeta: {FeatureBasic, FeatureLongLiving}, }
var SubscriptionTypeMeta = MessagingTypeMeta(resources.SubscriptionKind)
SubscriptionTypeMeta is the TypeMeta ref for Subscription.
var TriggerTypeMeta = EventingTypeMeta(resources.TriggerKind)
TriggerTypeMeta is the TypeMeta ref for Trigger.
Functions ¶
func AwaitForAll ¶ added in v0.15.0
func AwaitForAll(log *zap.SugaredLogger) error
AwaitForAll will wait until all registered wait routines resolves
func CreateNamespaceWithRetry ¶ added in v0.24.0
CreateNamespaceWithRetry creates the given namespace with retries.
func CreateRBACPodsEventsGetListWatch ¶ added in v0.25.0
func CreateRBACPodsGetEventsAll ¶ added in v0.25.0
func DeleteNameSpace ¶
DeleteNameSpace deletes the namespace that has the given name.
func EventingTypeMeta ¶
EventingTypeMeta returns the TypeMeta ref for an eventing resource.
func ExportLogs ¶ added in v0.17.0
func ExportLogs(systemLogsDir, systemNamespace string)
func FlowsTypeMeta ¶
FlowsTypeMeta returns the TypeMeta ref for an eventing messaging resource.
func GetNextNamespaceId ¶ added in v0.24.0
func GetNextNamespaceId() int
GetNextNamespaceId return the next unique ID for the next namespace.
func InterestingHeaders ¶ added in v0.14.0
func InterestingHeaders() []string
InterestingHeaders is used by logging pods to decide interesting HTTP headers to log
func MessagingTypeMeta ¶
MessagingTypeMeta returns the TypeMeta ref for an eventing messaging resource.
func NextNamespace ¶ added in v0.24.0
func NextNamespace() string
NextNamespace returns the next unique namespace.
func SetupPullSecret ¶ added in v0.24.0
SetupPullSecret sets up kn-eventing-test-pull-secret on the client namespace.
func SetupServiceAccount ¶ added in v0.24.0
SetupServiceAccount creates a new namespace if it does not exist.
func WaitFor ¶ added in v0.15.0
func WaitFor(name string, routine AwaitRoutine)
WaitFor will register a wait routine to be resolved later
func WaitForReadiness ¶ added in v0.15.0
func WaitForReadiness(port int, log *zap.SugaredLogger) error
WaitForReadiness will wait until readiness endpoint reports OK
Types ¶
type AwaitRoutine ¶ added in v0.15.0
type AwaitRoutine func() error
type Client ¶
type Client struct { Kube kubernetes.Interface Eventing *eventing.Clientset Apiextensions *apiextensionsv1.ApiextensionsV1Client Dynamic dynamic.Interface Config *rest.Config EventListener *EventListener Namespace string T *testing.T Tracker *Tracker TracingCfg string // contains filtered or unexported fields }
Client holds instances of interfaces for making requests to Knative.
func CreateNamespacedClient ¶ added in v0.24.0
func GSetup ¶ added in v0.26.0
func GSetup(t *testing.T, options ...SetupClientOption) *Client
GSetup creates - the client objects needed in the e2e tests, - the namespace hosting all objects needed by the test
func NewClient ¶
NewClient instantiates and returns several clientsets required for making request to the cluster specified by the combination of clusterName and configPath.
func Setup ¶
func Setup(t *testing.T, runInParallel bool, options ...SetupClientOption) *Client
Setup creates - the client objects needed in the e2e tests, - the namespace hosting all objects needed by the test
func (*Client) Cleanup ¶ added in v0.17.0
func (c *Client) Cleanup(f func())
Cleanup acts similarly to testing.T, but it's tied to the client lifecycle
func (*Client) CreateApiServerSourceV1OrFail ¶ added in v0.19.0
func (c *Client) CreateApiServerSourceV1OrFail(apiServerSource *sourcesv1.ApiServerSource)
CreateApiServerSourceV1OrFail will create an v1 ApiServerSource
func (*Client) CreateBrokerConfigMapOrFail ¶ added in v0.13.0
func (*Client) CreateBrokerOrFail ¶
func (c *Client) CreateBrokerOrFail(name string, options ...resources.BrokerOption) *eventingv1.Broker
CreateBrokerV1OrFail will create a v1 Broker or fail the test if there is an error.
func (*Client) CreateChannelOrFail ¶
CreateChannelOrFail will create a typed Channel Resource in Eventing or fail the test if there is an error.
func (*Client) CreateChannelWithDefaultOrFail ¶
func (c *Client) CreateChannelWithDefaultOrFail(channel *messagingv1.Channel)
CreateChannelV1WithDefaultOrFail will create a default Channel Resource in Eventing or fail the test if there is an error.
func (*Client) CreateChannelsOrFail ¶
CreateChannelsOrFail will create a list of typed Channel Resources in Eventing or fail the test if there is an error.
func (*Client) CreateClusterRoleBindingOrFail ¶
CreateClusterRoleBindingOrFail will create a ClusterRoleBinding or fail the test if there is an error.
func (*Client) CreateClusterRoleOrFail ¶
func (c *Client) CreateClusterRoleOrFail(cr *rbacv1.ClusterRole)
CreateClusterRoleOrFail creates the given ClusterRole or fail the test if there is an error.
func (*Client) CreateConfigMapOrFail ¶ added in v0.13.0
func (c *Client) CreateConfigMapOrFail(name, namespace string, data map[string]string) *corev1.ConfigMap
CreateConfigMapOrFail will create a configmap or fail the test if there is an error.
func (*Client) CreateContainerSourceV1OrFail ¶ added in v0.19.0
func (c *Client) CreateContainerSourceV1OrFail(containerSource *sourcesv1.ContainerSource)
CreateContainerSourceV1OrFail will create a v1 ContainerSource.
func (*Client) CreateCronJobOrFail ¶
func (c *Client) CreateCronJobOrFail(cronjob *batchv1.CronJob, options ...func(*batchv1.CronJob, *Client) error)
CreateCronJobOrFail will create a CronJob or fail the test if there is an error.
func (*Client) CreateDeploymentOrFail ¶
func (c *Client) CreateDeploymentOrFail(deploy *appsv1.Deployment, options ...func(*appsv1.Deployment, *Client) error)
CreateDeploymentOrFail will create a Deployment or fail the test if there is an error.
func (*Client) CreateFlowsParallelOrFail ¶
CreateFlowsParallelOrFail will create a Parallel (in flows.knative.dev api group) or fail the test if there is an error.
func (*Client) CreateFlowsSequenceOrFail ¶
CreateFlowsSequenceOrFail will create a Sequence (in flows.knative.dev api group) or fail the test if there is an error.
func (*Client) CreatePingSourceV1Beta2OrFail ¶ added in v0.20.0
func (c *Client) CreatePingSourceV1Beta2OrFail(pingSource *sourcesv1beta2.PingSource)
CreatePingSourceV1Beta2OrFail will create a PingSource
func (*Client) CreatePingSourceV1OrFail ¶ added in v0.23.0
func (c *Client) CreatePingSourceV1OrFail(pingSource *sourcesv1.PingSource)
CreatePingSourceV1OrFail will create a PingSource
func (*Client) CreatePodOrFail ¶
CreatePodOrFail will create a Pod or fail the test if there is an error.
func (*Client) CreateRoleBindingOrFail ¶
CreateRoleBindingOrFail will create a RoleBinding or fail the test if there is an error.
func (*Client) CreateRoleOrFail ¶
CreateRoleOrFail creates the given Role in the Client namespace or fail the test if there is an error.
func (*Client) CreateServiceAccountOrFail ¶
CreateServiceAccountOrFail will create a ServiceAccount or fail the test if there is an error.
func (*Client) CreateServiceOrFail ¶
func (*Client) CreateSinkBindingV1OrFail ¶ added in v0.19.0
func (c *Client) CreateSinkBindingV1OrFail(sb *sourcesv1.SinkBinding)
CreateSinkBindingV1OrFail will create a SinkBinding or fail the test if there is an error.
func (*Client) CreateSubscriptionOrFail ¶
func (c *Client) CreateSubscriptionOrFail( name, channelName string, channelTypeMeta *metav1.TypeMeta, options ...resources.SubscriptionOption, ) *messagingv1.Subscription
CreateSubscriptionV1OrFail will create a v1 Subscription or fail the test if there is an error.
func (*Client) CreateSubscriptionsOrFail ¶
func (c *Client) CreateSubscriptionsOrFail( names []string, channelName string, channelTypeMeta *metav1.TypeMeta, options ...resources.SubscriptionOption, )
CreateSubscriptionsV1OrFail will create a list of v1 Subscriptions with the same configuration except the name.
func (*Client) CreateTriggerOrFail ¶
func (c *Client) CreateTriggerOrFail(name string, options ...resources.TriggerOption) *eventingv1.Trigger
CreateTriggerOrFail will create a v1 Trigger or fail the test if there is an error.
func (*Client) ExportLogs ¶ added in v0.15.0
func (*Client) GetAddressableURI ¶
func (c *Client) GetAddressableURI(addressableName string, typeMeta *metav1.TypeMeta) (string, error)
GetAddressableURI returns the URI of the addressable resource. To use this function, the given resource must have implemented the Addressable duck-type.
func (*Client) GetServiceHost ¶ added in v0.16.0
GetServiceHost returns the service hostname for the specified podName
func (*Client) LabelNamespace ¶
LabelNamespace labels the given namespace with the labels map.
func (*Client) RetryWebhookErrors ¶ added in v0.17.0
func (*Client) SendEvent ¶ added in v0.16.0
func (c *Client) SendEvent( ctx context.Context, senderName string, uri string, event cloudevents.Event, option ...func(*corev1.Pod), )
SendEvent will create a sender pod, which will send the given event to the given url.
func (*Client) SendEventToAddressable ¶ added in v0.16.0
func (c *Client) SendEventToAddressable( ctx context.Context, senderName, addressableName string, typemeta *metav1.TypeMeta, event cloudevents.Event, option ...func(*corev1.Pod), )
SendEventToAddressable will send the given event to the given Addressable.
func (*Client) SendRequest ¶ added in v0.16.0
func (c *Client) SendRequest( ctx context.Context, senderName string, uri string, headers map[string]string, body string, option ...func(*corev1.Pod), )
SendRequest will create a sender pod, which will send the given request to the given url.
func (*Client) SendRequestToAddressable ¶ added in v0.16.0
func (c *Client) SendRequestToAddressable( ctx context.Context, senderName, addressableName string, typemeta *metav1.TypeMeta, headers map[string]string, body string, option ...func(*corev1.Pod), )
SendRequestToAddressable will send the given request to the given Addressable.
func (*Client) WaitForAllTestResourcesReady ¶
WaitForAllTestResourcesReady waits until all test resources in the namespace are Ready.
func (*Client) WaitForAllTestResourcesReadyOrFail ¶
func (*Client) WaitForResourceReadyOrFail ¶
WaitForResourceReadyOrFail waits for the resource to become ready or fail. To use this function, the given resource must have implemented the Status duck-type.
func (*Client) WaitForResourcesReadyOrFail ¶
WaitForResourcesReadyOrFail waits for resources of the given type in the namespace to become ready or fail. To use this function, the given resource must have implemented the Status duck-type.
type ComponentsTestRunner ¶ added in v0.16.0
type ComponentsTestRunner struct { ComponentFeatureMap map[metav1.TypeMeta][]Feature ComponentsToTest []metav1.TypeMeta ComponentName string ComponentNamespace string // contains filtered or unexported fields }
ComponentsTestRunner is used to run tests against different eventing components.
func (*ComponentsTestRunner) AddComponentSetupClientOption ¶ added in v0.17.0
func (tr *ComponentsTestRunner) AddComponentSetupClientOption(component metav1.TypeMeta, options ...SetupClientOption)
AddComponentSetupClientOption adds a SetupClientOption that should only run when component gets selected to run. This should be used when there's an expensive initialization code should take place conditionally (e.g. create an instance of a source or a channel) as opposed to other cheap initialization code that is safe to be called in all cases (e.g. installation of a CRD)
func (*ComponentsTestRunner) RunTests ¶ added in v0.16.0
func (tr *ComponentsTestRunner) RunTests( t *testing.T, feature Feature, testFunc func(st *testing.T, component metav1.TypeMeta), )
RunTests will use all components that support the given feature, to run a test for the testFunc.
func (*ComponentsTestRunner) RunTestsWithComponentOptions ¶ added in v0.17.0
func (tr *ComponentsTestRunner) RunTestsWithComponentOptions( t *testing.T, feature Feature, strict bool, testFunc func(st *testing.T, component metav1.TypeMeta, options ...SetupClientOption), )
RunTestsWithComponentOptions will use all components that support the given feature, to run a test for the testFunc while passing the component specific SetupClientOptions to testFunc. You should used this method instead of RunTests if you have used AddComponentSetupClientOption to add some component specific initialization code. If strict is set to true, tests will not run for components that don't exist in the ComponentFeatureMap.
type EventHandler ¶ added in v0.17.8
EventHandler is the callback type for the EventListener
type EventListener ¶ added in v0.17.8
type EventListener struct {
// contains filtered or unexported fields
}
EventListener is a type that broadcasts new k8s events
func NewEventListener ¶ added in v0.17.8
func NewEventListener(client kubernetes.Interface, namespace string, logf func(string, ...interface{})) *EventListener
NewEventListener creates a new event listener
func (*EventListener) AddHandler ¶ added in v0.17.8
func (el *EventListener) AddHandler(handler EventHandler) int
func (*EventListener) Stop ¶ added in v0.17.8
func (el *EventListener) Stop()
type Feature ¶
type Feature string
Feature is the feature supported by the channel.
const ( // FeatureBasic is the feature that should be supported by all components. FeatureBasic Feature = "basic" // FeatureRedelivery means if downstream rejects an event, that request will be attempted again. FeatureRedelivery Feature = "redelivery" // FeaturePersistence means if channel's Pod goes down, all events already ACKed by the channel // will persist and be retransmitted when the Pod restarts. FeaturePersistence Feature = "persistence" // A long living component FeatureLongLiving Feature = "longliving" // A batch style of components that run once and complete FeatureBatch Feature = "batch" )
type ResourceDeleter ¶
type ResourceDeleter struct { Resource dynamic.ResourceInterface Name string Namespace string }
ResourceDeleter holds the resource interface and name of resource to be cleaned
type SetupClientOption ¶
type SetupClientOption func(*Client)
SetupClientOption does further setup for the Client. It can be used if other projects need to do extra setups to run the tests we expose as test helpers.
var SetupClientOptionNoop SetupClientOption = func(*Client) {
}
SetupClientOptionNoop is a SetupClientOption that does nothing.
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker holds resources that need to be tracked during test execution. It includes: 1. KResources that need to check their Ready status; 2. All Kubernetes resources that need to be cleaned after test is done.
func NewTracker ¶
NewTracker creates a new Tracker
func (*Tracker) Add ¶
Add will register a resource to be cleaned by the Clean function This function is generic enough so as to be able to register any resources Each resource is identified by: * group (e.g. serving.knative.dev) * version (e.g. v1alpha1) * resource's plural (e.g. routes) * namespace (use "" if the resource is not tied to any namespace) * actual name of the resource (e.g. myroute)
func (*Tracker) AddObj ¶
func (t *Tracker) AddObj(obj kmeta.OwnerRefable)
AddObj will register a resource that implements OwnerRefable interface to be cleaned by the Clean function. It also register the resource for checking if its status is Ready. Note this function assumes all resources that implement kmeta.OwnerRefable are KResources.
func (*Tracker) WaitForKResourcesReady ¶
WaitForKResourcesReady will wait for all registered KResources to become ready.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
recorder_vent
Package recorder_vent implements an recordevents.EventLog backed by Kubernetes Events using an event recorder.
|
Package recorder_vent implements an recordevents.EventLog backed by Kubernetes Events using an event recorder. |