You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2023/04/25 10:14:43 UTC

[camel-k] branch main updated: fix(#3476) Add tests for enabling traits at IntegrationPlatform

This is an automated email from the ASF dual-hosted git repository.

pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git


The following commit(s) were added to refs/heads/main by this push:
     new 621b92941 fix(#3476) Add tests for enabling traits at IntegrationPlatform
621b92941 is described below

commit 621b92941e10bbf8013e1bd6887dc9bddcce81ee
Author: Jan Bouska <jb...@redhat.com>
AuthorDate: Wed Apr 5 14:02:32 2023 +0200

    fix(#3476) Add tests for enabling traits at IntegrationPlatform
---
 .../platform_traits_test.go                        | 77 ++++++++++++++++++++++
 1 file changed, 77 insertions(+)

diff --git a/e2e/commonwithcustominstall/platform_traits_test.go b/e2e/commonwithcustominstall/platform_traits_test.go
new file mode 100644
index 000000000..c8f6e13a2
--- /dev/null
+++ b/e2e/commonwithcustominstall/platform_traits_test.go
@@ -0,0 +1,77 @@
+//go:build integration
+// +build integration
+
+// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"
+
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package commonwithcustominstall
+
+import (
+	"testing"
+
+	"github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
+
+	. "github.com/onsi/gomega"
+
+	corev1 "k8s.io/api/core/v1"
+
+	. "github.com/apache/camel-k/v2/e2e/support"
+	v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
+)
+
+func TestTraitOnIntegrationPlatform(t *testing.T) {
+	WithNewTestNamespace(t, func(ns string) {
+		operatorID := "camel-k-platform-trait-test"
+		Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
+
+		containerTestName := "testname"
+		ip := Platform(ns)()
+		ip.Spec.Traits = v1.Traits{Logging: &trait.LoggingTrait{Level: "DEBUG"}, Container: &trait.ContainerTrait{Name: containerTestName}}
+
+		if err := TestClient().Update(TestContext, ip); err != nil {
+			t.Fatal("Can't create IntegrationPlatform", err)
+		}
+
+		name := "java"
+		t.Run("Run integration with platform traits", func(t *testing.T) {
+			Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
+				"--name", name,
+			).Execute()).To(Succeed())
+			Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+			Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+			Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+			Expect(IntegrationPod(ns, name)().Spec.Containers[0].Name).To(BeEquivalentTo(containerTestName))
+
+			found := false
+			for _, env := range IntegrationPod(ns, name)().Spec.Containers[0].Env {
+				if env.Name == "QUARKUS_LOG_LEVEL" {
+					Expect(env.Value).To(BeEquivalentTo("DEBUG"))
+					found = true
+					break
+				}
+			}
+			Expect(found).To(BeTrue(), "Can't find QUARKUS_LOG_LEVEL ENV variable")
+			Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("DEBUG"))
+
+			Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+		})
+	})
+}
+