From a534f4920b6297eece3255846b513718a21bfd08 Mon Sep 17 00:00:00 2001 From: Michael Abel <75477722+abelikt@users.noreply.github.com> Date: Mon, 22 Nov 2021 13:44:02 +0100 Subject: [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 --- ci/ci_smoke_test_c8y.sh | 121 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100755 ci/ci_smoke_test_c8y.sh (limited to 'ci/ci_smoke_test_c8y.sh') 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 +# 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 -- cgit v1.2.3