Skip to content

Add end-to-end integration test framework with first feature tests. - #359

Open
mattday-etas wants to merge 1 commit into
eclipse-score:mainfrom
etas-contrib:e2e-time-integration-tests-1
Open

mattday-etas wants to merge 1 commit into
eclipse-score:mainfrom
etas-contrib:e2e-time-integration-tests-1

Conversation

@mattday-etas

@mattday-etas mattday-etas commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Part 1 of 2. Followed by #360.

What this adds

A framework that runs the real time_slave and time_daemon binaries together in a QEMU VM. A software gPTP grandmaster on the host feeds them time, and the tests read vehicle time and notifications back through the public score::time client API. The existing unit tests cover single classes, and this checks the feature requirements on the whole stack.

  • Framework (score/tests/common/): the Bazel macro qemu_itf_tests(), the pytest fixtures and helpers, a Python gPTP grandmaster with fault injection, the vehicle_time_probe C++ client, target images for Linux x86_64 (ITF Ubuntu image) and QNX aarch64, and known_issues.py (see below).
  • Tests (score/tests/feature/): test_clocks, test_startup, test_synchronization. They are a deliberately small set of happy-path tests that exercise the whole framework.
  • CI: .github/workflows/e2e-tests.yml runs the Linux x86_64 feature target.
  • Docs: docs/module/manuals/integration_tests.rst. It covers the architecture, fixtures, known issues, running and troubleshooting.
  • Build: .bazelrc and MODULE.bazel additions, and tools/qemu/setup_qemu_host.sh.

The remaining feature tests and the component tests come in #360. Their BUILD files glob test_*.py, so that PR needs no build changes.

Design notes

  • Real binaries, no mocks. These are end-to-end integration tests, and as such, are significantly slower than unit tests.
  • The grandmaster time is host CLOCK_REALTIME plus a fixed 1 h offset. This means a result that merely echoes the guest's own clock can't pass.
  • The probe is a separate C++ binary printing JSON. It's deployed to the guest and sampled over SSH. ProbeStream samples it every 20 ms, so short-lived states (such as a time-jump flag clearing after two Syncs) are visible.
  • --config=qemu runs under run_under_qemu. That creates a private user and network namespace with its own tap0, so no sudo or host tap device is needed.
  • The tests are tagged manual. They need KVM and CAP_NET_RAW, so they stay out of //score/... and are named explicitly in CI.
  • Tests are written against the requirements, not the current behaviour. Where the implementation has a known defect, the test carries an xfail marker from known_issues.py, which is the only place markers are defined.
    • strict=True is for deterministic defects. The test fails when the defect is fixed, which reminds whoever fixes it to remove the marker.
    • strict=False is for platform-dependent failures, mainly software timestamp jitter on the virtio NIC, which has no hardware timestamps.
    • Each marker links its GitHub issue and fixing PR where there is one. This PR contains only the markers its three tests use.
  • A session fixture checks the host clock. It stops the run if CLOCK_MONOTONIC and CLOCK_MONOTONIC_RAW differ by more than 0.5 %. A slewed host clock (seen on WSL2 with systemd-timesyncd) would otherwise cause confusing drift failures. --test_arg=--skip-host-clock-check bypasses it.

How to run the tests

Prerequisites: Run tools/qemu/setup_qemu_host.sh from the devcontainer to install QEMU and add your user to the kvm group. Unless you log out and back in, you must then prefix commands with sg kvm -c '...'. You may also need sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 for the user namespace (CI does the same). If running under WSL, the timesync daemon can unnecessarily interfere with the clock in some circumstances, and cause tests to fail. It can be disabled with sudo systemctl disable --now systemd-timesyncd.

Example command:

sg kvm -c 'bazel test --config=x86_64-linux --config=qemu --test_output=streamed \
    //score/tests/feature:test_feature_qemu_linux_x86_64'

Useful extras: --test_arg=-k --test_arg=startup runs a subset, and --nocache_test_results forces a rerun. The log is at bazel-testlogs/score/tests/feature/<target>/test.log.

The QNX target (--config=arm64-qnx --config=qemu, target suffix _qnx_aarch64) needs the QNX SDP toolchain and licence. It is emulated, so it's slow, and CI doesn't run it.

Timing: The tests take about 3 minutes on Linux x86_64 (KVM), including the VM boot, assuming a cached build. The QNX aarch64 target is emulated without KVM, so it is slower, at around 5 minutes.

Review tips

Start with docs/module/manuals/integration_tests.rst, then common/fixtures.py and common/qemu_tests.bzl. gptp_grandmaster.py and helpers.py are the bulk of the lines.

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run //:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Extracting Bazel installation...
Starting local Bazel server (8.8.2) and connecting to it...
INFO: Invocation ID: b4060f29-24fb-4514-a4f5-78fecdb6a206
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
WARNING: For repository 'nlohmann_json', the root module requires module version nlohmann_json@3.11.3, but got nlohmann_json@3.12.0.bcr.1 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Loading: 
Loading: 2 packages loaded
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
WARNING: Target pattern parsing failed.
ERROR: Skipping '//:license-check': no such target '//:license-check': target 'license-check' not declared in package '' defined by /home/runner/work/time/time/BUILD
ERROR: no such target '//:license-check': target 'license-check' not declared in package '' defined by /home/runner/work/time/time/BUILD
INFO: Elapsed time: 16.552s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Quality pack traceability report for this pull request:

Status: PASS (workflow run)

Traceability gate input: /home/runner/work/time/time/_build/metrics.json
------------------------------------------------------------------------
[comp_req]
  Requirements with source links: 40/58 (68.97%)
  Requirements with test links:   5/58 (8.62%)
  Requirements fully linked:      5/58 (8.62%)
  Tests linked to requirements:   8/490 (1.63%)
  Broken test references:         0
------------------------------------------------------------------------
Threshold check passed.

@github-actions

Copy link
Copy Markdown
Contributor

Documentation preview for this pull request is available at:
pr-359: https://eclipse-score.github.io/time/pr-359/

Introduces the QEMU-based end-to-end test framework (Linux x86_64 and QNX
aarch64 targets), the software gPTP grandmaster, the vehicle time probe,
the known-issue xfail markers, the documentation and the GitHub Actions
workflow, together with a first set of feature tests: clocks, startup and
synchronization.
@mattday-etas
mattday-etas force-pushed the e2e-time-integration-tests-1 branch from 3479208 to 0fb4e8f Compare November 25, 2026 17:41
@mattday-etas
mattday-etas marked this pull request as ready for review November 26, 2026 17:20

This branch is waiting to be deployed

1 waiting deployment
workflow-approval — 0fb4e8fb Waiting Nov 25, 2026 by mattday-etas via qnx-build (x86_64-qnx) / approval #1421
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant