You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2021/05/17 09:57:01 UTC

[camel-k] branch main updated (bcd6811 -> 01e9c19)

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

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


    from bcd6811  chore: Update README badges
     new c51e390  chore(example): complete set of user config
     new 434e08c  chore(e2e): resource test refactory
     new e0b9be1  feat(e2e): property test
     new 4759a4b  chore(e2e): support configmap and secret creation
     new 01e9c19  chore(e2e): complete config integration test

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitignore                                         |   1 +
 e2e/common/config/config_test.go                   | 123 +++++++++++++++++++++
 .../common/config/files/configmap-route.groovy     |  11 +-
 e2e/common/config/files/my.properties              |   2 +
 .../common/config/files/property-file-route.groovy |  10 +-
 .../common/config/files/property-route.groovy      |  12 +-
 .../files/resources-base64-encoded-route.groovy    |   9 +-
 .../config/files/resources-binary-route.groovy     |  12 +-
 .../common/config/files}/resources-data.txt        |   0
 .../config}/files/resources-data.zip               | Bin
 .../common/config/files}/resources-route.groovy    |   5 +-
 .../common/config/files/secret-route.groovy        |  11 +-
 e2e/resources/files/ResourcesBinary.java           |  40 -------
 e2e/resources/files/ResourcesText.java             |  29 -----
 e2e/resources/resources_test.go                    |  56 ----------
 e2e/support/test_support.go                        |  30 +++++
 examples/README.md                                 |   3 +-
 examples/basic/README.md                           |   3 -
 examples/basic/props.js                            |  25 -----
 examples/cron/README.md                            |   3 +
 examples/{basic => cron}/cron.groovy               |   0
 examples/kafka/README.md                           |   6 +
 examples/user-config/README.md                     |   3 +
 .../configmap-route.groovy}                        |  11 +-
 examples/user-config/my.properties                 |   2 +
 .../property-file-route.groovy}                    |  10 +-
 .../property-route.groovy}                         |  12 +-
 .../resources-base64-encoded-route.groovy}         |   9 +-
 .../resources-binary-route.groovy}                 |  12 +-
 .../user-config}/resources-data.txt                |   0
 examples/user-config/resources-data.zip            | Bin 0 -> 199 bytes
 .../{basic => user-config}/resources-route.groovy  |   5 +-
 .../secret-route.groovy}                           |  11 +-
 pkg/cmd/util.go                                    |   9 +-
 pkg/resources/resources.go                         |   4 +-
 script/Makefile                                    |   5 +-
 36 files changed, 250 insertions(+), 234 deletions(-)
 create mode 100644 e2e/common/config/config_test.go
 copy examples/basic/resources-route.groovy => e2e/common/config/files/configmap-route.groovy (75%)
 create mode 100644 e2e/common/config/files/my.properties
 copy examples/basic/resources-route.groovy => e2e/common/config/files/property-file-route.groovy (77%)
 copy examples/kamelets/timer-source/usage.groovy => e2e/common/config/files/property-route.groovy (80%)
 mode change 100755 => 100644
 copy examples/basic/resources-route.groovy => e2e/common/config/files/resources-base64-encoded-route.groovy (80%)
 copy examples/basic/resources-route.groovy => e2e/common/config/files/resources-binary-route.groovy (74%)
 rename {examples/basic => e2e/common/config/files}/resources-data.txt (100%)
 rename e2e/{resources => common/config}/files/resources-data.zip (100%)
 copy {examples/basic => e2e/common/config/files}/resources-route.groovy (88%)
 copy examples/basic/resources-route.groovy => e2e/common/config/files/secret-route.groovy (76%)
 delete mode 100644 e2e/resources/files/ResourcesBinary.java
 delete mode 100644 e2e/resources/files/ResourcesText.java
 delete mode 100644 e2e/resources/resources_test.go
 delete mode 100644 examples/basic/README.md
 delete mode 100644 examples/basic/props.js
 create mode 100644 examples/cron/README.md
 rename examples/{basic => cron}/cron.groovy (100%)
 create mode 100644 examples/user-config/README.md
 copy examples/{basic/resources-route.groovy => user-config/configmap-route.groovy} (75%)
 create mode 100644 examples/user-config/my.properties
 copy examples/{basic/resources-route.groovy => user-config/property-file-route.groovy} (77%)
 copy examples/{kamelets/timer-source/usage.groovy => user-config/property-route.groovy} (80%)
 mode change 100755 => 100644
 copy examples/{basic/resources-route.groovy => user-config/resources-base64-encoded-route.groovy} (80%)
 copy examples/{basic/resources-route.groovy => user-config/resources-binary-route.groovy} (74%)
 rename {e2e/resources/files => examples/user-config}/resources-data.txt (100%)
 create mode 100644 examples/user-config/resources-data.zip
 copy examples/{basic => user-config}/resources-route.groovy (88%)
 rename examples/{basic/resources-route.groovy => user-config/secret-route.groovy} (76%)

[camel-k] 02/05: chore(e2e): resource test refactory

Posted by as...@apache.org.
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 434e08c42e93af7a8d3f103d43211b546b3a216f
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Fri May 14 14:33:23 2021 +0200

    chore(e2e): resource test refactory
    
    * Changed Java test with Groovy test
    * Covered all resources cases (base encoded)
    
    Ref #2003
---
 .gitignore                                         |   1 +
 .../files/resources-base64-encoded-route.groovy}   |  32 +++------
 .../files/resources-binary-route.groovy}           |  20 +++---
 e2e/{resources => config}/files/resources-data.txt |   0
 e2e/{resources => config}/files/resources-data.zip | Bin
 .../files/resources-route.groovy}                  |  21 +++---
 e2e/config/resources_test.go                       |  73 +++++++++++++++++++++
 e2e/resources/resources_test.go                    |  56 ----------------
 pkg/cmd/util.go                                    |   9 +--
 pkg/resources/resources.go                         |   4 +-
 script/Makefile                                    |   4 +-
 11 files changed, 110 insertions(+), 110 deletions(-)

