You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2022/12/15 08:17:08 UTC
[camel-k] 03/03: chore(e2e): more test to cover failing KLB
This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 4189b8dd8c82cd0e1f95af73fb41aabda7459d4a
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Wed Dec 14 17:56:14 2022 +0100
chore(e2e): more test to cover failing KLB
---
e2e/global/common/kamelet_binding_test.go | 18 ++++++++++++++++++
e2e/global/common/traits/errored_trait_test.go | 10 ++++++++++
e2e/support/test_support.go | 10 ++++++++++
3 files changed, 38 insertions(+)
diff --git a/e2e/global/common/kamelet_binding_test.go b/e2e/global/common/kamelet_binding_test.go
index 97aca4411..6673b0279 100644
--- a/e2e/global/common/kamelet_binding_test.go
+++ b/e2e/global/common/kamelet_binding_test.go
@@ -31,6 +31,7 @@ import (
. "github.com/apache/camel-k/e2e/support"
"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+ "github.com/apache/camel-k/pkg/util/kubernetes"
)
func TestKameletBinding(t *testing.T) {
@@ -128,6 +129,23 @@ func TestKameletBinding(t *testing.T) {
Eventually(IntegrationLogs(ns, "kb-with-traits"), TestTimeoutShort).Should(ContainSubstring("hello from test"))
Eventually(IntegrationLogs(ns, "kb-with-traits"), TestTimeoutShort).Should(ContainSubstring("integrationLogger"))
})
+
+ // KameletBinding with wrong spec
+ t.Run("test KameletBinding with wrong spec", func(t *testing.T) {
+ RegisterTestingT(t)
+ name := "bad-klb"
+ kb := v1alpha1.NewKameletBinding(ns, name)
+ kb.Spec = v1alpha1.KameletBindingSpec{}
+ _, err := kubernetes.ReplaceResource(TestContext, TestClient(), &kb)
+ Eventually(err).Should(BeNil())
+ Eventually(KameletBindingPhase(ns, name), TestTimeoutShort).Should(Equal(v1alpha1.KameletBindingPhaseError))
+ Eventually(KameletBindingConditionStatus(ns, name, v1alpha1.KameletBindingConditionReady), TestTimeoutShort).ShouldNot(Equal(corev1.ConditionTrue))
+ Eventually(KameletBindingCondition(ns, name, v1alpha1.KameletBindingIntegrationConditionError), TestTimeoutShort).Should(
+ WithTransform(KameletBindingConditionMessage, And(
+ ContainSubstring("could not determine source URI"),
+ ContainSubstring("no ref or URI specified in endpoint"),
+ )))
+ })
})
}
diff --git a/e2e/global/common/traits/errored_trait_test.go b/e2e/global/common/traits/errored_trait_test.go
index 27a525065..a94c18e19 100644
--- a/e2e/global/common/traits/errored_trait_test.go
+++ b/e2e/global/common/traits/errored_trait_test.go
@@ -31,6 +31,7 @@ import (
. "github.com/apache/camel-k/e2e/support"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+ "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
)
func TestErroredTrait(t *testing.T) {
@@ -58,6 +59,15 @@ func TestErroredTrait(t *testing.T) {
"--name", name,
"-t", "kamelets.list=missing",
).Execute()).To(Succeed())
+ // KameletBinding
+ Eventually(KameletBindingPhase(ns, name), TestTimeoutShort).Should(Equal(v1alpha1.KameletBindingPhaseError))
+ Eventually(KameletBindingConditionStatus(ns, name, v1alpha1.KameletBindingConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
+ Eventually(KameletBindingCondition(ns, name, v1alpha1.KameletBindingConditionReady), TestTimeoutShort).Should(
+ WithTransform(KameletBindingConditionMessage, And(
+ ContainSubstring("error during trait customization"),
+ ContainSubstring("[missing] not found"),
+ )))
+ // Integration related
Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(And(
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 8470eb964..576f2b039 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -997,6 +997,16 @@ func KameletBinding(ns string, name string) func() *v1alpha1.KameletBinding {
}
}
+func KameletBindingPhase(ns string, name string) func() v1alpha1.KameletBindingPhase {
+ return func() v1alpha1.KameletBindingPhase {
+ klb := KameletBinding(ns, name)()
+ if klb == nil {
+ return ""
+ }
+ return klb.Status.Phase
+ }
+}
+
func KameletBindingSpecReplicas(ns string, name string) func() *int32 {
return func() *int32 {
klb := KameletBinding(ns, name)()