Skip to content

Commit

Permalink
Adding integration tests for timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
petderek committed Feb 23, 2019
1 parent 9e9a51b commit bcb4940
Showing 1 changed file with 98 additions and 0 deletions.
98 changes: 98 additions & 0 deletions agent/engine/ordering_integ_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ func TestDependencySuccess(t *testing.T) {
// TestDependencySuccess validates that the SUCCESS dependency condition will fail when the child exits 1. This is a
// contrast to how COMPLETE behaves. Instead of starting the parent, the task should simply exit.
func TestDependencySuccessErrored(t *testing.T) {
t.Skip("TODO: this test exposes a bug. Fix the bug and then remove this skip.")
taskEngine, done, _ := setupWithDefaultConfig(t)
defer done()

Expand Down Expand Up @@ -204,3 +205,100 @@ func TestDependencySuccessErrored(t *testing.T) {
// task should transition to stopped
verifyTaskIsStopped(stateChangeEvents, testTask)
}

// TestDependencySuccessTimeout
func TestDependencySuccessTimeout(t *testing.T) {
t.Skip("TODO: this test exposes a bug. Fix the bug and then remove this skip.")
taskEngine, done, _ := setupWithDefaultConfig(t)
defer done()

stateChangeEvents := taskEngine.StateChangeEvents()

taskArn := "testDependencySuccessTimeout"
testTask := createTestTask(taskArn)

parent := createTestContainerWithImageAndName(baseImageForOS, "parent")
dependency := createTestContainerWithImageAndName(baseImageForOS, "dependency")

parent.EntryPoint = &entryPointForOS
parent.Command = []string{"exit 0"}
parent.DependsOn = []apicontainer.DependsOn{
{
Container: "dependency",
Condition: "SUCCESS",
},
}

dependency.EntryPoint = &entryPointForOS
dependency.Command = []string{"sleep 15 && exit 0"}
dependency.Essential = false

// set the timeout to be shorter than the amount of time it takes to stop
dependency.StartTimeout = 8

testTask.Containers = []*apicontainer.Container{
parent,
dependency,
}

go taskEngine.AddTask(testTask)

// First container should run to completion
verifyContainerRunningStateChange(t, taskEngine)
verifyContainerStoppedStateChange(t, taskEngine)

// task should transition to stopped
verifyTaskIsStopped(stateChangeEvents, testTask)
}

// TestDependencyHealthyTimeout
func TestDependencyHealthyTimeout(t *testing.T) {
t.Skip("TODO: this test exposes a bug. Fix the bug and then remove this skip.")
taskEngine, done, _ := setupWithDefaultConfig(t)
defer done()

stateChangeEvents := taskEngine.StateChangeEvents()

taskArn := "testDependencyHealthyTimeout"
testTask := createTestTask(taskArn)

parent := createTestContainerWithImageAndName(baseImageForOS, "parent")
dependency := createTestContainerWithImageAndName(baseImageForOS, "dependency")

parent.EntryPoint = &entryPointForOS
parent.Command = []string{"exit 0"}
parent.DependsOn = []apicontainer.DependsOn{
{
Container: "dependency",
Condition: "HEALTHY",
},
}

dependency.EntryPoint = &entryPointForOS
dependency.Command = []string{"sleep 30"}
dependency.HealthCheckType = apicontainer.DockerHealthCheckType

// enter a healthcheck that will fail
dependency.DockerConfig.Config = aws.String(`{
"HealthCheck":{
"Test":["CMD-SHELL", "exit 1"]
}
}`)

// set the timeout. Duration doesn't matter since healthcheck will always be unhealthy.
dependency.StartTimeout = 8

testTask.Containers = []*apicontainer.Container{
parent,
dependency,
}

go taskEngine.AddTask(testTask)

// First container should run to completion
verifyContainerRunningStateChange(t, taskEngine)
verifyContainerStoppedStateChange(t, taskEngine)

// task should transition to stopped
verifyTaskIsStopped(stateChangeEvents, testTask)
}

0 comments on commit bcb4940

Please sign in to comment.