-
Notifications
You must be signed in to change notification settings - Fork 60
Sequencer tests for OTA blob updates #1281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
a7f7fb1
Enable ota blob updates in pubber
khyatimahendru dfa0f86
Fix typo
khyatimahendru 27045fa
Fix CI job
khyatimahendru fc19ade
Fix failing tests
khyatimahendru 810075f
Sequencer tests for OTA blob updates
khyatimahendru 8bf8bbd
Add sequencer golden files
khyatimahendru c117632
remove redundant pubber flag
khyatimahendru ee337df
More tests for OTA updates
khyatimahendru 415387d
Merge branch 'master' into ota-updates
khyatimahendru 263c1c0
Add missing import
khyatimahendru 3d2b354
Fix pubber build
khyatimahendru 5d7e09b
Fix validator build
khyatimahendru 266e2a7
Fix schema tests
khyatimahendru 53de1c4
Fix pubber build
khyatimahendru 4401506
Fix OTA updates test script
khyatimahendru 2edd259
Rename blob update target and fix validator build
khyatimahendru 9181ae8
Restore golden files
khyatimahendru a9aa0b8
Restore golden files
khyatimahendru 84039aa
Cleanup
khyatimahendru 93eadbb
Fix validator and pubber builds
khyatimahendru 9b93182
Fix gencode and schemas test
khyatimahendru f31b902
Add golden files for sequencer tests
khyatimahendru fa365e2
Add golden files for itemized tests
khyatimahendru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,108 @@ | ||
| #!/bin/bash -e | ||
|
|
||
| ROOT_DIR=$(realpath $(dirname $0)/..) | ||
| cd $ROOT_DIR | ||
|
|
||
| if [[ $# != 1 ]]; then | ||
| echo Usage: $0 PROJECT_SPEC | ||
| false | ||
| fi | ||
|
|
||
| project_spec=$1 | ||
| shift | ||
|
|
||
| function log { | ||
| $ROOT_DIR/bin/timestamp $@ | ||
| } | ||
|
|
||
| function fail { | ||
| $ROOT_DIR/bin/timestamp $@ | ||
| false | ||
| } | ||
|
|
||
| site_path=sites/udmi_site_model | ||
| device_id=AHU-1 | ||
| serial_no=sequencer-$RANDOM | ||
|
|
||
| # Use tag v2 for OTA update | ||
| target_commit="v2" | ||
|
|
||
| mkdir -p out/ | ||
|
|
||
| rm -f out/pubber.log.* | ||
| rm -f out/blobs.json | ||
| pubber_log=out/pubber.log.${serial_no} | ||
|
|
||
| log "Starting pubber with serial $serial_no..." | ||
| bin/pubber $site_path $project_spec $device_id $serial_no > $pubber_log 2>&1 & | ||
| pubber_pid=$! | ||
|
|
||
| log "Waiting for pubber to start..." | ||
| sleep 20 | ||
|
|
||
| log "Target commit for update: $target_commit" | ||
|
|
||
| log "Generating OTA config..." | ||
| base64_payload=$(echo -n $target_commit | base64 -w 0) | ||
| sha256_payload=$(echo -n $target_commit | openssl sha256 | awk '{print $2}') | ||
| generation_payload=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | ||
|
|
||
| cat <<EOF > out/blobs.json | ||
| { | ||
| "blobset": { | ||
| "blobs": { | ||
| "pubber_module": { | ||
| "phase": "final", | ||
| "url": "data:application/json;base64,$base64_payload", | ||
| "sha256": "$sha256_payload", | ||
| "generation": "$generation_payload" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| EOF | ||
|
|
||
| out_base=$site_path/devices/$device_id/out | ||
| config_base=$site_path/devices/$device_id/config | ||
| mkdir -p $config_base | ||
|
|
||
| rm -f $config_base/ota_config.json | ||
|
|
||
| if [ -f $out_base/generated_config.json ]; then | ||
| jq -s '.[0] * .[1]' $out_base/generated_config.json out/blobs.json > $config_base/ota_config.json | ||
| else | ||
| cp out/blobs.json $config_base/ota_config.json | ||
| fi | ||
|
|
||
| log "Applying update config..." | ||
| bin/reset_config $site_path $project_spec $device_id ota_config.json | ||
|
|
||
| log "Waiting for pubber to process update..." | ||
| sleep 20 | ||
|
|
||
| log "Verifying logs..." | ||
| if grep -q "Triggering mock OTA update to commit $target_commit" $pubber_log; then | ||
| log "Update trigger detected." | ||
| else | ||
| fail "Update trigger NOT detected." | ||
| fi | ||
|
|
||
| # Wait for update to complete and state to propagate | ||
| sleep 20 | ||
|
|
||
| if grep -q "Mock OTA update completed successfully" $pubber_log; then | ||
| log "OTA success detected." | ||
| else | ||
| fail "OTA success NOT detected." | ||
| fi | ||
|
|
||
| if jq -e --arg gen "$generation_payload" '.blobset.blobs.pubber_module.phase == "final" and .blobset.blobs.pubber_module.generation == $gen' pubber/out/state.json > /dev/null; then | ||
| log "Blob state phase: FINAL verified in state" | ||
| else | ||
| fail "Blob state phase: FINAL NOT found in state" | ||
| fi | ||
|
|
||
| log "OTA updates test passed!" | ||
|
|
||
| echo Cleaning up pubber background process... | ||
| kill $pubber_pid |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -58,6 +58,13 @@ could be used with a **WARNING** level for a warning case during normal operatio | |
| * _blob_: Conditions specific to an individual blob | ||
| * _receive_: (**DEBUG**) About receiving a blob update | ||
| * _fetch_: (**DEBUG**) Fetching a blob update | ||
| * _success_: (**DEBUG**) Successfully fetched a blob | ||
| * _failure_: (**ERROR**) Blob fetch failed | ||
| * _verify_: Verifying a blob | ||
| * _parse_: (**ERROR**) Error parsing blob | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. some kind of INFO level for logging? These categories aren't just error states, but also logging. Not totally consistent, but something to at least pretend we understand. |
||
| * _hash_: (**ERROR**) Blob hash mismatch | ||
| * _incompatible_: (**ERROR**) Blob is incompatible with the device | ||
| * _dependency_: (**ERROR**) Expected software dependencies not found | ||
| * _apply_: (**NOTICE**) Applying a blob update | ||
| * _validation_: Handling validation pipeline messages | ||
| * _device_: Conditions specific to processing a given device message. | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
INFO?