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

commit 1cf62ec451405fcb7ad21a5bccf479976ebc6b3f
Author: Pasquale Congiusti <pasquale.congiu...@gmail.com>
AuthorDate: Tue Oct 10 11:38:27 2023 +0200

    chore(e2e): kamelet trait test
---
 e2e/common/traits/files/webhook.yaml | 21 +++++++++++
 e2e/common/traits/kamelet_test.go    | 67 ++++++++++++++++++++++++++++++++++++
 e2e/support/test_support.go          | 10 ++++++
 3 files changed, 98 insertions(+)

diff --git a/e2e/common/traits/files/webhook.yaml 
b/e2e/common/traits/files/webhook.yaml
new file mode 100644
index 000000000..c6deb4c8b
--- /dev/null
+++ b/e2e/common/traits/files/webhook.yaml
@@ -0,0 +1,21 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+
+- from:
+    uri: "kamelet:capabilities-webhook-source"
+    steps:
+      - log: "${body}"
diff --git a/e2e/common/traits/kamelet_test.go 
b/e2e/common/traits/kamelet_test.go
new file mode 100644
index 000000000..bd6ec96af
--- /dev/null
+++ b/e2e/common/traits/kamelet_test.go
@@ -0,0 +1,67 @@
+//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 traits
+
+import (
+       "testing"
+
+       . "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 TestKameletTrait(t *testing.T) {
+       RegisterTestingT(t)
+
+       t.Run("discover kamelet capabilities", func(t *testing.T) {
+               template := map[string]interface{}{
+                       "from": map[string]interface{}{
+                               "uri": "platform-http:///webhook";,
+                               "steps": []map[string]interface{}{
+                                       {
+                                               "to": "kamelet:sink",
+                                       },
+                               },
+                       },
+               }
+               Expect(CreateKamelet(ns, "capabilities-webhook-source", 
template, nil, nil)()).To(Succeed())
+
+               name := "webhook"
+               Expect(KamelRunWithID(operatorID, ns, "files/webhook.yaml", 
"--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("Started 
capabilities-webhook-source-1 (platform-http:///webhook)"))
+               // Verify Integration capabilities
+               Eventually(IntegrationStatusCapabilities(ns, name), 
TestTimeoutShort).Should(ContainElements("platform-http"))
+               // Verify expected resources from Kamelet (Service in this case)
+               service := Service(ns, name)
+               Eventually(service, TestTimeoutShort).ShouldNot(BeNil())
+       })
+
+       // Clean-up
+       Expect(DeleteKamelet(ns, "capabilities-webhook-source")).To(Succeed())
+       Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+}
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 7b57a711b..91b4228ad 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -998,6 +998,16 @@ func IntegrationSpecProfile(ns string, name string) func() 
v1.TraitProfile {
        }
 }
 
+func IntegrationStatusCapabilities(ns string, name string) func() []string {
+       return func() []string {
+               it := Integration(ns, name)()
+               if it == nil || &it.Status == nil {
+                       return nil
+               }
+               return it.Status.Capabilities
+       }
+}
+
 func IntegrationSpecSA(ns string, name string) func() string {
        return func() string {
                it := Integration(ns, name)()

Reply via email to