diff --git a/pkg/reconciler/broker/broker_test.go b/pkg/reconciler/broker/broker_test.go index 3081a50c299..b8cd4fe14bc 100644 --- a/pkg/reconciler/broker/broker_test.go +++ b/pkg/reconciler/broker/broker_test.go @@ -48,6 +48,7 @@ import ( eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1" eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" "knative.dev/eventing/pkg/apis/feature" + v1 "knative.dev/eventing/pkg/apis/messaging/v1" "knative.dev/eventing/pkg/auth" fakeeventingclient "knative.dev/eventing/pkg/client/injection/client/fake" "knative.dev/eventing/pkg/client/injection/ducks/duck/v1/channelable" @@ -405,6 +406,48 @@ func TestReconcile(t *testing.T) { WithDLSNotConfigured(), WithBrokerEventPoliciesReadyBecauseOIDCDisabled()), }}, + }, { + Name: "Propagate annotations", + Key: testKey, + Objects: []runtime.Object{ + makeDLSServiceAsUnstructured(), + NewBroker(brokerName, testNS, + WithBrokerClass(eventing.MTChannelBrokerClassValue), + WithBrokerConfig(config()), + WithInitBrokerConditions, + WithBrokerAnnotation(v1.AsyncHandlerAnnotation, "true")), + createChannel(withChannelReady), + imcConfigMap(), + NewEndpoints(filterServiceName, systemNS, + WithEndpointsLabels(FilterLabels()), + WithEndpointsAddresses(corev1.EndpointAddress{IP: "127.0.0.1"})), + NewEndpoints(ingressServiceName, systemNS, + WithEndpointsLabels(IngressLabels()), + WithEndpointsAddresses(corev1.EndpointAddress{IP: "127.0.0.1"})), + }, + WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ + Object: NewBroker(brokerName, testNS, + WithBrokerClass(eventing.MTChannelBrokerClassValue), + WithBrokerConfig(config()), + WithBrokerAnnotation(v1.AsyncHandlerAnnotation, "true"), + WithBrokerReady, + WithDLSNotConfigured(), + WithBrokerAddressURI(brokerAddress), + WithChannelAddressAnnotation(triggerChannelURL), + WithChannelAPIVersionAnnotation(triggerChannelAPIVersion), + WithChannelKindAnnotation(triggerChannelKind), + WithChannelNameAnnotation(triggerChannelName), + WithBrokerEventPoliciesReadyBecauseOIDCDisabled()), + }}, + WantPatches: []clientgotesting.PatchActionImpl{ + { + ActionImpl: clientgotesting.ActionImpl{ + Namespace: testNS, + }, + Name: fmt.Sprintf("%s-kne-trigger", brokerName), + Patch: []byte(`[{"op":"add","path":"/metadata/annotations/messaging.knative.dev~1async-handler","value":"` + "true" + `"}]`), + }, + }, }, { Name: "Successful Reconciliation with a Channel with CA certs", Key: testKey, diff --git a/pkg/reconciler/testing/v1/broker.go b/pkg/reconciler/testing/v1/broker.go index e4bfa7141e4..b04ed910d96 100644 --- a/pkg/reconciler/testing/v1/broker.go +++ b/pkg/reconciler/testing/v1/broker.go @@ -61,6 +61,15 @@ func WithBrokerFinalizers(finalizers ...string) BrokerOption { } } +func WithBrokerAnnotation(key, value string) BrokerOption { + return func(b *v1.Broker) { + if b.Annotations == nil { + b.Annotations = map[string]string{} + } + b.Annotations[key] = value + } +} + func WithBrokerResourceVersion(rv string) BrokerOption { return func(b *v1.Broker) { b.ResourceVersion = rv