From 77e01b9ffd0e2aacd3ac1904800c8ad5290a75eb Mon Sep 17 00:00:00 2001 From: Martin Gencur Date: Mon, 4 Nov 2024 16:34:22 +0100 Subject: [PATCH] Use GetServiceHostname when passing URL to JobSink This allows using Knative Service as the sink simply by adding an option to enviroment: eventshub.WithKnativeServiceForwarder --- test/rekt/features/jobsink/jobsink.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/rekt/features/jobsink/jobsink.go b/test/rekt/features/jobsink/jobsink.go index 127b8464a79..c872dc64f46 100644 --- a/test/rekt/features/jobsink/jobsink.go +++ b/test/rekt/features/jobsink/jobsink.go @@ -29,6 +29,7 @@ import ( "k8s.io/apimachinery/pkg/util/wait" "knative.dev/pkg/apis" kubeclient "knative.dev/pkg/client/injection/kube/client" + "knative.dev/pkg/network" "knative.dev/reconciler-test/pkg/environment" "knative.dev/reconciler-test/pkg/eventshub" "knative.dev/reconciler-test/pkg/eventshub/assert" @@ -49,13 +50,17 @@ func Success() *feature.Feature { jobSink := feature.MakeRandomK8sName("jobsink") source := feature.MakeRandomK8sName("source") - sinkURL := &apis.URL{Scheme: "http", Host: sink} - event := cetest.FullEvent() event.SetID(uuid.NewString()) f.Setup("install forwarder sink", eventshub.Install(sink, eventshub.StartReceiver)) - f.Setup("install job sink", jobsink.Install(jobSink, jobsink.WithForwarderJob(sinkURL.String()))) + f.Setup("install job sink", func(ctx context.Context, t feature.T) { + sinkURL := &apis.URL{ + Scheme: "http", + Host: network.GetServiceHostname(sink, environment.FromContext(ctx).Namespace()), + } + jobsink.Install(jobSink, jobsink.WithForwarderJob(sinkURL.String()))(ctx, t) + }) f.Setup("jobsink is addressable", jobsink.IsAddressable(jobSink)) f.Setup("jobsink is ready", jobsink.IsReady(jobSink))