Giter VIP home page Giter VIP logo

autohat's Introduction

Autohat - Automated Hardware Testing

Technology preview

This projects hopes to make it easy to do automated testing of OS images. This test framework is based on robotframework. The included resources should make it easy to write tests in Gherkin.

The resources directory contains Robot Keyword helpers for resincli and hardware specific .robot files. This could be extended to add helpers for other cli tools and hardware. We have included a Dockerfile to setup the environment required to run the example.

Instructions for running the example:

Running with QEMU device type

  • Clone this repo and change your directory to it.

  • Build the autohat container by running the following command:

    docker build -t autohat .

  • Build a resin-qemux86 or resin-qemux86-64 image from https://github.com/resin-os/resin-qemu/

  • Alternatively you can also download an uninitialized resin-qemux86 or resin-qemux86-64 image from resin by executing:

    resin os download qemux86 -o resin.img or

    resin os download qemux86-64 -o resin.img

  • Create a env.list with all the environment variables needed to run the tests - Please check env.list.example for a sample environment file.

    • WARNING! The application name given needs to be unique as the test suite will delete and recreate any existing application and key of the same name in the settings.
  • Load the KVM module

  • Execute the following to run an example test against the resin-qemux86 or resin-qemux86-64 image you just downloaded.

    docker run -it --rm -v <path_to_repo>:/autohat -v /dev/:/dev2 --privileged --env-file ./env.list autohat robot --exitonerror /autohat/qemu.robot

Running with Autohat test rig on connected hardware (Example - Raspberry Pi 3)

  • Clone this repo and change your directory to it.

  • Build the autohat container by running the following command:

    docker build -t autohat .

  • Build the device specific resin image or download an uninitialized image from resin by executing:

    resin os download raspberrypi3 -o resin.img

  • Create a env.list with all the environment variables needed to run the tests - Please check env.list.example for a sample environment file.

    • Please make sure that the rig_device_id, rig_sd_card match your rig's FTDI serial, the SD card path respectively

    • WARNING! The application name given needs to be unique as the test suite will delete and recreate any existing application and key of the same name in the settings.

  • Execute the following to run an example test against the raspberrypi3 image you just downloaded.

    docker run -it --rm -v <path_to_repo>:/autohat -v /dev/:/dev2 --privileged --env-file ./env.list autohat robot --exitonerror /autohat/raspberrypi3.robot

Troubleshooting

Ctrl-A-X to exit QEMU monitor

docker exec -ti {{id-or-name-of-running-autohat-container}} bash

minicom -D unix\#/tmp/console.sock

autohat's People

Contributors

ab77 avatar agherzan avatar alexgg avatar balena-ci avatar balena-renovate[bot] avatar brownjohnf avatar cmfcruz avatar fisehara avatar floion avatar flowzone-app[bot] avatar horia-delicoti avatar jakogut avatar klutchell avatar lekkas avatar lifeeth avatar mikesimos avatar nghiant2710 avatar rcooke-warwick avatar renovate-bot avatar thgreasi avatar villaseca avatar zubairlk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

autohat's Issues

Test that the identification LED is working

Resin CLI has the following command that can be used to trigger the identification LED

resin device identify

  • Will need to abstract GPIO checking in Robot.
  • Will need to figure out how to get GPIO access on a qemu machine.

Automated CI tests?

Looking at #48 (and the way it now sprinkles device_uuid1, device_uuid2 and device_uuid in various places), I wonder if it'd be worth running the Qemu autohat tests on TravisCI? Or would they be too slow / too intensive?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.


โš  Dependency Lookup Warnings โš 

  • Renovate failed to look up the following dependencies: Failed to look up docker package balenalib/${ARCH}-node, Failed to look up docker package balenalib/${ARCH}-python.

Files affected: Dockerfile


This repository currently has no open or pending branches.

Detected dependencies

dockerfile
Dockerfile
  • balenalib/amd64-node 19-bullseye-build
  • balenalib/amd64-python 3-bullseye-build
  • balenalib/amd64-python 3-bullseye-run
github-actions
.github/workflows/flowzone.yml
pip_requirements
requirements.txt
  • robotframework ==6.0.2
  • requests ==2.31.0
  • robotframework-requests ==0.9.4
  • pylibftdi ==0.20.0
regex
Dockerfile
  • balenalib/${ARCH}-node 19-bullseye-build AS cli-build
  • balenalib/${ARCH}-python 3-bullseye-build AS qemu-build
  • balenalib/${ARCH}-python 3-bullseye-run

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

dockerfile
Dockerfile
  • balenalib/aarch64-node 20-bookworm-build
  • balenalib/aarch64-python 3-bookworm-build
  • balenalib/aarch64-python 3-bookworm-run
  • balenalib/amd64-node 20-bookworm-build
  • balenalib/amd64-python 3-bookworm-build
  • balenalib/amd64-python 3-bookworm-run
github-actions
.github/workflows/flowzone.yml
  • product-os/flowzone master
