diff options
author | Michael Abel <75477722+abelikt@users.noreply.github.com> | 2021-11-22 13:44:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-22 13:44:02 +0100 |
commit | a534f4920b6297eece3255846b513718a21bfd08 (patch) | |
tree | ad361db05fe66415494efe60a58d8e57db0afb0b /ci/ci_smoke_test_c8y.sh | |
parent | 7e67ebda4485dad5da927f43fef4b65961a1c28b (diff) |
[CIT-455] Finalize azure roundtrip (#581)
* Checkout changes from CI branch
* Fix typos and switch to main repo
* Add forgotten file
* Add device name to topic
* Add secret to workflow
* Ignore Azure for now
* Extract settings to GH Secrets
* Revert "Ignore Azure for now"
This reverts commit 92b5ec93a437e33ecfb9d027355a080129f447be.
* Use more pythonic way of accessing the environment
* Further review comments and improvements
* Bugfix + run black
* Rename c8y smoketest
* Rewrite get_auth_token
* Rewrite generate_sas_token
Diffstat (limited to 'ci/ci_smoke_test_c8y.sh')
-rwxr-xr-x | ci/ci_smoke_test_c8y.sh | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/ci/ci_smoke_test_c8y.sh b/ci/ci_smoke_test_c8y.sh new file mode 100755 index 00000000..e56a94b3 --- /dev/null +++ b/ci/ci_smoke_test_c8y.sh @@ -0,0 +1,121 @@ +#!/usr/bin/sh + +# Smoke test for Cumulocity +# - Rebuild bridge +# - Publish some values with tedge cli +# - Run a smoke test for c8y smartREST +# - Run a smoke test for c8y Thin Edge JSON + +# This script is intended to be executed by a GitHub self-hosted runner +# on a Raspberry Pi. + +# Command line parameters: +# ci_smoke_test_c8y.sh <timezone> +# Environment variables: +# C8YDEVICE +# C8YUSERNAME +# C8YTENANT +# C8YPASS +# C8YDEVICEID +# EXAMPLEDIR + +# a simple function to append lines to files if not already there +appendtofile() { + STRING=$1 + FILE=$2 + if grep "$STRING" $FILE; then + echo 'line already there'; + else + echo $STRING >> $FILE; + fi +} + +if [ -z $C8YDEVICE ]; then + echo "Error: Please supply your device name as environment variable C8YDEVICE" + exit 1 +else + echo "Your device: HIDDEN" +fi + +if [ -z $C8YDEVICEID ]; then + echo "Error: Please supply your Cumulocity device ID name as environment variable C8YDEVICEID" + exit 1 +else + echo "Your device: HIDDEN" +fi + + +if [ -z $C8YUSERNAME ]; then + echo "Error: Please supply your user name as environment variable C8YUSERNAME" + exit 1 +else + echo "Your user name: HIDDEN" +fi + +if [ -z $C8YTENANT ]; then + echo "Error: Please supply your tenant ID as environment variable C8YTENANT" + exit 1 +else + echo "Your tenant ID: HIDDEN" +fi + +if [ -z $C8YPASS ]; then + echo "Error: Please supply your Cumulocity password environment variable C8YPASS" + exit 1 +else + echo "Your password: HIDDEN" +fi + +if [ -z $EXAMPLEDIR ]; then + echo "Error: Please supply the path to the sawtooth_publisher as EXAMPLEDIR" + exit 1 +else + echo "Your exampledir: $EXAMPLEDIR" +fi + +if [ -z $TEBASEDIR ]; then + echo "Error: Please supply the path to the sawtooth_publisher as TEBASEDIR" + exit 1 +else + echo "Your thin edge base dir: $TEBASEDIR" +fi + +# Adding sbin seems to be necessary for non Raspberry P OS systems as Debian or Ubuntu +PATH=$PATH:/usr/sbin + +echo "Disconnect old bridge" + +# Disconnect - may fail if not there +sudo tedge disconnect c8y + +# From now on exit if a command exits with a non-zero status. +# Commands above are allowed to fail +set -e + +./ci/configure_bridge.sh + +echo "Connect again" +sudo tedge connect c8y + +echo "Start smoke tests" + +# Publish some values +for val in 20 30 20 30; do + tedge mqtt pub c8y/s/us 211,$val + sleep 0.1 +done + +# Wait some seconds until our 10 seconds window is empty again +sleep 12 + +# Uses SmartREST for publishing +./ci/roundtrip_local_to_c8y.py -m REST -pub $EXAMPLEDIR -u $C8YUSERNAME -t $C8YTENANT -id $C8YDEVICEID + +# Wait some seconds until our 10 seconds window is empty again +sleep 12 + +# Uses thin-edge JSON for publishing +./ci/roundtrip_local_to_c8y.py -m JSON -pub $EXAMPLEDIR -u $C8YUSERNAME -t $C8YTENANT -id $C8YDEVICEID + +echo "Disonnect again" +sudo tedge disconnect c8y |