lib

package
v0.16.4 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2020 License: Apache-2.0 Imports: 49 Imported by: 58

Documentation

Index

Constants

View Source
const (
	// Default Event values
	DefaultEventSource = "http://knative.test"
	DefaultEventType   = "dev.knative.test.event"
)
View Source
const (
	ClusterRoleKind = "ClusterRole"
	RoleKind        = "Role"
)

Variables

BrokerTypeMeta is the TypeMeta ref for Broker.

ComponentFeatureMap saves the channel-features mapping. Each pair means the channel support the list of features.

ChannelTypeMeta is the TypeMeta ref for Channel.

View Source
var DefaultChannel = InMemoryChannelTypeMeta

DefaultChannel is the default channel we will run tests against.

View Source
var FlowsParallelTypeMeta = FlowsTypeMeta(resources.FlowsParallelKind)

FlowsParallelTypeMeta is the TypeMeta ref for Parallel (in flows.knative.dev).

View Source
var FlowsSequenceTypeMeta = FlowsTypeMeta(resources.FlowsSequenceKind)

FlowsSequenceTypeMeta is the TypeMeta ref for Sequence (in flows.knative.dev).

View Source
var InMemoryChannelTypeMeta = metav1.TypeMeta{
	APIVersion: resources.MessagingAPIVersion,
	Kind:       resources.InMemoryChannelKind,
}

InMemoryChannelTypeMeta is the metav1.TypeMeta for InMemoryChannel.

View Source
var MessagingChannelTypeMeta = metav1.TypeMeta{
	APIVersion: resources.MessagingAPIVersion,
	Kind:       resources.ChannelKind,
}

MessagingChannelTypeMeta is the metav1.TypeMeta for messaging.Channel.

ParallelTypeMeta is the TypeMeta ref for Parallel.

SequenceTypeMeta is the TypeMeta ref for Sequence.

SubscriptionTypeMeta is the TypeMeta ref for Subscription.

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 CreateNamespaceIfNeeded

func CreateNamespaceIfNeeded(t *testing.T, client *Client, namespace string)

CreateNamespaceIfNeeded creates a new namespace if it does not exist.

func DeleteNameSpace

func DeleteNameSpace(client *Client) error

DeleteNameSpace deletes the namespace that has the given name.

func EventingTypeMeta

func EventingTypeMeta(kind string) *metav1.TypeMeta

EventingTypeMeta returns the TypeMeta ref for an eventing resource.

func FlowsTypeMeta

func FlowsTypeMeta(kind string) *metav1.TypeMeta

FlowsTypeMeta returns the TypeMeta ref for an eventing messaing resource.

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

func MessagingTypeMeta(kind string) *metav1.TypeMeta

MessagingTypeMeta returns the TypeMeta ref for an eventing messaging resource.

func TearDown

func TearDown(client *Client)

TearDown will delete created names using clients.

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

func WithService

func WithService(name string) func(*corev1.Pod, *Client) error

WithService returns an option that creates a Service binded with the given pod.

Types

type AwaitRoutine added in v0.15.0

type AwaitRoutine func() error

type Client

type Client struct {
	Kube          *test.KubeClient
	Eventing      *eventing.Clientset
	Apiextensions *apiextensionsv1beta1.ApiextensionsV1beta1Client
	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) CreateApiServerSourceOrFail

func (c *Client) CreateApiServerSourceOrFail(apiServerSource *sourcesv1alpha2.ApiServerSource)

CreateApiServerSourceOrFail will create an ApiServerSource

func (*Client) CreateBrokerConfigMapOrFail added in v0.13.0

func (c *Client) CreateBrokerConfigMapOrFail(name string, channel *metav1.TypeMeta) *duckv1.KReference

func (*Client) CreateBrokerV1Beta1OrFail added in v0.13.0

func (c *Client) CreateBrokerV1Beta1OrFail(name string, options ...resources.BrokerV1Beta1Option) *v1beta1.Broker

CreateBrokerV1Beta1OrFail will create a v1beta1 Broker or fail the test if there is an error.

