This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Automated Tests

Eclipse Leda is using the Robot Framework for black box tests and system tests.

The black box tests are supposed to only use public API from SDV components, for example the MQTT interface of the Self Update Agent. The system tests are supposed to test on Leda Distro level and can use shell and SSH commands to verify system behavior, e.g. performing a reboot.

Leda Tests Docker Compose Setup Overview

  1. Test Execution: an external trigger, such as the ./test-docker.sh shell script, starts the leda-tests container.
  2. Docker Compose ensures that the needed containers are built and started. The test cases and test resources are copied into the leda-tests container at build time.
  3. The Robot process is started and performs the execution of all test cases
  4. Black box test cases use the MQTT interface to connect to the test target and publish messages
  5. System level test cases use SSH to connect to the test target and execute commands
  6. Test reports are written to a mounted volume, so that they are available on the host for further processing

Run the tests

The easiest way to run the test cases is to run it in the Docker Compose setup:

  1. Clone the leda-distro repository:

     git clone https://github.com/eclipse-leda/leda-distro
    
  2. Optional: Build both images (qemuarm64 and qemux86-64) using kas / BitBake. If you omit this step, docker compose will download the latest container images from the Eclipse Leda Container Registry on ghcr.io.

     kas build kas/leda-qemux86-64.yml
     kas build kas/leda-qemuarm64.yml
    
  3. Switch to the docker-snapshot directory:

     cd resources/docker-snapshot/
    
  4. Run the Leda Tests

     ./test-docker.sh
    

Test Reports

The output of test-docker.sh will show the test results from Robot.

The test reports and debug logs are available on the host’s filesystem in the path resources/docker-snapshot/leda-tests-reports

  • output.xml - The main Robot output report
  • report.html - A Robot HTML summary report
  • leda-tests-xunit.xml - A xUnit report file suitable for rendering with various tools
  • log.html - A Robot HTML report with the test execution log
  • leda-tests-debug.log - Debug log file of the test execution, helpful during implementation of test cases and troubleshooting of failed tests

The xunit report is being used to visualize the test execution results in the GitHub Workflow:

Example Test Report:

GitHub Leda Tests Robot Report

Adding new tests

The tests are located in the following locations of the leda-distro repository:

  • resources/docker-snapshot/dockerfiles/leda-tests - Robot Tests which are executed inside of a Docker Compose setup
  • tests/src/robot - Robot Tests which can be executed on the build host with a Leda Runqemu instance running

General steps are:

  1. Decide whether to implement a system-level test or a black-box integration test
  2. Add the test case to an existing, matching .robot file. If no matching test suite can be found, create a new .robot file. Prefix with the order number, e.g. 33__my-new-test.robot
  3. Check if a refactoring of new keywords may be worthwhile for better reusability.

1 - Robot Keywords

In the Leda Robot Tests, keywords are used for reusable functionality. Common keywords are defined in resources/docker-snapshot/dockerfiles/leda-tests/leda_keywords.resource

The goal is to treat the Leda Quickstart image as a black box, utilizing as much as possible with public APIs.

Interaction with Self Update Agent

  • Trigger to start update: Send a “Desired State Request” to the target, to install a RAUC Update Bundle
  • Connect and Subscribe to Listen: Wait for the asynchronous messages which indicate a successful installation of an update

Arbitrary Commands

Nevertheless, during implementation of test cases, it may be necessary to execute lower level processes for system level tests. For that, a fallback is possible to execute arbitrary test commands via remote SSH connection. These commands are executed through another docker container running in the same Docker network (leda-network) and allow access to the target QEMU instances:

  • Leda Execute: Execute an arbitrary shell command via SSH on the test target

2 - Rust Tests

Note: The Rust tests are being replaced with test cases implemented in Robot.

Cross Compiling to X86_64 on Ubuntu 20.04

There is currently a step to cross-compile tests to X86_64. In order to successfully run the step, you need to make sure that the following artifacts are available on the runner:

You may restart your current shell so that all components are available as env vars.