Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Octogonapus committed Mar 14, 2024
1 parent 2c7972b commit 158836f
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 126 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,29 @@ jobs:
- macOS-latest
arch:
- x64
permissions:
id-token: write # for OIDC
contents: read # to clone
steps:
- uses: actions/checkout@v4

- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}

- uses: julia-actions/cache@v1

- uses: julia-actions/julia-buildpkg@v1

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::533267155197:role/AWSCRT-OIDC
role-session-name: awscrt-test
role-duration-seconds: 3600
aws-region: ${{ env.AWS_DEFAULT_REGION }}

- name: Run regular tests
uses: julia-actions/julia-runtest@v1
env:
Expand All @@ -48,6 +62,7 @@ jobs:
julia -t $NTHREADS test/run_parallel_commands.jl $NTIMES julia -t 2 --project -e 'using Pkg; Pkg.test()'
- uses: julia-actions/julia-processcoverage@v1

- uses: codecov/codecov-action@v4
with:
file: ./lcov.info
Expand All @@ -69,12 +84,16 @@ jobs:
- x64
steps:
- uses: actions/checkout@v4

- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}

- uses: julia-actions/cache@v1

- uses: julia-actions/julia-buildpkg@v1

- run: |
julia --project -e 'import Pkg; Pkg.develop(path=".."); Pkg.instantiate(); Pkg.build();'
MQTT_ENABLED=false julia --project=sysimage -e 'import Pkg; Pkg.instantiate(); Pkg.build(); include(joinpath("sysimage", "build_sysimage.jl")); build()'
Expand Down
6 changes: 4 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
LibAWSCRT = "df7458b6-5204-493f-a0e7-404b4eb72fac"

[compat]
Aqua = "0.8"
AWSCRT_jll = "0.1"
AWS = "1"
Aqua = "0.8"
CEnum = "0.4"
CountDownLatches = "2"
Dates = "1"
Expand All @@ -25,11 +26,12 @@ Test = "1"
julia = "1.9"

[extras]
AWS = "fbe9abb3-538b-5e4e-ba9e-bc94f4f92ebc"
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "Dates", "Documenter", "Random", "Test"]
test = ["AWS", "Aqua", "Dates", "Documenter", "Random", "Test"]
8 changes: 4 additions & 4 deletions test/debug.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ add comments to CRT callbacks that note they block the event loop
# msgs::Vector{Any}
# shadow_callback::Function

# function OOBShadowClient(oob_connection, thing1_name, shadow_name)
# function OOBShadowClient(oob_connection, THING1_name, shadow_name)
# msgs = Any[]
# function shadow_callback(
# shadow_client::ShadowClient,
Expand All @@ -187,7 +187,7 @@ add comments to CRT callbacks that note they block the event loop
# )
# push!(msgs, (; shadow_client, topic, payload, dup, qos, retain))
# end
# return new(ShadowClient(oob_connection, thing1_name, shadow_name), msgs, shadow_callback)
# return new(ShadowClient(oob_connection, THING1_name, shadow_name), msgs, shadow_callback)
# end
# end

Expand Down Expand Up @@ -248,7 +248,7 @@ add comments to CRT callbacks that note they block the event loop

# sf = ShadowFramework(
# connection,
# thing1_name,
# THING1_name,
# shadow_name,
# doc;
# shadow_document_pre_update_callback = pre_update_cb,
Expand All @@ -270,7 +270,7 @@ add comments to CRT callbacks that note they block the event loop
# end

# oobc = new_mqtt_connection()
# oobsc = OOBShadowClient(oobc, thing1_name, shadow_name)
# oobsc = OOBShadowClient(oobc, THING1_name, shadow_name)

# fetch(subscribe(sf)[1])
# sleep(3)
Expand Down
28 changes: 14 additions & 14 deletions test/shadow_client_test.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if !parallel
@testset "unnamed shadow document" begin
connection = new_mqtt_connection()
shadow = ShadowClient(connection, thing1_name, nothing)
shadow = ShadowClient(connection, THING1_name, nothing)

