Documentation ¶
Overview ¶
Utility functions used for testing
Index ¶
- Constants
- Variables
- func AddRandomFile(ctx context.Context, t *testing.T, bucketName, fileName, project string)
- func AssertMetrics(t *testing.T, client *Client, topicName, psName string)
- func BuildWithConfigFile(t *testing.T, imageName string) string
- func CloudBuildImage(project, imageName string) string
- func DeleteBucket(ctx context.Context, t *testing.T, bucketName string)
- func DeleteTopicOrDie(t *testing.T, topicName string)
- func DuplicatePubSubSecret(ctx context.Context, client *eventingtestlib.Client)
- func GetCredential(ctx context.Context, client *eventingtestlib.Client, workloadIdentity bool)
- func GetEnvOrFail(t *testing.T, key string) string
- func GetTopic(t *testing.T, topicName string) *pubsub.Topic
- func MakeAuditLogsJobOrDie(client *Client, ...)
- func MakeAuditLogsOrDie(client *Client, config AuditLogsConfig)
- func MakeAuditLogsV1beta1OrDie(client *Client, config AuditLogsConfig)
- func MakeBucket(ctx context.Context, t *testing.T, project string) string
- func MakeBuildOrDie(client *Client, config BuildConfig)
- func MakeBuildTargetJobOrDie(client *Client, images, targetName, eventType string)
- func MakeBuildV1beta1OrDie(client *Client, config BuildConfig)
- func MakePubSub(client *Client, config PubSubConfig)
- func MakePubSubOrDie(client *Client, config PubSubConfig)
- func MakePubSubTargetJobOrDie(client *Client, source, targetName, eventType string, schema string)
- func MakePubSubV1beta1OrDie(client *Client, config PubSubConfig)
- func MakePullSubscriptionOrDie(client *Client, config PullSubscriptionConfig)
- func MakePullSubscriptionV1beta1OrDie(client *Client, config PullSubscriptionConfig)
- func MakeSchedulerJobOrDie(client *Client, data, targetName, eventType string)
- func MakeSchedulerOrDie(client *Client, config SchedulerConfig)
- func MakeSchedulerV1beta1OrDie(client *Client, config SchedulerConfig)
- func MakeStorageJobOrDie(client *Client, source, subject, targetName, eventType string)
- func MakeStorageOrDie(client *Client, config StorageConfig)
- func MakeStorageV1beta1OrDie(client *Client, config StorageConfig)
- func MakeTopicOrDie(t *testing.T) (string, func())
- func MakeTopicWithNameIfItDoesNotExist(t *testing.T, topicName string)
- func MakeTopicWithNameOrDie(t *testing.T, topicName string) (string, func())
- func NotificationExists(t *testing.T, bucketName, notificationID string) bool
- func SchedulerJobExists(t *testing.T, jobName string) bool
- func SetTracingToZipkin(ctx context.Context, client *eventingtestlib.Client)
- func StackdriverSinkExists(t *testing.T, sinkID string) bool
- func SubscriptionExists(t *testing.T, subID string) bool
- func TearDown(ctx context.Context, client *Client)
- func TopicExists(t *testing.T, topicID string) bool
- func WaitForSourceAuthCheckPending(dynamicClient dynamic.Interface, obj *resources.MetaResource, ...) error
- func WithServiceForJob(name string) func(*batchv1.Job, *Client) error
- type AuditLogsConfig
- type AuthConfig
- type BrokerMetricAssertion
- type BuildConfig
- type Client
- func (c *Client) CreateAuditLogsOrFail(auditlogs *eventsv1.CloudAuditLogsSource)
- func (c *Client) CreateAuditLogsV1beta1OrFail(auditlogs *eventsv1beta1.CloudAuditLogsSource)
- func (c *Client) CreateBuildOrFail(build *eventsv1.CloudBuildSource)
- func (c *Client) CreateBuildV1beta1OrFail(build *eventsv1beta1.CloudBuildSource)
- func (c *Client) CreateChannelOrFail(channel *messagingv1beta1.Channel)
- func (c *Client) CreateGCPBrokerV1Beta1OrFail(name string, options ...reconcilertesting.BrokerOption) *v1beta1.Broker
- func (c *Client) CreateJobOrFail(job *batchv1.Job, options ...func(*batchv1.Job, *Client) error)
- func (c *Client) CreatePubSubOrFail(pubsub *eventsv1.CloudPubSubSource)
- func (c *Client) CreatePubSubV1beta1OrFail(pubsub *eventsv1beta1.CloudPubSubSource)
- func (c *Client) CreatePullSubscriptionOrFail(pullsubscription *inteventsv1.PullSubscription)
- func (c *Client) CreatePullSubscriptionV1beta1OrFail(pullsubscription *inteventsv1beta1.PullSubscription)
- func (c *Client) CreateSchedulerOrFail(scheduler *eventsv1.CloudSchedulerSource)
- func (c *Client) CreateSchedulerV1beta1OrFail(scheduler *eventsv1beta1.CloudSchedulerSource)
- func (c *Client) CreateSecretOrFail(secret *corev1.Secret)
- func (c *Client) CreateServiceAccountOrFail(sa *corev1.ServiceAccount)
- func (c *Client) CreateStorageOrFail(storage *eventsv1.CloudStorageSource)
- func (c *Client) CreateStorageV1beta1OrFail(storage *eventsv1beta1.CloudStorageSource)
- func (c *Client) CreateTopicOrFail(topic *inteventsv1.Topic)
- func (c *Client) CreateUnstructuredObjOrFail(spec *unstructured.Unstructured)
- func (c *Client) DeleteAuditLogsOrFail(name string)
- func (c *Client) DeleteBuildOrFail(name string)
- func (c *Client) DeleteGCPBrokerOrFail(name string)
- func (c *Client) DeletePubSubOrFail(name string)
- func (c *Client) DeleteSchedulerOrFail(name string)
- func (c *Client) DeleteStorageOrFail(name string)
- func (c *Client) GetAuditLogsOrFail(name string) *eventsv1.CloudAuditLogsSource
- func (c *Client) GetBuildOrFail(name string) *eventsv1.CloudBuildSource
- func (c *Client) GetPubSubOrFail(name string) *eventsv1.CloudPubSubSource
- func (c *Client) GetSchedulerOrFail(name string) *eventsv1.CloudSchedulerSource
- func (c *Client) GetStorageOrFail(name string) *eventsv1.CloudStorageSource
- func (c *Client) LogsFor(ctx context.Context, namespace, name string, tm *metav1.TypeMeta) (string, error)
- func (c *Client) SetupStackDriverMetrics(ctx context.Context, t *testing.T)
- func (c *Client) SetupStackDriverMetricsInNamespace(ctx context.Context, t *testing.T)
- func (c *Client) StackDriverEventCountMetricFor(_, projectID, filter string) (int64, error)
- func (c *Client) WaitForSourceAuthCheckPendingOrFail(name string, typemeta *metav1.TypeMeta, wantMessage string)
- func (c *Client) WaitUntilJobDone(ctx context.Context, namespace, name string) (string, error)
- type Output
- type PropPair
- type PubSubConfig
- type PullSubscriptionConfig
- type SchedulerConfig
- type SenderOutput
- type StorageConfig
- type TargetOutput
- type TriggerAssertionKey
- type TriggerMetricAssertion
Constants ¶
const ( PubSubServiceName = "pubsub.googleapis.com" PubSubCreateTopicMethodName = "google.pubsub.v1.Publisher.CreateTopic" )
const ( ProwProjectKey = "E2E_PROJECT_ID" EventCountMetricType = "custom.googleapis.com/cloud.google.com/source/event_count" GlobalMetricResourceType = "global" StorageResourceGroup = "storages.events.cloud.google.com" PubsubResourceGroup = "pubsubs.events.cloud.google.com" BrokerEventCountMetricType = "knative.dev/eventing/broker/event_count" BrokerMetricResourceType = "knative_broker" TriggerEventCountMetricType = "knative.dev/eventing/trigger/event_count" TriggerEventDispatchLatencyType = "knative.dev/eventing/trigger/event_dispatch_latencies" TriggerEventProcessingLatencyType = "knative.dev/eventing/trigger/event_processing_latencies" TriggerMonitoredResourceType = "knative_trigger" EventType = "type" EventSource = "source" EventDataSchema = "dataschema" EventSubject = "subject" EventSubjectPrefix = "subject-prefix" EventID = "id" EventData = "data" E2ERespEventIDPrefix = "e2e-testing-resp-event-id" E2EPubSubRespEventID = E2ERespEventIDPrefix + "-pubsub" E2EBuildRespEventID = E2ERespEventIDPrefix + "-build" E2EStorageRespEventID = E2ERespEventIDPrefix + "-storage" E2EAuditLogsRespEventID = E2ERespEventIDPrefix + "-auditlogs" E2ESchedulerRespEventID = E2ERespEventIDPrefix + "-scheduler" E2ESampleRespEventID = E2ERespEventIDPrefix + "-sample" E2ERespEventTypePrefix = "e2e-testing-resp-event-type" E2EPubSubRespEventType = E2ERespEventTypePrefix + "-pubsub" E2EBuildRespEventType = E2ERespEventTypePrefix + "-build" E2EStorageRespEventType = E2ERespEventTypePrefix + "-storage" E2EAuditLogsRespType = E2ERespEventTypePrefix + "-auditlogs" E2ESchedulerRespType = E2ERespEventTypePrefix + "-scheduler" E2ESampleRespEventType = E2ERespEventTypePrefix + "-sample" // Used in ../test_images/sender, ../test_images/receiver and ../test_images/receiver // E2ESampleEventID is the id of the event sent by image `sender` E2ESampleEventID = "e2e-sample-event-id" // E2ESampleEventType is the type of the event sent by image `sender` E2ESampleEventType = "e2e-sample-event-type" // E2ESampleEventSource is the source of the event sent by image `sender` E2ESampleEventSource = "e2e-sample-event-source" // E2ESampleRespEventSource is the source of the resp event sent by image `receiver` E2ESampleRespEventSource = "e2e-sample-resp-event-source" )
Variables ¶
var BrokerGVK = metav1.GroupVersionKind{
Group: "eventing.knative.dev",
Version: "v1beta1",
Kind: "Broker"}
var ChannelTypeMeta = messagingTypeMeta(resources.ChannelKind)
var CloudAuditLogsSourceV1TypeMeta = eventsV1TypeMeta(resources.CloudAuditLogsSourceKind)
var CloudAuditLogsSourceV1alpha1TypeMeta = eventsV1alpha1TypeMeta(resources.CloudAuditLogsSourceKind)
var CloudAuditLogsSourceV1beta1TypeMeta = eventsV1beta1TypeMeta(resources.CloudAuditLogsSourceKind)
var CloudBuildSourceV1TypeMeta = eventsV1TypeMeta(resources.CloudBuildSourceKind)
var CloudBuildSourceV1alpha1TypeMeta = eventsV1alpha1TypeMeta(resources.CloudBuildSourceKind)
var CloudBuildSourceV1beta1TypeMeta = eventsV1beta1TypeMeta(resources.CloudBuildSourceKind)
var CloudPubSubSourceV1TypeMeta = eventsV1TypeMeta(resources.CloudPubSubSourceKind)
var CloudPubSubSourceV1alpha1TypeMeta = eventsV1alpha1TypeMeta(resources.CloudPubSubSourceKind)
var CloudPubSubSourceV1beta1TypeMeta = eventsV1beta1TypeMeta(resources.CloudPubSubSourceKind)
var CloudSchedulerSourceV1TypeMeta = eventsV1TypeMeta(resources.CloudSchedulerSourceKind)
var CloudSchedulerSourceV1alpha1TypeMeta = eventsV1alpha1TypeMeta(resources.CloudSchedulerSourceKind)
var CloudSchedulerSourceV1beta1TypeMeta = eventsV1beta1TypeMeta(resources.CloudSchedulerSourceKind)
var CloudStorageSourceV1TypeMeta = eventsV1TypeMeta(resources.CloudStorageSourceKind)
var CloudStorageSourceV1alpha1TypeMeta = eventsV1alpha1TypeMeta(resources.CloudStorageSourceKind)
var CloudStorageSourceV1beta1TypeMeta = eventsV1beta1TypeMeta(resources.CloudStorageSourceKind)
var JobTypeMeta = batchTypeMeta(resources.JobKind)
var KsvcTypeMeta = servingTypeMeta(resources.KServiceKind)
var PullSubscriptionV1TypeMeta = inteventsV1TypeMeta(resources.PullSubscriptionKind)
var PullSubscriptionV1alpha1TypeMeta = inteventsV1alpha1TypeMeta(resources.PullSubscriptionKind)
var PullSubscriptionV1beta1TypeMeta = inteventsV1beta1TypeMeta(resources.PullSubscriptionKind)
var ServiceGVK = metav1.GroupVersionKind{
Version: "v1",
Kind: "Service"}
Functions ¶
func AddRandomFile ¶
func CloudBuildImage ¶
func DeleteTopicOrDie ¶
func DuplicatePubSubSecret ¶
func DuplicatePubSubSecret(ctx context.Context, client *eventingtestlib.Client)
DuplicatePubSubSecret duplicates the PubSub secret to the test namespace.
func GetCredential ¶
func GetCredential(ctx context.Context, client *eventingtestlib.Client, workloadIdentity bool)
func GetEnvOrFail ¶
GetEnvOrFail gets the specified environment variable. If the variable is not set, then the test exits with an error.
func MakeAuditLogsJobOrDie ¶
func MakeAuditLogsOrDie ¶
func MakeAuditLogsOrDie(client *Client, config AuditLogsConfig)
func MakeAuditLogsV1beta1OrDie ¶
func MakeAuditLogsV1beta1OrDie(client *Client, config AuditLogsConfig)
func MakeBucket ¶
MakeBucket retrieves the bucket name for the test. If it does not exist, it will create it.
func MakeBuildOrDie ¶
func MakeBuildOrDie(client *Client, config BuildConfig)
func MakeBuildTargetJobOrDie ¶
func MakeBuildV1beta1OrDie ¶
func MakeBuildV1beta1OrDie(client *Client, config BuildConfig)
func MakePubSub ¶ added in v0.21.0
func MakePubSub(client *Client, config PubSubConfig)
func MakePubSubOrDie ¶
func MakePubSubOrDie(client *Client, config PubSubConfig)
func MakePubSubV1beta1OrDie ¶
func MakePubSubV1beta1OrDie(client *Client, config PubSubConfig)
func MakePullSubscriptionOrDie ¶
func MakePullSubscriptionOrDie(client *Client, config PullSubscriptionConfig)
func MakePullSubscriptionV1beta1OrDie ¶
func MakePullSubscriptionV1beta1OrDie(client *Client, config PullSubscriptionConfig)
func MakeSchedulerJobOrDie ¶
func MakeSchedulerOrDie ¶
func MakeSchedulerOrDie(client *Client, config SchedulerConfig)
func MakeSchedulerV1beta1OrDie ¶
func MakeSchedulerV1beta1OrDie(client *Client, config SchedulerConfig)
func MakeStorageJobOrDie ¶
func MakeStorageOrDie ¶
func MakeStorageOrDie(client *Client, config StorageConfig)
func MakeStorageV1beta1OrDie ¶
func MakeStorageV1beta1OrDie(client *Client, config StorageConfig)
func MakeTopicOrDie ¶
func MakeTopicWithNameOrDie ¶
func NotificationExists ¶
func SetTracingToZipkin ¶
func SetTracingToZipkin(ctx context.Context, client *eventingtestlib.Client)
func WaitForSourceAuthCheckPending ¶ added in v0.21.0
func WaitForSourceAuthCheckPending(dynamicClient dynamic.Interface, obj *resources.MetaResource, wantMessage string) error
WaitForSourceAuthCheckPending polls the status of the Source from client every interval until isSourceAuthCheckPending returns `true` indicating the Source is in AuthenticationCheckPending state and has wanted messages, or returns an error, or timeout. AuthenticationCheckPending is the state that will continue until authentication check succeeds.
Types ¶
type AuditLogsConfig ¶
type AuthConfig ¶
type BrokerMetricAssertion ¶
type BrokerMetricAssertion struct { ProjectID string BrokerName string BrokerNamespace string StartTime time.Time CountPerType map[string]int64 }
func (BrokerMetricAssertion) Assert ¶
func (a BrokerMetricAssertion) Assert(client *monitoring.MetricClient) error
func (BrokerMetricAssertion) StackdriverFilter ¶
func (a BrokerMetricAssertion) StackdriverFilter() string
type BuildConfig ¶
type BuildConfig struct { SinkGVK metav1.GroupVersionKind BuildName string SinkName string ServiceAccountName string }
type Client ¶
type Client struct { Core *lib.Client KnativeGCP *knativegcp.Clientset Namespace string T *testing.T Tracker *lib.Tracker }
Client holds instances of interfaces for making requests to Knative.
func (*Client) CreateAuditLogsOrFail ¶
func (c *Client) CreateAuditLogsOrFail(auditlogs *eventsv1.CloudAuditLogsSource)
func (*Client) CreateAuditLogsV1beta1OrFail ¶
func (c *Client) CreateAuditLogsV1beta1OrFail(auditlogs *eventsv1beta1.CloudAuditLogsSource)
func (*Client) CreateBuildOrFail ¶
func (c *Client) CreateBuildOrFail(build *eventsv1.CloudBuildSource)
func (*Client) CreateBuildV1beta1OrFail ¶
func (c *Client) CreateBuildV1beta1OrFail(build *eventsv1beta1.CloudBuildSource)
func (*Client) CreateChannelOrFail ¶
func (c *Client) CreateChannelOrFail(channel *messagingv1beta1.Channel)
func (*Client) CreateGCPBrokerV1Beta1OrFail ¶
func (c *Client) CreateGCPBrokerV1Beta1OrFail(name string, options ...reconcilertesting.BrokerOption) *v1beta1.Broker
CreateGCPBrokerV1Beta1OrFail will create a GCP Broker or fail the test if there is an error.
func (*Client) CreateJobOrFail ¶
func (*Client) CreatePubSubOrFail ¶
func (c *Client) CreatePubSubOrFail(pubsub *eventsv1.CloudPubSubSource)
func (*Client) CreatePubSubV1beta1OrFail ¶
func (c *Client) CreatePubSubV1beta1OrFail(pubsub *eventsv1beta1.CloudPubSubSource)
func (*Client) CreatePullSubscriptionOrFail ¶
func (c *Client) CreatePullSubscriptionOrFail(pullsubscription *inteventsv1.PullSubscription)
func (*Client) CreatePullSubscriptionV1beta1OrFail ¶
func (c *Client) CreatePullSubscriptionV1beta1OrFail(pullsubscription *inteventsv1beta1.PullSubscription)
func (*Client) CreateSchedulerOrFail ¶
func (c *Client) CreateSchedulerOrFail(scheduler *eventsv1.CloudSchedulerSource)
func (*Client) CreateSchedulerV1beta1OrFail ¶
func (c *Client) CreateSchedulerV1beta1OrFail(scheduler *eventsv1beta1.CloudSchedulerSource)
func (*Client) CreateSecretOrFail ¶ added in v0.21.0
func (*Client) CreateServiceAccountOrFail ¶ added in v0.21.0
func (c *Client) CreateServiceAccountOrFail(sa *corev1.ServiceAccount)
func (*Client) CreateStorageOrFail ¶
func (c *Client) CreateStorageOrFail(storage *eventsv1.CloudStorageSource)
func (*Client) CreateStorageV1beta1OrFail ¶
func (c *Client) CreateStorageV1beta1OrFail(storage *eventsv1beta1.CloudStorageSource)
func (*Client) CreateTopicOrFail ¶
func (c *Client) CreateTopicOrFail(topic *inteventsv1.Topic)
func (*Client) CreateUnstructuredObjOrFail ¶
func (c *Client) CreateUnstructuredObjOrFail(spec *unstructured.Unstructured)
func (*Client) DeleteAuditLogsOrFail ¶
func (*Client) DeleteBuildOrFail ¶
func (*Client) DeleteGCPBrokerOrFail ¶
func (*Client) DeletePubSubOrFail ¶
func (*Client) DeleteSchedulerOrFail ¶
func (*Client) DeleteStorageOrFail ¶
func (*Client) GetAuditLogsOrFail ¶
func (c *Client) GetAuditLogsOrFail(name string) *eventsv1.CloudAuditLogsSource
func (*Client) GetBuildOrFail ¶
func (c *Client) GetBuildOrFail(name string) *eventsv1.CloudBuildSource
func (*Client) GetPubSubOrFail ¶
func (c *Client) GetPubSubOrFail(name string) *eventsv1.CloudPubSubSource
func (*Client) GetSchedulerOrFail ¶
func (c *Client) GetSchedulerOrFail(name string) *eventsv1.CloudSchedulerSource
func (*Client) GetStorageOrFail ¶
func (c *Client) GetStorageOrFail(name string) *eventsv1.CloudStorageSource
func (*Client) LogsFor ¶
func (c *Client) LogsFor(ctx context.Context, namespace, name string, tm *metav1.TypeMeta) (string, error)
TODO(chizhg): move this function to knative/pkg/test or knative/eventing/test
func (*Client) SetupStackDriverMetrics ¶
func (*Client) SetupStackDriverMetricsInNamespace ¶
func (*Client) StackDriverEventCountMetricFor ¶
TODO make this function more generic.
func (*Client) WaitForSourceAuthCheckPendingOrFail ¶ added in v0.21.0
func (c *Client) WaitForSourceAuthCheckPendingOrFail(name string, typemeta *metav1.TypeMeta, wantMessage string)
WaitForSourceAuthCheckPendingOrFail waits for the GCP Sources to have authenticationCheckPending condition reason for PullSubscriptionConditionReady condition or fail, and checks if the condition contains wanted message. To use this function, the given resource must have implemented the PubSub Status duck-type, and have PullSubscriptionConditionReady condition.
type PubSubConfig ¶
type PullSubscriptionConfig ¶
type SchedulerConfig ¶
type SenderOutput ¶
type SenderOutput struct { TraceID string `json:"traceid"` // contains filtered or unexported fields }
func (*SenderOutput) Successful ¶
func (o *SenderOutput) Successful() bool
type StorageConfig ¶
type StorageConfig struct { SinkGVK metav1.GroupVersionKind BucketName string StorageName string SinkName string ServiceAccountName string Options []reconcilertestingv1.CloudStorageSourceOption }
type TargetOutput ¶
type TargetOutput struct {
// contains filtered or unexported fields
}
func (*TargetOutput) Successful ¶
func (o *TargetOutput) Successful() bool
type TriggerAssertionKey ¶
type TriggerMetricAssertion ¶
type TriggerMetricAssertion struct { ProjectID string BrokerNamespace string BrokerName string StartTime time.Time CountPerTriggerWithRespCode map[TriggerAssertionKey]int64 CountPerTriggerNoRespCode map[TriggerAssertionKey]int64 }
func (TriggerMetricAssertion) Assert ¶
func (a TriggerMetricAssertion) Assert(client *monitoring.MetricClient) error
func (TriggerMetricAssertion) StackdriverFilter ¶
func (a TriggerMetricAssertion) StackdriverFilter(metric string) string