Skip to content

Device Sequencer Test Suite #197

Device Sequencer Test Suite

Device Sequencer Test Suite #197

Workflow file for this run

name: Device Sequencer Test Suite
on:
push:
workflow_dispatch:
schedule:
- cron: '0 23 * * *'
concurrency:
group: ci-${{ github.repository }}
cancel-in-progress: true
env:
UDMI_REPO: ${{ vars.UDMI_REPO }}
UDMI_VERSION: ${{ vars.UDMI_VERSION }}
UPDATE_OPTS: ${{ vars.UPDATE_OPTS }}
SITE_MODEL: ${{ vars.SITE_MODEL }}
REFLECTOR_PKCS8_B64: ${{ secrets.REFLECTOR_PKCS8_B64 }}
DEVICE_NAME: ${{ vars.DEVICE_NAME }}
DEVICE_SERIAL: ${{ vars.DEVICE_SERIAL }}
PROJECT_ID: ${{ vars.PROJECT_ID }}
SITE_OPTS: ${{ vars.SITE_OPTS }}
PUBBER_OPTS: ${{ vars.PUBBER_OPTS }}
PUBBER_PKCS8_B64: ${{ secrets.PUBBER_PKCS8_B64 }}
KEYGEN_DEVICE: ${{ vars.KEYGEN_DEVICE }}
SEQUENCER_OPTS: ${{ vars.SEQUENCER_OPTS }}
SEQUENCER_TESTS: ${{ vars.SEQUENCER_TESTS }}
VALIDATOR_OPTS: ${{ vars.VALIDATOR_OPTS }}
VALIDATOR_TIMEOUT: ${{ vars.VALIDATOR_TIMEOUT }}
defaults:
run:
shell: bash -e -c "source ~/udmi/etc/actions_init.sh; source {0}"
jobs:
udmis:
name: Site model actions
runs-on: ubuntu-latest
timeout-minutes: 30
if: vars.UDMI_REPO != ''
steps:
- name: Checkout site model source
uses: actions/checkout@v3
- name: Clone UDMI tools
shell: bash -e {0}
run: |
echo Cloning UDMI tools repo...
[[ -n $UDMI_REPO ]] || (echo UDMI_REPO not defined.; false)
[[ -n $UDMI_VERSION ]] || UDMI_VERSION=$(git rev-parse --abbrev-ref HEAD)
[[ -n $UDMI_VERSION ]] || (echo UDMI_VERSION not defined.; false)
cd $HOME
git clone $UDMI_REPO
cd udmi
echo Switching to UDMI_VERSION $UDMI_VERSION
git switch $UDMI_VERSION
git log -n 1
- name: Perform environment sanity check
run: |
steps to check to see that required env variables are defined.
[[ -n $UDMI_BIN ]] || fail UDMI_BIN not defined.
[[ -n $PROJECT_ID ]] || fail PROJECT_ID not defined.
[[ -n $SITE_MODEL ]] || fail SITE_MODEL not defined.
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Setup UDMI
run: |
steps to setup UDMI tools and dependencies
$UDMI_BIN/setup_base
- name: Setup reflector key
if: env.REFLECTOR_PKCS8_B64 != ''
run: |
steps to setup the UDMI reflector key from environment REFLECTOR_PKCS8_B64.
mkdir -p $SITE_MODEL/reflector/
keyfile=$SITE_MODEL/reflector/rsa_private.pkcs8
echo $REFLECTOR_PKCS8_B64 | tr -d ' \n' | base64 --decode > $keyfile
md5sum $keyfile
- name: Upgrade UDMIS install
if: vars.UPDATE_OPTS != ''
run: |
steps to update GKE udmis k8s install
echo $UDMI_BIN/update_udmis $SITE_MODEL $PROJECT_ID
$UDMI_BIN/update_udmis $SITE_MODEL $PROJECT_ID
- name: Generate device key pair
if: vars.KEYGEN_DEVICE != ''
run: |
steps to generate rsa key pair for device KEYGEN_DEVICE
rm -f $SITE_MODEL/devices/$KEYGEN_DEVICE/rsa_*.*
auth_type=$(jq -r .cloud.auth_type $SITE_MODEL/devices/$KEYGEN_DEVICE/metadata.json)
echo Extracted auth_type $auth_type from device metadata file
echo $UDMI_BIN/keygen $auth_type $SITE_MODEL/devices/$KEYGEN_DEVICE
$UDMI_BIN/keygen $auth_type $SITE_MODEL/devices/$KEYGEN_DEVICE
md5sum $SITE_MODEL/devices/$KEYGEN_DEVICE/rsa_private.pkcs8
- name: Perform registrar complete site run
if: vars.SITE_OPTS != ''
run: |
steps to registrar on the entire site.
md5sum $SITE_MODEL/reflector/rsa_private.pkcs8
echo $UDMI_BIN/registrar $SITE_MODEL $PROJECT_ID $SITE_OPTS
$UDMI_BIN/registrar $SITE_MODEL $PROJECT_ID $SITE_OPTS
- name: Perform registrar device-only run
if: vars.SITE_OPTS == ''
run: |
steps to registrar just the device DEVICE_NAME.
md5sum $SITE_MODEL/reflector/rsa_private.pkcs8
[[ -z DEVICE_NAME ]] && fail DEVICE_NAME not defined.
echo $UDMI_BIN/registrar $SITE_MODEL $PROJECT_ID $DEVICE_NAME
$UDMI_BIN/registrar $SITE_MODEL $PROJECT_ID $DEVICE_NAME
- name: Output of registrar errors
run: |
steps to show a summary of registrar errors.
more $SITE_MODEL/devices/*/out/e* | cat
- name: Startup testing pubber instance
if: vars.PUBBER_OPTS != ''
run: |
steps to run pubber for device DEVICE_NAME, maybe with key from PUBBER_PKCS8_B64.
[[ -z DEVICE_NAME ]] && fail DEVICE_NAME not defined.
[[ -z DEVICE_SERIAL ]] && fail DEVICE_SERIAL not defined.
[[ -n $PUBBER_PKCS8_B64 ]] && $UDMI_BIN/augment_auth $SITE_MODEL $DEVICE_NAME "$PUBBER_PKCS8_B64"
echo $UDMI_BIN/pubber $SITE_MODEL $PROJECT_ID $DEVICE_NAME $DEVICE_SERIAL $PUBBER_OPTS
$UDMI_BIN/pubber $SITE_MODEL $PROJECT_ID $DEVICE_NAME $DEVICE_SERIAL $PUBBER_OPTS > $HOME/pubber.out 2>&1 &
PUBBER_PID=$!
sleep 60 # Wait for connection retries, and supported features file.
$UDMI_BIN/augment_metadata $SITE_MODEL $DEVICE_NAME
more $HOME/pubber.out | cat
[[ -d /proc/$PUBBER_PID ]] || fail pubber instance no longer running
- name: Perform site-wide validator run
if: vars.VALIDATOR_OPTS != ''
run: |
steps to validate all site telemetry.
[[ -n VALIDATOR_TIMEOUT ]] || echo Defaulting VALIDATOR_TIMEOUT to 10m
echo timeout ${VALIDATOR_TIMEOUT:-10m} $UDMI_BIN/validator $SITE_MODEL $PROJECT_ID $VALIDATOR_OPTS
timeout ${VALIDATOR_TIMEOUT:-10m} $UDMI_BIN/validator $SITE_MODEL $PROJECT_ID $VALIDATOR_OPTS || true
- name: Validator results
if: vars.VALIDATOR_OPTS != ''
run: |
more $SITE_MODEL/out/validation_report.json | cat
- name: Perform device sequencer run
if: vars.SEQUENCER_OPTS != ''
run: |
steps to run a complete sequence test on device DEVICE_NAME.
[[ -z DEVICE_NAME ]] && fail DEVICE_NAME not defined.
[[ -z DEVICE_SERIAL ]] && fail DEVICE_SERIAL not defined.
echo $UDMI_BIN/sequencer $SEQUENCER_OPTS $SITE_MODEL $PROJECT_ID $DEVICE_NAME $DEVICE_SERIAL $SEQUENCER_TESTS
$UDMI_BIN/sequencer $SEQUENCER_OPTS $SITE_MODEL $PROJECT_ID $DEVICE_NAME $DEVICE_SERIAL $SEQUENCER_TESTS | tee sequencer.log
cp $SITE_MODEL/out/devices/$DEVICE_NAME/results.md $GITHUB_STEP_SUMMARY
- name: Sequencer results
if: vars.SEQUENCER_OPTS != ''
run: |
steps to show sequencer results.
RESULT_LOG=$SITE_MODEL/out/devices/${DEVICE_NAME}/RESULT.log
sort -k 4 $RESULT_LOG | sponge $RESULT_LOG
more $SITE_MODEL/out/sequencer_${DEVICE_NAME}.json $RESULT_LOG | cat
if [[ -d expected ]]; then
echo
echo ::::::::::::::
echo Checking diff -u expected/sequencer-results_${DEVICE_NAME}.log $RESULT_LOG
diff -u expected/sequencer-results_${DEVICE_NAME}.log $RESULT_LOG
fi
- name: sequence test timing
if: ${{ always() && vars.SEQUENCER_OPTS != '' }}
run: fgrep ' ending test ' sequencer.log
- name: Pubber output log
if: vars.PUBBER_OPTS != ''
run: more $HOME/pubber.out | cat
- name: Create support bundle
if: ${{ always() }}
run: $UDMI_BIN/support
- name: Upload support bundle
uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
if-no-files-found: error
name: udmi-support_${{ github.run_id }}-${{ github.run_attempt }}
path: 'udmi-support_*.tgz'