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
The following commit(s) were added to refs/heads/main by this push:
new 17c780f47 e2e(ctrl): Add reconciliation recorvery tests
17c780f47 is described below
commit 17c780f4779aaa19ac14389fd7bb8b19c5544d2b
Author: Gaelle Fournier <[email protected]>
AuthorDate: Tue Oct 10 17:40:35 2023 +0200
e2e(ctrl): Add reconciliation recorvery tests
---
e2e/common/misc/files/InvalidJava.java | 28 ++++++++++++++
e2e/common/misc/integration_fail_test.go | 66 +++++++++++++++++++++++++++++++-
2 files changed, 93 insertions(+), 1 deletion(-)
diff --git a/e2e/common/misc/files/InvalidJava.java
b/e2e/common/misc/files/InvalidJava.java
new file mode 100644
index 000000000..89ce67c29
--- /dev/null
+++ b/e2e/common/misc/files/InvalidJava.java
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class InvalidJava extends RouteBuilder {
+ @Override
+ public void configure() throws Exception {
+ from("timer:tick")
+ .setHeader("m").constant("string!")
+ .setBody().simple("Magic${header.m}")
+ .log("${body}")
+ }
+}
diff --git a/e2e/common/misc/integration_fail_test.go
b/e2e/common/misc/integration_fail_test.go
index 18514628d..c423abfb7 100644
--- a/e2e/common/misc/integration_fail_test.go
+++ b/e2e/common/misc/integration_fail_test.go
@@ -54,6 +54,11 @@ func TestBadRouteIntegration(t *testing.T) {
Should(gstruct.PointTo(BeNumerically("==", 2)))
// Check the Integration stays in error phase
Eventually(IntegrationPhase(ns, name),
TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
+
+ // Kit valid
+ kitName := IntegrationKit(ns, name)()
+ integrationKitNamespace := IntegrationKitNamespace(ns, name)()
+ Eventually(KitPhase(integrationKitNamespace, kitName),
TestTimeoutShort).Should(Equal(v1.IntegrationKitPhaseReady))
})
t.Run("run missing dependency java route", func(t *testing.T) {
@@ -62,14 +67,32 @@ func TestBadRouteIntegration(t *testing.T) {
"-d",
"mvn:com.example:nonexistent:1.0").Execute()).To(Succeed())
// Integration in error
Eventually(IntegrationPhase(ns, name),
TestTimeoutLong).Should(Equal(v1.IntegrationPhaseError))
+ Eventually(IntegrationConditionStatus(ns, name,
v1.IntegrationConditionKitAvailable),
TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
+ Eventually(IntegrationCondition(ns, name,
v1.IntegrationConditionKitAvailable), TestTimeoutShort).Should(
+ WithTransform(IntegrationConditionReason,
Equal(v1.IntegrationConditionKitAvailableReason)))
+ Eventually(IntegrationCondition(ns, name,
v1.IntegrationConditionKitAvailable), TestTimeoutShort).Should(
+ WithTransform(IntegrationConditionMessage,
ContainSubstring("is in state \"Error\"")))
+ // Kit in error
kitName := IntegrationKit(ns, name)()
integrationKitNamespace := IntegrationKitNamespace(ns, name)()
- // Kit in error
Eventually(KitPhase(integrationKitNamespace, kitName),
TestTimeoutShort).Should(Equal(v1.IntegrationKitPhaseError))
//Build in error with 5 attempts
build := Build(integrationKitNamespace, kitName)()
Eventually(build.Status.Phase,
TestTimeoutShort).Should(Equal(v1.BuildPhaseError))
Eventually(build.Status.Failure.Recovery.Attempt,
TestTimeoutShort).Should(Equal(5))
+
+ // Fixing the route should reconcile the Integration
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPhase(ns, name),
TestTimeoutLong).Should(Equal(v1.IntegrationPhaseRunning))
+ // New Kit success
+ kitRecoveryName := IntegrationKit(ns, name)()
+ integrationKitRecoveryNamespace := IntegrationKitNamespace(ns,
name)()
+ Eventually(KitPhase(integrationKitRecoveryNamespace,
kitRecoveryName), TestTimeoutShort).Should(Equal(v1.IntegrationKitPhaseReady))
+ Expect(kitRecoveryName).NotTo(Equal(kitName))
+ // New Build success
+ buildRecovery := Build(integrationKitRecoveryNamespace,
kitRecoveryName)()
+ Eventually(buildRecovery.Status.Phase,
TestTimeoutShort).Should(Equal(v1.BuildPhaseSucceeded))
+
})
t.Run("run invalid dependency java route", func(t *testing.T) {
@@ -93,6 +116,13 @@ func TestBadRouteIntegration(t *testing.T) {
Eventually(IntegrationConditionStatus(ns, name,
v1.IntegrationConditionReady), TestTimeoutShort).
Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, name),
TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ // New Kit success
+ kitRecoveryName := IntegrationKit(ns, name)()
+ integrationKitRecoveryNamespace := IntegrationKitNamespace(ns,
name)()
+ Eventually(KitPhase(integrationKitRecoveryNamespace,
kitRecoveryName), TestTimeoutShort).Should(Equal(v1.IntegrationKitPhaseReady))
+ // New Build success
+ buildRecovery := Build(integrationKitRecoveryNamespace,
kitRecoveryName)()
+ Eventually(buildRecovery.Status.Phase,
TestTimeoutShort).Should(Equal(v1.BuildPhaseSucceeded))
})
t.Run("run unresolvable component java route", func(t *testing.T) {
@@ -115,6 +145,40 @@ func TestBadRouteIntegration(t *testing.T) {
Eventually(IntegrationConditionStatus(ns, name,
v1.IntegrationConditionReady), TestTimeoutShort).
Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, name),
TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ // New Kit success
+ kitRecoveryName := IntegrationKit(ns, name)()
+ integrationKitRecoveryNamespace := IntegrationKitNamespace(ns,
name)()
+ Eventually(KitPhase(integrationKitRecoveryNamespace,
kitRecoveryName), TestTimeoutShort).Should(Equal(v1.IntegrationKitPhaseReady))
+ // New Build success
+ buildRecovery := Build(integrationKitRecoveryNamespace,
kitRecoveryName)()
+ Eventually(buildRecovery.Status.Phase,
TestTimeoutShort).Should(Equal(v1.BuildPhaseSucceeded))
+ })
+
+ t.Run("run invalid java route", func(t *testing.T) {
+ name := "invalid-java-route"
+ Expect(KamelRunWithID(operatorID, ns, "files/InvalidJava.java",
"--name", name).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, name),
TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationPhase(ns, name),
TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
+ Eventually(IntegrationConditionStatus(ns, name,
v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionFalse))
+ Eventually(IntegrationLogs(ns, name),
TestTimeoutShort).Should(ContainSubstring("Compilation error"))
+
+ // Kit valid
+ kitName := IntegrationKit(ns, name)()
+ integrationKitNamespace := IntegrationKitNamespace(ns, name)()
+ Eventually(KitPhase(integrationKitNamespace, kitName),
TestTimeoutShort).Should(Equal(v1.IntegrationKitPhaseReady))
+
+ // 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!"))
+
+ // Kit should not have changed
+ kitRecoveryName := IntegrationKit(ns, name)()
+ Expect(kitRecoveryName).To(Equal(kitName))
+
})
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())