diff --git a/.gitignore b/.gitignore
index 4698207..94ad8cb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,6 +32,7 @@
 build/_output
 build/_test
 build/_maven_output
+build/_maven_overlay
 build/_kamelets
 /api_*
 
diff --git a/e2e/resources/files/ResourcesBinary.java b/e2e/config/files/resources-base64-encoded-route.groovy
similarity index 56%
rename from e2e/resources/files/ResourcesBinary.java
rename to e2e/config/files/resources-base64-encoded-route.groovy
index e1dbb55..02559f0 100644
--- a/e2e/resources/files/ResourcesBinary.java
+++ b/e2e/config/files/resources-base64-encoded-route.groovy
@@ -1,3 +1,4 @@
+// camel-k: language=groovy
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -14,27 +15,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- 
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
 
-public class ResourcesBinary extends org.apache.camel.builder.RouteBuilder {
+//
+// To run this integrations use:
+// kamel run --resource resources-data.txt --compression=true resources-base64-encoded-route.groovy --dev
+//
 
-    @Override
-    public void configure() throws Exception {
-        from("file:/etc/camel/resources/i-resource-000/?noop=true")
-                .unmarshal().zipFile()
-                .convertBodyTo(String.class)
-                .process(new ZipEntryProcessor());
-    }
-
-}
-
-class ZipEntryProcessor implements Processor {
-
-    @Override
-    public void process(Exchange exchange) throws Exception {
-        System.out.println(exchange.getIn().getBody().toString());
-    }
-
-}
\ No newline at end of file
+from('timer:resources-bas64')
+    .routeId('resources-base64')
+    .setBody()
+        .simple("resource:classpath:resources-data.txt")
+    .log('resource file base64 content is: ${body}')
diff --git a/e2e/resources/files/ResourcesText.java b/e2e/config/files/resources-binary-route.groovy
similarity index 68%
copy from e2e/resources/files/ResourcesText.java
copy to e2e/config/files/resources-binary-route.groovy
index 8ae314f..8b0878b 100644
--- a/e2e/resources/files/ResourcesText.java
+++ b/e2e/config/files/resources-binary-route.groovy
@@ -1,3 +1,4 @@
+// camel-k: language=groovy
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -14,16 +15,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- 
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
 
-public class ResourcesText extends org.apache.camel.builder.RouteBuilder {
+//
+// To run this integrations use:
+// kamel run --resource resources-data.zip resources-binary-route.groovy -d camel-zipfile --dev
+//
 
-    @Override
-    public void configure() throws Exception {
-        from("file:/etc/camel/resources/i-resource-000/?noop=true")
-                .log("${body}");
-    }
-
-}
\ No newline at end of file
+from('file:/etc/camel/resources/?fileName=resources-data.zip&noop=true&idempotent=false')
+    .routeId('resources-zip')
+    .unmarshal().zipFile()
+    .log('resource file unzipped content is: ${body}')
diff --git a/e2e/resources/files/resources-data.txt b/e2e/config/files/resources-data.txt
similarity index 100%
rename from e2e/resources/files/resources-data.txt
rename to e2e/config/files/resources-data.txt
diff --git a/e2e/resources/files/resources-data.zip b/e2e/config/files/resources-data.zip
similarity index 100%
rename from e2e/resources/files/resources-data.zip
rename to e2e/config/files/resources-data.zip
diff --git a/e2e/resources/files/ResourcesText.java b/e2e/config/files/resources-route.groovy
similarity index 71%
rename from e2e/resources/files/ResourcesText.java
rename to e2e/config/files/resources-route.groovy
index 8ae314f..6f57285 100644
--- a/e2e/resources/files/ResourcesText.java
+++ b/e2e/config/files/resources-route.groovy
@@ -1,3 +1,4 @@
+// camel-k: language=groovy
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -14,16 +15,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- 
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
 
