Skip to content

Commit

Permalink
tests: make windows test run a bit faster
Browse files Browse the repository at this point in the history
* Remove need to pull 'latest' server core

By removing the :latest tag from all windowsservercore containers,
we will have the tests use the container thats already baked into
the AMI.

* Remove depdency on golang and python containers

We are removing the need to use any containers other than servercore
and nanoserver. This reduces the number of downloads needed and the
number of builds that happen before the tests start running.

* Explicit timeouts on order tests

The ordering tests are broken at the moment, so we are capping them
with a fixed timeout.
  • Loading branch information
petderek committed Feb 24, 2019
1 parent 83c928b commit c065ad3
Show file tree
Hide file tree
Showing 53 changed files with 118 additions and 174 deletions.
4 changes: 2 additions & 2 deletions agent/engine/engine_windows_integ_test.go
Expand Up @@ -58,7 +58,7 @@ func isDockerRunning() bool { return true }
func createTestContainer() *apicontainer.Container {
return &apicontainer.Container{
Name: "windows",
Image: "microsoft/windowsservercore:latest",
Image: "microsoft/windowsservercore",
Essential: true,
DesiredStatusUnsafe: apicontainerstatus.ContainerRunning,
CPU: 512,
Expand Down Expand Up @@ -96,7 +96,7 @@ func createTestHealthCheckTask(arn string) *apitask.Task {
DesiredStatusUnsafe: apitaskstatus.TaskRunning,
Containers: []*apicontainer.Container{createTestContainer()},
}
testTask.Containers[0].Image = "microsoft/nanoserver:latest"
testTask.Containers[0].Image = "microsoft/nanoserver"
testTask.Containers[0].Name = "test-health-check"
testTask.Containers[0].HealthCheckType = "docker"
testTask.Containers[0].Command = []string{"powershell", "-command", "Start-Sleep -s 300"}
Expand Down
81 changes: 55 additions & 26 deletions agent/engine/ordering_integ_test.go
Expand Up @@ -20,6 +20,7 @@ import (

apicontainer "github.com/aws/amazon-ecs-agent/agent/api/container"
"github.com/aws/aws-sdk-go/aws"
"time"
)

// TestDependencyHealthCheck is a happy-case integration test that considers a workflow with a HEALTHY dependency
Expand Down Expand Up @@ -57,15 +58,21 @@ func TestDependencyHealthCheck(t *testing.T) {

go taskEngine.AddTask(testTask)

// Both containers should start
verifyContainerRunningStateChange(t, taskEngine)
verifyContainerRunningStateChange(t, taskEngine)
verifyTaskIsRunning(stateChangeEvents, testTask)
finished := make(chan interface{})
go func() {
// Both containers should start
verifyContainerRunningStateChange(t, taskEngine)
verifyContainerRunningStateChange(t, taskEngine)
verifyTaskIsRunning(stateChangeEvents, testTask)

// Task should stop all at once
verifyContainerStoppedStateChange(t, taskEngine)
verifyContainerStoppedStateChange(t, taskEngine)
verifyTaskIsStopped(stateChangeEvents, testTask)
// Task should stop all at once
verifyContainerStoppedStateChange(t, taskEngine)
verifyContainerStoppedStateChange(t, taskEngine)
verifyTaskIsStopped(stateChangeEvents, testTask)
close(finished)
}()

waitFinished(t, finished, 90*time.Second)

}

Expand Down Expand Up @@ -103,17 +110,23 @@ func TestDependencyComplete(t *testing.T) {

go taskEngine.AddTask(testTask)

// First container should run to completion and then exit
verifyContainerRunningStateChange(t, taskEngine)
verifyContainerStoppedStateChange(t, taskEngine)
finished := make(chan interface{})

// Second container starts after the first stops, task becomes running
verifyContainerRunningStateChange(t, taskEngine)
verifyTaskIsRunning(stateChangeEvents, testTask)
go func() {
// First container should run to completion and then exit
verifyContainerRunningStateChange(t, taskEngine)
verifyContainerStoppedStateChange(t, taskEngine)

// Last container stops and then the task stops
verifyContainerStoppedStateChange(t, taskEngine)
verifyTaskIsStopped(stateChangeEvents, testTask)
// Second container starts after the first stops, task becomes running
verifyContainerRunningStateChange(t, taskEngine)
verifyTaskIsRunning(stateChangeEvents, testTask)

// Last container stops and then the task stops
verifyContainerStoppedStateChange(t, taskEngine)
verifyTaskIsStopped(stateChangeEvents, testTask)
}()

waitFinished(t, finished, 90*time.Second)
}

// TestDependencySuccess validates that the SUCCESS dependency condition will resolve when the child container exits
Expand Down Expand Up @@ -150,17 +163,22 @@ func TestDependencySuccess(t *testing.T) {

go taskEngine.AddTask(testTask)

// First container should run to completion
verifyContainerRunningStateChange(t, taskEngine)
verifyContainerStoppedStateChange(t, taskEngine)
finished := make(chan interface{})
go func() {
// First container should run to completion
verifyContainerRunningStateChange(t, taskEngine)
verifyContainerStoppedStateChange(t, taskEngine)

// Second container starts after the first stops, task becomes running
verifyContainerRunningStateChange(t, taskEngine)
verifyTaskIsRunning(stateChangeEvents, testTask)
// Second container starts after the first stops, task becomes running
verifyContainerRunningStateChange(t, taskEngine)
verifyTaskIsRunning(stateChangeEvents, testTask)

// Last container stops and then the task stops
verifyContainerStoppedStateChange(t, taskEngine)
verifyTaskIsStopped(stateChangeEvents, testTask)
// Last container stops and then the task stops
verifyContainerStoppedStateChange(t, taskEngine)
verifyTaskIsStopped(stateChangeEvents, testTask)
}()

waitFinished(t, finished, 90*time.Second)
}

// TestDependencySuccess validates that the SUCCESS dependency condition will fail when the child exits 1. This is a
Expand Down Expand Up @@ -302,3 +320,14 @@ func TestDependencyHealthyTimeout(t *testing.T) {
// task should transition to stopped
verifyTaskIsStopped(stateChangeEvents, testTask)
}

func waitFinished(t *testing.T, finished <-chan interface{}, duration time.Duration) {
select {
case <-finished:
t.Log("Finished successfully.")
return
case <-time.After(90 * time.Second):
t.Error("timed out after: ", duration)
t.FailNow()
}
}
2 changes: 1 addition & 1 deletion agent/engine/ordering_integ_windows_test.go
Expand Up @@ -20,5 +20,5 @@ const (
)

var (
entryPointForOS = []string{"pwsh", "-c"}
entryPointForOS = []string{"powershell"}
)
Expand Up @@ -5,7 +5,7 @@
"memory": 512,
"name": "awslogs-datetime-windows",
"cpu": 1024,
"image": "microsoft/windowsservercore:latest",
"image": "microsoft/windowsservercore",
"entryPoint": ["powershell"],
"command": ["echo", "\"May 01, 2017 19:00:01 ECS\nMay 01, 2017 19:00:04 Agent\nRunning\nin the instance\""],
"logConfiguration": {
Expand Down
Expand Up @@ -5,7 +5,7 @@
"memory": 512,
"name": "awslogs-multiline-windows",
"cpu": 1024,
"image": "microsoft/windowsservercore:latest",
"image": "microsoft/windowsservercore",
"entryPoint": ["powershell"],
"command": ["echo", "\"INFO: ECS Agent\nRunning\nINFO: Instance\""],
"logConfiguration": {
Expand Down
Expand Up @@ -5,7 +5,7 @@
"memory": 512,
"name": "awslogs",
"cpu": 1024,
"image": "microsoft/windowsservercore:latest",
"image": "microsoft/windowsservercore",
"logConfiguration": {
"logDriver": "awslogs",
"options": {
Expand Down
@@ -1,7 +1,7 @@
{
"family": "ecsftest-cleanup-windows",
"containerDefinitions": [{
"image": "microsoft/windowsservercore:latest",
"image": "microsoft/windowsservercore",
"name": "cleanup-windows",
"cpu": 1024,
"memory": 512,
Expand Down
Expand Up @@ -24,4 +24,4 @@
}
}]
}


Expand Up @@ -21,4 +21,4 @@
}
}]
}


Expand Up @@ -5,7 +5,7 @@
"host": {}
}],
"containerDefinitions": [{
"image": "microsoft/windowsservercore:latest",
"image": "microsoft/windowsservercore",
"name": "exit",
"cpu": 512,
"memory": 256,
Expand All @@ -15,7 +15,7 @@
}],
"command": ["powershell", "-c", "while (1) { sleep 1; if (test-path \"C:/data/success\") { exit 42 }}; done"]
}, {
"image": "microsoft/windowsservercore:latest",
"image": "microsoft/windowsservercore",
"name": "dataSource",
"cpu": 512,
"memory": 256,
Expand All @@ -25,7 +25,7 @@
}],
"command": ["powershell", "-c", "New-Item -ItemType file C:/data/success"]
}, {
"image": "microsoft/windowsservercore:latest",
"image": "microsoft/windowsservercore",
"name": "data-volume-source",
"cpu": 512,
"memory": 256,
Expand Down
@@ -1,7 +1,7 @@
{
"family": "ecsftest-hostname",
"containerDefinitions": [{
"image": "microsoft/windowsservercore:latest",
"image": "microsoft/windowsservercore",
"name": "exit",
"cpu": 1024,
"memory": 512,
Expand Down
@@ -1,7 +1,7 @@
{
"family": "ecsftest-labels-windows",
"containerDefinitions": [{
"image": "microsoft/windowsservercore:latest",
"image": "microsoft/windowsservercore",
"name": "labeled",
"cpu": 1024,
"memory": 512,
Expand Down
@@ -1,7 +1,7 @@
{
"family": "ecsinteg-json-file-rollover",
"containerDefinitions": [{
"image": "microsoft/windowsservercore:latest",
"image": "microsoft/windowsservercore",
"name": "exit",
"memory": 512,
"cpu": 1024,
Expand Down
Expand Up @@ -2,7 +2,7 @@
"family": "ecsftest-networkmode",
"networkMode": "$$$$NETWORK_MODE$$$$",
"containerDefinitions": [{
"image": "microsoft/windowsservercore:latest",
"image": "microsoft/windowsservercore",
"entryPoint": ["powershell"],
"command": ["sleep", "60"],
"name": "network-$$$$NETWORK_MODE$$$$",
Expand Down
Expand Up @@ -5,8 +5,8 @@
"memory": 256,
"name": "memory-overcommit",
"cpu": 512,
"image": "amazon/amazon-ecs-windows-python:make",
"command": ["python", "-c", "import time; time.sleep(30); foo=' '*1024*1024*1024;"]
"image": "amazon/amazon-ecs-windows-telemetry-test:make",
"command": ["-concurrency", "10", "-memory", "1024"]
}]
}

@@ -1,7 +1,7 @@
{
"family": "ecsftest-savedstate-windows",
"containerDefinitions": [{
"image": "microsoft/windowsservercore:latest",
"image": "microsoft/windowsservercore",
"name": "savedstate-windows",
"cpu": 1024,
"memory": 512,
Expand Down
Expand Up @@ -17,4 +17,4 @@
]
}
]
}
}
@@ -1,7 +1,7 @@
{
"family": "ecsinteg-simple-exit-windows",
"containerDefinitions": [{
"image": "microsoft/windowsservercore:latest",
"image": "microsoft/windowsservercore",
"name": "exit",
"cpu": 1024,
"memory": 512,
Expand Down
Expand Up @@ -23,4 +23,4 @@
"deviceType": "eia1.medium"
}
]
}
}
Expand Up @@ -2,7 +2,7 @@
"family": "ecsftest-task-local-volume",
"containerDefinitions": [
{
"image": "microsoft/windowsservercore:latest",
"image": "microsoft/windowsservercore",
"name": "exit",
"cpu": 512,
"memory": 256,
Expand Down
Expand Up @@ -32,4 +32,4 @@
}
}
]
}
}
Expand Up @@ -3,7 +3,7 @@
"containerDefinitions": [
{
"name": "task-shared-vol-read",
"image": "microsoft/windowsservercore:latest",
"image": "microsoft/windowsservercore",
"cpu": 512,
"memory": 256,
"essential": true,
Expand Down
Expand Up @@ -2,7 +2,7 @@
"family": "ecsftest-task-local-volume",
"containerDefinitions": [
{
"image": "microsoft/windowsservercore:latest",
"image": "microsoft/windowsservercore",
"name": "task-shared-vol-write-windows",
"cpu": 512,
"memory": 256,
Expand Down
@@ -1,7 +1,7 @@
{
"family": "ecsftest-working-dir-windows",
"containerDefinitions": [{
"image": "microsoft/windowsservercore:latest",
"image": "microsoft/windowsservercore",
"name": "exit",
"cpu": 1024,
"memory": 512,
Expand Down
2 changes: 1 addition & 1 deletion misc/container-health-windows/windows.dockerfile
Expand Up @@ -10,7 +10,7 @@
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.
FROM microsoft/windowsservercore:latest
FROM microsoft/windowsservercore

MAINTAINER Amazon Web Services, Inc.

Expand Down
Expand Up @@ -11,6 +11,6 @@
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.

FROM microsoft/nanoserver:latest
FROM microsoft/windowsservercore

ADD container-metadata-file-validator-windows.exe container-metadata-file-validator-windows.exe
Expand Up @@ -14,23 +14,7 @@
$oldPref = $ErrorActionPreference
$ErrorActionPreference = 'Stop'

Invoke-Expression ${PSScriptRoot}\..\windows-deploy\hostsetup.ps1

# Create amazon/amazon-ecs-container-metadata-file-validator-windows for tests
$buildscript = @"
mkdir C:\md
cp C:\ecs\container-metadata-file-validator-windows.go C:\md
go build -o C:\md\container-metadata-file-validator-windows.exe C:\md\container-metadata-file-validator-windows.go
cp C:\md\container-metadata-file-validator-windows.exe C:\ecs
"@

$buildimage="golang:1.7-nanoserver"
docker pull $buildimage

docker run `
--volume ${PSScriptRoot}:C:\ecs `
$buildimage `
powershell ${buildscript}

Invoke-Expression "go build -o ${PSScriptRoot}\container-metadata-file-validator-windows.exe ${PSScriptRoot}\container-metadata-file-validator-windows.go"
Invoke-Expression "docker build -t amazon/amazon-ecs-container-metadata-file-validator-windows --file ${PSScriptRoot}\container-metadata-file-validator-windows.dockerfile ${PSScriptRoot}"
$ErrorActionPreference = $oldPref
2 changes: 1 addition & 1 deletion misc/image-cleanup-test-images/windows0.dockerfile
Expand Up @@ -10,7 +10,7 @@
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.
FROM microsoft/windowsservercore:latest
FROM microsoft/windowsservercore

MAINTAINER Amazon Web Services, Inc.

Expand Down

0 comments on commit c065ad3

Please sign in to comment.