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 404b7a2abe..03a0add95f 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/common/config/files/configmap-route.groovy b/e2e/common/config/files/configmap-route.groovy new file mode 100644 index 0000000000..5a61c56b0f --- /dev/null +++ b/e2e/common/config/files/configmap-route.groovy @@ -0,0 +1,30 @@ +// 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: +// +// kubectl create configmap my-cm --from-literal=my-configmap-key="configmap content" +// kamel run --configmap my-cm configmap-route.groovy --dev +// + +from('timer:configmap') + .routeId('configmap') + .setBody() + .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% rename from e2e/config/files/resources-route.groovy rename to e2e/common/config/files/resources-route.groovy diff --git a/e2e/common/config/files/secret-route.groovy b/e2e/common/config/files/secret-route.groovy new file mode 100644 index 0000000000..49966aed6b --- /dev/null +++ b/e2e/common/config/files/secret-route.groovy @@ -0,0 +1,30 @@ +// 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: +// +// 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:secret') + .routeId('secret') + .setBody() + .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 479bb6a9a9..0000000000 --- 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 fcfc9b5ed0..a7760660c6 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