func (*Client) CreateBrokerV1OrFail added in v0.16.0

func (c *Client) CreateBrokerV1OrFail(name string, options ...resources.BrokerV1Option) *eventingv1.Broker

CreateBrokerV1OrFail will create a v1 Broker or fail the test if there is an error.

func (*Client) CreateChannelOrFail

func (c *Client) CreateChannelOrFail(name string, channelTypeMeta *metav1.TypeMeta)

CreateChannelOrFail will create a typed Channel Resource in Eventing or fail the test if there is an error.

func (*Client) CreateChannelV1WithDefaultOrFail added in v0.16.0

func (c *Client) CreateChannelV1WithDefaultOrFail(channel *messagingv1.Channel)

CreateChannelV1WithDefaultOrFail will create a default Channel Resource in Eventing or fail the test if there is an error.

func (*Client) CreateChannelWithDefaultOrFail

func (c *Client) CreateChannelWithDefaultOrFail(channel *messagingv1beta1.Channel)

CreateChannelWithDefaultOrFail will create a default Channel Resource in Eventing or fail the test if there is an error.

func (*Client) CreateChannelsOrFail

func (c *Client) CreateChannelsOrFail(names []string, channelTypeMeta *metav1.TypeMeta)

CreateChannelsOrFail will create a list of typed Channel Resources in Eventing or fail the test if there is an error.

func (*Client) CreateClusterRoleBindingOrFail

func (c *Client) CreateClusterRoleBindingOrFail(saName, crName, crbName string)

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) CreateContainerSourceV1Alpha2OrFail added in v0.14.0

func (c *Client) CreateContainerSourceV1Alpha2OrFail(containerSource *sourcesv1alpha2.ContainerSource)

CreateContainerSourceV1Alpha2OrFail will create a ContainerSource.

func (*Client) CreateCronJobOrFail

