From aeeb846d96e8f018cc459265d537138f5b148848 Mon Sep 17 00:00:00 2001 From: Amogh Rathore Date: Wed, 24 Aug 2022 18:00:32 +0000 Subject: [PATCH 1/2] Increase sleep when killing mock exec command agent --- agent/engine/engine_windows_integ_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agent/engine/engine_windows_integ_test.go b/agent/engine/engine_windows_integ_test.go index 29ba2c7b33..c59f6b7efd 100644 --- a/agent/engine/engine_windows_integ_test.go +++ b/agent/engine/engine_windows_integ_test.go @@ -889,5 +889,5 @@ func killMockExecCommandAgent(t *testing.T, client *sdkClient.Client, containerI require.NoError(t, err) // Windows docker exec takes longer than Linux - time.Sleep(4 * time.Second) + time.Sleep(8 * time.Second) } From 1a89c365d120833bfcd20758a090f36ee2377945 Mon Sep 17 00:00:00 2001 From: Amogh Rathore Date: Thu, 25 Aug 2022 17:47:47 +0000 Subject: [PATCH 2/2] Keep looping if expectedPid matches process id and we are checking for a stopped process --- agent/engine/engine_windows_integ_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/agent/engine/engine_windows_integ_test.go b/agent/engine/engine_windows_integ_test.go index c59f6b7efd..f0a32d50c9 100644 --- a/agent/engine/engine_windows_integ_test.go +++ b/agent/engine/engine_windows_integ_test.go @@ -837,7 +837,10 @@ func verifyMockExecCommandAgentStatus(t *testing.T, client *sdkClient.Client, co require.NotEqual(t, -1, pidPos, "PID title not found in the container top response") for _, proc := range top.Processes { matched, _ := regexp.MatchString(execCmdAgentProcessRegex, proc[cmdPos]) - if matched { + // Process we are checking to be stopped might still be running. + // expectedPid matches the pid of the process in that case, so wait if that's + // the case. + if matched && (checkIsRunning || expectedPid != proc[pidPos]) { res <- proc[pidPos] return } @@ -846,7 +849,7 @@ func verifyMockExecCommandAgentStatus(t *testing.T, client *sdkClient.Client, co select { case <-ctx.Done(): return - case <-time.After(time.Second * 4): + case <-time.After(time.Second * 1): } } }() @@ -887,7 +890,4 @@ func killMockExecCommandAgent(t *testing.T, client *sdkClient.Client, containerI Detach: true, }) require.NoError(t, err) - - // Windows docker exec takes longer than Linux - time.Sleep(8 * time.Second) }