Skip to content

Commit

Permalink
Added regression test for binary events with extensions
Browse files Browse the repository at this point in the history
Signed-off-by: Calum Murray <[email protected]>
  • Loading branch information
Cali0707 committed Nov 22, 2023
1 parent ee8d67d commit ec634bd
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/e2e_new/kafka_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,21 @@ func TestKafkaSourceBinaryEvent(t *testing.T) {
env.Test(ctx, t, features.KafkaSourceBinaryEvent())
}

func TestKafkaSourceBinaryEventWithExtensions(t *testing.T) {
t.Parallel()

ctx, env := global.Environment(
knative.WithKnativeNamespace(system.Namespace()),
knative.WithLoggingConfig,
knative.WithTracingConfig,
k8s.WithEventListener,
environment.WithPollTimings(PollInterval, PollTimeout),
environment.Managed(t),
)

env.Test(ctx, t, features.KafkaSourceBinaryEventWithExtensions())
}

func TestKafkaSourceStructuredEvent(t *testing.T) {
t.Parallel()

Expand Down
35 changes: 35 additions & 0 deletions test/rekt/features/kafka_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,41 @@ func KafkaSourceBinaryEvent() *feature.Feature {
)
}

func KafkaSourceBinaryEventWithExtensions() *feature.Feature {
senderOptions := []eventshub.EventsHubOption{
eventshub.InputHeader("ce-specversion", cloudevents.VersionV1),
eventshub.InputHeader("ce-type", "com.github.pull.create"),
eventshub.InputHeader("ce-source", "github.com/cloudevents/spec/pull"),
eventshub.InputHeader("ce-subject", "123"),
eventshub.InputHeader("ce-id", "A234-1234-1234"),
eventshub.InputHeader("content-type", "application/json"),
}
matcher := AllOf(
HasSpecVersion(cloudevents.VersionV1),
HasType("com.github.pull.create"),
HasSource("github.com/cloudevents/spec/pull"),
HasSubject("123"),
HasId("A234-1234-1234"),
HasDataContentType("application/json"),
HasExtension("comexampleextension1", "value"),
HasExtension("comexampleothervalue", "5"),
)

return kafkaSourceFeature("KafkaSourceBinaryEvent",
kafkaSourceConfig{
authMech: PlainMech,
opts: []manifest.CfgFn{
kafkasource.WithExtensions(map[string]string{
"comexampleextension1": "value",
"comexampleothervalue": "5",
})},
},
kafkaSinkConfig{},
senderOptions,
matcher,
)
}

func KafkaSourceStructuredEvent() *feature.Feature {
eventTime, _ := cetypes.ParseTime("2018-04-05T17:31:00Z")
senderOptions := []eventshub.EventsHubOption{
Expand Down

0 comments on commit ec634bd

Please sign in to comment.