-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
77: Adds testing on ECS r=iamed2 a=morris25 A cleaned up version of ECS testing from #71. In response to #66. Co-authored-by: morris25 <[email protected]>
- Loading branch information
Showing
3 changed files
with
244 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
# To test, do: | ||
# ``` | ||
# BRANCH="name-of-branch-to-test" | ||
# | ||
# id=$(aws batch submit-job \ | ||
# --job-name $BRANCH \ | ||
# --job-definition AWSCore-ECS-00001-Job:1 \ | ||
# --job-queue AWSCore-ECS-00001-JobQueue \ | ||
# --container-overrides \ | ||
# "environment=[{name=AWSCORE_BRANCH,value=$BRANCH}]" --query jobId --output text) | ||
|
||
# status=$(aws batch describe-jobs --jobs $id --query jobs[0].status --output text) | ||
# while [ "$status" ] && [ "$status" != "FAILED" ] && [ "$status" != "SUCCEEDED" ]; do | ||
# echo "Waiting for job $id, status: $status..." | ||
# sleep 30 | ||
# status=$(aws batch describe-jobs --jobs $id --query jobs[0].status --output text) | ||
# done | ||
# echo "Job $id finished, status: $status" | ||
|
||
# logstream=$(aws batch describe-jobs --jobs $id --query jobs[0].container.logStreamName --output text) | ||
# if [ "$logstream" ]; then | ||
# aws logs get-log-events --log-group-name /aws/batch/job --log-stream-name $logstream --query events[*].message --output text | tr '\t' '\n' | ||
# fi | ||
|
||
# test "$status" == "SUCCEEDED" | ||
# ``` | ||
|
||
AWSTemplateFormatVersion: 2010-09-09 | ||
Description: >- | ||
A bare bones AWS Batch environment for testing with AWSCore | ||
Parameters: | ||
PublicCIUser: | ||
Description: User which can assume the testing role | ||
Type: String | ||
MaxVCPUs: | ||
Description: >- | ||
The maximum number of VCPUs. Typically this number does not need to be touched | ||
Type: Number | ||
Default: 16 | ||
SubnetId: | ||
Description: >- | ||
The Subnet in the default VPC to launch the ComputeEnvironment into. | ||
Can be found with: | ||
`aws ec2 describe-subnets --filter Name=defaultForAz,Values=true Name=vpc-id,Values=$default_vpc | ||
--query Subnets[0].SubnetId --output text` | ||
Type: AWS::EC2::Subnet::Id | ||
VPCId: | ||
Description: >- | ||
The default VPC in which SubnetId is located. | ||
Can be found with: | ||
`aws ec2 describe-vpcs --filters Name=isDefault,Values=true --query Vpcs[0].VpcId --output text` | ||
Type: AWS::EC2::VPC::Id | ||
|
||
Resources: | ||
ECSTravisPolicy: | ||
Type: AWS::IAM::ManagedPolicy | ||
Properties: | ||
Users: | ||
- !Sub ${PublicCIUser} | ||
PolicyDocument: | ||
Version: 2012-10-17 | ||
Statement: | ||
- Effect: Allow | ||
Action: batch:DescribeJobs | ||
Resource: "*" | ||
- Effect: Allow | ||
Action: logs:GetLogEvents | ||
Resource: | ||
- !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/batch/job* | ||
- Effect: Allow | ||
Action: batch:SubmitJob | ||
Resource: | ||
- !Ref AWSCoreTestJob | ||
- !Ref JobQueue | ||
|
||
AWSCoreTestJob: | ||
Type: AWS::Batch::JobDefinition | ||
Properties: | ||
JobDefinitionName: !Sub ${AWS::StackName}-Job | ||
Type: container | ||
ContainerProperties: | ||
# Job must have a JobRole for `ecs_instance_credentials()` to succeed | ||
JobRoleArn: !Ref JobRole | ||
Memory: 1600 | ||
Command: | ||
- julia | ||
- -e | ||
- using Pkg; Pkg.add(PackageSpec(url=ENV["AWSCORE_URL"], rev=ENV["AWSCORE_BRANCH"])); Pkg.build("AWSCore"); Pkg.test("AWSCore") | ||
Environment: | ||
- Name: AWSCORE_URL | ||
Value: https://github.com/JuliaCloud/AWSCore.jl | ||
- Name: AWSCORE_BRANCH | ||
Value: master | ||
- Name: AWSCORE_INSTANCE_TYPE | ||
Value: ECS | ||
Image: julia:1.0.3 | ||
Vcpus: 1 | ||
Timeout: | ||
AttemptDurationSeconds: 900 | ||
JobRole: | ||
Type: AWS::IAM::Role | ||
Properties: | ||
AssumeRolePolicyDocument: | ||
Version: 2012-10-17 | ||
Statement: | ||
- Effect: Allow | ||
Principal: | ||
Service: | ||
- ecs-tasks.amazonaws.com # Note: Shouldn't be batch.amazonaws.com | ||
Action: sts:AssumeRole | ||
|
||
ComputeEnvironment: | ||
Type: AWS::Batch::ComputeEnvironment | ||
DependsOn: BatchServiceRole # Removing the ServiceRole before deleting the ComputeEnvironment will cause issues | ||
Properties: | ||
Type: MANAGED | ||
ComputeEnvironmentName: !Ref AWS::StackName | ||
ComputeResources: | ||
Type: SPOT | ||
BidPercentage: 100 | ||
MinvCpus: 0 | ||
MaxvCpus: !Ref MaxVCPUs | ||
InstanceTypes: | ||
- optimal | ||
Subnets: | ||
- !Ref SubnetId | ||
SecurityGroupIds: | ||
- !Ref SecurityGroup | ||
InstanceRole: !Ref IamInstanceProfile | ||
SpotIamFleetRole: !Ref BatchSpotFleetRole | ||
Tags: | ||
Name: !Sub "AWS Batch (${AWS::StackName})" | ||
ServiceRole: !Ref BatchServiceRole | ||
JobQueue: | ||
Type: AWS::Batch::JobQueue | ||
Properties: | ||
JobQueueName: !Sub ${AWS::StackName}-JobQueue | ||
Priority: 1 | ||
ComputeEnvironmentOrder: | ||
- Order: 1 | ||
ComputeEnvironment: !Ref ComputeEnvironment | ||
|
||
IamInstanceProfile: | ||
Type: AWS::IAM::InstanceProfile | ||
Properties: | ||
Roles: | ||
- !Ref EcsInstanceRole | ||
EcsInstanceRole: | ||
Type: AWS::IAM::Role | ||
Properties: | ||
AssumeRolePolicyDocument: | ||
Version: 2008-10-17 | ||
Statement: | ||
- Sid: '' | ||
Effect: Allow | ||
Principal: | ||
Service: ec2.amazonaws.com | ||
Action: sts:AssumeRole | ||
ManagedPolicyArns: | ||
- arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role | ||
BatchServiceRole: | ||
Type: AWS::IAM::Role | ||
Properties: | ||
AssumeRolePolicyDocument: | ||
Version: 2012-10-17 | ||
Statement: | ||
- Effect: Allow | ||
Principal: | ||
Service: batch.amazonaws.com | ||
Action: sts:AssumeRole | ||
ManagedPolicyArns: | ||
- arn:aws:iam::aws:policy/service-role/AWSBatchServiceRole | ||
|
||
# http://docs.aws.amazon.com/batch/latest/userguide/spot_fleet_IAM_role.html | ||
BatchSpotFleetRole: | ||
Type: AWS::IAM::Role | ||
Properties: | ||
AssumeRolePolicyDocument: | ||
Version: 2012-10-17 | ||
Statement: | ||
- Effect: Allow | ||
Principal: | ||
Service: spotfleet.amazonaws.com | ||
Action: sts:AssumeRole | ||
ManagedPolicyArns: | ||
- arn:aws:iam::aws:policy/service-role/AmazonEC2SpotFleetTaggingRole | ||
SecurityGroup: | ||
Type: AWS::EC2::SecurityGroup | ||
Properties: | ||
GroupDescription: EC2 Security Group for instances launched in the VPC by Batch | ||
VpcId: !Ref VPCId | ||
|
||
Outputs: | ||
JobQueueArn: | ||
Value: !Ref JobQueue | ||
JobDefinitionArn: | ||
Value: !Ref AWSCoreTestJob |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters