Documentation ¶
Index ¶
- Constants
- func DeployEventRecordOrFail(ctx context.Context, client *testlib.Client, name string, ...) *corev1.Pod
- func DeployEventSenderOrFail(ctx context.Context, client *testlib.Client, name string, sink string, ...) *corev1.Pod
- func MatchHeartBeatsImageMessage(expectedMsg string) cetest.EventMatcher
- type EventGeneratorType
- type EventInfo
- type EventInfoMatcher
- type EventInfoStore
- func (ei *EventInfoStore) AsSinkRef() *duckv1.KReference
- func (ei *EventInfoStore) AssertAtLeast(min int, matchers ...EventInfoMatcher) []EventInfo
- func (ei *EventInfoStore) AssertExact(n int, matchers ...EventInfoMatcher) []EventInfo
- func (ei *EventInfoStore) AssertInRange(min int, max int, matchers ...EventInfoMatcher) []EventInfo
- func (ei *EventInfoStore) AssertNot(matchers ...EventInfoMatcher) []EventInfo
- func (ei *EventInfoStore) Find(matchers ...EventInfoMatcher) ([]EventInfo, SearchedInfo, []error, error)
- type EventKind
- type EventLog
- type EventLogType
- type EventLogs
- type EventRecordOption
- func AddTracing() EventRecordOption
- func EnableIncrementalId() EventRecordOption
- func InputEncoding(encoding cloudevents.Encoding) EventRecordOption
- func InputEvent(event cloudevents.Event) EventRecordOption
- func InputHeaders(headers map[string]string) EventRecordOption
- func ReplyWithAppendedData(appendData string) EventRecordOption
- func ReplyWithTransformedEvent(replyEventType string, replyEventSource string, replyEventData string) EventRecordOption
- type SearchedInfo
Constants ¶
const (
// EventReason is the Kubernetes event reason used for observed events.
CloudEventObservedReason = "CloudEventObserved"
)
const EventRecordReceivePort = 8080
Variables ¶
This section is empty.
Functions ¶
func DeployEventRecordOrFail ¶ added in v0.17.8
func DeployEventRecordOrFail(ctx context.Context, client *testlib.Client, name string, options ...EventRecordOption) *corev1.Pod
DeployEventRecordOrFail deploys the recordevents image with necessary sa, roles, rb to execute the image
func DeployEventSenderOrFail ¶ added in v0.20.0
func DeployEventSenderOrFail(ctx context.Context, client *testlib.Client, name string, sink string, options ...EventRecordOption) *corev1.Pod
DeployEventSenderOrFail deploys the recordevents image with necessary sa, roles, rb to execute the image
func MatchHeartBeatsImageMessage ¶
func MatchHeartBeatsImageMessage(expectedMsg string) cetest.EventMatcher
MatchHeartBeatsImageMessage matches that the data field of the event, in the format of the heartbeats image, contains the following msg field
Types ¶
type EventGeneratorType ¶ added in v0.20.0
type EventGeneratorType string
const ( ReceiverEventGenerator EventGeneratorType = "receiver" SenderEventGenerator EventGeneratorType = "sender" )
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 only non CE headers. // Otherwise, it contains all the 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"` Origin string `json:"origin,omitempty"` Observer string `json:"observer,omitempty"` Time time.Time `json:"time,omitempty"` Sequence uint64 `json:"sequence"` }
Structure to hold information about an event seen by recordevents pod.
type EventInfoMatcher ¶
Does the provided EventInfo match some criteria
func AllOf ¶
func AllOf(matchers ...EventInfoMatcher) EventInfoMatcher
AllOf combines matchers together
func HasAdditionalHeader ¶
func HasAdditionalHeader(key, value string) EventInfoMatcher
Convert a matcher that checks valid messages to a function that checks EventInfo structures, returning an error for any that don't contain valid events.
func MatchEvent ¶
func MatchEvent(evf ...cetest.EventMatcher) EventInfoMatcher
Convert a matcher that checks valid messages to a function that checks EventInfo structures, returning an error for any that don't contain valid events.
func MatchKind ¶ added in v0.20.0
func MatchKind(kind EventKind) EventInfoMatcher
MatchKind matches the kind of EventInfo
func NoError ¶
func NoError() EventInfoMatcher
Matcher that fails if there is an error in the EventInfo
type EventInfoStore ¶
type EventInfoStore struct {
// contains filtered or unexported fields
}
Stateful store of events received by the recordevents pod it is pointed at. This pulls events from the pod during any Find or Wait call, storing them locally and trimming them from the remote pod store.
func NewEventInfoStore ¶
func NewEventInfoStore(client *testlib.Client, podName string, podNamespace string) (*EventInfoStore, error)
Creates an EventInfoStore that is used to iteratively download events recorded by the recordevents pod.
func StartEventRecordOrFail ¶
func StartEventRecordOrFail(ctx context.Context, client *testlib.Client, podName string, options ...EventRecordOption) (*EventInfoStore, *corev1.Pod)
Deploys a new recordevents pod and start the associated EventInfoStore
func (*EventInfoStore) AsSinkRef ¶ added in v0.26.0
func (ei *EventInfoStore) AsSinkRef() *duckv1.KReference
func (*EventInfoStore) AssertAtLeast ¶
func (ei *EventInfoStore) AssertAtLeast(min int, matchers ...EventInfoMatcher) []EventInfo
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 (*EventInfoStore) AssertExact ¶
func (ei *EventInfoStore) AssertExact(n int, matchers ...EventInfoMatcher) []EventInfo
Assert that there are exactly n matches for the provided matchers. This method fails the test if the assert is not fulfilled.
func (*EventInfoStore) AssertInRange ¶
func (ei *EventInfoStore) AssertInRange(min int, max int, matchers ...EventInfoMatcher) []EventInfo
Assert 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 (*EventInfoStore) AssertNot ¶
func (ei *EventInfoStore) AssertNot(matchers ...EventInfoMatcher) []EventInfo
Assert that there aren't any matches for the provided matchers. This method fails the test if the assert is not fulfilled.
func (*EventInfoStore) Find ¶
func (ei *EventInfoStore) Find(matchers ...EventInfoMatcher) ([]EventInfo, SearchedInfo, []error, error)
Find all events received by the recordevents 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 recordevents pod
type EventLogType ¶ added in v0.20.0
type EventLogType string
const ( RecorderEventLog EventLogType = "recorder" LoggerEventLog EventLogType = "logger" )
type EventLogs ¶ added in v0.17.8
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 ¶ added in v0.20.0
type EventRecordOption ¶ added in v0.17.0
var EchoEvent EventRecordOption = envOption("REPLY", "true")
EchoEvent is an option to let the recordevents reply with the received event
func AddTracing ¶ added in v0.20.0
func AddTracing() EventRecordOption
AddTracing adds tracing headers when sending events.
func EnableIncrementalId ¶ added in v0.20.0
func EnableIncrementalId() EventRecordOption
EnableIncrementalId creates a new incremental id for each sent event.
func InputEncoding ¶ added in v0.20.0
func InputEncoding(encoding cloudevents.Encoding) EventRecordOption
InputEncoding forces the encoding of the event for each sent event.
func InputEvent ¶ added in v0.20.0
func InputEvent(event cloudevents.Event) EventRecordOption
InputEvent is an option to provide the event to send when deploying the event sender
func InputHeaders ¶ added in v0.20.0
func InputHeaders(headers map[string]string) EventRecordOption
InputHeaders adds the following headers to the sent requests.
func ReplyWithAppendedData ¶ added in v0.17.8
func ReplyWithAppendedData(appendData string) EventRecordOption
ReplyWithAppendedData is an option to let the recordevents reply with the transformed event with appended data
func ReplyWithTransformedEvent ¶ added in v0.17.8
func ReplyWithTransformedEvent(replyEventType string, replyEventSource string, replyEventData string) EventRecordOption
ReplyWithTransformedEvent is an option to let the recordevents reply with the transformed event
type SearchedInfo ¶
type SearchedInfo struct { TotalEvent int LastNEvent []EventInfo // contains filtered or unexported fields }
This is mainly used for providing better failure messages
func (*SearchedInfo) String ¶
func (s *SearchedInfo) String() string
Pretty print the SearchedInfor for error messages
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package recorder_vent implements an recordevents.EventLog backed by Kubernetes Events using an event recorder.
|
Package recorder_vent implements an recordevents.EventLog backed by Kubernetes Events using an event recorder. |