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 2089fc29e chore(e2e): Dev mode flaky test rendomize name
2089fc29e is described below

commit 2089fc29e996784e9af9c695c8bbb40f6a59ece1
Author: Gaelle Fournier <gaelle.fournier.w...@gmail.com>
AuthorDate: Thu Nov 16 16:48:50 2023 +0100

    chore(e2e): Dev mode flaky test rendomize name
---
 e2e/common/cli/dev_mode_test.go | 41 ++++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/e2e/common/cli/dev_mode_test.go b/e2e/common/cli/dev_mode_test.go
index cc6518769..d2c3a2fbe 100644
--- a/e2e/common/cli/dev_mode_test.go
+++ b/e2e/common/cli/dev_mode_test.go
@@ -59,24 +59,25 @@ func TestRunDevMode(t *testing.T) {
                defer piper.Close()
 
                file := util.MakeTempCopy(t, "files/yaml.yaml")
+               name := RandomizedSuffixName("yaml")
 
-               kamelRun := KamelRunWithContext(ctx, operatorID, ns, file, 
"--dev")
+               kamelRun := KamelRunWithContext(ctx, operatorID, ns, file, 
"--name", name, "--dev")
                kamelRun.SetOut(pipew)
 
-               logScanner := util.NewLogScanner(ctx, piper, `integration 
"yaml" in phase Running`, "Magicstring!", "Magicjordan!")
+               logScanner := util.NewLogScanner(ctx, piper, `integration 
"`+name+`" in phase Running`, "Magicstring!", "Magicjordan!")
 
                args := os.Args
                defer func() { os.Args = args }()
 
                globalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true"
                if globalTest {
-                       os.Args = []string{"kamel", "run", "-n", ns, file, 
"--dev"}
+                       os.Args = []string{"kamel", "run", "-n", ns, file, 
"--name", name, "--dev"}
                } else {
-                       os.Args = []string{"kamel", "run", "-n", ns, 
"--operator-id", operatorID, file, "--dev"}
+                       os.Args = []string{"kamel", "run", "-n", ns, 
"--operator-id", operatorID, file, "--name", name, "--dev"}
                }
                go kamelRun.Execute()
 
-               Eventually(logScanner.IsFound(`integration "yaml" in phase 
Running`), TestTimeoutMedium).Should(BeTrue())
+               Eventually(logScanner.IsFound(`integration "`+name+`" in phase 
Running`), TestTimeoutMedium).Should(BeTrue())
                Eventually(logScanner.IsFound("Magicstring!"), 
TestTimeoutMedium).Should(BeTrue())
                Expect(logScanner.IsFound("Magicjordan!")()).To(BeFalse())
 
@@ -93,7 +94,8 @@ func TestRunDevMode(t *testing.T) {
                defer piper.Close()
 
                remoteFile := 
"https://raw.githubusercontent.com/apache/camel-k/b29333f0a878d5d09fb3965be8fe586d77dd95d0/e2e/common/files/yaml.yaml";
-               kamelRun := KamelRunWithContext(ctx, operatorID, ns, 
remoteFile, "--dev")
+               name := RandomizedSuffixName("yaml")
+               kamelRun := KamelRunWithContext(ctx, operatorID, ns, 
remoteFile, "--name", name, "--dev")
                kamelRun.SetOut(pipew)
 
                logScanner := util.NewLogScanner(ctx, piper, "Magicstring!")
@@ -103,9 +105,9 @@ func TestRunDevMode(t *testing.T) {
 
                globalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true"
                if globalTest {
-                       os.Args = []string{"kamel", "run", "-n", ns, 
remoteFile, "--dev"}
+                       os.Args = []string{"kamel", "run", "-n", ns, 
remoteFile, "--name", name, "--dev"}
                } else {
-                       os.Args = []string{"kamel", "run", "-n", ns, 
"--operator-id", operatorID, remoteFile, "--dev"}
+                       os.Args = []string{"kamel", "run", "-n", ns, 
"--operator-id", operatorID, remoteFile, "--name", name, "--dev"}
                }
 
                go kamelRun.Execute()
@@ -123,14 +125,15 @@ func TestRunDevMode(t *testing.T) {
                 * the integration startup.
                 */
                RegisterTestingT(t)
+               name := RandomizedSuffixName("yaml")
 
                // First run (warm up)
-               Expect(KamelRunWithID(operatorID, ns, 
"files/yaml.yaml").Execute()).To(Succeed())
-               Eventually(IntegrationPodPhase(ns, "yaml"), 
TestTimeoutLong).Should(Equal(corev1.PodRunning))
-               Eventually(IntegrationLogs(ns, "yaml"), 
TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-               Expect(Kamel("delete", "yaml", "-n", 
ns).Execute()).To(Succeed())
-               Eventually(Integration(ns, "yaml")).Should(BeNil())
-               Eventually(IntegrationPod(ns, "yaml"), 
TestTimeoutMedium).Should(BeNil())
+               Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml", 
"--name", name).Execute()).To(Succeed())
+               Eventually(IntegrationPodPhase(ns, name), 
TestTimeoutLong).Should(Equal(corev1.PodRunning))
+               Eventually(IntegrationLogs(ns, name), 
TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+               Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
+               Eventually(Integration(ns, name)).Should(BeNil())
+               Eventually(IntegrationPod(ns, name), 
TestTimeoutMedium).Should(BeNil())
 
                // Second run (rebuild)
                ctx, cancel := context.WithCancel(TestContext)
@@ -141,26 +144,26 @@ func TestRunDevMode(t *testing.T) {
 
                file := util.MakeTempCopy(t, "files/yaml.yaml")
 
-               kamelRun := KamelRunWithContext(ctx, operatorID, ns, file, 
"--dev")
+               kamelRun := KamelRunWithContext(ctx, operatorID, ns, file, 
"--name", name, "--dev")
                kamelRun.SetOut(pipew)
 
-               logScanner := util.NewLogScanner(ctx, piper, `integration 
"yaml" in phase Running`, "Magicstring!")
+               logScanner := util.NewLogScanner(ctx, piper, `integration 
"`+name+`" in phase Running`, "Magicstring!")
 
                args := os.Args
                defer func() { os.Args = args }()
 
                globalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true"
                if globalTest {
-                       os.Args = []string{"kamel", "run", "-n", ns, file, 
"--dev"}
+                       os.Args = []string{"kamel", "run", "-n", ns, file, 
"--name", name, "--dev"}
                } else {
-                       os.Args = []string{"kamel", "run", "-n", ns, 
"--operator-id", operatorID, file, "--dev"}
+                       os.Args = []string{"kamel", "run", "-n", ns, 
"--operator-id", operatorID, file, "--name", name, "--dev"}
                }
 
                go kamelRun.Execute()
 
                // Second run should start up within a few seconds
                timeout := 10 * time.Second
-               Eventually(logScanner.IsFound(`integration "yaml" in phase 
Running`), timeout).Should(BeTrue())
+               Eventually(logScanner.IsFound(`integration "`+name+`" in phase 
Running`), timeout).Should(BeTrue())
                Eventually(logScanner.IsFound("Magicstring!"), 
timeout).Should(BeTrue())
        })
 

Reply via email to