Documentation ¶
Index ¶
- Constants
- Variables
- func CheckerContains(content string) func(string) bool
- func CheckerContainsAll(contents []string) func(string) bool
- func CheckerContainsAtLeast(content string, count int) func(string) bool
- func CheckerContainsCount(content string, count int) func(string) bool
- func CreateNamespaceIfNeeded(t *testing.T, client *Client, namespace string)
- func DeleteNameSpace(client *Client) error
- func EventingTypeMeta(kind string) *metav1.TypeMeta
- func FlowsTypeMeta(kind string) *metav1.TypeMeta
- func LegacySourcesTypeMeta(kind string) *metav1.TypeMeta
- func MessagingTypeMeta(kind string) *metav1.TypeMeta
- func TearDown(client *Client)
- func WithService(name string) func(*corev1.Pod, *Client) error
- type ChannelTestRunner
- type Client
- func (client *Client) CheckConfigMapsEqual(originalNamespace, cmp string, names ...string) error
- func (client *Client) CheckConfigMapsExist(namespace string, names ...string) error
- func (client *Client) CheckLog(podName string, checker func(string) bool) error
- func (client *Client) CheckLogEmpty(podName string, timeout time.Duration) error
- func (client *Client) CreateApiServerSourceOrFail(apiServerSource *sourcesv1alpha1.ApiServerSource)
- func (client *Client) CreateBrokerConfigMapOrFail(name string, channel *metav1.TypeMeta) *duckv1.KReference
- func (client *Client) CreateBrokerOrFail(name string, options ...resources.BrokerOption) *v1alpha1.Broker
- func (client *Client) CreateBrokerV1Beta1OrFail(name string, options ...resources.BrokerV1Beta1Option) *v1beta1.Broker
- func (client *Client) CreateBrokersOrFail(names []string, channelTypeMeta *metav1.TypeMeta)
- func (client *Client) CreateChannelOrFail(name string, channelTypeMeta *metav1.TypeMeta)
- func (client *Client) CreateChannelWithDefaultOrFail(channel *messagingv1alpha1.Channel)
- func (client *Client) CreateChannelsOrFail(names []string, channelTypeMeta *metav1.TypeMeta)
- func (client *Client) CreateClusterRoleBindingOrFail(saName, crName, crbName string)
- func (client *Client) CreateClusterRoleOrFail(cr *rbacv1.ClusterRole)
- func (client *Client) CreateConfigMapOrFail(name, namespace string, data map[string]string) *corev1.ConfigMap
- func (client *Client) CreateConfigMapPropagationOrFail(name string) *configsv1alpha1.ConfigMapPropagation
- func (client *Client) CreateCronJobOrFail(cronjob *batchv1beta1.CronJob, ...)
- func (client *Client) CreateDeploymentOrFail(deploy *appsv1.Deployment, options ...func(*appsv1.Deployment, *Client) error)
- func (client *Client) CreateFlowsParallelOrFail(parallel *flowsv1alpha1.Parallel)
- func (client *Client) CreateFlowsSequenceOrFail(sequence *flowsv1alpha1.Sequence)
- func (client *Client) CreateLegacyApiServerSourceOrFail(apiServerSource *legacysourcesv1alpha1.ApiServerSource)
- func (client *Client) CreateLegacyContainerSourceOrFail(containerSource *legacysourcesv1alpha1.ContainerSource)
- func (client *Client) CreateLegacyCronJobSourceOrFail(cronJobSource *legacysourcesv1alpha1.CronJobSource)
- func (client *Client) CreateLegacySinkBindingOrFail(sb *legacysourcesv1alpha1.SinkBinding)
- func (client *Client) CreatePingSourceV1Alpha1OrFail(pingSource *sourcesv1alpha1.PingSource)
- func (client *Client) CreatePingSourceV1Alpha2OrFail(pingSource *sourcesv1alpha2.PingSource)
- func (client *Client) CreatePodOrFail(pod *corev1.Pod, options ...func(*corev1.Pod, *Client) error)
- func (client *Client) CreateRBACResourcesForBrokers()
- func (client *Client) CreateRoleBindingOrFail(saName, rKind, rName, rbName, rbNamespace string)
- func (client *Client) CreateRoleOrFail(r *rbacv1.Role)
- func (client *Client) CreateServiceAccountOrFail(saName string)
- func (client *Client) CreateServiceOrFail(svc *corev1.Service) *corev1.Service
- func (client *Client) CreateSinkBindingV1Alpha1OrFail(sb *sourcesv1alpha1.SinkBinding)
- func (client *Client) CreateSinkBindingV1Alpha2OrFail(sb *sourcesv1alpha2.SinkBinding)
- func (client *Client) CreateSubscriptionOrFail(name, channelName string, channelTypeMeta *metav1.TypeMeta, ...)
- func (client *Client) CreateSubscriptionOrFailV1Beta1(name, channelName string, channelTypeMeta *metav1.TypeMeta, ...)
- func (client *Client) CreateSubscriptionsOrFail(names []string, channelName string, channelTypeMeta *metav1.TypeMeta, ...)
- func (client *Client) CreateTriggerOrFail(name string, options ...resources.TriggerOption) *v1alpha1.Trigger
- func (client *Client) CreateTriggerOrFailV1Beta1(name string, options ...resources.TriggerOptionV1Beta1) *v1beta1.Trigger
- func (client *Client) FindAnyLogContents(podName string, contents []string) (bool, error)
- func (client *Client) GetAddressableURI(addressableName string, typeMeta *metav1.TypeMeta) (string, error)
- func (client *Client) GetLog(podName string) (string, error)
- func (client *Client) LabelNamespace(labels map[string]string) error
- func (client *Client) SendFakeEventToAddressableOrFail(senderName, addressableName string, typemeta *metav1.TypeMeta, ...)
- func (client *Client) SendFakeEventWithTracingToAddressableOrFail(senderName, addressableName string, typemeta *metav1.TypeMeta, ...)
- func (client *Client) WaitForAllTestResourcesReady() error
- func (client *Client) WaitForAllTestResourcesReadyOrFail()
- func (client *Client) WaitForResourceReadyOrFail(name string, typemeta *metav1.TypeMeta)
- func (client *Client) WaitForResourcesReadyOrFail(typemeta *metav1.TypeMeta)
- func (client *Client) WaitForServiceEndpointsOrFail(svcName string, numberOfExpectedEndpoints int)
- type Feature
- type ResourceDeleter
- type SetupClientOption
- type Tracker
Constants ¶
const ( ClusterRoleKind = "ClusterRole" RoleKind = "Role" )
const TestPullSecretName = "kn-eventing-test-pull-secret"
Variables ¶
var BrokerTypeMeta = EventingTypeMeta(resources.BrokerKind)
BrokerTypeMeta is the TypeMeta ref for Broker.
var ChannelFeatureMap = map[metav1.TypeMeta][]Feature{ InMemoryChannelTypeMeta: {FeatureBasic}, MessagingChannelTypeMeta: {FeatureBasic}, }
ChannelFeatureMap 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 ContainerSourceTypeMeta = LegacySourcesTypeMeta(resources.ContainerSourceKind)
ContainerSourceTypeMeta is the TypeMeta ref for ContainerSource.
var CronJobSourceTypeMeta = LegacySourcesTypeMeta(resources.CronJobSourceKind)
CronJobSourceTypeMeta is the TypeMeta ref for CronJobSource.
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 LegacyApiServerSourceTypeMeta = LegacySourcesTypeMeta(resources.ApiServerSourceKind)
LegacyApiServerSourceTypeMeta is the TypeMeta ref for ApiServerSource.
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 SequenceTypeMeta = MessagingTypeMeta(resources.SequenceKind)
SequenceTypeMeta is the TypeMeta ref for Sequence.
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 CheckerContains ¶
CheckerContains returns a checker function to check if the log contains the given content.
func CheckerContainsAll ¶
CheckerContainsAll returns a checker function to check if the log contains all the given contents.
func CheckerContainsAtLeast ¶
CheckerContainsAtLeast returns a checker function to check if the log contains at least the count number of given content.
func CheckerContainsCount ¶
CheckerContainsCount returns a checker function to check if the log contains the count number of given content.
func CreateNamespaceIfNeeded ¶
CreateNamespaceIfNeeded creates a new namespace if it does not exist.
func DeleteNameSpace ¶
DeleteNameSpace deletes the namespace that has the given name.
func EventingTypeMeta ¶
EventingTypeMeta returns the TypeMeta ref for an eventing resource.
func FlowsTypeMeta ¶
FlowsTypeMeta returns the TypeMeta ref for an eventing messaing resource.
func LegacySourcesTypeMeta ¶
LegacySourcesTypeMeta returns the TypeMeta ref for an eventing sources resource.
func MessagingTypeMeta ¶
MessagingTypeMeta returns the TypeMeta ref for an eventing messaging resource.
Types ¶
type ChannelTestRunner ¶
type ChannelTestRunner struct { ChannelFeatureMap map[metav1.TypeMeta][]Feature ChannelsToTest []metav1.TypeMeta }
ChannelTestRunner is used to run tests against channels.
type Client ¶
type Client struct { Kube *test.KubeClient Eventing *eventing.Clientset Legacy *legacy.Clientset Dynamic dynamic.Interface Config *rest.Config Namespace string T *testing.T Tracker *Tracker // contains filtered or unexported fields }
Client holds instances of interfaces for making requests to Knative.
func NewClient ¶
func NewClient(configPath string, clusterName string, namespace string, t *testing.T) (*Client, error)
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, and does other setups, like creating namespaces, set the test case to run in parallel, etc.
func (*Client) CheckConfigMapsEqual ¶ added in v0.13.0
CheckConfigMapsEqual will check if configmaps have the same data as the original one.
func (*Client) CheckConfigMapsExist ¶ added in v0.13.0
CheckConfigMapsExist will check if copy configmaps exist.
func (*Client) CheckLog ¶
CheckLog waits until logs for the logger Pod satisfy the checker. If the checker does not pass within timeout it returns error.
func (*Client) CheckLogEmpty ¶
CheckLogEmpty waits the given amount of time and check the log is empty
func (*Client) CreateApiServerSourceOrFail ¶
func (client *Client) CreateApiServerSourceOrFail(apiServerSource *sourcesv1alpha1.ApiServerSource)
CreateApiServerSourceOrFail will create an ApiServerSource
func (*Client) CreateBrokerConfigMapOrFail ¶ added in v0.13.0
func (*Client) CreateBrokerOrFail ¶
func (client *Client) CreateBrokerOrFail(name string, options ...resources.BrokerOption) *v1alpha1.Broker
CreateBrokerOrFail will create a Broker or fail the test if there is an error.
func (*Client) CreateBrokerV1Beta1OrFail ¶ added in v0.13.0
func (client *Client) CreateBrokerV1Beta1OrFail(name string, options ...resources.BrokerV1Beta1Option) *v1beta1.Broker
CreateBrokerOrFail will create a Broker or fail the test if there is an error.
func (*Client) CreateBrokersOrFail ¶
CreateBrokersOrFail will create a list of Brokers.
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 (client *Client) CreateChannelWithDefaultOrFail(channel *messagingv1alpha1.Channel)
CreateChannelWithDefaultOrFail 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 (client *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 (client *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) CreateConfigMapPropagationOrFail ¶ added in v0.13.0
func (client *Client) CreateConfigMapPropagationOrFail(name string) *configsv1alpha1.ConfigMapPropagation
func (*Client) CreateCronJobOrFail ¶
func (client *Client) CreateCronJobOrFail(cronjob *batchv1beta1.CronJob, options ...func(*batchv1beta1.CronJob, *Client) error)
CreateCronJobOrFail will create a CronJob or fail the test if there is an error.
func (*Client) CreateDeploymentOrFail ¶
func (client *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 ¶
func (client *Client) CreateFlowsParallelOrFail(parallel *flowsv1alpha1.Parallel)
CreateFlowsParallelOrFail will create a Parallel (in flows.knative.dev api group) or fail the test if there is an error.
func (*Client) CreateFlowsSequenceOrFail ¶
func (client *Client) CreateFlowsSequenceOrFail(sequence *flowsv1alpha1.Sequence)
CreateFlowsSequenceOrFail will create a Sequence (in flows.knative.dev api group) or fail the test if there is an error.
func (*Client) CreateLegacyApiServerSourceOrFail ¶
func (client *Client) CreateLegacyApiServerSourceOrFail(apiServerSource *legacysourcesv1alpha1.ApiServerSource)
CreateLegacyApiServerSourceOrFail will create an ApiServerSource
func (*Client) CreateLegacyContainerSourceOrFail ¶
func (client *Client) CreateLegacyContainerSourceOrFail(containerSource *legacysourcesv1alpha1.ContainerSource)
CreateLegacyContainerSourceOrFail will create a ContainerSource or fail the test if there is an error.
func (*Client) CreateLegacyCronJobSourceOrFail ¶
func (client *Client) CreateLegacyCronJobSourceOrFail(cronJobSource *legacysourcesv1alpha1.CronJobSource)
CreateLegacyCronJobSourceOrFail will create a CronJobSource or fail the test if there is an error.
func (*Client) CreateLegacySinkBindingOrFail ¶
func (client *Client) CreateLegacySinkBindingOrFail(sb *legacysourcesv1alpha1.SinkBinding)
CreateLegacySinkBindingOrFail will create a SinkBinding or fail the test if there is an error.
func (*Client) CreatePingSourceV1Alpha1OrFail ¶ added in v0.13.0
func (client *Client) CreatePingSourceV1Alpha1OrFail(pingSource *sourcesv1alpha1.PingSource)
CreatePingSourceV1Alpha1OrFail will create an PingSource
func (*Client) CreatePingSourceV1Alpha2OrFail ¶ added in v0.13.0
func (client *Client) CreatePingSourceV1Alpha2OrFail(pingSource *sourcesv1alpha2.PingSource)
CreatePingSourceV1Alpha2OrFail will create an PingSource
func (*Client) CreatePodOrFail ¶
CreatePodOrFail will create a Pod or fail the test if there is an error.
func (*Client) CreateRBACResourcesForBrokers ¶
func (client *Client) CreateRBACResourcesForBrokers()
CreateRBACResourcesForBrokers creates required RBAC resources for creating Brokers, see https://github.com/knative/docs/blob/master/docs/eventing/broker-trigger.md - Manual Setup.
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) CreateSinkBindingV1Alpha1OrFail ¶ added in v0.13.0
func (client *Client) CreateSinkBindingV1Alpha1OrFail(sb *sourcesv1alpha1.SinkBinding)
CreateSinkBindingV1Alpha1OrFail will create a SinkBinding or fail the test if there is an error.
func (*Client) CreateSinkBindingV1Alpha2OrFail ¶ added in v0.13.0
func (client *Client) CreateSinkBindingV1Alpha2OrFail(sb *sourcesv1alpha2.SinkBinding)
CreateSinkBindingV1Alpha2OrFail will create a SinkBinding or fail the test if there is an error.
func (*Client) CreateSubscriptionOrFail ¶
func (client *Client) CreateSubscriptionOrFail( name, channelName string, channelTypeMeta *metav1.TypeMeta, options ...resources.SubscriptionOption, )
CreateSubscriptionOrFail will create a Subscription or fail the test if there is an error.
func (*Client) CreateSubscriptionOrFailV1Beta1 ¶ added in v0.13.0
func (client *Client) CreateSubscriptionOrFailV1Beta1( name, channelName string, channelTypeMeta *metav1.TypeMeta, options ...resources.SubscriptionOptionV1Beta1, )
CreateSubscriptionOrFailV1Beta1 will create a Subscription or fail the test if there is an error.
func (*Client) CreateSubscriptionsOrFail ¶
func (client *Client) CreateSubscriptionsOrFail( names []string, channelName string, channelTypeMeta *metav1.TypeMeta, options ...resources.SubscriptionOption, )
CreateSubscriptionsOrFail will create a list of Subscriptions with the same configuration except the name.
func (*Client) CreateTriggerOrFail ¶
func (client *Client) CreateTriggerOrFail(name string, options ...resources.TriggerOption) *v1alpha1.Trigger
CreateTriggerOrFail will create a Trigger or fail the test if there is an error.
func (*Client) CreateTriggerOrFailV1Beta1 ¶ added in v0.13.0
func (client *Client) CreateTriggerOrFailV1Beta1(name string, options ...resources.TriggerOptionV1Beta1) *v1beta1.Trigger
CreateTriggerOrFailV1Beta1 will create a v1beta1 Trigger or fail the test if there is an error.
func (*Client) FindAnyLogContents ¶
FindAnyLogContents attempts to find logs for given Pod/Container that has 'any' of the given contents. It returns an error if it couldn't retrieve the logs. In case 'any' of the contents are there, it returns true.
func (*Client) GetAddressableURI ¶
func (client *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) GetLog ¶
GetLog gets the logs from the given Pod in the namespace of this client. It will get the logs from the first container, whichever it is.
func (*Client) LabelNamespace ¶
LabelNamespace labels the given namespace with the labels map.
func (*Client) SendFakeEventToAddressableOrFail ¶ added in v0.13.0
func (client *Client) SendFakeEventToAddressableOrFail( senderName, addressableName string, typemeta *metav1.TypeMeta, event *cloudevents.CloudEvent, )
SendFakeEventToAddressableOrFail will send the given event to the given Addressable.
func (*Client) SendFakeEventWithTracingToAddressableOrFail ¶ added in v0.13.0
func (client *Client) SendFakeEventWithTracingToAddressableOrFail( senderName, addressableName string, typemeta *metav1.TypeMeta, event *cloudevents.CloudEvent, )
SendFakeEventWithTracingToAddressableOrFail will send the given event with tracing to the given Addressable.
func (*Client) WaitForAllTestResourcesReady ¶
WaitForAllTestResourcesReady waits until all test resources in the namespace are Ready.
func (*Client) WaitForAllTestResourcesReadyOrFail ¶
func (client *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.
func (*Client) WaitForServiceEndpointsOrFail ¶
type Feature ¶
type Feature string
Feature is the feature supported by the channel.
const ( // FeatureBasic is the feature that should be supported by all channels. 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" )
type ResourceDeleter ¶
type ResourceDeleter struct { Resource dynamic.ResourceInterface Name 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.