Skip to content

Commit

Permalink
fix for integration test for ECS Exec on Windows
Browse files Browse the repository at this point in the history
This change fixes the following issues-
- Golang base image is Windows release specific and is not scalable. The change introduced here ensures that the correct base image is being used instead of the generic golang image. Also, we will build the binary and then copy it to the container image.
- We need to disable Go Module in order to build the binary. We enable it at the end of the script.
  • Loading branch information
Harsh Rawat authored and sharanyad committed Oct 8, 2021
1 parent bc2452d commit 9c91a3a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
10 changes: 8 additions & 2 deletions misc/exec-command-agent-test/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.

go env -w GO111MODULE=off
go build -tags integration -o ${PSScriptRoot}\sleep.exe ${PSScriptRoot}\sleep\

# create the container image used to run execcmd integ tests
docker build -t "amazon/amazon-ecs-exec-command-agent-windows-test:make" -f "${PSScriptRoot}/windows.dockerfile" ${PSScriptRoot}

$SIMULATED_ECS_AGENT_DEPS_BIN_DIR="C:\Program Files\Amazon\ECS\managed-agents\execute-command\bin\1.0.0.0"
Remove-Item -Path $SIMULATED_ECS_AGENT_DEPS_BIN_DIR -Recurse -Force -ErrorAction SilentlyContinue
New-Item -Path $SIMULATED_ECS_AGENT_DEPS_BIN_DIR -ItemType Directory -Force
go build -tags integration -installsuffix cgo -a -o $SIMULATED_ECS_AGENT_DEPS_BIN_DIR\amazon-ssm-agent.exe ${PSScriptRoot}\sleep\
Move-Item -Path ${PSScriptRoot}\sleep.exe -Destination $SIMULATED_ECS_AGENT_DEPS_BIN_DIR\amazon-ssm-agent.exe
New-Item -Path $SIMULATED_ECS_AGENT_DEPS_BIN_DIR\ssm-agent-worker.exe -ItemType File -Force
New-Item -Path $SIMULATED_ECS_AGENT_DEPS_BIN_DIR\ssm-session-worker.exe -ItemType File -Force

Expand All @@ -41,4 +44,7 @@ if(!(Test-Path -path $SIMULATED_SSM_PLUGINS_DIR\awsCloudWatch))
if(!(Test-Path -path $SIMULATED_SSM_PLUGINS_DIR\awsDomainJoin))
{
New-Item -Path $SIMULATED_SSM_PLUGINS_DIR\awsDomainJoin -ItemType directory -Force
}
}

# Set the Go Modules to auto once we have built the binaries.
go env -w GO111MODULE=auto
25 changes: 15 additions & 10 deletions misc/exec-command-agent-test/windows.dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# escape=`

FROM golang:1.12 as build-env
MAINTAINER Amazon Web Services, Inc.

# There is dockerfile documentation on how to treat windows paths
WORKDIR C:\Users\Administrator\go\src\sleep
COPY ./sleep C:/Users/Administrator/go/src/sleep
RUN go build -tags integration -installsuffix cgo -a -o C:/Users/Administrator/go/src/sleep/sleep.exe .
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may
# not use this file except in compliance with the License. A copy of the
# License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is distributed
# 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 amazon-ecs-ftest-windows-base:make

MAINTAINER Amazon Web Services, Inc.
COPY --from=build-env C:/Users/Administrator/go/src/sleep/sleep.exe C:/

ADD sleep.exe C:/sleep.exe

0 comments on commit 9c91a3a

Please sign in to comment.