Skip to content

Commit

Permalink
OTA download test for CI (#14414)
Browse files Browse the repository at this point in the history
A continuous integration test that builds the applications and runs the OTA image download scenario on Linux. The Provider, Requestor and chip-tool logs are saved as artifacts.
  • Loading branch information
mykrupp authored and pull[bot] committed Jan 25, 2024
1 parent 5666989 commit 0dd8800
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 2 deletions.
35 changes: 33 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ concurrency:
jobs:
test_suites_linux:
name: Test Suites - Linux
timeout-minutes: 120
timeout-minutes: 150

strategy:
matrix:
Expand Down Expand Up @@ -95,6 +95,21 @@ jobs:
--all-clusters-app ./out/linux-x64-all-clusters-${BUILD_VARIANT}-test-group/chip-all-clusters-app \
--tv-app ./out/linux-x64-tv-app-${BUILD_VARIANT}/chip-tv-app \
"
- name: Build and run OTA example
timeout-minutes: 30
run: |
rm -rf /tmp/ota/
mkdir -p /tmp/ota/
scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/ota_provider_debug chip_config_network_layer_ble=false
scripts/examples/gn_build_example.sh examples/ota-requestor-app/linux out/ota_requestor_debug chip_config_network_layer_ble=false
scripts/tests/ota_test.sh
- name: Uploading OTA logs
if: always()
uses: actions/upload-artifact@v2
with:
name: OTA,Linux-Examples,${{ env.GH_EVENT_PR }},${{ env.GH_EVENT_HASH }},${{ env.GH_EVENT_PARENT }},${{ github.event_name }}
path: |
/tmp/ota/
- name: Uploading core files
uses: actions/upload-artifact@v2
if: ${{ failure() }} && ${{ !env.ACT }}
Expand All @@ -115,7 +130,7 @@ jobs:
retention-days: 5
test_suites_darwin:
name: Test Suites - Darwin
timeout-minutes: 120
timeout-minutes: 150

strategy:
matrix:
Expand Down Expand Up @@ -185,6 +200,22 @@ jobs:
--iterations 1 \
--all-clusters-app ./out/darwin-x64-all-clusters-${BUILD_VARIANT}/chip-all-clusters-app \
"
- name: Build and run OTA example
timeout-minutes: 30
run: |
brew install openssl pkg-config coreutils
rm -rf /tmp/ota/
mkdir -p /tmp/ota/
scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/ota_provider_debug chip_config_network_layer_ble=false
scripts/examples/gn_build_example.sh examples/ota-requestor-app/linux out/ota_requestor_debug chip_config_network_layer_ble=false
scripts/tests/ota_test.sh
- name: Uploading OTA logs
if: always()
uses: actions/upload-artifact@v2
with:
name: OTA,Darwin-Examples,${{ env.GH_EVENT_PR }},${{ env.GH_EVENT_HASH }},${{ env.GH_EVENT_PARENT }},${{ github.event_name }}
path: |
/tmp/ota/
- name: Uploading core files
uses: actions/upload-artifact@v2
if: ${{ failure() }} && ${{ !env.ACT }}
Expand Down
64 changes: 64 additions & 0 deletions scripts/tests/ota_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env bash

PASSCODE=${1:-20202021}
DISCRIMINATOR=${2:-42}
UDP_PORT=${3:-5560}

pkill chip-ota-provider-app
pkill chip-ota-requestor-app

scripts/examples/gn_build_example.sh examples/chip-tool out/

touch my-firmware.bin

rm /tmp/chip_*

./src/app/ota_image_tool.py create -v 0xDEAD -p 0xBEEF -vn 1 -vs "1.0" -da sha256 my-firmware.bin my-firmware.ota

if [ ! -f "my-firmware.ota" ]; then
exit 1
fi

./out/ota_provider_debug/chip-ota-provider-app -f my-firmware.ota | tee /tmp/ota/provider-log.txt &
provider_pid=$!

echo "Commissioning Provider"

./out/chip-tool pairing onnetwork 1 "$PASSCODE" | tee /tmp/ota/chip-tool-commission-provider.txt
if grep "Device commissioning completed with success" /tmp/ota/chip-tool-commission-provider.txt; then
echo Provider Commissioned
else
echo Provider not commissioned properly
fi

./out/chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [112233], "targets": null}, {"fabricIndex": 1, "privilege": 3, "authMode": 2, "subjects": null, "targets": null}]' 1 0

stdbuf -o0 ./out/ota_requestor_debug/chip-ota-requestor-app --discriminator "$DISCRIMINATOR" --secured-device-port "$UDP_PORT" --KVS /tmp/chip_kvs_requestor | tee /tmp/ota/requestor-log.txt &
requestor_pid=$!

echo "Commissioning Requestor"

./out/chip-tool pairing onnetwork-long 2 "$PASSCODE" "$DISCRIMINATOR" | tee /tmp/ota/chip-tool-commission-requestor.txt

if grep "Device commissioning completed with success" /tmp/ota/chip-tool-commission-requestor.txt; then
echo Requestor Commissioned
else
echo Requestor not commissioned properly
fi

echo "Sending announce-ota-provider"

./out/chip-tool otasoftwareupdaterequestor announce-ota-provider 1 0 0 0 2 0 | tee /tmp/ota/chip-tool-announce-ota.txt

timeout 30 grep -q "OTA image downloaded to" <(tail -n0 -f /tmp/ota/requestor-log.txt)

echo "Exiting, logs are in tmp/ota/"

kill "$provider_pid"
kill "$requestor_pid"

if grep "OTA image downloaded to" /tmp/ota/requestor-log.txt; then
echo Test passed && exit 0
else
echo Test failed && exit 1
fi

0 comments on commit 0dd8800

Please sign in to comment.