You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ts...@apache.org on 2022/09/15 23:42:34 UTC

[camel-k] 09/11: test(e2e): add E2E tests for handling of invalid components and dependencies

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

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

commit 30b15a4f729286cf67afbc98803f94ccd9f05896
Author: Tadayoshi Sato <sa...@gmail.com>
AuthorDate: Wed Sep 14 14:04:46 2022 +0900

    test(e2e): add E2E tests for handling of invalid components and dependencies
---
 e2e/global/common/integration_fail_test.go | 29 ++++++++++++++++++++++++++++-
 e2e/local/local_build_test.go              | 15 +++++++++++----
 e2e/local/local_inspect_test.go            | 16 ++++++++++++----
 e2e/local/local_run_test.go                | 15 +++++++++++----
 4 files changed, 62 insertions(+), 13 deletions(-)

diff --git a/e2e/global/common/integration_fail_test.go b/e2e/global/common/integration_fail_test.go
index cf999630c..ebfeda9f5 100644
--- a/e2e/global/common/integration_fail_test.go
+++ b/e2e/global/common/integration_fail_test.go
@@ -81,11 +81,38 @@ func TestBadRouteIntegration(t *testing.T) {
 			Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
 		})
 
+		t.Run("run invalid dependency java route", func(t *testing.T) {
+			RegisterTestingT(t)
+			name := "invalid-dependency"
+			Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name,
+				"-d", "camel:non-existent").Execute()).To(Succeed())
+			// Integration in error with Initialization Failed condition
+			Eventually(IntegrationPhase(ns, name), TestTimeoutLong).Should(Equal(v1.IntegrationPhaseError))
+			Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+				Should(Equal(corev1.ConditionFalse))
+			Eventually(IntegrationCondition(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(And(
+				WithTransform(IntegrationConditionReason, Equal(v1.IntegrationConditionInitializationFailedReason)),
+				WithTransform(IntegrationConditionMessage, HavePrefix("error during trait customization")),
+			))
+			// Kit shouldn't be created
+			Consistently(IntegrationKit(ns, name), 10*time.Second).Should(BeEmpty())
+
+			// Fixing the route should reconcile the Integration in Initialization Failed condition to Running
+			Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
+			Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+			Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+				Should(Equal(corev1.ConditionTrue))
+			Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+			// Clean up
+			Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+		})
+
 		t.Run("run unresolvable component java route", func(t *testing.T) {
 			RegisterTestingT(t)
 			name := "unresolvable-route"
 			Expect(KamelRunWithID(operatorID, ns, "files/Unresolvable.java", "--name", name).Execute()).To(Succeed())
-			// Integration in error
+			// Integration in error with Initialization Failed condition
 			Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
 			Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
 				Should(Equal(corev1.ConditionFalse))
diff --git a/e2e/local/local_build_test.go b/e2e/local/local_build_test.go
index 54d9be9a6..543f0da2c 100644
--- a/e2e/local/local_build_test.go
+++ b/e2e/local/local_build_test.go
@@ -126,11 +126,17 @@ func TestLocalBuildWithInvalidDependency(t *testing.T) {
 	file := testutil.MakeTempCopy(t, "files/yaml.yaml")
 	image := "test/test-" + strings.ToLower(util.RandomString(10))
 
-	kamelBuild := KamelWithContext(ctx, "local", "build", file, "--image", image, "-d", "camel-xxx")
+	kamelBuild := KamelWithContext(ctx, "local", "build", file, "--image", image,
+		"-d", "camel-xxx",
+		"-d", "mvn:org.apache.camel:camel-http:3.18.0",
+		"-d", "mvn:org.apache.camel.quarkus:camel-quarkus-netty:2.11.0")
 	kamelBuild.SetOut(pipew)
 	kamelBuild.SetErr(pipew)
 
-	logScanner := testutil.NewLogScanner(ctx, piper, "Warning: dependency camel:xxx not found in Camel catalog")
+	warn1 := "Warning: dependency camel:xxx not found in Camel catalog"
+	warn2 := "Warning: do not use mvn:org.apache.camel:camel-http:3.18.0. Use camel:http instead"
+	warn3 := "Warning: do not use mvn:org.apache.camel.quarkus:camel-quarkus-netty:2.11.0. Use camel:netty instead"
+	logScanner := testutil.NewLogScanner(ctx, piper, warn1, warn2, warn3)
 
 	var wg sync.WaitGroup
 	wg.Add(1)
@@ -141,8 +147,9 @@ func TestLocalBuildWithInvalidDependency(t *testing.T) {
 		cancel()
 	}()
 
-	Eventually(logScanner.IsFound("Warning: dependency camel:xxx not found in Camel catalog"), TestTimeoutShort).
-		Should(BeTrue())
+	Eventually(logScanner.IsFound(warn1), TestTimeoutShort).Should(BeTrue())
+	Eventually(logScanner.IsFound(warn2), TestTimeoutShort).Should(BeTrue())
+	Eventually(logScanner.IsFound(warn3), TestTimeoutShort).Should(BeTrue())
 	wg.Wait()
 }
 
diff --git a/e2e/local/local_inspect_test.go b/e2e/local/local_inspect_test.go
index 92dbec905..20aad1f9b 100644
--- a/e2e/local/local_inspect_test.go
+++ b/e2e/local/local_inspect_test.go
@@ -76,12 +76,19 @@ func TestLocalInspectWithDependencies(t *testing.T) {
 
 	file := testutil.MakeTempCopy(t, "files/yaml.yaml")
 
-	kamelInspect := KamelWithContext(ctx, "local", "inspect", file, "-d", "camel-amqp", "-d", "camel-xxx")
+	kamelInspect := KamelWithContext(ctx, "local", "inspect", file,
+		"-d", "camel-amqp",
+		"-d", "camel-xxx",
+		"-d", "mvn:org.apache.camel:camel-http:3.18.0",
+		"-d", "mvn:org.apache.camel.quarkus:camel-quarkus-netty:2.11.0")
 	kamelInspect.SetOut(pipew)
 	kamelInspect.SetErr(pipew)
 
+	warn1 := "Warning: dependency camel:xxx not found in Camel catalog"
+	warn2 := "Warning: do not use mvn:org.apache.camel:camel-http:3.18.0. Use camel:http instead"
+	warn3 := "Warning: do not use mvn:org.apache.camel.quarkus:camel-quarkus-netty:2.11.0. Use camel:netty instead"
 	logScanner := testutil.NewLogScanner(ctx, piper,
-		"Warning: dependency camel:xxx not found in Camel catalog",
+		warn1, warn2, warn3,
 		"camel:amqp",
 		"camel:log",
 		"camel:timer",
@@ -93,8 +100,9 @@ func TestLocalInspectWithDependencies(t *testing.T) {
 		cancel()
 	}()
 
-	Eventually(logScanner.IsFound("Warning: dependency camel:xxx not found in Camel catalog"), TestTimeoutShort).
-		Should(BeTrue())
+	Eventually(logScanner.IsFound(warn1), TestTimeoutShort).Should(BeTrue())
+	Eventually(logScanner.IsFound(warn2), TestTimeoutShort).Should(BeTrue())
+	Eventually(logScanner.IsFound(warn3), TestTimeoutShort).Should(BeTrue())
 	Eventually(logScanner.IsFound("camel:amqp"), TestTimeoutShort).Should(BeTrue())
 	Eventually(logScanner.IsFound("camel:log"), TestTimeoutShort).Should(BeTrue())
 	Eventually(logScanner.IsFound("camel:timer"), TestTimeoutShort).Should(BeTrue())
diff --git a/e2e/local/local_run_test.go b/e2e/local/local_run_test.go
index 3c3dbd49e..9ac6f864b 100644
--- a/e2e/local/local_run_test.go
+++ b/e2e/local/local_run_test.go
@@ -96,11 +96,17 @@ func TestLocalRunWithInvalidDependency(t *testing.T) {
 
 	file := testutil.MakeTempCopy(t, "files/yaml.yaml")
 
-	kamelRun := KamelWithContext(ctx, "local", "run", file, "-d", "camel-xxx")
+	kamelRun := KamelWithContext(ctx, "local", "run", file,
+		"-d", "camel-xxx",
+		"-d", "mvn:org.apache.camel:camel-http:3.18.0",
+		"-d", "mvn:org.apache.camel.quarkus:camel-quarkus-netty:2.11.0")
 	kamelRun.SetOut(pipew)
 	kamelRun.SetErr(pipew)
 
-	logScanner := testutil.NewLogScanner(ctx, piper, "Warning: dependency camel:xxx not found in Camel catalog")
+	warn1 := "Warning: dependency camel:xxx not found in Camel catalog"
+	warn2 := "Warning: do not use mvn:org.apache.camel:camel-http:3.18.0. Use camel:http instead"
+	warn3 := "Warning: do not use mvn:org.apache.camel.quarkus:camel-quarkus-netty:2.11.0. Use camel:netty instead"
+	logScanner := testutil.NewLogScanner(ctx, piper, warn1, warn2, warn3)
 
 	var wg sync.WaitGroup
 	wg.Add(1)
@@ -111,8 +117,9 @@ func TestLocalRunWithInvalidDependency(t *testing.T) {
 		cancel()
 	}()
 
-	Eventually(logScanner.IsFound("Warning: dependency camel:xxx not found in Camel catalog"), TestTimeoutShort).
-		Should(BeTrue())
+	Eventually(logScanner.IsFound(warn1), TestTimeoutShort).Should(BeTrue())
+	Eventually(logScanner.IsFound(warn2), TestTimeoutShort).Should(BeTrue())
+	Eventually(logScanner.IsFound(warn3), TestTimeoutShort).Should(BeTrue())
 	wg.Wait()
 }