Skip to content

Commit

Permalink
Update how test ensures container exits
Browse files Browse the repository at this point in the history
  • Loading branch information
arun-annamalai authored and Harsh Rawat committed Sep 23, 2021
1 parent e2d21a1 commit f6676dd
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions agent/engine/engine_windows_integ_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,11 +679,20 @@ func TestManagedAgentEvent(t *testing.T) {
assert.False(t, timeout)

if tc.ShouldBeRunning {
containerMap, _ := taskEngine.(*DockerTaskEngine).state.ContainerMapByArn(testTask.Arn)
cid := containerMap[testTask.Containers[0].Name].DockerID
// Kill the existing container now
err = client.ContainerKill(context.TODO(), cid, "SIGKILL")
assert.NoError(t, err, "Could not kill container")
stateChangeEvents := taskEngine.StateChangeEvents()
taskUpdate := createTestExecCommandAgentTask(testTaskId, testContainerName, time.Minute*tc.ManagedAgentLifetime)
taskUpdate.SetDesiredStatus(apitaskstatus.TaskStopped)
go taskEngine.AddTask(taskUpdate)

ctx, cancel := context.WithTimeout(context.Background(), time.Second*20)
go func() {
verifyTaskIsStopped(stateChangeEvents, testTask)
cancel()
}()

<-ctx.Done()
require.NotEqual(t, context.DeadlineExceeded, ctx.Err(), "Timed out waiting for task (%s) to stop", testTaskId)
assert.NotNil(t, testTask.Containers[0].GetKnownExitCode(), "No exit code found")
}

taskEngine.(*DockerTaskEngine).deleteTask(testTask)
Expand Down

0 comments on commit f6676dd

Please sign in to comment.