Documentation
¶
Overview ¶
Example ¶
package main import ( "embed" "os" testlog "knative.dev/reconciler-test/pkg/logging" "knative.dev/reconciler-test/pkg/manifest" ) //go:embed 102-service.yaml 103-pod.yaml var templates embed.FS func main() { ctx := testlog.NewContext() images := map[string]string{ "ko://knative.dev/reconciler-test/cmd/eventshub": "uri://a-real-container", } cfg := map[string]interface{}{ "name": "hubhub", "serviceName": "hubhub", "namespace": "example", "image": "ko://knative.dev/reconciler-test/cmd/eventshub", "isReceiver": true, "envs": map[string]string{ "foo": "bar", "baz": "boof", }, } files, err := manifest.ExecuteYAML(ctx, templates, images, cfg) if err != nil { panic(err) } manifest.OutputYAML(os.Stdout, files) }
Output: apiVersion: v1 kind: Service metadata: name: hubhub namespace: example spec: selector: app: eventshub-hubhub ports: - protocol: TCP name: http port: 80 targetPort: 8080 --- apiVersion: v1 kind: Pod metadata: name: hubhub namespace: example labels: app: eventshub-hubhub spec: serviceAccountName: "hubhub" restartPolicy: "OnFailure" containers: - name: eventshub image: uri://a-real-container imagePullPolicy: "IfNotPresent" readinessProbe: httpGet: port: 8080 path: /health/ready env: - name: "SYSTEM_NAMESPACE" valueFrom: fieldRef: fieldPath: "metadata.namespace" - name: "POD_NAME" valueFrom: fieldRef: fieldPath: "metadata.name" - name: "EVENT_LOGS" value: "recorder,logger" - name: "baz" value: "boof" - name: "foo" value: "bar"
Index ¶
- Constants
- Variables
- func ConfigureLogging(ctx context.Context, name string) context.Context
- func ConfigureTracing(logger *zap.SugaredLogger, serviceName string) (tracing.Tracer, error)
- func GetCaCerts(ctx context.Context) *string
- func ImageFromContext(ctx context.Context) string
- func Install(name string, options ...EventsHubOption) feature.StepFn
- func IsInsecureCipherSuite(conn *tls.ConnectionState) bool
- func ParseDurationStr(durationStr string, defaultDuration int) time.Duration
- func ParseHeaders(serializedHeaders string) http.Header
- func ReceiverGVR(ctx context.Context) schema.GroupVersionResource
- func Start(eventLogFactories map[string]EventLogFactory, ...)
- func WithCaCerts(ctx context.Context, caCerts *string) context.Context
- func WithClientTracing(client *http.Client) error
- func WithCustomImage(image string) environment.EnvOpts
- func WithKnativeServiceForwarder(ctx context.Context, env environment.Environment) (context.Context, error)
- func WithServerTracing(handler http.Handler) http.Handler
- func WithTLS(t feature.T) environment.EnvOpts
- type ClientOption
- type Connection
- type ConnectionTLS
- type EventGeneratorStarter
- type EventInfo
- type EventInfoCombined
- type EventInfoMatcher
- type EventInfoMatcherCtx
- type EventKind
- type EventLog
- type EventLogFactory
- type EventLogs
- type EventProber
- func (p *EventProber) AsKReference(prefix string) *duckv1.KReference
- func (p *EventProber) AssertReceivedAll(fromPrefix, toPrefix string) feature.StepFn
- func (p *EventProber) AssertReceivedNone(fromPrefix, toPrefix string) feature.StepFn
- func (p *EventProber) AssertReceivedOrRejectedAll(fromPrefix, toPrefix string) feature.StepFn
- func (p *EventProber) AssertSentAll(fromPrefix string) feature.StepFn
- func (p *EventProber) DumpState(ctx context.Context, t feature.T)
- func (p *EventProber) ExpectEvents(ids []string)
- func (p *EventProber) ExpectYAMLEvents(path string) error
- func (p *EventProber) ReceivedBy(ctx context.Context, prefix string) []EventInfo
- func (p *EventProber) ReceivedOrRejectedBy(ctx context.Context, prefix string) []EventInfo
- func (p *EventProber) ReceiverDone(from, to string) feature.StepFn
- func (p *EventProber) ReceiverInstall(prefix string, opts ...EventsHubOption) feature.StepFn
- func (p *EventProber) ReceiversHaveResponseDelay(delay time.Duration)
- func (p *EventProber) ReceiversRejectFirstN(n uint)
- func (p *EventProber) ReceiversRejectResponseCode(code int)
- func (p *EventProber) RejectedBy(ctx context.Context, prefix string) []EventInfo
- func (p *EventProber) SenderDone(prefix string) feature.StepFn
- func (p *EventProber) SenderEventsFromSVC(svcName, path string) feature.StepFn
- func (p *EventProber) SenderEventsFromURI(uri string)
- func (p *EventProber) SenderFullEvents(count int)
- func (p *EventProber) SenderInstall(prefix string, opts ...EventsHubOption) feature.StepFn
- func (p *EventProber) SenderMinEvents(count int)
- func (p *EventProber) SentBy(ctx context.Context, prefix string) []EventInfoCombined
- func (p *EventProber) SetTargetKRef(ref *duckv1.KReference) error
- func (p *EventProber) SetTargetResource(targetGVR schema.GroupVersionResource, targetName string)
- func (p *EventProber) SetTargetURI(targetURI string)
- type EventsHubOption
- func DropEventsResponseBody(body string) EventsHubOption
- func DropEventsResponseCode(code int) EventsHubOption
- func DropEventsResponseHeaders(headers map[string]string) EventsHubOption
- func DropFirstN(n uint) EventsHubOption
- func EnableProbeSink(timeout time.Duration) EventsHubOption
- func InitialSenderDelay(delay time.Duration) EventsHubOption
- func InputBody(b string) EventsHubOption
- func InputEvent(event cloudevents.Event) EventsHubOption
- func InputEventWithEncoding(event cloudevents.Event, encoding cloudevents.Encoding) EventsHubOption
- func InputHeader(k, v string) EventsHubOption
- func InputMethod(method string) EventsHubOption
- func InputYAML(path string) EventsHubOption
- func IssuerRef(kind, name string) EventsHubOption
- func OIDCCorruptedSignature() EventsHubOption
- func OIDCExpiredToken() EventsHubOption
- func OIDCInvalidAudience() EventsHubOption
- func OIDCReceiverAudience(aud string) EventsHubOption
- func OIDCSinkAudience(aud string) EventsHubOption
- func OIDCSubject(sub string) EventsHubOption
- func OIDCToken(jwt string) EventsHubOption
- func ReplyWithAppendedData(appendData string) EventsHubOption
- func ReplyWithTransformedEvent(replyEventType string, replyEventSource string, replyEventData string) EventsHubOption
- func ResponseWaitTime(delay time.Duration) EventsHubOption
- func SendMultipleEvents(numberOfEvents int, period time.Duration) EventsHubOption
- func StartSender(sinkSvc string) EventsHubOption
- func StartSenderTLS(sinkSvc string, caCerts *string) EventsHubOption
- func StartSenderToNamespacedResource(gvr schema.GroupVersionResource, name, namespace string) EventsHubOption
- func StartSenderToNamespacedResourceTLS(gvr schema.GroupVersionResource, name, namespace string, caCerts *string) EventsHubOption
- func StartSenderToResource(gvr schema.GroupVersionResource, name string) EventsHubOption
- func StartSenderToResourceTLS(gvr schema.GroupVersionResource, name string, caCerts *string) EventsHubOption
- func StartSenderURL(sink string) EventsHubOption
- func StartSenderURLTLS(sink string, caCerts *string) EventsHubOption
- func VerifyEventFormat(format string) EventsHubOption
- func VerifyEventFormatBinary() EventsHubOption
- func VerifyEventFormatStructured() EventsHubOption
- type HandlerFunc
- type SearchedInfo
- type Store
- func (ei *Store) AssertAtLeast(ctx context.Context, t feature.T, min int, matchers ...EventInfoMatcher) []EventInfo
- func (ei *Store) AssertExact(ctx context.Context, t feature.T, n int, matchers ...EventInfoMatcher) []EventInfo
- func (ei *Store) AssertInRange(ctx context.Context, t feature.T, min int, max int, ...) []EventInfo
- func (ei *Store) AssertNot(t feature.T, matchers ...EventInfoMatcher) []EventInfo
- func (ei *Store) Collected() []EventInfo
- func (ei *Store) Find(matchers ...EventInfoMatcher) ([]EventInfo, SearchedInfo, []error, error)
- func (ei *Store) Handle(event *corev1.Event)
Examples ¶
Constants ¶
const ( ReceiverEventGenerator string = "receiver" SenderEventGenerator string = "sender" ForwarderEventGenerator string = "forwarder" RecorderEventLog string = "recorder" LoggerEventLog string = "logger" )
const ( ConfigTracingEnv = "K_CONFIG_TRACING" ConfigLoggingEnv = "K_CONFIG_LOGGING" EventGeneratorsEnv = "EVENT_GENERATORS" EventLogsEnv = "EVENT_LOGS" OIDCEnabledEnv = "ENABLE_OIDC_AUTH" OIDCGenerateExpiredTokenEnv = "OIDC_GENERATE_EXPIRED_TOKEN" OIDCGenerateInvalidAudienceTokenEnv = "OIDC_GENERATE_INVALID_AUDIENCE_TOKEN" OIDCSubjectEnv = "OIDC_SUBJECT" OIDCGenerateCorruptedSignatureTokenEnv = "OIDC_GENERATE_CORRUPTED_SIG_TOKEN" OIDCSinkAudienceEnv = "OIDC_SINK_AUDIENCE" OIDCReceiverAudienceEnv = "OIDC_AUDIENCE" OIDCTokenEnv = "OIDC_TOKEN" EnforceTLS = "ENFORCE_TLS" )
const (
// EventReason is the Kubernetes event reason used for observed events.
CloudEventObservedReason = "CloudEventObserved"
)
const (
OIDCTokenExpiryMinutes = 10
)
Variables ¶
var AddSequence = envOption("ADD_SEQUENCE", "true")
AddSequence adds an extension named 'sequence' which contains the incremental number of sent events (similar to EnableIncrementalId, but without overwriting the id attribute).
var AddTracing = envOption("ADD_TRACING", "true")
AddTracing adds tracing headers when sending events. Deprecated: Exporting traces from the client/sender is enabled by default.
var DisableProbeSink = envOption("PROBE_SINK", "false")
DisableProbeSink will disable the probe sink feature of sender, starting sending directly events after it's started.
var EnableIncrementalId = envOption("INCREMENTAL_ID", "true")
EnableIncrementalId replaces the event id with a new incremental id for each sent event.
var FibonacciDrop = envOption("SKIP_ALGORITHM", dropevents.Fibonacci)
FibonacciDrop will cause the receiver to reply with a bad status code following the fibonacci sequence
var OverrideTime = envOption("OVERRIDE_TIME", "true")
OverrideTime overrides the event time with the time when sending the event.
Functions ¶
func ConfigureLogging ¶
ConfigureTracing can be used in test-images to configure tracing
func ConfigureTracing ¶
ConfigureTracing can be used in test-images to configure tracing
func GetCaCerts ¶
func ImageFromContext ¶
ImageFromContext gets the eventshub image from context
func Install ¶
func Install(name string, options ...EventsHubOption) feature.StepFn
Install starts a new eventshub with the provided name Note: this function expects that the Environment is configured with the following options, otherwise it will panic:
ctx, env := global.Environment( knative.WithKnativeNamespace("knative-namespace"), knative.WithLoggingConfig, knative.WithTracingConfig, k8s.WithEventListener, )
func IsInsecureCipherSuite ¶
func IsInsecureCipherSuite(conn *tls.ConnectionState) bool
func ParseDurationStr ¶
ParseDurationStr parses `durationStr` as number of seconds (not time.Duration string), if parsing fails, returns back default duration.
func ParseHeaders ¶
func ReceiverGVR ¶
func ReceiverGVR(ctx context.Context) schema.GroupVersionResource
func Start ¶
func Start(eventLogFactories map[string]EventLogFactory, eventGeneratorFactories map[string]EventGeneratorStarter)
Start starts a new eventshub process, with the provided factories. You can create your own eventshub providing event log factories and event generator factories.
func WithClientTracing ¶
WithClientTracing enables exporting traces by the client's transport.
func WithCustomImage ¶
func WithCustomImage(image string) environment.EnvOpts
WithCustomImage allows you to specify a custom eventshub image to be used when invoking eventshub.Install
func WithKnativeServiceForwarder ¶
func WithKnativeServiceForwarder(ctx context.Context, env environment.Environment) (context.Context, error)
WithKnativeServiceForwarder deploys a Knative Service forwarder that will forward requests to eventshub.
func WithServerTracing ¶
WithServerTracing wraps the provided handler in a tracing handler
Types ¶
type ClientOption ¶
type Connection ¶
type Connection struct {
TLS *ConnectionTLS `json:"TLS,omitempty"`
}
func TLSConnectionStateToConnection ¶
func TLSConnectionStateToConnection(state *tls.ConnectionState) *Connection
type ConnectionTLS ¶
type ConnectionTLS struct { CipherSuite uint16 `json:"cipherSuite,omitempty"` CipherSuiteName string `json:"cipherSuiteName,omitempty"` HandshakeComplete bool `json:"handshakeComplete,omitempty"` IsInsecureCipherSuite bool `json:"isInsecureCipherSuite,omitempty"` PemPeerCertificates []string `json:"pemPeerCertificates,omitempty"` }
type EventGeneratorStarter ¶
EventGeneratorStarter starts a new event generator. This function is executed in a separate goroutine, so it can block.
type EventInfo ¶
type EventInfo struct { Kind EventKind `json:"kind"` // Set if the http request received by the pod couldn't be decoded or // didn't pass validation Error string `json:"error,omitempty"` // Event received if the cloudevent received by the pod passed validation Event *cloudevents.Event `json:"event,omitempty"` // In case there is a valid event in this instance, this contains all the HTTP headers, // including the CE- headers. HTTPHeaders map[string][]string `json:"httpHeaders,omitempty"` // In case there is a valid event in this instance, this field is not filled Body []byte `json:"body,omitempty"` StatusCode int `json:"statusCode,omitempty"` // Connection holds some underlying connection info like TLS, etc. Connection *Connection `json:"connection,omitempty"` Origin string `json:"origin,omitempty"` Observer string `json:"observer,omitempty"` Time time.Time `json:"time,omitempty"` Sequence uint64 `json:"sequence"` // SentId is just a correlator to correlate EventSent and EventResponse kinds. // This is filled with the ID of the sent event (if any) and in the Response also // jot it down so you can correlate which event (ID) as well as sequence to match sent/response 1:1. SentId string `json:"id"` // AdditionalInfo can be used by event generator implementations to add more event details AdditionalInfo map[string]interface{} `json:"additionalInfo"` // OIDCUserInfo is the user info of the subject of the OIDC token used in the request OIDCUserInfo *v1.UserInfo `json:"oidcUserInfo,omitempty"` }
Structure to hold information about an event seen by eventshub pod.
type EventInfoCombined ¶
func CorrelateSent ¶
func CorrelateSent(origin string, in []EventInfo) []EventInfoCombined
CorrelateSent takes in an array of mixed Sent / Response events (matched with sentEventMatcher for example) and correlates them based on the sequence into a pair.
type EventInfoMatcher ¶
EventInfoMatcher returns an error if the input event info doesn't match the criteria
func (EventInfoMatcher) WithContext ¶
func (m EventInfoMatcher) WithContext() EventInfoMatcherCtx
WithContext transforms EventInfoMatcher to EventInfoMatcherCtx.
type EventInfoMatcherCtx ¶
EventInfoMatcherCtx returns an error if the input event info doesn't match the criteria
func (EventInfoMatcherCtx) WithContext ¶
func (m EventInfoMatcherCtx) WithContext(ctx context.Context) EventInfoMatcher
WithContext transforms EventInfoMatcherCtx to EventInfoMatcher.
type EventLogFactory ¶
EventLogFactory creates a new EventLog instance.
type EventLogs ¶
type EventLogs struct {
// contains filtered or unexported fields
}
EventLogs is a struct to hold different EventLog and run them, guarded by a lock
func NewEventLogs ¶
type EventProber ¶
type EventProber struct {
// contains filtered or unexported fields
}
func NewProber ¶
func NewProber() *EventProber
func (*EventProber) AsKReference ¶
func (p *EventProber) AsKReference(prefix string) *duckv1.KReference
AsKReference returns the short-named component as a KReference.
func (*EventProber) AssertReceivedAll ¶
func (p *EventProber) AssertReceivedAll(fromPrefix, toPrefix string) feature.StepFn
AssertReceivedAll tests that all events sent by `fromPrefix` were received by `toPrefix`.
func (*EventProber) AssertReceivedNone ¶
func (p *EventProber) AssertReceivedNone(fromPrefix, toPrefix string) feature.StepFn
AssertReceivedNone tests that no events sent by `fromPrefix` were received by `toPrefix`.
func (*EventProber) AssertReceivedOrRejectedAll ¶
func (p *EventProber) AssertReceivedOrRejectedAll(fromPrefix, toPrefix string) feature.StepFn
AssertReceivedAll tests that all events sent by `fromPrefix` were received by `toPrefix`.
func (*EventProber) AssertSentAll ¶
func (p *EventProber) AssertSentAll(fromPrefix string) feature.StepFn
AssertSentAll tests that `fromPrefix` sent all known events known to the prober.
func (*EventProber) ExpectEvents ¶
func (p *EventProber) ExpectEvents(ids []string)
ExpectEvents registers event IDs into the prober.
func (*EventProber) ExpectYAMLEvents ¶
func (p *EventProber) ExpectYAMLEvents(path string) error
ExpectYAMLEvents registered expected events into the prober.
func (*EventProber) ReceivedBy ¶
func (p *EventProber) ReceivedBy(ctx context.Context, prefix string) []EventInfo
ReceivedBy returns events received by the named receiver.
func (*EventProber) ReceivedOrRejectedBy ¶
func (p *EventProber) ReceivedOrRejectedBy(ctx context.Context, prefix string) []EventInfo
ReceivedOrRejectedBy returns events received or rejected by the named receiver.
func (*EventProber) ReceiverDone ¶
func (p *EventProber) ReceiverDone(from, to string) feature.StepFn
ReceiverDone will poll until the receiver has received all expected events.
func (*EventProber) ReceiverInstall ¶
func (p *EventProber) ReceiverInstall(prefix string, opts ...EventsHubOption) feature.StepFn
ReceiverInstall installs an eventshub receiver into the test env.
func (*EventProber) ReceiversHaveResponseDelay ¶
func (p *EventProber) ReceiversHaveResponseDelay(delay time.Duration)
ReceiversHaveResponseDelay adds ResponseWaitTime to the default config for new receivers.
func (*EventProber) ReceiversRejectFirstN ¶
func (p *EventProber) ReceiversRejectFirstN(n uint)
ReceiversRejectFirstN adds DropFirstN to the default config for new receivers.
func (*EventProber) ReceiversRejectResponseCode ¶
func (p *EventProber) ReceiversRejectResponseCode(code int)
ReceiversRejectResponseCode adds DropEventsResponseCode to the default config for new receivers.
func (*EventProber) RejectedBy ¶
func (p *EventProber) RejectedBy(ctx context.Context, prefix string) []EventInfo
RejectedBy returns events rejected by the named receiver.
func (*EventProber) SenderDone ¶
func (p *EventProber) SenderDone(prefix string) feature.StepFn
SenderDone will poll until the sender sends all expected events.
func (*EventProber) SenderEventsFromSVC ¶
func (p *EventProber) SenderEventsFromSVC(svcName, path string) feature.StepFn
SenderEventsFromSVC configures a sender to send a yaml based events fetched a service in the testing environment. Namespace of the svc will come from env.Namespace(), based on context from the StepFn.
func (*EventProber) SenderEventsFromURI ¶
func (p *EventProber) SenderEventsFromURI(uri string)
SenderEventsFromURI configures a sender to send a url/yaml based events.
func (*EventProber) SenderFullEvents ¶
func (p *EventProber) SenderFullEvents(count int)
SenderFullEvents creates `count` cloudevents.FullEvent events with new IDs into a sender and registers them for the prober. Warning: only call once.
func (*EventProber) SenderInstall ¶
func (p *EventProber) SenderInstall(prefix string, opts ...EventsHubOption) feature.StepFn
SenderInstall installs an eventshub sender resource into the test env.
func (*EventProber) SenderMinEvents ¶
func (p *EventProber) SenderMinEvents(count int)
SenderMinEvents creates `count` cloudevents.MinEvent events with new IDs into a sender and registers them for the prober. Warning: only call once.
func (*EventProber) SentBy ¶
func (p *EventProber) SentBy(ctx context.Context, prefix string) []EventInfoCombined
SentBy returns events sent by the named sender.
func (*EventProber) SetTargetKRef ¶
func (p *EventProber) SetTargetKRef(ref *duckv1.KReference) error
SetTargetKRef configures the senders target as KRef, used when sender is installed. Note: namespace is ignored.
func (*EventProber) SetTargetResource ¶
func (p *EventProber) SetTargetResource(targetGVR schema.GroupVersionResource, targetName string)
SetTargetResource configures the senders target as a GVR and name, used when sender is installed.
func (*EventProber) SetTargetURI ¶
func (p *EventProber) SetTargetURI(targetURI string)
SetTargetURI configures the senders target as a URI, used when sender is installed.
type EventsHubOption ¶
EventsHubOption is used to define an env for the eventshub image
var EchoEvent EventsHubOption = envOption("REPLY", "true")
EchoEvent is an option to let the eventshub reply with the received event
var StartReceiver EventsHubOption = envAdditive(EventGeneratorsEnv, "receiver")
StartReceiver starts the receiver in the eventshub This can be used together with EchoEvent, ReplyWithTransformedEvent, ReplyWithAppendedData
var StartReceiverTLS EventsHubOption = compose(StartReceiver, envAdditive(EnforceTLS, "true"))
StartReceiverTLS starts the receiver in the eventshub with TLS enforcement. This can be used together with EchoEvent, ReplyWithTransformedEvent, ReplyWithAppendedData.
It requires cert-manager operator to be able to create TLS Certificate. To get the CA certificate used you can use GetCaCerts.
func DropEventsResponseBody ¶
func DropEventsResponseBody(body string) EventsHubOption
DropEventsResponseBody will cause the receiver to reply with the specific body to the dropped events
func DropEventsResponseCode ¶
func DropEventsResponseCode(code int) EventsHubOption
DropEventsResponseCode will cause the receiver to reply with the specific status code to the dropped events
func DropEventsResponseHeaders ¶
func DropEventsResponseHeaders(headers map[string]string) EventsHubOption
DropEventsResponseHeaders will cause the receiver to reply with the specific headers to the dropped events
func DropFirstN ¶
func DropFirstN(n uint) EventsHubOption
DropFirstN will cause the receiver to reply with a bad status code to the first n events
func EnableProbeSink ¶
func EnableProbeSink(timeout time.Duration) EventsHubOption
EnableProbeSink probes the sink with HTTP head requests up until the sink replies. The specified duration defines the maximum timeout to probe it, before failing. Note: the probe sink is executed after the initial delay
func InitialSenderDelay ¶
func InitialSenderDelay(delay time.Duration) EventsHubOption
InitialSenderDelay defines how much the sender has to wait (in millisecond), when started, before start sending events. Note: this delay is executed before the probe sink.
func InputBody ¶
func InputBody(b string) EventsHubOption
InputBody overwrites the request header with the following body.
func InputEvent ¶
func InputEvent(event cloudevents.Event) EventsHubOption
InputEvent is an option to provide the event to send when deploying the event sender
func InputEventWithEncoding ¶
func InputEventWithEncoding(event cloudevents.Event, encoding cloudevents.Encoding) EventsHubOption
InputEventWithEncoding is an option to provide the event to send when deploying the event sender forcing the specified encoding.
func InputHeader ¶
func InputHeader(k, v string) EventsHubOption
InputHeader adds the following header to the sent headers.
func InputMethod ¶
func InputMethod(method string) EventsHubOption
InputMethod overrides which http method to use when sending events (default is POST)
func InputYAML ¶
func InputYAML(path string) EventsHubOption
InputYAML is an option to provide the events to send via yaml path when deploying the event sender
func IssuerRef ¶
func IssuerRef(kind, name string) EventsHubOption
func OIDCCorruptedSignature ¶
func OIDCCorruptedSignature() EventsHubOption
OIDCCorruptedSignature adds an OIDC token with an invalid signature to the request.
func OIDCExpiredToken ¶
func OIDCExpiredToken() EventsHubOption
OIDCExpiredToken adds an expired OIDC token to the request. As the minimal expiry for JWTs from Kubernetes are 10 minutes, the sender will delay the send by 10 + 1 minutes. This should be used in combination of an increase of the poll timout (via environment.PollTimingsFromContext()) to not run in the default 2 minutes timeout while waiting for an event which is send after 10 + 1 minutes.
func OIDCInvalidAudience ¶
func OIDCInvalidAudience() EventsHubOption
OIDCInvalidAudience creates an OIDC token with an invalid audience
func OIDCReceiverAudience ¶
func OIDCReceiverAudience(aud string) EventsHubOption
OIDCReceiverAudience sets the expected audience for received OIDC tokens on the receiver side
func OIDCSinkAudience ¶
func OIDCSinkAudience(aud string) EventsHubOption
OIDCSinkAudience sets the Audience of the Sink
func OIDCSubject ¶
func OIDCSubject(sub string) EventsHubOption
OIDCSubject sets the name of the OIDC subject to use by the sender. If this option is not set, it defaults to "oidc-<eventshub-name>"
func OIDCToken ¶
func OIDCToken(jwt string) EventsHubOption
OIDCToken adds the given token used for OIDC authentication to the request.
func ReplyWithAppendedData ¶
func ReplyWithAppendedData(appendData string) EventsHubOption
ReplyWithAppendedData is an option to let the eventshub reply with the transformed event with appended data
func ReplyWithTransformedEvent ¶
func ReplyWithTransformedEvent(replyEventType string, replyEventSource string, replyEventData string) EventsHubOption
ReplyWithTransformedEvent is an option to let the eventshub reply with the transformed event
func ResponseWaitTime ¶
func ResponseWaitTime(delay time.Duration) EventsHubOption
ResponseWaitTime defines how much the receiver has to wait before replying.
func SendMultipleEvents ¶
func SendMultipleEvents(numberOfEvents int, period time.Duration) EventsHubOption
SendMultipleEvents defines how much events to send and the period (in millisecond) between them.
func StartSender ¶
func StartSender(sinkSvc string) EventsHubOption
StartSender starts the sender in the eventshub This can be used together with InputEvent, AddTracing, EnableIncrementalId, InputEncoding and InputHeader options
func StartSenderTLS ¶
func StartSenderTLS(sinkSvc string, caCerts *string) EventsHubOption
StartSenderTLS starts the sender in the eventshub with TLS enforcement.
func StartSenderToNamespacedResource ¶
func StartSenderToNamespacedResource(gvr schema.GroupVersionResource, name, namespace string) EventsHubOption
StartSenderToNamespacedResource starts the sender in the eventshub pointing to the provided resource This can be used together with InputEvent, AddTracing, EnableIncrementalId, InputEncoding and InputHeader options
func StartSenderToNamespacedResourceTLS ¶
func StartSenderToNamespacedResourceTLS(gvr schema.GroupVersionResource, name, namespace string, caCerts *string) EventsHubOption
StartSenderToNamespacedResourceTLS starts the sender in the eventshub pointing to the provided namespaced resource. `caCerts` parameter is optional, if nil, it will fall back to use the addressable CA certs. This can be used together with InputEvent, AddTracing, EnableIncrementalId, InputEncoding and InputHeader options
func StartSenderToResource ¶
func StartSenderToResource(gvr schema.GroupVersionResource, name string) EventsHubOption
StartSenderToResource starts the sender in the eventshub pointing to the provided resource This can be used together with InputEvent, AddTracing, EnableIncrementalId, InputEncoding and InputHeader options
func StartSenderToResourceTLS ¶
func StartSenderToResourceTLS(gvr schema.GroupVersionResource, name string, caCerts *string) EventsHubOption
StartSenderToResourceTLS starts the sender in the eventshub pointing to the provided resource. `caCerts` parameter is optional, if nil, it will fall back to use the addressable CA certs. This can be used together with InputEvent, AddTracing, EnableIncrementalId, InputEncoding and InputHeader options
func StartSenderURL ¶
func StartSenderURL(sink string) EventsHubOption
StartSenderURL starts the sender in the eventshub sinking to a URL. This can be used together with InputEvent, AddTracing, EnableIncrementalId, InputEncoding and InputHeader options
func StartSenderURLTLS ¶
func StartSenderURLTLS(sink string, caCerts *string) EventsHubOption
StartSenderURLTLS starts the sender in the eventshub sinking to a URL. This can be used together with InputEvent, AddTracing, EnableIncrementalId, InputEncoding and InputHeader options
func VerifyEventFormat ¶
func VerifyEventFormat(format string) EventsHubOption
VerifyEventFormat has the receiver verify the event format when receiving events
func VerifyEventFormatBinary ¶
func VerifyEventFormatBinary() EventsHubOption
VerifyEventFormat has the receiver verify the event format is binary when receiving events
func VerifyEventFormatStructured ¶
func VerifyEventFormatStructured() EventsHubOption
VerifyEventFormat has the receiver verify the event format is structured when receiving events
type SearchedInfo ¶
type SearchedInfo struct { TotalEvent int LastNEvent []EventInfo StoreEventsSeen int StoreEventsNotMine int }
This is mainly used for providing better failure messages
func (*SearchedInfo) String ¶
func (s *SearchedInfo) String() string
Pretty print the SearchedInfor for error messages
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Stateful store of events published by eventshub pod it is pointed at. Implements k8s.EventHandler
func (*Store) AssertAtLeast ¶
func (ei *Store) AssertAtLeast(ctx context.Context, t feature.T, min int, matchers ...EventInfoMatcher) []EventInfo
AssertAtLeast assert that there are at least min number of match for the provided matchers. This method fails the test if the assert is not fulfilled.
func (*Store) AssertExact ¶
func (ei *Store) AssertExact(ctx context.Context, t feature.T, n int, matchers ...EventInfoMatcher) []EventInfo
AssertExact assert that there are exactly n matches for the provided matchers. This method fails the test if the assert is not fulfilled.
func (*Store) AssertInRange ¶
func (ei *Store) AssertInRange(ctx context.Context, t feature.T, min int, max int, matchers ...EventInfoMatcher) []EventInfo
AssertInRange asserts that there are at least min number of matches and at most max number of matches for the provided matchers. This method fails the test if the assert is not fulfilled.
func (*Store) AssertNot ¶
func (ei *Store) AssertNot(t feature.T, matchers ...EventInfoMatcher) []EventInfo
AssertNot asserts that there aren't any matches for the provided matchers. This method fails the test if the assert is not fulfilled.
func (*Store) Find ¶
func (ei *Store) Find(matchers ...EventInfoMatcher) ([]EventInfo, SearchedInfo, []error, error)
Find all events received by the eventshub pod that match the provided matchers, returning all matching events as well as a SearchedInfo structure including the last 5 events seen and the total events matched. This SearchedInfo structure is primarily to ease debugging in failure printouts. The provided function is guaranteed to be called exactly once on each EventInfo from the pod. The error array contains the eventual match errors, while the last return error contains an eventual communication error while trying to get the events from the eventshub pod
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
assert contains the necessary matchers and steps to perform assertions on eventshub contents
|
assert contains the necessary matchers and steps to perform assertions on eventshub contents |
Package recorder_vent implements an eventshub.EventLog backed by Kubernetes Events using an event recorder.
|
Package recorder_vent implements an eventshub.EventLog backed by Kubernetes Events using an event recorder. |