-public class ResourcesText extends org.apache.camel.builder.RouteBuilder {
+//
+// To run this integrations use:
+// kamel run --resource resources-data.txt resources-route.groovy --dev
+//
 
-    @Override
-    public void configure() throws Exception {
-        from("file:/etc/camel/resources/i-resource-000/?noop=true")
-                .log("${body}");
-    }
-
-}
\ No newline at end of file
+from('timer:resources')
+    .routeId('resources')
+    .setBody()
+        .simple("resource:classpath:resources-data.txt")
+    .log('resource file content is: ${body}')
diff --git a/e2e/config/resources_test.go b/e2e/config/resources_test.go
new file mode 100644
index 0000000..404b7a2
--- /dev/null
+++ b/e2e/config/resources_test.go
@@ -0,0 +1,73 @@
+// +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 resources
+
+import (
+	"testing"
+
+	. "github.com/onsi/gomega"
+	"github.com/stretchr/testify/assert"
+
+	v1 "k8s.io/api/core/v1"
+
+	"io/ioutil"
+
+	. "github.com/apache/camel-k/e2e/support"
+	camelv1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+	"github.com/apache/camel-k/pkg/util/gzip"
+)
+
+func TestRunResourceExamples(t *testing.T) {
+	WithNewTestNamespace(t, func(ns string) {
+		Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
+
+		t.Run("Plain text resource file", func(t *testing.T) {
+			Expect(Kamel("run", "-n", ns, "./files/resources-route.groovy", "--resource", "./files/resources-data.txt").Execute()).To(Succeed())
+			Eventually(IntegrationPodPhase(ns, "resources-route"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
+			Eventually(IntegrationCondition(ns, "resources-route", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
+			Eventually(IntegrationLogs(ns, "resources-route"), TestTimeoutShort).Should(ContainSubstring("the file body"))
+			Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+		})
+
+		t.Run("Binary (zip) resource file", func(t *testing.T) {
+			Expect(Kamel("run", "-n", ns, "./files/resources-binary-route.groovy", "--resource", "./files/resources-data.zip", "-d", "camel-zipfile").Execute()).To(Succeed())
+			Eventually(IntegrationPodPhase(ns, "resources-binary-route"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
+			Eventually(IntegrationCondition(ns, "resources-binary-route", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
+			Eventually(IntegrationLogs(ns, "resources-binary-route"), TestTimeoutShort).Should(ContainSubstring("the file body"))
+			Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+		})
+
+		t.Run("Base64 compressed binary resource file", func(t *testing.T) {
+			// We calculate the expected content
+			source, err := ioutil.ReadFile("./files/resources-data.txt")
+			assert.Nil(t, err)
+			expectedBytes, err := gzip.CompressBase64([]byte(source))
+			assert.Nil(t, err)
+
+			Expect(Kamel("run", "-n", ns, "./files/resources-base64-encoded-route.groovy", "--resource", "./files/resources-data.txt", "--compression=true").Execute()).To(Succeed())
+			Eventually(IntegrationPodPhase(ns, "resources-base64-encoded-route"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
+			Eventually(IntegrationCondition(ns, "resources-base64-encoded-route", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
+			Eventually(IntegrationLogs(ns, "resources-base64-encoded-route"), TestTimeoutShort).Should(ContainSubstring(string(expectedBytes)))
+			Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+		})
+	})
+}
diff --git a/e2e/resources/resources_test.go b/e2e/resources/resources_test.go
deleted file mode 100644
index c7b08ba..0000000
--- a/e2e/resources/resources_test.go
+++ /dev/null
@@ -1,56 +0,0 @@
-// +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 resources
-
-import (
-	"testing"
-
-	. "github.com/onsi/gomega"
-
-	v1 "k8s.io/api/core/v1"
-
-	. "github.com/apache/camel-k/e2e/support"
-	camelv1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-)
-
-func TestRunResourceExamples(t *testing.T) {
-	WithNewTestNamespace(t, func(ns string) {
-		Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
-
-		t.Run("run java", func(t *testing.T) {
-			Expect(Kamel("run", "-n", ns, "./files/ResourcesText.java", "--resource", "./files/resources-data.txt").Execute()).To(Succeed())
-			Eventually(IntegrationPodPhase(ns, "resources-text"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
-			Eventually(IntegrationCondition(ns, "resources-text", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
-			Eventually(IntegrationLogs(ns, "resources-text"), TestTimeoutShort).Should(ContainSubstring("the file body"))
-			Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
-		})
-
-		t.Run("run java", func(t *testing.T) {
-			Expect(Kamel("run", "-n", ns, "./files/ResourcesBinary.java",
-				"--resource", "./files/resources-data.zip", "-d", "camel-zipfile").Execute()).To(Succeed())
-			Eventually(IntegrationPodPhase(ns, "resources-binary"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
-			Eventually(IntegrationCondition(ns, "resources-binary", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
-			Eventually(IntegrationLogs(ns, "resources-binary"), TestTimeoutShort).Should(ContainSubstring("the file body"))
-			Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
-		})
-	})
-}
diff --git a/pkg/cmd/util.go b/pkg/cmd/util.go
index 3e364a6..b287529 100644
--- a/pkg/cmd/util.go
+++ b/pkg/cmd/util.go
@@ -18,9 +18,7 @@ limitations under the License.
 package cmd
 
 import (
-	"bytes"
 	"context"
-	"encoding/base64"
 	"encoding/csv"
 	"encoding/json"
 	"fmt"
@@ -243,11 +241,10 @@ func fieldByMapstructureTagName(target reflect.Value, tagName string) (reflect.S
 }
 
 func compressToString(content []byte) (string, error) {
-	var b bytes.Buffer
-
-	if err := gzip.Compress(&b, content); err != nil {
+	bytes, err := gzip.CompressBase64(content)
+	if err != nil {
 		return "", err
 	}
 
-	return base64.StdEncoding.EncodeToString(b.Bytes()), nil
+	return string(bytes), nil
 }
diff --git a/pkg/resources/resources.go b/pkg/resources/resources.go
index 1005db3..93f34e0 100644
--- a/pkg/resources/resources.go
+++ b/pkg/resources/resources.go
@@ -467,9 +467,9 @@ var assets = func() http.FileSystem {
 		"/traits.yaml": &vfsgen۰CompressedFileInfo{
 			name:             "traits.yaml",
 			modTime:          time.Time{},
-			uncompressedSize: 38387,
+			uncompressedSize: 38635,
 
-			compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x7d\x6d\x6f\x1c\x37\xd2\xe0\x77\xff\x0a\x42\xcf\x01\x7a\xc1\x4c\x4b\xce\x22\xbb\x39\xdd\xf9\x16\x8a\xed\xec\x2a\x89\x6d\x9d\xe5\xcd\xe2\xe0\x0b\x76\x38\xdd\x35\x33\xb4\xd8\x64\x2f\xc9\x96\x3c\x39\xdc\x7f\x3f\xb0\x8a\x6f\x3d\xd3\x92\x46\x4e\x14\x44\x87\x67\xf7\x43\x2c\xa9\xbb\x58\x2c\x16\xeb\xbd\xaa\x9d\xe1\xc2\xd9\xd3\x67\x53\xa6\x78\x0b\xa7\x8c\x2f\x16\x42\x09\xb7\x7e\xc6\x58\x27\xb9\x5b\x68\xd3\x9e\xb2\x05\x97\x [...]
+			compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x7d\x6d\x6f\x1c\x37\xd2\xe0\x77\xff\x0a\x42\xcf\x01\x7a\xc1\x4c\x4b\xce\x22\xbb\x39\xdd\xf9\x16\x8a\xed\xec\x2a\x89\x6d\x9d\xe5\xcd\xe2\xe0\x0b\x76\x38\xdd\x35\x33\xb4\xd8\x64\x2f\xc9\x96\x3c\x39\xdc\x7f\x3f\xb0\x8a\x6f\x3d\xd3\x92\x46\x4e\x14\x44\x87\x67\xf7\x43\x2c\xa9\xbb\x58\x2c\x16\xeb\xbd\xaa\x9d\xe1\xc2\xd9\xd3\x67\x53\xa6\x78\x0b\xa7\x8c\x2f\x16\x42\x09\xb7\x7e\xc6\x58\x27\xb9\x5b\x68\xd3\x9e\xb2\x05\x97\x [...]
 		},
 	}
 	fs["/"].(*vfsgen۰DirInfo).entries = []os.FileInfo{
diff --git a/script/Makefile b/script/Makefile
index b19990f..fcfc9b5 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -168,8 +168,8 @@ test-local: build
 	#go test -timeout 60m -v ./e2e/local -tags=integration
 
 test-resources: build
-	STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" go test -timeout 60m -v ./e2e/resources -tags=integration
-	#go test -timeout 60m -v ./e2e/resources -tags=integration
+	STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" go test -timeout 60m -v ./e2e/config -tags=integration
+	#go test -timeout 60m -v ./e2e/config -tags=integration
 
 test-kamel-cli: build
 	STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" go test -timeout 60m -v ./e2e/common/cli -tags=integration

[camel-k] 03/05: feat(e2e): property test

Posted by as...@apache.org.
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 e0b9be15debb16836db4a8c3a4d92ceedbae8c8d
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Fri May 14 14:33:46 2021 +0200

    feat(e2e): property test
    
    Ref #2003
---
 e2e/config/files/my.properties              |  2 ++
 e2e/config/files/property-file-route.groovy | 27 ++++++++++++++
 e2e/config/files/property-route.groovy      | 27 ++++++++++++++
 e2e/config/properties_test.go               | 55 +++++++++++++++++++++++++++++
 4 files changed, 111 insertions(+)

diff --git a/e2e/config/files/my.properties b/e2e/config/files/my.properties
new file mode 100644
index 0000000..3ab9036
--- /dev/null
+++ b/e2e/config/files/my.properties
@@ -0,0 +1,2 @@
+my.key.1=hello
+my.key.2=world
\ No newline at end of file
diff --git a/e2e/config/files/property-file-route.groovy b/e2e/config/files/property-file-route.groovy
new file mode 100644
index 0000000..13a09fc
--- /dev/null
+++ b/e2e/config/files/property-file-route.groovy
@@ -0,0 +1,27 @@
+// 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.
+ */
+
+//
+// To run this integrations use:
+//
+// kamel run --property-file my.properties property-file-route.groovy --dev
+//
+
+from('timer:property-file')
+    .routeId('property-file')
+    .log('property file content is: {{my.key.1}} {{my.key.2}}')
diff --git a/e2e/config/files/property-route.groovy b/e2e/config/files/property-route.groovy
new file mode 100644
index 0000000..705eca6
--- /dev/null
+++ b/e2e/config/files/property-route.groovy
@@ -0,0 +1,27 @@
+// 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.
+ */
+
+//
+// To run this integrations use:
+//
+// kamel run -p my.message=test-property property-route.groovy --dev
+//
+
+from('timer:property')
+    .routeId('property')
+    .log('property content is: {{my.message}}')
diff --git a/e2e/config/properties_test.go b/e2e/config/properties_test.go
new file mode 100644
index 0000000..479bb6a
--- /dev/null
+++ b/e2e/config/properties_test.go
@@ -0,0 +1,55 @@
+// +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 resources
+
+import (
+	"testing"
+
+	. "github.com/onsi/gomega"
+
+	v1 "k8s.io/api/core/v1"
+
+	. "github.com/apache/camel-k/e2e/support"
+	camelv1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+)
+
+func TestRunPropertyExamples(t *testing.T) {
+	WithNewTestNamespace(t, func(ns string) {
+		Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
+
+		t.Run("Simple property", func(t *testing.T) {
+			Expect(Kamel("run", "-n", ns, "./files/property-route.groovy", "-p", "my.message=test-property").Execute()).To(Succeed())
+			Eventually(IntegrationPodPhase(ns, "property-route"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
+			Eventually(IntegrationCondition(ns, "property-route", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
+			Eventually(IntegrationLogs(ns, "property-route"), TestTimeoutShort).Should(ContainSubstring("test-property"))
+			Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+		})
+
+		t.Run("Property file", func(t *testing.T) {
+			Expect(Kamel("run", "-n", ns, "./files/property-file-route.groovy", "--property-file", "./files/my.properties").Execute()).To(Succeed())
+			Eventually(IntegrationPodPhase(ns, "property-file-route"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
+			Eventually(IntegrationCondition(ns, "property-file-route", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
+			Eventually(IntegrationLogs(ns, "property-file-route"), TestTimeoutShort).Should(ContainSubstring("hello world"))
+			Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+		})
+	})
+}

[camel-k] 01/05: chore(example): complete set of user config

Posted by as...@apache.org.
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 c51e39081d18d51bdffec7d19dbcc6b5e9541022
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Fri May 14 10:51:46 2021 +0200

    chore(example): complete set of user config
    
    Ref #2003
---
 examples/README.md                                 |   3 ++-
 examples/basic/README.md                           |   3 ---
 examples/basic/props.js                            |  25 ---------------------
 examples/cron/README.md                            |   3 +++
 examples/{basic => cron}/cron.groovy               |   0
 examples/kafka/README.md                           |   6 +++++
 examples/user-config/README.md                     |   3 +++
 .../configmap-route.groovy}                        |  11 ++++-----
 examples/user-config/my.properties                 |   2 ++
 .../property-file-route.groovy}                    |  10 ++++-----
 .../property-route.groovy}                         |  13 +++++++----
 .../resources-base64-encoded-route.groovy}         |   9 ++++----
 .../resources-binary-route.groovy}                 |  12 +++++-----
 examples/{basic => user-config}/resources-data.txt |   0
 examples/user-config/resources-data.zip            | Bin 0 -> 199 bytes
 .../{basic => user-config}/resources-route.groovy  |   5 ++---
 .../secret-route.groovy}                           |  11 ++++-----
 17 files changed, 52 insertions(+), 64 deletions(-)

diff --git a/examples/README.md b/examples/README.md
index 239916c..a7db709 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -9,7 +9,8 @@ In this section you will find the most basic examples. Useful to start learning
 | Type  |  Description | Link  |
 |---|---|---|
 | Languages | Simple integrations developed in various supported languages | [see examples](./languages/)|
-| Basic | Basic features such as `cron`, `properties` or `resource`s | [see examples](./basic/)|
+| Cron | How to create a `cront` integration | [see examples](./cron/)|
+| User Config | Explore how to include a `property`, `secret`, `configmap` or file `resource` in your integration | [see examples](./user-config/)|
 | Processor | Show how to include `Processor`s logic | [see examples](./processor/)|
 | Open API | `Open API` support | [see examples](./openapi/)|
 | Rest | Produce/Consume `REST`ful services | [see examples](./rest/)|
diff --git a/examples/basic/README.md b/examples/basic/README.md
deleted file mode 100644
index 721f701..0000000
--- a/examples/basic/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Basic Camel K examples
-
-Find useful examples about how to use certain basic features of Camel K.
\ No newline at end of file
diff --git a/examples/basic/props.js b/examples/basic/props.js
deleted file mode 100644
index 6670b79..0000000
--- a/examples/basic/props.js
+++ /dev/null
@@ -1,25 +0,0 @@
-// camel-k: language=js
-// 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.
-
-//
-// To run this integrations use:
-//
-//     kamel run -p my.message=test-props examples/props.js
-//
-
-from('timer:props?period=1000')
-    .routeId('props')
-    .log('{{my.message}}')
diff --git a/examples/cron/README.md b/examples/cron/README.md
new file mode 100644
index 0000000..ff46201
--- /dev/null
+++ b/examples/cron/README.md
@@ -0,0 +1,3 @@
+# Camel K cron examples
+
+Find useful examples about how to create a cron route in Camel K.
\ No newline at end of file
diff --git a/examples/basic/cron.groovy b/examples/cron/cron.groovy
similarity index 100%
copy from examples/basic/cron.groovy
copy to examples/cron/cron.groovy
diff --git a/examples/kafka/README.md b/examples/kafka/README.md
index d92fbca..77b2435 100644
--- a/examples/kafka/README.md
+++ b/examples/kafka/README.md
@@ -2,6 +2,12 @@
 
 This example shows how Camel K can be used to connect to a Kafka broker.
 
+## Authentication to Kafka
+
+We have a dedicated section to show [how to authenticate Camel K to Kafka](./sasl_ssl/).
+
+## Simple usage
+
 To run this example first set-up Kafka on your k8s cluster.
 A convenient way to do so is by using the Strimzi project, if you are using minikube follow these instructions at https://strimzi.io/quickstarts/minikube/
 
diff --git a/examples/user-config/README.md b/examples/user-config/README.md
new file mode 100644
index 0000000..4af0fd8
--- /dev/null
+++ b/examples/user-config/README.md
@@ -0,0 +1,3 @@
+# Camel K user configuration examples
+
+Find useful examples about how to include a configuration property or a configuration file in Camel K.
\ No newline at end of file
diff --git a/examples/basic/resources-route.groovy b/examples/user-config/configmap-route.groovy
similarity index 75%
copy from examples/basic/resources-route.groovy
copy to examples/user-config/configmap-route.groovy
index 6f8be44..5a61c56 100644
--- a/examples/basic/resources-route.groovy
+++ b/examples/user-config/configmap-route.groovy
@@ -19,11 +19,12 @@
 //
 // To run this integrations use:
 //
-//     kamel run --resource examples/resources-data.txt examples/resources-route.groovy
+// kubectl create configmap my-cm --from-literal=my-configmap-key="configmap content"
+// kamel run --configmap my-cm configmap-route.groovy --dev
 //
 
-from('timer:resources')
-    .routeId('resources')
+from('timer:configmap')
+    .routeId('configmap')
     .setBody()
-        .simple("resource:classpath:resources-data.txt")
-    .log('file content is: ${body}')
+        .simple("resource:classpath:my-configmap-key")
+    .log('configmap content is: ${body}')
diff --git a/examples/user-config/my.properties b/examples/user-config/my.properties
new file mode 100644
index 0000000..3ab9036
--- /dev/null
+++ b/examples/user-config/my.properties
@@ -0,0 +1,2 @@
+my.key.1=hello
+my.key.2=world
\ No newline at end of file
diff --git a/examples/basic/resources-route.groovy b/examples/user-config/property-file-route.groovy
similarity index 77%
copy from examples/basic/resources-route.groovy
copy to examples/user-config/property-file-route.groovy
index 6f8be44..13a09fc 100644
--- a/examples/basic/resources-route.groovy
+++ b/examples/user-config/property-file-route.groovy
@@ -19,11 +19,9 @@
 //
 // To run this integrations use:
 //
-//     kamel run --resource examples/resources-data.txt examples/resources-route.groovy
+// kamel run --property-file my.properties property-file-route.groovy --dev
 //
 
-from('timer:resources')
-    .routeId('resources')
-    .setBody()
-        .simple("resource:classpath:resources-data.txt")
-    .log('file content is: ${body}')
+from('timer:property-file')
+    .routeId('property-file')
+    .log('property file content is: {{my.key.1}} {{my.key.2}}')
diff --git a/examples/basic/cron.groovy b/examples/user-config/property-route.groovy
similarity index 80%
rename from examples/basic/cron.groovy
rename to examples/user-config/property-route.groovy
index 717683f..705eca6 100644
--- a/examples/basic/cron.groovy
+++ b/examples/user-config/property-route.groovy
@@ -16,7 +16,12 @@
  * limitations under the License.
  */
 
-from('cron:tab?schedule=*+*+*+*+?') // once every minute
-    .setBody()
-        .simple('Hello Camel K using CronJob')
-    .to('log:info?showAll=false')
+//
+// To run this integrations use:
+//
+// kamel run -p my.message=test-property property-route.groovy --dev
+//
+
+from('timer:property')
+    .routeId('property')
+    .log('property content is: {{my.message}}')
diff --git a/examples/basic/resources-route.groovy b/examples/user-config/resources-base64-encoded-route.groovy
similarity index 80%
copy from examples/basic/resources-route.groovy
copy to examples/user-config/resources-base64-encoded-route.groovy
index 6f8be44..02559f0 100644
--- a/examples/basic/resources-route.groovy
+++ b/examples/user-config/resources-base64-encoded-route.groovy
@@ -18,12 +18,11 @@
 
 //
 // To run this integrations use:
-//
-//     kamel run --resource examples/resources-data.txt examples/resources-route.groovy
+// kamel run --resource resources-data.txt --compression=true resources-base64-encoded-route.groovy --dev
 //
 
-from('timer:resources')
-    .routeId('resources')
+from('timer:resources-bas64')
+    .routeId('resources-base64')
     .setBody()
         .simple("resource:classpath:resources-data.txt")
-    .log('file content is: ${body}')
+    .log('resource file base64 content is: ${body}')
diff --git a/examples/basic/resources-route.groovy b/examples/user-config/resources-binary-route.groovy
similarity index 74%
copy from examples/basic/resources-route.groovy
copy to examples/user-config/resources-binary-route.groovy
index 6f8be44..8b0878b 100644
--- a/examples/basic/resources-route.groovy
+++ b/examples/user-config/resources-binary-route.groovy
@@ -18,12 +18,10 @@
 
 //
 // To run this integrations use:
-//
-//     kamel run --resource examples/resources-data.txt examples/resources-route.groovy
+// kamel run --resource resources-data.zip resources-binary-route.groovy -d camel-zipfile --dev
 //
 
-from('timer:resources')
-    .routeId('resources')
-    .setBody()
-        .simple("resource:classpath:resources-data.txt")
-    .log('file content is: ${body}')
+from('file:/etc/camel/resources/?fileName=resources-data.zip&noop=true&idempotent=false')
+    .routeId('resources-zip')
+    .unmarshal().zipFile()
+    .log('resource file unzipped content is: ${body}')
diff --git a/examples/basic/resources-data.txt b/examples/user-config/resources-data.txt
similarity index 100%
rename from examples/basic/resources-data.txt
rename to examples/user-config/resources-data.txt
diff --git a/examples/user-config/resources-data.zip b/examples/user-config/resources-data.zip
new file mode 100644
index 0000000..667d0b0
Binary files /dev/null and b/examples/user-config/resources-data.zip differ
diff --git a/examples/basic/resources-route.groovy b/examples/user-config/resources-route.groovy
similarity index 88%
copy from examples/basic/resources-route.groovy
copy to examples/user-config/resources-route.groovy
index 6f8be44..6f57285 100644
--- a/examples/basic/resources-route.groovy
+++ b/examples/user-config/resources-route.groovy
@@ -18,12 +18,11 @@
 
 //
 // To run this integrations use:
-//
-//     kamel run --resource examples/resources-data.txt examples/resources-route.groovy
+// kamel run --resource resources-data.txt resources-route.groovy --dev
 //
 
 from('timer:resources')
     .routeId('resources')
     .setBody()
         .simple("resource:classpath:resources-data.txt")
-    .log('file content is: ${body}')
+    .log('resource file content is: ${body}')
diff --git a/examples/basic/resources-route.groovy b/examples/user-config/secret-route.groovy
similarity index 76%
rename from examples/basic/resources-route.groovy
rename to examples/user-config/secret-route.groovy
index 6f8be44..49966ae 100644
--- a/examples/basic/resources-route.groovy
+++ b/examples/user-config/secret-route.groovy
@@ -19,11 +19,12 @@
 //
 // To run this integrations use:
 //
-//     kamel run --resource examples/resources-data.txt examples/resources-route.groovy
+// kubectl create secret generic my-sec --from-literal=my-secret-key="very top secret"
+// kamel run --secret my-sec secret-route.groovy --dev
 //
 
-from('timer:resources')
-    .routeId('resources')
+from('timer:secret')
+    .routeId('secret')
     .setBody()
-        .simple("resource:classpath:resources-data.txt")
-    .log('file content is: ${body}')
+        .simple("resource:classpath:my-secret-key")
+    .log('secret content is: ${body}')

[camel-k] 05/05: chore(e2e): complete config integration test

Posted by as...@apache.org.
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 01e9c19954c9f085e8723d13a76d556c5124d19e
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Fri May 14 15:54:42 2021 +0200

    chore(e2e): complete config integration test
    
    * Added configmap and secret integration tests
    * Refactored to be included and run under /common dir
    
    Ref #2003
---
 .../config/config_test.go}                         |  56 +++++++++++++++++++--
 .../config/files/configmap-route.groovy}           |  12 +++--
 e2e/{ => common}/config/files/my.properties        |   0
 .../config/files/property-file-route.groovy        |   0
 .../config/files/property-route.groovy             |   0
 .../files/resources-base64-encoded-route.groovy    |   0
 .../config/files/resources-binary-route.groovy     |   0
 e2e/{ => common}/config/files/resources-data.txt   |   0
 e2e/{ => common}/config/files/resources-data.zip   | Bin
 .../config/files/resources-route.groovy            |   0
 .../config/files/secret-route.groovy}              |  12 +++--
 e2e/config/properties_test.go                      |  55 --------------------
 script/Makefile                                    |   5 +-
 13 files changed, 68 insertions(+), 72 deletions(-)

diff --git a/e2e/config/resources_test.go b/e2e/common/config/config_test.go
similarity index 55%
rename from e2e/config/resources_test.go
rename to e2e/common/config/config_test.go
index 404b7a2..03a0add 100644
--- a/e2e/config/resources_test.go
+++ b/e2e/common/config/config_test.go
@@ -22,6 +22,7 @@ limitations under the License.
 package resources
 
 import (
+	"io/ioutil"
 	"testing"
 
 	. "github.com/onsi/gomega"
@@ -29,17 +30,65 @@ import (
 
 	v1 "k8s.io/api/core/v1"
 
-	"io/ioutil"
-
 	. "github.com/apache/camel-k/e2e/support"
 	camelv1 "github.com/apache/camel-k/pkg/apis/camel/v1"
 	"github.com/apache/camel-k/pkg/util/gzip"
 )
 
-func TestRunResourceExamples(t *testing.T) {
+func TestRunConfigExamples(t *testing.T) {
 	WithNewTestNamespace(t, func(ns string) {
 		Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
 
+		// Properties
+
+		t.Run("Simple property", func(t *testing.T) {
+			Expect(Kamel("run", "-n", ns, "./files/property-route.groovy", "-p", "my.message=test-property").Execute()).To(Succeed())
+			Eventually(IntegrationPodPhase(ns, "property-route"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
+			Eventually(IntegrationCondition(ns, "property-route", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
+			Eventually(IntegrationLogs(ns, "property-route"), TestTimeoutShort).Should(ContainSubstring("test-property"))
+			Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+		})
+
+		t.Run("Property file", func(t *testing.T) {
+			Expect(Kamel("run", "-n", ns, "./files/property-file-route.groovy", "--property-file", "./files/my.properties").Execute()).To(Succeed())
+			Eventually(IntegrationPodPhase(ns, "property-file-route"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
+			Eventually(IntegrationCondition(ns, "property-file-route", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
+			Eventually(IntegrationLogs(ns, "property-file-route"), TestTimeoutShort).Should(ContainSubstring("hello world"))
+			Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+		})
+
+		// Configmap
+
+		t.Run("Textplain configmap", func(t *testing.T) {
+			// Store a configmap on the cluster
+			var cmData = make(map[string]string)
+			cmData["my-configmap-key"] = "my-configmap-content"
+			NewPlainTextConfigmap(ns, "my-cm", cmData)
+
+			Expect(Kamel("run", "-n", ns, "./files/configmap-route.groovy", "--configmap", "my-cm").Execute()).To(Succeed())
+			Eventually(IntegrationPodPhase(ns, "configmap-route"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
+			Eventually(IntegrationCondition(ns, "configmap-route", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
+			Eventually(IntegrationLogs(ns, "configmap-route"), TestTimeoutShort).Should(ContainSubstring(cmData["my-configmap-key"]))
+			Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+		})
+
+		// Secret
+
+		t.Run("Textplain secret", func(t *testing.T) {
+			// Store a secret on the cluster
+			var secData = make(map[string]string)
+			secData["my-secret-key"] = "very top secret"
+			NewPlainTextSecret(ns, "my-sec", secData)
+
+			Expect(Kamel("run", "-n", ns, "./files/secret-route.groovy", "--secret", "my-sec").Execute()).To(Succeed())
+			Eventually(IntegrationPodPhase(ns, "secret-route"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
+			Eventually(IntegrationCondition(ns, "secret-route", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
+			Eventually(IntegrationLogs(ns, "secret-route"), TestTimeoutShort).Should(ContainSubstring(secData["my-secret-key"]))
+			Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+		})
+
+		// Resources
+
 		t.Run("Plain text resource file", func(t *testing.T) {
 			Expect(Kamel("run", "-n", ns, "./files/resources-route.groovy", "--resource", "./files/resources-data.txt").Execute()).To(Succeed())
 			Eventually(IntegrationPodPhase(ns, "resources-route"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
@@ -69,5 +118,6 @@ func TestRunResourceExamples(t *testing.T) {
 			Eventually(IntegrationLogs(ns, "resources-base64-encoded-route"), TestTimeoutShort).Should(ContainSubstring(string(expectedBytes)))
 			Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
 		})
+
 	})
 }
diff --git a/e2e/config/files/resources-route.groovy b/e2e/common/config/files/configmap-route.groovy
similarity index 74%
copy from e2e/config/files/resources-route.groovy
copy to e2e/common/config/files/configmap-route.groovy
index 6f57285..5a61c56 100644
--- a/e2e/config/files/resources-route.groovy
+++ b/e2e/common/config/files/configmap-route.groovy
@@ -18,11 +18,13 @@
 
 //
 // To run this integrations use:
-// kamel run --resource resources-data.txt resources-route.groovy --dev
+//
+// kubectl create configmap my-cm --from-literal=my-configmap-key="configmap content"
+// kamel run --configmap my-cm configmap-route.groovy --dev
 //
 
-from('timer:resources')
-    .routeId('resources')
+from('timer:configmap')
+    .routeId('configmap')
     .setBody()
-        .simple("resource:classpath:resources-data.txt")
-    .log('resource file content is: ${body}')
+        .simple("resource:classpath:my-configmap-key")
+    .log('configmap content is: ${body}')
diff --git a/e2e/config/files/my.properties b/e2e/common/config/files/my.properties
similarity index 100%
rename from e2e/config/files/my.properties
rename to e2e/common/config/files/my.properties
diff --git a/e2e/config/files/property-file-route.groovy b/e2e/common/config/files/property-file-route.groovy
similarity index 100%
rename from e2e/config/files/property-file-route.groovy
rename to e2e/common/config/files/property-file-route.groovy
diff --git a/e2e/config/files/property-route.groovy b/e2e/common/config/files/property-route.groovy
similarity index 100%
rename from e2e/config/files/property-route.groovy
rename to e2e/common/config/files/property-route.groovy
diff --git a/e2e/config/files/resources-base64-encoded-route.groovy b/e2e/common/config/files/resources-base64-encoded-route.groovy
similarity index 100%
rename from e2e/config/files/resources-base64-encoded-route.groovy
rename to e2e/common/config/files/resources-base64-encoded-route.groovy
diff --git a/e2e/config/files/resources-binary-route.groovy b/e2e/common/config/files/resources-binary-route.groovy
similarity index 100%
rename from e2e/config/files/resources-binary-route.groovy
rename to e2e/common/config/files/resources-binary-route.groovy
diff --git a/e2e/config/files/resources-data.txt b/e2e/common/config/files/resources-data.txt
similarity index 100%
rename from e2e/config/files/resources-data.txt
rename to e2e/common/config/files/resources-data.txt
diff --git a/e2e/config/files/resources-data.zip b/e2e/common/config/files/resources-data.zip
similarity index 100%
rename from e2e/config/files/resources-data.zip
rename to e2e/common/config/files/resources-data.zip
diff --git a/e2e/config/files/resources-route.groovy b/e2e/common/config/files/resources-route.groovy
similarity index 100%
copy from e2e/config/files/resources-route.groovy
copy to e2e/common/config/files/resources-route.groovy
diff --git a/e2e/config/files/resources-route.groovy b/e2e/common/config/files/secret-route.groovy
similarity index 76%
rename from e2e/config/files/resources-route.groovy
rename to e2e/common/config/files/secret-route.groovy
index 6f57285..49966ae 100644
--- a/e2e/config/files/resources-route.groovy
+++ b/e2e/common/config/files/secret-route.groovy
@@ -18,11 +18,13 @@
 
 //
 // To run this integrations use:
-// kamel run --resource resources-data.txt resources-route.groovy --dev
+//
+// kubectl create secret generic my-sec --from-literal=my-secret-key="very top secret"
+// kamel run --secret my-sec secret-route.groovy --dev
 //
 
-from('timer:resources')
-    .routeId('resources')
+from('timer:secret')
+    .routeId('secret')
     .setBody()
-        .simple("resource:classpath:resources-data.txt")
-    .log('resource file content is: ${body}')
+        .simple("resource:classpath:my-secret-key")
+    .log('secret content is: ${body}')
diff --git a/e2e/config/properties_test.go b/e2e/config/properties_test.go
deleted file mode 100644
index 479bb6a..0000000
--- a/e2e/config/properties_test.go
+++ /dev/null
@@ -1,55 +0,0 @@
-// +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 resources
-
-import (
-	"testing"
-
-	. "github.com/onsi/gomega"
-
-	v1 "k8s.io/api/core/v1"
-
-	. "github.com/apache/camel-k/e2e/support"
-	camelv1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-)
-
-func TestRunPropertyExamples(t *testing.T) {
-	WithNewTestNamespace(t, func(ns string) {
-		Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
-
-		t.Run("Simple property", func(t *testing.T) {
-			Expect(Kamel("run", "-n", ns, "./files/property-route.groovy", "-p", "my.message=test-property").Execute()).To(Succeed())
-			Eventually(IntegrationPodPhase(ns, "property-route"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
-			Eventually(IntegrationCondition(ns, "property-route", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
-			Eventually(IntegrationLogs(ns, "property-route"), TestTimeoutShort).Should(ContainSubstring("test-property"))
-			Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
-		})
-
-		t.Run("Property file", func(t *testing.T) {
-			Expect(Kamel("run", "-n", ns, "./files/property-file-route.groovy", "--property-file", "./files/my.properties").Execute()).To(Succeed())
-			Eventually(IntegrationPodPhase(ns, "property-file-route"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
-			Eventually(IntegrationCondition(ns, "property-file-route", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
-			Eventually(IntegrationLogs(ns, "property-file-route"), TestTimeoutShort).Should(ContainSubstring("hello world"))
-			Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
-		})
-	})
-}
diff --git a/script/Makefile b/script/Makefile
index fcfc9b5..a776066 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -152,6 +152,7 @@ test-integration: build
 	go test -timeout 60m -v ./e2e/common -tags=integration && \
 	go test -timeout 60m -v ./e2e/common/build -tags=integration && \
 	go test -timeout 60m -v ./e2e/common/cli -tags=integration && \
+	go test -timeout 60m -v ./e2e/common/config -tags=integration && \
 	go test -timeout 60m -v ./e2e/common/languages -tags=integration && \
 	go test -timeout 60m -v ./e2e/common/traits -tags=integration
 
@@ -167,10 +168,6 @@ test-local: build
 	STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" go test -timeout 60m -v ./e2e/local -tags=integration
 	#go test -timeout 60m -v ./e2e/local -tags=integration
 
-test-resources: build
-	STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" go test -timeout 60m -v ./e2e/config -tags=integration
-	#go test -timeout 60m -v ./e2e/config -tags=integration
-
 test-kamel-cli: build
 	STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" go test -timeout 60m -v ./e2e/common/cli -tags=integration
 	#go test -timeout 60m -v ./e2e/common/cli -tags=integration

[camel-k] 04/05: chore(e2e): support configmap and secret creation

Posted by as...@apache.org.
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 4759a4bf490de6a3229c01e8816fc002efb46d7e
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Fri May 14 15:40:54 2021 +0200

    chore(e2e): support configmap and secret creation
---
 e2e/support/test_support.go | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index ad57ef6..01732cf 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -661,6 +661,36 @@ func Configmap(ns string, name string) func() *corev1.ConfigMap {
 	}
 }
 
+func NewPlainTextConfigmap(ns string, name string, data map[string]string) error {
+	cm := corev1.ConfigMap{
+		TypeMeta: metav1.TypeMeta{
+			Kind:       "ConfigMap",
+			APIVersion: corev1.SchemeGroupVersion.String(),
+		},
+		ObjectMeta: metav1.ObjectMeta{
+			Namespace: ns,
+			Name:      name,
+		},
+		Data: data,
+	}
+	return TestClient().Create(TestContext, &cm)
+}
+
+func NewPlainTextSecret(ns string, name string, data map[string]string) error {
+	sec := corev1.Secret{
+		TypeMeta: metav1.TypeMeta{
+			Kind:       "Secret",
+			APIVersion: corev1.SchemeGroupVersion.String(),
+		},
+		ObjectMeta: metav1.ObjectMeta{
+			Namespace: ns,
+			Name:      name,
+		},
+		StringData: data,
+	}
+	return TestClient().Create(TestContext, &sec)
+}
+
 func KnativeService(ns string, name string) func() *servingv1.Service {
 	return func() *servingv1.Service {
 		answer := servingv1.Service{