From 0bab81317dbfe9bba94551429135efcb147ece61 Mon Sep 17 00:00:00 2001 From: Gaelle Fournier Date: Thu, 16 Nov 2023 16:48:50 +0100 Subject: [PATCH] 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 cc65187698..d2c3a2fbe4 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()) })