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/10/07 03:48:13 UTC
[camel-k] 11/13: (e2e): Splits the TestKamelCLIRun tests
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 667d4c1c012dde49cc6eeaeb697ffebc7941eb3c
Author: phantomjinx <p....@phantomjinx.co.uk>
AuthorDate: Mon Oct 3 16:52:40 2022 +0100
(e2e): Splits the TestKamelCLIRun tests
* Rather than trying to delete resources at the end of each sub-test, it
is simpler and more reliable to generate a new namespace for each and
have it deleted
* The sampleJar URL is changed for the http dependency tests to avoid the
request have to do a redirect. This improves the reliability of its
retrieval
* Sets the http dependency tests to problematic since on OCP4, the
repositories are not being detected by the maven build causing test
failures. See #3708.
---
e2e/namespace/install/cli/run_test.go | 267 ++++++++++++++++++++--------------
1 file changed, 156 insertions(+), 111 deletions(-)
diff --git a/e2e/namespace/install/cli/run_test.go b/e2e/namespace/install/cli/run_test.go
index ca0a10ef5..472ad0552 100644
--- a/e2e/namespace/install/cli/run_test.go
+++ b/e2e/namespace/install/cli/run_test.go
@@ -24,6 +24,7 @@ package common
import (
"fmt"
+ "os"
"testing"
. "github.com/onsi/gomega"
@@ -36,117 +37,161 @@ import (
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
)
-func TestKamelCLIRun(t *testing.T) {
+var sampleJar = "https://raw.githubusercontent.com/apache/camel-k/main/e2e/global/common/traits/files/jvm/sample-1.0.jar"
+
+func operatorID(ns string) string {
+ return fmt.Sprintf("camel-k-%s", ns)
+}
+
+func installWithID(ns string) {
+ Expect(KamelInstallWithID(operatorID(ns), ns).Execute()).To(Succeed())
+ Eventually(OperatorPod(ns)).ShouldNot(BeNil())
+ Eventually(PlatformPhase(ns), TestTimeoutLong).Should(Equal(v1.IntegrationPlatformPhaseReady))
+}
+
+func TestKamelCLIRunGitHubExampleJava(t *testing.T) {
+ WithNewTestNamespace(t, func(ns string) {
+ installWithID(ns)
+
+ Expect(KamelRunWithID(operatorID(ns), ns,
+ "github:apache/camel-k/e2e/namespace/install/files/Java.java").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ })
+}
+
+func TestKamelCLIRunGitHubExampleJavaRaw(t *testing.T) {
+ WithNewTestNamespace(t, func(ns string) {
+ installWithID(ns)
+
+ Expect(KamelRunWithID(operatorID(ns), ns,
+ "https://raw.githubusercontent.com/apache/camel-k/main/e2e/namespace/install/files/Java.java").Execute()).
+ To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ })
+}
+
+func TestKamelCLIRunGitHubExampleJavaBranch(t *testing.T) {
+ WithNewTestNamespace(t, func(ns string) {
+ installWithID(ns)
+
+ Expect(KamelRunWithID(operatorID(ns), ns,
+ "github:apache/camel-k/e2e/namespace/install/files/Java.java?branch=main").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+ })
+}
+
+func TestKamelCLIRunGitHubExampleGistID(t *testing.T) {
+ WithNewTestNamespace(t, func(ns string) {
+ installWithID(ns)
+
+ name := "github-gist-id"
+ Expect(KamelRunWithID(operatorID(ns), ns, "--name", name,
+ "gist:e2c3f9a5fd0d9e79b21b04809786f17a").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!"))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Tick!"))
+ })
+}
+
+func TestKamelCLIRunGitHubExampleGistURL(t *testing.T) {
+ WithNewTestNamespace(t, func(ns string) {
+ installWithID(ns)
+
+ name := "github-gist-url"
+ Expect(KamelRunWithID(operatorID(ns), ns, "--name", name,
+ "https://gist.github.com/lburgazzoli/e2c3f9a5fd0d9e79b21b04809786f17a").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!"))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Tick!"))
+ })
+}
+
+func TestKamelCLIRunAndUpdate(t *testing.T) {
+ WithNewTestNamespace(t, func(ns string) {
+ installWithID(ns)
+
+ name := "run"
+ Expect(KamelRunWithID(operatorID(ns), ns, "files/run.yaml", "--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("Magic default"))
+
+ // Re-run the Integration with an updated configuration
+ Expect(KamelRunWithID(operatorID(ns), ns, "files/run.yaml", "--name", name, "-p", "property=value").Execute()).
+ To(Succeed())
+
+ // Check the Deployment has progressed successfully
+ Eventually(DeploymentCondition(ns, name, appsv1.DeploymentProgressing), TestTimeoutShort).
+ Should(MatchFields(IgnoreExtras, Fields{
+ "Status": Equal(corev1.ConditionTrue),
+ "Reason": Equal("NewReplicaSetAvailable"),
+ }))
+
+ // Check the new configuration is taken into account
+ Eventually(IntegrationPodPhase(ns, name), TestTimeoutShort).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magic value"))
+
+ })
+}
+
+/*
+ * TODO
+ * The dependency cannot be read by maven while building. See #3708
+ *
+ * Adding CAMEL_K_TEST_SKIP_PROBLEMATIC env var for the moment.
+ */
+func TestKamelCLIRunWithHttpDependency(t *testing.T) {
+ if os.Getenv("CAMEL_K_TEST_SKIP_PROBLEMATIC") == "true" {
+ t.Skip("WARNING: Test marked as problematic ... skipping")
+ }
+ WithNewTestNamespace(t, func(ns string) {
+ installWithID(ns)
+
+ fmt.Println("OperatorID: ", operatorID(ns))
+ Expect(KamelRunWithID(operatorID(ns), ns, "../../../global/common/traits/files/jvm/Classpath.java",
+ "-d", sampleJar, "--verbose",
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "classpath"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "classpath", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "classpath"), TestTimeoutShort).Should(ContainSubstring("Hello World!"))
+ })
+}
+
+/*
+ * TODO
+ * The dependency cannot be read by maven while building. See #3708
+ *
+ * Adding CAMEL_K_TEST_SKIP_PROBLEMATIC env var for the moment.
+ */
+func TestKamelCLIRunHttpDependencyUsingOptions(t *testing.T) {
+ if os.Getenv("CAMEL_K_TEST_SKIP_PROBLEMATIC") == "true" {
+ t.Skip("WARNING: Test marked as problematic ... skipping")
+ }
WithNewTestNamespace(t, func(ns string) {
- operatorID := fmt.Sprintf("camel-k-%s", ns)
- Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
-
- t.Run("Examples from GitHub", func(t *testing.T) {
- t.Run("Java", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns,
- "github:apache/camel-k/e2e/namespace/install/files/Java.java").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Java (RAW)", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns,
- "https://raw.githubusercontent.com/apache/camel-k/main/e2e/namespace/install/files/Java.java").Execute()).
- To(Succeed())
- Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Java (branch)", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns,
- "github:apache/camel-k/e2e/namespace/install/files/Java.java?branch=main").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Gist (ID)", func(t *testing.T) {
- name := "github-gist-id"
- Expect(KamelRunWithID(operatorID, ns, "--name", name,
- "gist:e2c3f9a5fd0d9e79b21b04809786f17a").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!"))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Tick!"))
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Gist (URL)", func(t *testing.T) {
- name := "github-gist-url"
- Expect(KamelRunWithID(operatorID, ns, "--name", name,
- "https://gist.github.com/lburgazzoli/e2c3f9a5fd0d9e79b21b04809786f17a").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!"))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Tick!"))
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
-
- // Clean up
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("Run and update", func(t *testing.T) {
- name := "run"
- Expect(KamelRunWithID(operatorID, ns, "files/run.yaml", "--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("Magic default"))
-
- // Re-run the Integration with an updated configuration
- Expect(KamelRunWithID(operatorID, ns, "files/run.yaml", "--name", name, "-p", "property=value").Execute()).
- To(Succeed())
-
- // Check the Deployment has progressed successfully
- Eventually(DeploymentCondition(ns, name, appsv1.DeploymentProgressing), TestTimeoutShort).
- Should(MatchFields(IgnoreExtras, Fields{
- "Status": Equal(corev1.ConditionTrue),
- "Reason": Equal("NewReplicaSetAvailable"),
- }))
-
- // Check the new configuration is taken into account
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutShort).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magic value"))
-
- // Clean up
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
- t.Run("Run with http dependency", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "../../../global/common/traits/files/jvm/Classpath.java",
- "-d", "https://github.com/apache/camel-k/raw/main/e2e/global/common/traits/files/jvm/sample-1.0.jar",
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "classpath"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "classpath", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "classpath"), TestTimeoutShort).Should(ContainSubstring("Hello World!"))
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
- t.Run("Run with http dependency using options", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "../../../global/common/traits/files/jvm/Classpath.java",
- "-d", "https://github.com/apache/camel-k/raw/main/e2e/global/common/traits/files/jvm/sample-1.0.jar",
- "-d", "https://raw.githubusercontent.com/apache/camel-k/main/e2e/namespace/install/cli/files/Java.java|targetPath=/tmp/foo",
- ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "classpath"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "classpath", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "classpath"), TestTimeoutShort).Should(ContainSubstring("Hello World!"))
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
+ installWithID(ns)
+
+ Expect(KamelRunWithID(operatorID(ns), ns, "../../../global/common/traits/files/jvm/Classpath.java",
+ "-d", sampleJar, "--verbose",
+ "-d", "https://raw.githubusercontent.com/apache/camel-k/main/e2e/namespace/install/cli/files/Java.java|targetPath=/tmp/foo",
+ ).Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "classpath"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, "classpath", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, "classpath"), TestTimeoutShort).Should(ContainSubstring("Hello World!"))
})
}