Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added rekt test for broker eventtype autocreate #7202

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions test/experimental/eventtype_autocreate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"knative.dev/pkg/system"
"knative.dev/reconciler-test/pkg/environment"
"knative.dev/reconciler-test/pkg/feature"
"knative.dev/reconciler-test/pkg/k8s"
"knative.dev/reconciler-test/pkg/knative"
)
Expand All @@ -41,6 +42,22 @@ func TestIMCEventTypeAutoCreate(t *testing.T) {
env.Test(ctx, t, eventtype_autocreate.AutoCreateEventTypesOnIMC())
}

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

ctx, env := global.Environment(
knative.WithKnativeNamespace(system.Namespace()),
knative.WithLoggingConfig,
knative.WithTracingConfig,
k8s.WithEventListener,
environment.Managed(t),
)
brokerName := feature.MakeRandomK8sName("broker")

env.Prerequisite(ctx, t, InstallMTBroker(brokerName))
env.Test(ctx, t, eventtype_autocreate.AutoCreateEventTypesOnBroker(brokerName))
}

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

Expand Down
33 changes: 32 additions & 1 deletion test/experimental/features/eventtype_autocreate/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"knative.dev/reconciler-test/pkg/eventshub"
"knative.dev/reconciler-test/pkg/eventshub/assert"
"knative.dev/reconciler-test/pkg/feature"
"knative.dev/reconciler-test/pkg/k8s"
"knative.dev/reconciler-test/pkg/manifest"
"knative.dev/reconciler-test/pkg/resources/service"
)
Expand All @@ -38,7 +39,7 @@ func AutoCreateEventTypesOnIMC() *feature.Feature {
f := feature.NewFeature()

event := cetest.FullEvent()
event.SetType("test.custom.event.type")
event.SetType("test.imc.custom.event.type")

sender := feature.MakeRandomK8sName("sender")
sub := feature.MakeRandomK8sName("subscription")
Expand Down Expand Up @@ -69,6 +70,36 @@ func AutoCreateEventTypesOnIMC() *feature.Feature {
return f
}

func AutoCreateEventTypesOnBroker(brokerName string) *feature.Feature {
f := feature.NewFeature()

event := cetest.FullEvent()
event.SetType("test.broker.custom.event.type")

sender := feature.MakeRandomK8sName("sender")
triggerName := feature.MakeRandomK8sName("trigger")
sink := feature.MakeRandomK8sName("sink")

f.Setup("install sink", eventshub.Install(sink, eventshub.StartReceiver))
f.Setup("install subscription", trigger.Install(triggerName, brokerName, trigger.WithSubscriber(service.AsKReference(sink), "")))

f.Setup("trigger is ready", trigger.IsReady(triggerName))
f.Setup("broker is addressable", k8s.IsAddressable(broker.GVR(), brokerName))

f.Requirement("install event sender", eventshub.Install(sender,
eventshub.StartSenderToResource(broker.GVR(), brokerName),
eventshub.InputEvent(event),
))

expectedTypes := sets.New(event.Type())

f.Alpha("broker").
Must("deliver events to subscriber", assert.OnStore(sink).MatchEvent(cetest.HasId(event.ID())).AtLeast(1)).
Must("create event type", eventtype.WaitForEventType(eventtype.AssertPresent(expectedTypes)))

return f
}

func AutoCreateEventTypeEventsFromPingSource() *feature.Feature {
source := feature.MakeRandomK8sName("source")
sink := feature.MakeRandomK8sName("sink")
Expand Down
Loading