This is an automated email from the ASF dual-hosted git repository. squakez pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit ca24165610ef10169e2587e61be145619315facc Author: UchihaIthachi <[email protected]> AuthorDate: Fri Nov 6 20:22:30 2026 +0530 test(e2e/keda): run the Pulsar test in a random namespace Signed-off-by: UchihaIthachi <[email protected]> --- e2e/keda/files/keda-it-pulsar-to-log-auto.yaml | 2 +- e2e/keda/files/timer-to-pulsar.yaml | 2 +- e2e/keda/keda_pulsar_test.go | 33 +++++++++++++++++++------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/e2e/keda/files/keda-it-pulsar-to-log-auto.yaml b/e2e/keda/files/keda-it-pulsar-to-log-auto.yaml index 01b3c97a8..0bf7e0f97 100644 --- a/e2e/keda/files/keda-it-pulsar-to-log-auto.yaml +++ b/e2e/keda/files/keda-it-pulsar-to-log-auto.yaml @@ -29,7 +29,7 @@ spec: traits: camel: properties: - - camel.component.pulsar.service-url=pulsar://pulsar.keda.svc:6650 + - camel.component.pulsar.service-url=pulsar://pulsar.%%%.svc:6650 keda: enabled: true minReplicaCount: 0 diff --git a/e2e/keda/files/timer-to-pulsar.yaml b/e2e/keda/files/timer-to-pulsar.yaml index 52262bfc1..e3527ec5e 100644 --- a/e2e/keda/files/timer-to-pulsar.yaml +++ b/e2e/keda/files/timer-to-pulsar.yaml @@ -31,4 +31,4 @@ spec: traits: camel: properties: - - camel.component.pulsar.service-url=pulsar://pulsar.keda.svc:6650 + - camel.component.pulsar.service-url=pulsar://pulsar.%%%.svc:6650 diff --git a/e2e/keda/keda_pulsar_test.go b/e2e/keda/keda_pulsar_test.go index b20e33a62..2000e1a2c 100644 --- a/e2e/keda/keda_pulsar_test.go +++ b/e2e/keda/keda_pulsar_test.go @@ -24,6 +24,9 @@ package keda import ( "context" + "os" + "path/filepath" + "strings" "testing" . "github.com/onsi/gomega" @@ -35,7 +38,7 @@ import ( ) func TestPulsarKedaAutoscale(t *testing.T) { - WithExistingNamedTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { + WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { ExpectExecSucceed(t, g, Kubectl("apply", "-f", "files/pulsar-ephemeral.yaml", "-n", ns)) ExpectExecSucceed(t, g, Kubectl("rollout", "status", "deployment", "pulsar", "-n", ns, "--timeout=300s")) @@ -43,7 +46,7 @@ func TestPulsarKedaAutoscale(t *testing.T) { consumerName := "keda-it-pulsar-to-log-auto" producerName := "timer-to-pulsar" - ExpectExecSucceed(t, g, Kubectl("apply", "-f", "files/keda-it-pulsar-to-log-auto.yaml", "-n", ns)) + ExpectExecSucceed(t, g, Kubectl("apply", "-f", cloneAndReplaceNamespace(t, "files/keda-it-pulsar-to-log-auto.yaml", ns), "-n", ns)) // The ScaledObject uses the trigger discovered from the Pulsar endpoint URI g.Eventually(ScaledObject(t, ctx, ns, consumerName), TestTimeoutMedium).ShouldNot(BeNil()) @@ -52,7 +55,7 @@ func TestPulsarKedaAutoscale(t *testing.T) { g.Expect(scaledObj.Spec.Triggers[0].Type).To(Equal("pulsar")) g.Expect(scaledObj.Spec.Triggers[0].Metadata["topic"]).To(Equal("persistent://public/default/my-topic")) g.Expect(scaledObj.Spec.Triggers[0].Metadata["subscription"]).To(Equal("my-subscription")) - g.Expect(scaledObj.Spec.Triggers[0].Metadata["adminURL"]).To(Equal("http://pulsar.keda.svc:8080")) + g.Expect(scaledObj.Spec.Triggers[0].Metadata["adminURL"]).To(Equal("http://pulsar." + ns + ".svc:8080")) // Start consumer; it creates the subscription g.Eventually(IntegrationConditionStatus(t, ctx, ns, consumerName, v1.IntegrationConditionReady), TestTimeoutLong). @@ -63,7 +66,7 @@ func TestPulsarKedaAutoscale(t *testing.T) { Should(PointTo(BeNumerically("==", 0))) // Start producer to build a backlog - ExpectExecSucceed(t, g, Kubectl("apply", "-f", "files/timer-to-pulsar.yaml", "-n", ns)) + ExpectExecSucceed(t, g, Kubectl("apply", "-f", cloneAndReplaceNamespace(t, "files/timer-to-pulsar.yaml", ns), "-n", ns)) g.Eventually(IntegrationConditionStatus(t, ctx, ns, producerName, v1.IntegrationConditionReady), TestTimeoutLong). Should(Equal(corev1.ConditionTrue)) @@ -77,10 +80,24 @@ func TestPulsarKedaAutoscale(t *testing.T) { ExpectExecSucceed(t, g, Kubectl("delete", "it", producerName, "-n", ns)) g.Eventually(IntegrationStatusReplicas(t, ctx, ns, consumerName), TestTimeoutMedium). Should(PointTo(BeNumerically("==", 0))) - - ExpectExecSucceed(t, g, Kubectl("delete", "it", "--all", "-n", ns)) }) + }) +} + +// cloneAndReplaceNamespace clones and replace the content marked as %%% with the namespace passed as parameter. +func cloneAndReplaceNamespace(t *testing.T, srcPath, namespace string) string { + t.Helper() + + tempPath := filepath.Join(t.TempDir(), filepath.Base(srcPath)) + + content, err := os.ReadFile(srcPath) + if err != nil { + t.Fatalf("failed to read src file: %v", err) + } + updated := strings.ReplaceAll(string(content), "%%%", namespace) + if err := os.WriteFile(tempPath, []byte(updated), 0o644); err != nil { + t.Fatalf("failed to write dst file: %v", err) + } - ExpectExecSucceed(t, g, Kubectl("delete", "-f", "files/pulsar-ephemeral.yaml", "-n", ns)) - }, "keda") + return tempPath }