func (c *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 (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

func (c *Client) CreateFlowsParallelOrFail(parallel *flowsv1beta1.Parallel)

CreateFlowsParallelOrFail will create a Parallel (in flows.knative.dev api group) or fail the test if there is an error.

func (*Client) CreateFlowsParallelV1OrFail added in v0.16.0

func (c *Client) CreateFlowsParallelV1OrFail(parallel *flowsv1.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 (c *Client) CreateFlowsSequenceOrFail(sequence *flowsv1beta1.Sequence)

CreateFlowsSequenceOrFail will create a Sequence (in flows.knative.dev api group) or fail the test if there is an error.

func (*Client) CreateFlowsSequenceV1OrFail added in v0.16.0

func (c *Client) CreateFlowsSequenceV1OrFail(sequence *flowsv1.Sequence)

CreateFlowsSequenceOrFail will create a Sequence (in flows.knative.dev api group) or fail the test if there is an error.

func (*Client) CreatePingSourceV1Alpha1OrFail added in v0.13.0

func (c *Client) CreatePingSourceV1Alpha1OrFail(pingSource *sourcesv1alpha1.PingSource)

CreatePingSourceV1Alpha1OrFail will create an PingSource

func (*Client) CreatePingSourceV1Alpha2OrFail added in v0.13.0

func (c *Client) CreatePingSourceV1Alpha2OrFail(pingSource *sourcesv1alpha2.PingSource)

CreatePingSourceV1Alpha2OrFail will create an PingSource

func (*Client) CreatePodOrFail

func (c *Client) CreatePodOrFail(pod *corev1.Pod, options ...func(*corev1.Pod, *Client) error)

CreatePodOrFail will create a Pod or fail the test if there is an error.

func (*Client) CreateRBACResourcesForBrokers

func (c *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

func (c *Client) CreateRoleBindingOrFail(saName, rKind, rName, rbName, rbNamespace string)

CreateRoleBindingOrFail will create a RoleBinding or fail the test if there is an error.

func (*Client) CreateRoleOrFail

func (c *Client) CreateRoleOrFail(r *rbacv1.Role)

CreateRoleOrFail creates the given Role in the Client namespace or fail the test if there is an error.

func (*Client) CreateServiceAccountOrFail

func (c *Client) CreateServiceAccountOrFail(saName string)

CreateServiceAccountOrFail will create a ServiceAccount or fail the test if there is an error.

func (*Client) CreateServiceOrFail

func (c *Client) CreateServiceOrFail(svc *corev1.Service) *corev1.Service

func (*Client) CreateSinkBindingV1Alpha1OrFail added in v0.13.0

func (c *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 (c *Client) CreateSinkBindingV1Alpha2OrFail(sb *sourcesv1alpha2.SinkBinding)

CreateSinkBindingV1Alpha2OrFail 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.SubscriptionOptionV1Beta1,
) *messagingv1beta1.Subscription

CreateSubscriptionOrFail will create a v1beta1 Subscription or fail the test if there is an error.

func (*Client) CreateSubscriptionV1OrFail added in v0.16.0

func (c *Client) CreateSubscriptionV1OrFail(
	name, channelName string,
	channelTypeMeta *metav1.TypeMeta,
	options ...resources.SubscriptionOptionV1,
) *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.SubscriptionOptionV1Beta1,
)

CreateSubscriptionsOrFail will create a list of v1beta1 Subscriptions with the same configuration except the name.

func (*Client) CreateSubscriptionsV1OrFail added in v0.16.0

func (c *Client) CreateSubscriptionsV1OrFail(
	names []string,
	channelName string,
	channelTypeMeta *metav1.TypeMeta,
	options ...resources.SubscriptionOptionV1,
)

CreateSubscriptionsV1OrFail will create a list of v1 Subscriptions with the same configuration except the name.

func (*Client) CreateTriggerOrFailV1Beta1 added in v0.13.0

func (c *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) CreateTriggerV1OrFail added in v0.16.0

func (c *Client) CreateTriggerV1OrFail(name string, options ...resources.TriggerOptionV1) *eventingv1.Trigger

CreateTriggerOrFailV1 will create a v1 Trigger or fail the test if there is an error.

func (*Client) ExportLogs added in v0.15.0

func (c *Client) ExportLogs(dir string) error

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

func (c *Client) GetServiceHost(podName string) string

GetServiceHost returns the service hostname for the specified podName

func (*Client) LabelNamespace

func (c *Client) LabelNamespace(labels map[string]string) error

LabelNamespace labels the given namespace with the labels map.

func (*Client) SendEvent added in v0.16.0

func (c *Client) SendEvent(
	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(
	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(
	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(
	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

func (c *Client) WaitForAllTestResourcesReady() error

WaitForAllTestResourcesReady waits until all test resources in the namespace are Ready.

func (*Client) WaitForAllTestResourcesReadyOrFail

func (c *Client) WaitForAllTestResourcesReadyOrFail()

func (*Client) WaitForResourceReadyOrFail

func (c *Client) WaitForResourceReadyOrFail(name string, typemeta *metav1.TypeMeta)

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

func (c *Client) WaitForResourcesReadyOrFail(typemeta *metav1.TypeMeta)

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

func (c *Client) WaitForServiceEndpointsOrFail(svcName string, numberOfExpectedEndpoints int)

type ComponentsTestRunner added in v0.16.0

type ComponentsTestRunner struct {
	ComponentFeatureMap map[metav1.TypeMeta][]Feature
	ComponentsToTest    []metav1.TypeMeta
}

ComponentsTestRunner is used to run tests against different eventing components.

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.

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

func NewTracker(t *testing.T, client dynamic.Interface) *Tracker

NewTracker creates a new Tracker

func (*Tracker) Add

func (t *Tracker) Add(group string, version string, resource string, namespace string, name string)

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) Clean

func (t *Tracker) Clean(awaitDeletion bool) error

Clean will delete all registered resources

func (*Tracker) WaitForKResourcesReady

func (t *Tracker) WaitForKResourcesReady() error

WaitForKResourcesReady will wait for all registered KResources to become ready.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL