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

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

commit 90cbbda23ee38feb294fcaf4add219b7be1a7960
Author: Pasquale Congiusti <[email protected]>
AuthorDate: Mon Jun 7 12:38:43 2021 +0200

    chore(e2e): configmap/secret key test
    
    Ref #2003
---
 e2e/common/config/config_test.go                     | 17 +++++++++++++++++
 .../resource-configmap-key-location-route.groovy     | 20 ++++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/e2e/common/config/config_test.go b/e2e/common/config/config_test.go
index 9282fad..07ba32f 100644
--- a/e2e/common/config/config_test.go
+++ b/e2e/common/config/config_test.go
@@ -64,6 +64,12 @@ func TestRunConfigExamples(t *testing.T) {
                cmData["my-configmap-key"] = "my-configmap-content"
                NewPlainTextConfigmap(ns, "my-cm", cmData)
 
+               // Store a configmap with multiple values
+               var cmDataMulti = make(map[string]string)
+               cmDataMulti["my-configmap-key"] = "should-not-see-it"
+               cmDataMulti["my-configmap-key-2"] = "my-configmap-content-2"
+               NewPlainTextConfigmap(ns, "my-cm-multi", cmDataMulti)
+
                t.Run("Config configmap", func(t *testing.T) {
                        Expect(Kamel("run", "-n", ns, 
"./files/config-configmap-route.groovy", "--config", 
"configmap:my-cm").Execute()).To(Succeed())
                        Eventually(IntegrationPodPhase(ns, 
"config-configmap-route"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
@@ -92,6 +98,17 @@ func TestRunConfigExamples(t *testing.T) {
                        Expect(Kamel("delete", "--all", "-n", 
ns).Execute()).To(Succeed())
                })
 
+               t.Run("Resource configmap with filtered key and destination", 
func(t *testing.T) {
+                       // We'll use the configmap contaning 2 values filtering 
only 1 key
+
+                       Expect(Kamel("run", "-n", ns, 
"./files/resource-configmap-key-location-route.groovy", "--resource", 
"configmap:my-cm-multi/my-configmap-key-2@/tmp/app").Execute()).To(Succeed())
+                       Eventually(IntegrationPodPhase(ns, 
"resource-configmap-key-location-route"), 
TestTimeoutMedium).Should(Equal(v1.PodRunning))
+                       Eventually(IntegrationCondition(ns, 
"resource-configmap-key-location-route", camelv1.IntegrationConditionReady), 
TestTimeoutShort).Should(Equal(v1.ConditionTrue))
+                       Eventually(IntegrationLogs(ns, 
"resource-configmap-key-location-route"), 
TestTimeoutShort).ShouldNot(ContainSubstring(cmDataMulti["my-configmap-key"]))
+                       Eventually(IntegrationLogs(ns, 
"resource-configmap-key-location-route"), 
TestTimeoutShort).Should(ContainSubstring(cmDataMulti["my-configmap-key-2"]))
+                       Expect(Kamel("delete", "--all", "-n", 
ns).Execute()).To(Succeed())
+               })
+
                // Secret
 
                // Store a secret on the cluster
diff --git 
a/e2e/common/config/files/resource-configmap-key-location-route.groovy 
b/e2e/common/config/files/resource-configmap-key-location-route.groovy
new file mode 100644
index 0000000..c065401
--- /dev/null
+++ b/e2e/common/config/files/resource-configmap-key-location-route.groovy
@@ -0,0 +1,20 @@
+// camel-k: language=groovy
+/*
+ * 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('file:/tmp/app/?noop=true&idempotent=false')
+    .log('resource file content is: ${body}')

Reply via email to