From b1e6f3dead26d9e36dd62cdae5e65713cc905c27 Mon Sep 17 00:00:00 2001 From: Matthias Wessendorf Date: Tue, 12 Nov 2024 16:15:33 +0100 Subject: [PATCH] Instead of re-installing the channel_impl, lets update the annotations. Otherwise we loose the channel's Spec.Subscribers Signed-off-by: Matthias Wessendorf --- test/rekt/features/channel/features.go | 23 +++++++++++++++---- .../resources/channel_impl/channel_impl.yaml | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/test/rekt/features/channel/features.go b/test/rekt/features/channel/features.go index 61213dd1076..22178a0720c 100644 --- a/test/rekt/features/channel/features.go +++ b/test/rekt/features/channel/features.go @@ -25,6 +25,7 @@ import ( "github.com/cloudevents/sdk-go/v2/binding" "github.com/cloudevents/sdk-go/v2/test" "github.com/google/uuid" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" duckv1 "knative.dev/pkg/apis/duck/v1" "knative.dev/pkg/network" "knative.dev/reconciler-test/pkg/environment" @@ -191,12 +192,24 @@ func AsyncHandlerUpdate(createSubscriberFn func(ref *duckv1.KReference, uri stri f.Setup("channel is ready", channel_impl.IsReady(name)) f.Setup("subscription is ready", subscription.IsReady(sub)) - f.Requirement("update channel async handler", channel_impl.Install(name, channel_impl.WithAnnotations(map[string]interface{}{ - v1.AsyncHandlerAnnotation: "false", - }))) - f.Requirement("channel is ready", channel_impl.IsReady(name)) + f.Requirement("update channel async handler", func(ctx context.Context, t feature.T) { + dc := Client(ctx) - f.Assert("install source", eventshub.Install(source, eventshub.InputEvent(event), eventshub.StartSenderToResource(channel_impl.GVR(), name))) + imc, err := dc.ChannelImpl.Get(ctx, name, metav1.GetOptions{}) + if err != nil { + t.Fatalf("Failed to retrieve InMemoryChannel: %v", err) + } + // swap and update it to false + imc.SetAnnotations(map[string]string{ + v1.AsyncHandlerAnnotation: "true", + }) + if _, err := dc.ChannelImpl.Update(ctx, imc, metav1.UpdateOptions{}); err != nil { + t.Fatalf("Failed to update async handler annotation: %v", err) + } + }) + + f.Requirement("channel is ready", channel_impl.IsReady(name)) + f.Requirement("install source", eventshub.Install(source, eventshub.InputEvent(event), eventshub.StartSenderToResource(channel_impl.GVR(), name))) f.Assert("Event sent", assert.OnStore(source). MatchSentEvent(test.HasId(event.ID())). diff --git a/test/rekt/resources/channel_impl/channel_impl.yaml b/test/rekt/resources/channel_impl/channel_impl.yaml index d75bc854c06..78a042beed7 100644 --- a/test/rekt/resources/channel_impl/channel_impl.yaml +++ b/test/rekt/resources/channel_impl/channel_impl.yaml @@ -17,8 +17,8 @@ kind: {{ .kind }} metadata: name: {{ .name }} namespace: {{ .namespace }} - annotations: {{ if .annotations }} + annotations: {{ range $key, $value := .annotations }} {{ $key }}: "{{ $value }}" {{ end }}