You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2020/05/05 11:47:34 UTC
[camel-k] 02/06: Fix #1171: add e2e tests for checking ready
condition
This is an automated email from the ASF dual-hosted git repository.
nferraro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 4fdbb3ff6e6a05e1a26c1a4891bd151b314bb00b
Author: Nicola Ferraro <ni...@gmail.com>
AuthorDate: Thu Apr 30 11:53:04 2020 +0200
Fix #1171: add e2e tests for checking ready condition
---
e2e/common/cron_test.go | 2 ++
e2e/common/run_test.go | 15 ++++++++++-----
e2e/knative/knative_test.go | 4 ++++
e2e/support/test_support.go | 14 ++++++++++++++
4 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/e2e/common/cron_test.go b/e2e/common/cron_test.go
index ed961a6..fdd22ff 100644
--- a/e2e/common/cron_test.go
+++ b/e2e/common/cron_test.go
@@ -25,6 +25,7 @@ import (
"testing"
. "github.com/apache/camel-k/e2e/support"
+ camelv1 "github.com/apache/camel-k/pkg/apis/camel/v1"
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
)
@@ -38,6 +39,7 @@ func TestRunCronExample(t *testing.T) {
Expect(Kamel("run", "-n", ns, "files/cron.groovy").Execute()).Should(BeNil())
Eventually(IntegrationCronJob(ns, "cron"), TestTimeoutMedium).ShouldNot(BeNil())
+ Eventually(IntegrationConditionHolds(ns, "cron", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(BeTrue())
Eventually(IntegrationLogs(ns, "cron"), TestTimeoutMedium).Should(ContainSubstring("Magicstring!"))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
})
diff --git a/e2e/common/run_test.go b/e2e/common/run_test.go
index 96fd9a3..fed637b 100644
--- a/e2e/common/run_test.go
+++ b/e2e/common/run_test.go
@@ -22,19 +22,15 @@ limitations under the License.
package common
import (
- "os"
"testing"
. "github.com/apache/camel-k/e2e/support"
+ camelv1 "github.com/apache/camel-k/pkg/apis/camel/v1"
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
)
func TestRunSimpleExamples(t *testing.T) {
- if os.Getenv("KAMEL_INSTALL_BUILD_PUBLISH_STRATEGY") == "Buildah" {
- t.Skip("Apparently this test require too much CI resources to be run with Buildah, let's save some...")
- return
- }
WithNewTestNamespace(t, func(ns string) {
Expect(Kamel("install", "-n", ns).Execute()).Should(BeNil())
@@ -43,6 +39,7 @@ func TestRunSimpleExamples(t *testing.T) {
RegisterTestingT(t)
Expect(Kamel("run", "-n", ns, "files/Java.java").Execute()).Should(BeNil())
Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
+ Eventually(IntegrationConditionHolds(ns, "java", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(BeTrue())
Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
})
@@ -51,6 +48,7 @@ func TestRunSimpleExamples(t *testing.T) {
RegisterTestingT(t)
Expect(Kamel("run", "-n", ns, "files/Prop.java", "--property-file", "files/prop.properties").Execute()).Should(BeNil())
Eventually(IntegrationPodPhase(ns, "prop"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
+ Eventually(IntegrationConditionHolds(ns, "prop", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(BeTrue())
Eventually(IntegrationLogs(ns, "prop"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
})
@@ -59,6 +57,7 @@ func TestRunSimpleExamples(t *testing.T) {
RegisterTestingT(t)
Expect(Kamel("run", "-n", ns, "files/xml.xml").Execute()).Should(BeNil())
Eventually(IntegrationPodPhase(ns, "xml"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
+ Eventually(IntegrationConditionHolds(ns, "xml", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(BeTrue())
Eventually(IntegrationLogs(ns, "xml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
})
@@ -67,6 +66,7 @@ func TestRunSimpleExamples(t *testing.T) {
RegisterTestingT(t)
Expect(Kamel("run", "-n", ns, "files/groovy.groovy").Execute()).Should(BeNil())
Eventually(IntegrationPodPhase(ns, "groovy"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
+ Eventually(IntegrationConditionHolds(ns, "groovy", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(BeTrue())
Eventually(IntegrationLogs(ns, "groovy"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
})
@@ -75,6 +75,7 @@ func TestRunSimpleExamples(t *testing.T) {
RegisterTestingT(t)
Expect(Kamel("run", "-n", ns, "files/js.js").Execute()).Should(BeNil())
Eventually(IntegrationPodPhase(ns, "js"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
+ Eventually(IntegrationConditionHolds(ns, "js", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(BeTrue())
Eventually(IntegrationLogs(ns, "js"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
})
@@ -83,6 +84,7 @@ func TestRunSimpleExamples(t *testing.T) {
RegisterTestingT(t)
Expect(Kamel("run", "-n", ns, "files/kotlin.kts").Execute()).Should(BeNil())
Eventually(IntegrationPodPhase(ns, "kotlin"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
+ Eventually(IntegrationConditionHolds(ns, "kotlin", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(BeTrue())
Eventually(IntegrationLogs(ns, "kotlin"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
})
@@ -91,6 +93,7 @@ func TestRunSimpleExamples(t *testing.T) {
RegisterTestingT(t)
Expect(Kamel("run", "-n", ns, "files/yaml.yaml").Execute()).Should(BeNil())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
+ Eventually(IntegrationConditionHolds(ns, "yaml", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(BeTrue())
Eventually(IntegrationLogs(ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
})
@@ -99,6 +102,7 @@ func TestRunSimpleExamples(t *testing.T) {
RegisterTestingT(t)
Expect(Kamel("run", "-n", ns, "--name", "yaml-quarkus", "files/yaml.yaml", "-t", "quarkus.enabled=true").Execute()).Should(BeNil())
Eventually(IntegrationPodPhase(ns, "yaml-quarkus"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
+ Eventually(IntegrationConditionHolds(ns, "yaml-quarkus", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(BeTrue())
Eventually(IntegrationLogs(ns, "yaml-quarkus"), TestTimeoutShort).Should(ContainSubstring("powered by Quarkus"))
Eventually(IntegrationLogs(ns, "yaml-quarkus"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
@@ -108,6 +112,7 @@ func TestRunSimpleExamples(t *testing.T) {
RegisterTestingT(t)
Expect(Kamel("run", "-n", ns, "--name", "polyglot", "files/js-polyglot.js", "files/yaml-polyglot.yaml").Execute()).Should(BeNil())
Eventually(IntegrationPodPhase(ns, "polyglot"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
+ Eventually(IntegrationConditionHolds(ns, "polyglot", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(BeTrue())
Eventually(IntegrationLogs(ns, "polyglot"), TestTimeoutShort).Should(ContainSubstring("Magicpolyglot-yaml"))
Eventually(IntegrationLogs(ns, "polyglot"), TestTimeoutShort).Should(ContainSubstring("Magicpolyglot-js"))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
diff --git a/e2e/knative/knative_test.go b/e2e/knative/knative_test.go
index 20a996d..3ac2d86 100644
--- a/e2e/knative/knative_test.go
+++ b/e2e/knative/knative_test.go
@@ -26,6 +26,7 @@ import (
"time"
. "github.com/apache/camel-k/e2e/support"
+ camelv1 "github.com/apache/camel-k/pkg/apis/camel/v1"
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
)
@@ -36,10 +37,13 @@ func TestRunServiceCombo(t *testing.T) {
Expect(Kamel("install", "-n", ns, "--trait-profile", "knative").Execute()).Should(BeNil())
Expect(Kamel("run", "-n", ns, "files/knative2.groovy").Execute()).Should(BeNil())
Eventually(IntegrationPodPhase(ns, "knative2"), TestTimeoutLong).Should(Equal(v1.PodRunning))
+ Eventually(IntegrationConditionHolds(ns, "knative2", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(BeTrue())
Expect(Kamel("run", "-n", ns, "files/knative3.groovy").Execute()).Should(BeNil())
Eventually(IntegrationPodPhase(ns, "knative3"), TestTimeoutLong).Should(Equal(v1.PodRunning))
+ Eventually(IntegrationConditionHolds(ns, "knative3", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(BeTrue())
Expect(Kamel("run", "-n", ns, "files/knative1.groovy").Execute()).Should(BeNil())
Eventually(IntegrationPodPhase(ns, "knative1"), TestTimeoutLong).Should(Equal(v1.PodRunning))
+ Eventually(IntegrationConditionHolds(ns, "knative1", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(BeTrue())
// Correct logs
Eventually(IntegrationLogs(ns, "knative1"), TestTimeoutMedium).Should(ContainSubstring("Received from 2: Hello from knative2"))
Eventually(IntegrationLogs(ns, "knative1"), TestTimeoutMedium).Should(ContainSubstring("Received from 3: Hello from knative3"))
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 3a21b74..deb788f 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -269,6 +269,20 @@ func IntegrationPod(ns string, name string) func() *corev1.Pod {
}
}
+func IntegrationConditionHolds(ns string, name string, conditionType v1.IntegrationConditionType) func() bool {
+ return func() bool {
+ it := Integration(ns, name)()
+ if it == nil {
+ return false
+ }
+ c := it.Status.GetCondition(conditionType)
+ if c == nil {
+ return false
+ }
+ return c.Status == corev1.ConditionTrue
+ }
+}
+
func ConfigMap(ns string, name string) func() *corev1.ConfigMap {
return func() *corev1.ConfigMap {
cm := corev1.ConfigMap{}