pip_requirements
requirements.txt
  • robotframework ==7.1
  • requests ==2.32.3
  • robotframework-requests ==0.9.7
  • pylibftdi ==0.22.0
regex
Dockerfile
  • balena-io/balena-cli v19.0.10

Test Metrics: Add test case to write and read a 100MB file in /data

This test case would allow us to see trends over time of I/O speeds. Since Robot framework automatically records the execution time of test cases - we could just have two cases one just writing from /dev/null to a 100MB file and one reading from the 100 MB file to /dev/null using dd.

  1. Helps us in predicting a failure of the hardware rig.
  2. Find regressions in kernel configurations causing SDcard I/O slow downs.
  3. Allow us to have a rig to benchmark different SD card speeds.

Resin-Supervisor: test the different update strategies

Test steps:

  • For each of the update strategies:
    • Set a RESIN_SUPERVISOR_UPDATE_STRATEGY config var to the corresponding value
    • Push an update to a running app

Expected result:
The system logs show the corresponding steps (kill, download, start, delete) for the selected strategy are done in the correct order.

Resin-Supervisor: test its API endpoints

For each of the supervisor's API endpoints (docs) hit the endpoint and check response and expected behavior. (Shutdown might be hard to test, but it should be okay if reboot works).

Please ping me for any questions about the expected behavior of the endpoints.

Resin-Supervisor: test disabling logs to display

Valid for any board with Resin OS.
Test steps:

  • Check that the device host OS has a [email protected] that is enabled.
  • Set a RESIN_HOST_LOG_TO_DISPLAY=0 config variable
  • Expected result: the device logs show the change is being applied, the device reboots and the resin-info service is disabled.
  • Change RESIN_HOST_LOG_TO_DISPLAY=1.
  • Expected result: the device logs show the change is being applied, the device reboots and the resin-info service is enabled again.

Resin Supervisor - Adding deltas to a running supervisor

Test Steps:

  1. Add an application-wide RESIN_SUPERVISOR_DELTA = 1 config var. (It is important that the value is 1).
  2. Push an update to the application (e.g. changing what is outputted to the console).

Expected result:

  1. When setting RESIN_SUPERVISOR_DELTA, the device should not restart the app.
  2. The device should download the update correctly after pushing.
  3. Fetching the devices' environment variables should show that "RESIN_SUPERVISOR_DELTA" environment variable is set to 1.

Fingerprint test case doesn't work on 1.X resin images

Naming fingerprint file differs from 1.X to 2.X resin images versions.

On 2.X: RESIN_FINGERPRINT_EXT ?= "fingerprint"
RESIN_FINGERPRINT_FILENAME ?= "resinos"
Source: https://github.com/resin-os/meta-resin/blob/b9bba027aad797c7f9401f2e2d2952a328e900fb/meta-resin-common/classes/image_types_resin.bbclass#L89

On 1.X: echo -n '' > ${WORKDIR}/${RESIN_BOOT_FS_LABEL}.${FINGERPRINT_EXT}
Source: https://github.com/resin-os/meta-resin/blob/1.X/meta-resin-common/classes/image_types_resin.bbclass#L180

ResinCLI - Ensure resin sync works

Ensure the working of -> http://docs.resin.io/tools/cli/#sync-uuid-

  1. Adapt ondevice repo to work with resin sync
  2. Edit server.py in https://github.com/resin-io/autohat-ondevice/blob/master/server.py
    to return "Hello Resin Sync!" when accessed over device URL.
  3. The sync process should start with status messages appearing on each step ('Stopping application container...', 'Syncing..', 'Starting application container...').
  4. At the end of resin sync a "resin sync completed successfully!" message should appear.
  5. The device's Public Device URL should now show the new message, e.g. 'Hello Resin Sync!'

Provision a device into an application with deltas already enabled

Description: Provisioning a device on an app that already has deltas pushed

Test steps Provision a device on the same app used for TC10 (that already has the RESIN_SUPERVISOR_DELTA=1 var and a pushed image).

Expected result The device should appear on the dashboard and correctly download the image for the app. Running a web terminal and running "env" should show the RESIN_SUPERVISOR_DELTA env var set to 1.

Resin-Supervisor: test config.txt changes

To be tested only on the Raspberry Pi family.
Test steps:

  • Set a RESIN_HOST_CONFIG_foo variable
  • Expected result: Logs show the variable is being applied. The device reboots and has a foo variable in config.txt correctly set.
  • Change the variable to a different value.
  • Expected result: same as before, now after the reboot config.txt will show the updated value.
  • Delete the variable
  • Expected result: after reboot, the device no longer shows the foo variable in config.txt

Adding deltas to a running supervisor

Description: A supervisor that is running without deltas starts using them.

Test steps

  • Provision a device
  • Add an application-wide RESIN_SUPERVISOR_DELTA = 1
  • Push an update to the application (e.g. changing what is outputted to the console).

Expected result

  • When setting RESIN_SUPERVISOR_DELTA, the device should not restart the app.
  • The device should download the update correctly after pushing.
  • The containers ENV should have RESIN_SUPERVISOR_DELTA=1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.