This is an automated email from the ASF dual-hosted git repository.
tsato pushed a commit to branch release-1.8.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/release-1.8.x by this push:
new 2b6cf2ca5 test(e2e): add test for 'kamel run --dev' in a warmed-up
environment
2b6cf2ca5 is described below
commit 2b6cf2ca54bfd35f6e58b81221fa418976d8fa58
Author: Tadayoshi Sato <[email protected]>
AuthorDate: Wed May 25 13:55:15 2022 +0900
test(e2e): add test for 'kamel run --dev' in a warmed-up environment
Fix #3211
---
e2e/common/cli/dev_mode_test.go | 46 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/e2e/common/cli/dev_mode_test.go b/e2e/common/cli/dev_mode_test.go
index 251d83838..5ec290db4 100644
--- a/e2e/common/cli/dev_mode_test.go
+++ b/e2e/common/cli/dev_mode_test.go
@@ -29,9 +29,11 @@ import (
"io/ioutil"
"os"
"testing"
+ "time"
. "github.com/onsi/gomega"
"github.com/stretchr/testify/assert"
+ corev1 "k8s.io/api/core/v1"
. "github.com/apache/camel-k/e2e/support"
"github.com/apache/camel-k/e2e/support/util"
@@ -132,5 +134,49 @@ func TestRunDevMode(t *testing.T) {
// When the integration is deleted, then, also the
autogenerated configmaps must be cleaned
Eventually(AutogeneratedConfigmapsCount(ns),
TestTimeoutShort).Should(Equal(0))
})
+
+ // This test makes sure that `kamel run --dev` runs in seconds
after initial build is
+ // already done for the same integration.
+ t.Run("dev mode rebuild in seconds", func(t *testing.T) {
+ /*
+ * !!! NOTE !!!
+ * If you find this test flaky, instead of thinking it
as simply unstable, investigate
+ * why it does not finish in a few seconds and remove
the bottlenecks which are lagging
+ * the integration startup.
+ */
+ RegisterTestingT(t)
+
+ // First run (warm up)
+ Expect(Kamel("run", "-n", ns,
"files/yaml.yaml").Execute()).To(Succeed())
+ Eventually(IntegrationPodPhase(ns, "yaml"),
TestTimeoutMedium).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")).Should(BeNil())
+
+ // Second run (rebuild)
+ ctx, cancel := context.WithCancel(TestContext)
+ defer cancel()
+ piper, pipew := io.Pipe()
+ defer pipew.Close()
+ defer piper.Close()
+
+ file := util.MakeTempCopy(t, "files/yaml.yaml")
+
+ kamelRun := KamelWithContext(ctx, "run", "-n", ns,
file, "--dev")
+ kamelRun.SetOut(pipew)
+
+ logScanner := util.NewLogScanner(ctx, piper,
`integration "yaml" in phase Running`, "Magicstring!")
+
+ args := os.Args
+ defer func() { os.Args = args }()
+ os.Args = []string{"kamel", "run", "-n", ns, file,
"--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("Magicstring!"),
timeout).Should(BeTrue())
+ })
})
}