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:04 UTC
[camel-k] 03/05: feat(e2e): property test
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())
+ })
+ })
+}