msgs = []
function shadow_callback(
Expand All @@ -20,8 +20,8 @@ if !parallel
fetch(publish(shadow, "/get", "", AWS_MQTT_QOS_AT_LEAST_ONCE)[1])
wait_for(() -> !isempty(msgs))
@test msgs[1][:shadow_client] === shadow
@test msgs[1][:topic] == "\$aws/things/$thing1_name/shadow/get/rejected"
@test msgs[1][:payload] == "{\"code\":404,\"message\":\"No shadow exists with name: '$thing1_name'\"}"
@test msgs[1][:topic] == "\$aws/things/$THING1_name/shadow/get/rejected"
@test msgs[1][:payload] == "{\"code\":404,\"message\":\"No shadow exists with name: '$THING1_name'\"}"
empty!(msgs)

fetch(
Expand All @@ -33,8 +33,8 @@ if !parallel
)[1],
)
wait_for(() -> length(msgs) >= 2)
@test findfirst(it -> it[:topic] == "\$aws/things/$thing1_name/shadow/update/accepted", msgs) !== nothing
@test findfirst(it -> it[:topic] == "\$aws/things/$thing1_name/shadow/update/documents", msgs) !== nothing
@test findfirst(it -> it[:topic] == "\$aws/things/$THING1_name/shadow/update/accepted", msgs) !== nothing
@test findfirst(it -> it[:topic] == "\$aws/things/$THING1_name/shadow/update/documents", msgs) !== nothing
empty!(msgs)

fetch(
Expand All @@ -46,9 +46,9 @@ if !parallel
)[1],
)
wait_for(() -> length(msgs) >= 3)
@test findfirst(it -> it[:topic] == "\$aws/things/$thing1_name/shadow/update/accepted", msgs) !== nothing
@test findfirst(it -> it[:topic] == "\$aws/things/$thing1_name/shadow/update/documents", msgs) !== nothing
let msg = msgs[findfirst(it -> it[:topic] == "\$aws/things/$thing1_name/shadow/update/delta", msgs)]
@test findfirst(it -> it[:topic] == "\$aws/things/$THING1_name/shadow/update/accepted", msgs) !== nothing
@test findfirst(it -> it[:topic] == "\$aws/things/$THING1_name/shadow/update/documents", msgs) !== nothing
let msg = msgs[findfirst(it -> it[:topic] == "\$aws/things/$THING1_name/shadow/update/delta", msgs)]
payload = JSON.parse(msg[:payload])
@test payload["state"]["foo"] == 2
end
Expand All @@ -63,9 +63,9 @@ if !parallel
)[1],
)
wait_for(() -> length(msgs) >= 2)
@test findfirst(it -> it[:topic] == "\$aws/things/$thing1_name/shadow/update/accepted", msgs) !== nothing
@test findfirst(it -> it[:topic] == "\$aws/things/$thing1_name/shadow/update/documents", msgs) !== nothing
@test findfirst(it -> it[:topic] == "\$aws/things/$thing1_name/shadow/update/delta", msgs) === nothing
@test findfirst(it -> it[:topic] == "\$aws/things/$THING1_name/shadow/update/accepted", msgs) !== nothing
@test findfirst(it -> it[:topic] == "\$aws/things/$THING1_name/shadow/update/documents", msgs) !== nothing
@test findfirst(it -> it[:topic] == "\$aws/things/$THING1_name/shadow/update/delta", msgs) === nothing
empty!(msgs)

fetch(
Expand All @@ -77,8 +77,8 @@ if !parallel
)[1],
)
wait_for(() -> length(msgs) >= 2)
@test findfirst(it -> it[:topic] == "\$aws/things/$thing1_name/shadow/update/accepted", msgs) !== nothing
let msg = msgs[findfirst(it -> it[:topic] == "\$aws/things/$thing1_name/shadow/update/documents", msgs)]
@test findfirst(it -> it[:topic] == "\$aws/things/$THING1_name/shadow/update/accepted", msgs) !== nothing
let msg = msgs[findfirst(it -> it[:topic] == "\$aws/things/$THING1_name/shadow/update/documents", msgs)]
payload = JSON.parse(msg[:payload])
@test !haskey(payload["current"]["state"], "desired")
@test haskey(payload["current"]["state"], "reported")
Expand All @@ -87,7 +87,7 @@ if !parallel

fetch(publish(shadow, "/delete", "", AWS_MQTT_QOS_AT_LEAST_ONCE)[1])
wait_for(() -> length(msgs) >= 1)
@test findfirst(it -> it[:topic] == "\$aws/things/$thing1_name/shadow/delete/accepted", msgs) !== nothing
@test findfirst(it -> it[:topic] == "\$aws/things/$THING1_name/shadow/delete/accepted", msgs) !== nothing
empty!(msgs)

fetch(unsubscribe(shadow)[1])
Expand Down
Loading

0 comments on commit 158836f

Please sign in to comment.