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 643319735 Improve configmap test coverage (#6158)
643319735 is described below

commit 643319735fdfe1a0534ed282a1f940cf7cef0cbf
Author: cfitzw <[email protected]>
AuthorDate: Wed Oct 29 11:38:53 2025 -0500

    Improve configmap test coverage (#6158)
    
    * add coverage for config configmap properties file
    
    * add coverage for variable interpolation
---
 e2e/common/config/config_test.go                   | 20 +++++++++++++++++
 ...g-configmap-properties-interpolation-route.yaml | 25 ++++++++++++++++++++++
 e2e/common/config/files/my.properties              |  3 ++-
 e2e/support/test_support.go                        | 11 ++++++++++
 4 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/e2e/common/config/config_test.go b/e2e/common/config/config_test.go
index 5de48e969..f8b1ed7bf 100644
--- a/e2e/common/config/config_test.go
+++ b/e2e/common/config/config_test.go
@@ -106,6 +106,12 @@ func TestRunConfigConfigmaps(t *testing.T) {
                err = CreatePlainTextConfigmap(t, ctx, ns, "my-cm-multi", 
cmDataMulti)
                g.Expect(err).To(BeNil())
 
+               // Store a configmap that mocks the '--from-file' functionality
+               // kubectl create configmap my-cm-properties-file 
--from-file=./files/my.properties"
+
+               err = CreateFromFileConfigmap(t, ctx, ns, 
"my-cm-properties-file", "./files/my.properties")
+               g.Expect(err).To(BeNil())
+
                t.Run("Config configmap", func(t *testing.T) {
                        g.Expect(KamelRun(t, ctx, ns, 
"./files/config-configmap-route.yaml", "--config", 
"configmap:my-cm").Execute()).To(Succeed())
                        g.Eventually(IntegrationPodPhase(t, ctx, ns, 
"config-configmap-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
@@ -113,6 +119,20 @@ func TestRunConfigConfigmaps(t *testing.T) {
                        g.Eventually(IntegrationLogs(t, ctx, ns, 
"config-configmap-route"), 
TestTimeoutShort).Should(ContainSubstring(cmData["my-configmap-key"]))
                })
 
+               t.Run("Config configmap from properties file", func(t 
*testing.T) {
+                       g.Expect(KamelRun(t, ctx, ns, 
"./files/config-configmap-properties-route.yaml", "--config", 
"configmap:my-cm-properties-file").Execute()).To(Succeed())
+                       g.Eventually(IntegrationPodPhase(t, ctx, ns, 
"config-configmap-properties-route"), 
TestTimeoutLong).Should(Equal(corev1.PodRunning))
+                       g.Eventually(IntegrationConditionStatus(t, ctx, ns, 
"config-configmap-properties-route", v1.IntegrationConditionReady), 
TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+                       g.Eventually(IntegrationLogs(t, ctx, ns, 
"config-configmap-properties-route"), 
TestTimeoutShort).Should(ContainSubstring("hello world"))
+               })
+
+               t.Run("Config configmap from properties file (interpolated)", 
func(t *testing.T) {
+                       g.Expect(KamelRun(t, ctx, ns, 
"./files/config-configmap-properties-interpolation-route.yaml", "--config", 
"configmap:my-cm-properties-file").Execute()).To(Succeed())
+                       g.Eventually(IntegrationPodPhase(t, ctx, ns, 
"config-configmap-properties-interpolation-route"), 
TestTimeoutLong).Should(Equal(corev1.PodRunning))
+                       g.Eventually(IntegrationConditionStatus(t, ctx, ns, 
"config-configmap-properties-interpolation-route", 
v1.IntegrationConditionReady), 
TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+                       g.Eventually(IntegrationLogs(t, ctx, ns, 
"config-configmap-properties-interpolation-route"), 
TestTimeoutShort).Should(ContainSubstring("hello world"))
+               })
+
                t.Run("Resource configmap", func(t *testing.T) {
                        // We can reuse the configmap created previously
                        g.Expect(KamelRun(t, ctx, ns, 
"./files/resource-configmap-route.yaml", "--resource", 
"configmap:my-cm").Execute()).To(Succeed())
diff --git 
a/e2e/common/config/files/config-configmap-properties-interpolation-route.yaml 
b/e2e/common/config/files/config-configmap-properties-interpolation-route.yaml
new file mode 100644
index 000000000..57cf9d67f
--- /dev/null
+++ 
b/e2e/common/config/files/config-configmap-properties-interpolation-route.yaml
@@ -0,0 +1,25 @@
+# camel-k: language=yaml
+
+# ---------------------------------------------------------------------------
+# 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: "timer:configmap"
+    steps:
+      - setBody:
+          simple: "configmap content is: {{my.key.3}}"
+      - to: "log:info"
diff --git a/e2e/common/config/files/my.properties 
b/e2e/common/config/files/my.properties
index 3ab90369f..502ea7bfd 100644
--- a/e2e/common/config/files/my.properties
+++ b/e2e/common/config/files/my.properties
@@ -1,2 +1,3 @@
 my.key.1=hello
-my.key.2=world
\ No newline at end of file
+my.key.2=world
+my.key.3=${my.key.1} ${my.key.2}
\ No newline at end of file
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 9300c2261..5f1e9db4d 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -33,6 +33,7 @@ import (
        "io"
        "os"
        "os/exec"
+       "path/filepath"
        "reflect"
        "regexp"
        "runtime/debug"
@@ -1597,6 +1598,16 @@ func CreatePlainTextConfigmap(t *testing.T, ctx 
context.Context, ns string, name
        return CreatePlainTextConfigmapWithLabels(t, ctx, ns, name, data, 
map[string]string{})
 }
 
+func CreateFromFileConfigmap(t *testing.T, ctx context.Context, ns string, 
name string, pathToFile string) error {
+       content, _ := os.ReadFile(pathToFile)
+       filename := filepath.Base(pathToFile)
+
+       var data = make(map[string]string)
+       data[filename] = string(content)
+
+       return CreatePlainTextConfigmapWithLabels(t, ctx, ns, name, data, 
map[string]string{})
+}
+
 func CreatePlainTextConfigmapWithLabels(t *testing.T, ctx context.Context, ns 
string, name string, data map[string]string, labels map[string]string) error {
        cm := corev1.ConfigMap{
                TypeMeta: metav1.TypeMeta{

Reply via email to