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 GetChannelTypeMeta(provisioner string, isCRD bool) *metav1.TypeMeta
- func LogPodLogsForDebugging(client *Client, podName, containerName string)
- func MessagingTypeMeta(kind string) *metav1.TypeMeta
- func RunTests(t *testing.T, provisioners []string, feature Feature, ...)
- func SourcesTypeMeta(kind string) *metav1.TypeMeta
- func TearDown(client *Client)
- func WithService(name string) func(*corev1.Pod, *Client) error
- type ChannelConfig
- type Client
- func (client *Client) CheckLog(podName string, checker func(string) bool) error
- func (client *Client) CreateApiServerSourceOrFail(name string, apiServerSourceResources []sourcesv1alpha1.ApiServerResource, ...)
- func (client *Client) CreateBrokerOrFail(name string, channelTypeMeta *metav1.TypeMeta, provisionerName string)
- func (client *Client) CreateBrokersOrFail(names []string, channelTypeMeta *metav1.TypeMeta, provisionerName string)
- func (client *Client) CreateChannelOrFail(name string, channelTypeMeta *metav1.TypeMeta, provisionerName string)
- func (client *Client) CreateChannelsOrFail(names []string, channelTypeMeta *metav1.TypeMeta, provisionerName string)
- func (client *Client) CreateClusterRoleBindingOrFail(saName, crName, crbName string)
- func (client *Client) CreateClusterRoleOrFail(cr *rbacv1.ClusterRole)
- func (client *Client) CreateContainerSourceOrFail(name string, options ...resources.ContainerSourceOption)
- func (client *Client) CreateCronJobSourceOrFail(name, schedule, data string, options ...resources.CronJobSourceOption)
- func (client *Client) CreatePodOrFail(pod *corev1.Pod, options ...func(*corev1.Pod, *Client) error)
- func (client *Client) CreateRBACResourcesForBrokers()
- func (client *Client) CreateRoleBindingOrFail(saName, crName, rbName, rbNamespace string)
- func (client *Client) CreateServiceAccountOrFail(saName string)
- func (client *Client) CreateSubscriptionOrFail(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)
- func (client *Client) FindAnyLogContents(podName string, contents []string) (bool, error)
- func (client *Client) GetAddressableURI(addressableName string, typemeta *metav1.TypeMeta) (string, error)
- func (client *Client) LabelNamespace(labels map[string]string) error
- func (client *Client) SendFakeEventToAddressable(senderName, addressableName string, typemeta *metav1.TypeMeta, ...) error
- func (client *Client) WaitForAllTestResourcesReady() error
- func (client *Client) WaitForResourceReady(name string, typemeta *metav1.TypeMeta) error
- func (client *Client) WaitForResourcesReady(typemeta *metav1.TypeMeta) error
- type Feature
- type ResourceDeleter
- type Tracker
Constants ¶
const DefaultClusterChannelProvisioner = resources.InMemoryProvisioner
DefaultClusterChannelProvisioner is the default ClusterChannelProvisioner we will run tests against.
Variables ¶
var ApiServerSourceTypeMeta = SourcesTypeMeta(resources.ApiServerSourceKind)
ApiServerSourceTypeMeta is the TypeMeta ref for ApiServerSource.
var BrokerTypeMeta = EventingTypeMeta(resources.BrokerKind)
BrokerTypeMeta is the TypeMeta ref for Broker.
var ChannelTypeMeta = EventingTypeMeta(resources.ChannelKind)
ChannelTypeMeta is the TypeMeta ref for Channel.
var ContainerSourceTypeMeta = SourcesTypeMeta(resources.ContainerSourceKind)
ContainerSourceTypeMeta is the TypeMeta ref for ContainerSource.
var CronJobSourceTypeMeta = SourcesTypeMeta(resources.CronJobSourceKind)
CronJobSourceTypeMeta is the TypeMeta ref for CronJobSource.
var InMemoryChannelTypeMeta = MessagingTypeMeta(resources.InMemoryChannelKind)
InMemoryChannelTypeMeta is the TypeMeta ref for InMemoryChannel.
var KafkaChannelTypeMeta = MessagingTypeMeta(resources.KafkaChannelKind)
KafkaChannelTypeMeta is the TypeMeta ref for KafkaChannel.
var NatssChannelTypeMeta = MessagingTypeMeta(resources.NatssChannelKind)
NatssChannelTypeMeta is the TypeMeta ref for NatssChannel.
var ProvisionerChannelMap = map[string]*metav1.TypeMeta{ resources.KafkaProvisioner: KafkaChannelTypeMeta, resources.InMemoryProvisioner: InMemoryChannelTypeMeta, resources.NatssProvisioner: NatssChannelTypeMeta, }
ProvisionerChannelMap saves the mapping between provisioners and CRD channel typemeta. TODO(Fredy-Z): this map will not be needed anymore when we delete the provisioner implementation.
var SubscriptionTypeMeta = EventingTypeMeta(resources.SubscriptionKind)
SubscriptionTypeMeta is the TypeMeta ref for Subscription.
var TriggerTypeMeta = EventingTypeMeta(resources.TriggerKind)
TriggerTypeMeta is the TypeMeta ref for Trigger.
var ValidProvisionersMap = map[string]ChannelConfig{ resources.InMemoryProvisioner: { Features: []Feature{FeatureBasic}, CRDSupported: true, }, resources.GCPPubSubProvisioner: { Features: []Feature{FeatureBasic, FeatureRedelivery, FeaturePersistence}, }, resources.KafkaProvisioner: { Features: []Feature{FeatureBasic, FeatureRedelivery, FeaturePersistence}, CRDSupported: true, }, resources.NatssProvisioner: { Features: []Feature{FeatureBasic, FeatureRedelivery, FeaturePersistence}, CRDSupported: true, }, }
ValidProvisionersMap saves the provisioner-features mapping. Each pair means the provisioner support the list of features.
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 GetChannelTypeMeta ¶
GetChannelTypeMeta gets the actual typemeta of the Channel type. TODO(Fredy-Z): This function is a workaround when there are both provisioner and Channel CRD in this repo.
It needs to be removed when the provisioner implementation is removed.
func LogPodLogsForDebugging ¶
LogPodLogsForDebugging add the pod logs in the testing log for further debugging.
func MessagingTypeMeta ¶
MessagingTypeMeta returns the TypeMeta ref for an eventing messaing resource.
func RunTests ¶
func RunTests( t *testing.T, provisioners []string, feature Feature, testFunc func(st *testing.T, provisioner string, isCRD bool), )
RunTests will use all provisioners that support the given feature, to run a test for the testFunc.
func SourcesTypeMeta ¶
SourcesTypeMeta returns the TypeMeta ref for an eventing sources resource.
Types ¶
type ChannelConfig ¶
ChannelConfig includes general configuration for a Channel provisioner.
type Client ¶
type Client struct { Kube *test.KubeClient Eventing *eventing.Clientset Dynamic dynamic.Interface Kafka *kafkachannel.Clientset Natss *natsschannel.Clientset Namespace string T *testing.T Tracker *Tracker }
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 ¶
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) 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) CreateApiServerSourceOrFail ¶
func (client *Client) CreateApiServerSourceOrFail( name string, apiServerSourceResources []sourcesv1alpha1.ApiServerResource, mode string, options ...resources.ApiServerSourceOption, )
CreateApiServerSourceOrFail will create an ApiServerSource
func (*Client) CreateBrokerOrFail ¶
func (client *Client) CreateBrokerOrFail(name string, channelTypeMeta *metav1.TypeMeta, provisionerName string)
CreateBrokerOrFail will create a Broker or fail the test if there is an error.
func (*Client) CreateBrokersOrFail ¶
func (client *Client) CreateBrokersOrFail(names []string, channelTypeMeta *metav1.TypeMeta, provisionerName string)
CreateBrokersOrFail will create a list of Brokers.
func (*Client) CreateChannelOrFail ¶
func (client *Client) CreateChannelOrFail(name string, channelTypeMeta *metav1.TypeMeta, provisionerName string)
CreateChannelOrFail will create a Channel Resource in Eventing.
func (*Client) CreateChannelsOrFail ¶
func (client *Client) CreateChannelsOrFail(names []string, channelTypeMeta *metav1.TypeMeta, provisionerName string)
CreateChannelsOrFail will create a list of Channel Resources in Eventing.
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) CreateContainerSourceOrFail ¶
func (client *Client) CreateContainerSourceOrFail( name string, options ...resources.ContainerSourceOption, )
CreateContainerSourceOrFail will create a ContainerSource or fail the test if there is an error.
func (*Client) CreateCronJobSourceOrFail ¶
func (client *Client) CreateCronJobSourceOrFail( name, schedule, data string, options ...resources.CronJobSourceOption, )
CreateCronJobSourceOrFail will create a CronJobSource or fail the test if there is an error.
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) CreateServiceAccountOrFail ¶
CreateServiceAccountOrFail will create a ServiceAccount 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) 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)
CreateTriggerOrFail will create a 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) LabelNamespace ¶
LabelNamespace labels the given namespace with the labels map.
func (*Client) SendFakeEventToAddressable ¶
func (client *Client) SendFakeEventToAddressable( senderName, addressableName string, typemeta *metav1.TypeMeta, event *resources.CloudEvent, ) error
SendFakeEventToAddressable will send the given event to the given Addressable.
func (*Client) WaitForAllTestResourcesReady ¶
WaitForAllTestResourcesReady waits until all test resources in the namespace are Ready.
func (*Client) WaitForResourceReady ¶
WaitForResourceReady waits for the resource to become ready. To use this function, the given resource must have implemented the Status duck-type.
type Feature ¶
type Feature string
Feature is the feature supported by the Channel provisioner.
const ( // FeatureBasic is the feature that should be supported by all Channel provisioners 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 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(log logging.FormatLogger, client dynamic.Interface) *Tracker
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.