From c0f644b5897dee3025e29a7e55066e7806a5495e Mon Sep 17 00:00:00 2001 From: Anusha Hegde Date: Mon, 21 Mar 2022 11:10:46 +0000 Subject: [PATCH] Wait for the host agent process to start Since we are running the host agent in the containers for integration tests, the process is not started instantly sometimes and this causes flakes in the tests. Adding a check to ensure the host agent process is started and only then proceed with the tests Signed-off-by: Nilanjan Daw --- agent/host_agent_test.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/agent/host_agent_test.go b/agent/host_agent_test.go index cf722ebf9..5dd221b60 100644 --- a/agent/host_agent_test.go +++ b/agent/host_agent_test.go @@ -157,6 +157,18 @@ var _ = Describe("Agent", func() { output, _, err = runner.ExecByoDockerHost(byoHostContainer) Expect(err).NotTo(HaveOccurred()) + + // wait until the agent process starts inside the byoh host container + Eventually(func() bool { + containerTop, _ := runner.DockerClient.ContainerTop(ctx, byoHostContainer.ID, []string{}) + for _, proc := range containerTop.Processes { + if strings.Contains(proc[len(containerTop.Titles)-1], "agent") { + return true + } + + } + return false + }).Should(BeTrue()) }) AfterEach(func() { @@ -313,7 +325,7 @@ var _ = Describe("Agent", func() { } } return corev1.ConditionFalse - }, 60).Should(Equal(corev1.ConditionTrue)) + }, 100).Should(Equal(corev1.ConditionTrue)) // installing K8s components is a lengthy operation, setting the timeout to 100s }) }) })