Skip to content

Commit

Permalink
Merge #21
Browse files Browse the repository at this point in the history
21: Fix array jobs r=mattBrzezinski a=morris25

Submitting an array job yielded 
```
HTTP.ExceptionRequest.StatusError(400, "POST", "/v1/submitjob", HTTP.Messages.Response:
"""
HTTP/1.1 400 Bad Request
Date: Fri, 17 Sep 2021 22:09:44 GMT
Content-Type: application/json
Content-Length: 78
Connection: keep-alive
x-amzn-RequestId: 511cf789-aee3-4162-be47-96d84864ac02
Access-Control-Allow-Origin: *
x-amz-apigw-id: F0_GTHOeIAMFq7w=
Access-Control-Expose-Headers: X-amzn-errortype,X-amzn-requestid,X-amzn-errormessage,X-amzn-trace-id,X-amz-apigw-id,date
X-Amzn-Trace-Id: Root=1-61451228-5ef067776f7562351f5edde5

{"message":"An error occurred during JSON parsing","__type":"ClientException"}""")
```
because an array was used in the parameter block instead of an object. 
This fixes the param structure and fixes the test logic to allow users to manually run the online tests.

Co-authored-by: morris25 <[email protected]>
Co-authored-by: Sam Morrison <[email protected]>
  • Loading branch information
bors[bot] and morris25 authored Sep 20, 2021
2 parents c3caca5 + af80f5f commit d4a1257
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
6 changes: 4 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "AWSBatch"
uuid = "dcae83d4-2881-5875-9d49-e5534165e9c0"
license = "MIT"
authors = ["Invenia Technical Computing"]
version = "2.0.0"
version = "2.0.1"

[deps]
AWS = "fbe9abb3-538b-5e4e-ba9e-bc94f4f92ebc"
Expand All @@ -15,15 +15,17 @@ Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[compat]
AWS = "1"
AWSTools = "2"
AutoHashEquals = "0.2.0"
Memento = "0.7, 0.8, 0.9, 0.10, 0.11, 0.12, 0.13, 1"
Mocking = "0.7"
OrderedCollections = "1.4"
julia = "1"

[extras]
AWSTools = "83bcdc74-1232-581c-948a-f29122bf8259"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["HTTP", "Test"]
test = ["AWSTools", "HTTP", "Test"]
2 changes: 1 addition & 1 deletion src/batch_job.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function submit(
if num_jobs > 1
# https://docs.aws.amazon.com/batch/latest/userguide/array_jobs.html
@assert 2 <= num_jobs <= 10_000
push!(input, "arrayProperties" => ["size" => num_jobs])
push!(input, "arrayProperties" => Dict("size" => num_jobs))
end

debug(logger, "Input: $input")
Expand Down
2 changes: 2 additions & 0 deletions test/resources/batch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,5 @@ Resources:
Outputs:
JobQueueArn:
Value: !Ref JobQueue
JobRoleArn:
Value: !GetAtt JobRole.Arn
5 changes: 5 additions & 0 deletions test/run_batch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ end
apply(patches) do
job = run_batch(; name="example", definition="sleep60", queue="HighPriority")
@test job.id == "24fa2d7a-64c4-49d2-8b47-f8da4fbde8e9"

job = run_batch(;
name="example", definition="sleep60", queue="HighPriority", num_jobs=4
)
@test job.id == "24fa2d7a-64c4-49d2-8b47-f8da4fbde8e9"
end
end

Expand Down
20 changes: 10 additions & 10 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AWS
using AWSTools.CloudFormation: stack_output
using AWSBatch
using Dates
using HTTP: HTTP
Expand All @@ -11,10 +12,6 @@ using AWS.AWSExceptions: AWSException

Mocking.activate()

# need to define these to make sure we don't inadvertently try to talk to AWS
ENV["AWS_ACCESS_KEY_ID"] = ""
ENV["AWS_SECRET_ACCESS_KEY"] = ""

# Controls the running of various tests: "local", "batch"
const TESTS = strip.(split(get(ENV, "TESTS", "local"), r"\s*,\s*"))

Expand Down Expand Up @@ -76,12 +73,15 @@ include("mock.jl")

@testset "AWSBatch.jl" begin
if "local" in TESTS
include("compute_environment.jl")
include("job_queue.jl")
include("log_event.jl")
include("job_state.jl")
include("batch_job.jl")
include("run_batch.jl")
# need to define these to make sure we don't inadvertently try to talk to AWS
withenv("AWS_ACCESS_KEY_ID" => "", "AWS_SECRET_ACCESS_KEY" => "") do
include("compute_environment.jl")
include("job_queue.jl")
include("log_event.jl")
include("job_state.jl")
include("batch_job.jl")
include("run_batch.jl")
end
else
warn(logger, "Skipping \"local\" tests. Set `ENV[\"TESTS\"] = \"local\"` to run.")
end
Expand Down

2 comments on commit d4a1257

@mattBrzezinski
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/45221

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v2.0.1 -m "<description of version>" d4a12578d6e8eda0cf907907f6838fd319e97b86
git push origin v2.0.1

Please sign in to comment.