Repository navigation
POC: tests: e2e: Add a virtual Navigator target - #5014
Draft
joaoantoniocardoso wants to merge 19 commits into
Draft
joaoantoniocardoso wants to merge 19 commits into
joaoantoniocardoso wants to merge 19 commits into
Conversation
…bootstrap The module moves from targets/sil to targets, because a target that runs Docker on its own host uses it too. pull_if_missing takes a platform, and run_bootstrap takes the function that runs a command.
… calls The vehicle tests need to set the serial ports through ardupilot_manager, read and set the flight mode, and restart the autopilot and wait for the new firmware.
…virtual Navigator The GPIO registers are the file the firmware maps as /dev/mem, so the target drives an input pin and reads what the firmware did to an output pin. A serial port is a pseudo terminal that the test owns.
… tests The leak input triggers the leak failsafe, the firmware enables the PCA9685 outputs, a GPS stream on a port set in ardupilot_manager gives a fix, and the firmware comes back after a restart with the simulator still driving it.
The CI builds the arm64 core image of the commit under test and loads it into docker. No registry has that tag.
…ere is no login A fork has no Docker Hub secrets. The login step fails there, and the jobs that need the core image artifacts do not start. The steps that log in, push and inspect the pushed image now run only on a fork with no DOCKER_USERNAME. In the bluerobotics organization they always run, so a missing secret still fails the job. The steps that build and upload the artifacts run as before.
…ommit The test-and-deploy workflow builds an arm64 core image and uploads it as an artifact. The vnav job loads that image. The standalone runs of the vnav workflow keep the registry image.
A 32-bit client on a 64-bit kernel sends the compat ioctls. Their structs have 32-bit pointers, and I2C_FUNCS has a 4 byte answer. The forwarder decodes both layouts. ArduPilot sign extends the 32-bit pointers it puts in the 64-bit fields of spi_ioc_transfer. The kernel truncates them for a compat client, so the forwarder does the same. Add "bench check". It calls each ioctl a client uses and checks the answers. build.sh also builds it as a static 32-bit program, when a 32-bit compiler is there.
A 32-bit process cannot open the regular file that was bound to /dev/mem. The file is longer than 2 GiB, so open fails with EOVERFLOW. A block device has no such limit. Use a loop device on a sparse file. Its node is in /var/lib/vnav and not in /dev, because devtmpfs is mounted noexec and the firmware maps the memory with PROT_EXEC.
E2E_CORE_PLATFORM=linux/arm/v7 pulls the 32-bit core image. Its userland is 32-bit on the 64-bit kernel of the host, which is what BlueOS sees on a Raspberry Pi with a 64-bit kernel and 32-bit Raspberry Pi OS. Then ardupilot_manager reports "navigator" and runs the armhf firmware. The detection test expects the platform of the userland. A new test runs the bus ioctls as a 64-bit and as a 32-bit client. It skips when the host cannot run 32-bit programs.
Add a matrix entry that uses the arm-v7 core image. The ubuntu-24.04-arm runners do not all have a 32-bit mode: Neoverse-N2 CPUs have it and Neoverse-V3 CPUs do not. On a runner without it the entry skips its steps and prints a warning, because a job cannot choose its CPU.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
This is a proof of concept. It holds all the changes in one PR so you can see the full result and give feedback. It is not meant to merge as it is. If the idea is valuable, it will be split into the PRs listed in "Proposed work".
Open questions for reviewers
372f21f6f5. In this POC they live in this repository and CI builds the SITL from them. Some options:What this adds
This PR adds a new e2e target,
vnav: a "virtual Navigator". BlueOS sees a Navigator board, picks the official ArduSubnavigatorfirmware, and runs it unchanged. Behind the Linux I2C and SPI devices, a patched ArduPilot SITL simulates the vehicle and the sensor chips of the Navigator. So the vehicle tests run the real BlueOS core image and the real firmware binary on a GitHububuntu-24.04-armrunner, with no hardware.How it works
Devices:
vnav-forwarder(tests/e2e/targets/vnav/native/vnav-forwarder.c) creates/dev/i2c-*and/dev/spidev*with CUSE. It sends each transfer over TCP to the SITL and returns the answer. It serves 64-bit and 32-bit clients.Chip models: 23 patches on ArduPilot
372f21f6f5(tests/e2e/targets/vnav/sitl/patches/) add a TCP bridge and models of every chip on the Navigator:The env
SITL_VNAV_CHIPSselects the chip set. Each model gives the chip ID, the register map and the mounting rotation of the real board.build.shbuilds the SITL from the pinned commit and the patches. CI keeps the build in a cache.Board detection:
dtlinkgives/proc/device-treeon the ACPI runner, so BlueOS detects a Navigator. A loop device holds the GPIO registers in place of/dev/mem, so the leak input and the PCA9685 output enable can be read and set.Serial port: a pty, assigned with
PUT /serials, carries an NMEA GPS stream.Target:
VnavTarget(tests/e2e/targets/vnav/target.py) starts the forwarder, the SITL, the bootstrap and the core container. It stops only the containers it created.Tests
Vehicle scenarios in
tests/e2e/scenarios/vehicle/. Each skips on a target that does not have theVirtualNavigatorfeature.test_detection.pytest_health.pytest_motion.pytest_gpio.pytest_serial.pytest_reboot.pytest_timing.pyErrL), the loop rate stays above 50 % of 200 Hz, and the barometers stay healthy. The other loop values are logged only.Target tests in
tests/e2e/targets/vnav/: the forwarder ioctls for 64-bit and 32-bit clients, and the bus round trip.tests/e2e/targets/test_docker.pyis a unit test of the sharedhas_platform.CI
.github/workflows/e2e-vnav.ymlruns 3 entries onubuntu-24.04-arm:default: the arm64 core and the stable firmware that BlueOS picks.default-32bit: the arm/v7 core. BlueOS then picks the armhfnavigatorfirmware.alternative: the other chip set (LSM6DSV, IIS2MDC, BMP388), with ArduSub 4.7.2, because Navigator support for the LSM6DSV starts at 4.7.0.test-and-deploy.ymlcalls it as jobe2e-vnav-tests. The job uses the core image thatdeploy-docker-imagesbuilt for the commit, from the build artifacts.Changes to existing code
tests/e2e/targets/sil/docker.pymoves totests/e2e/targets/docker.py. The image pull and the bootstrap start are split into shared functions, which the SIL and vnav targets both use. A real SIL run ofscenarios/core/test_boot.pypassed after the move.tests/e2e/conftest.pyselects the target withE2E_TARGET(defaultsil)..github/workflows/test-and-deploy.yml: on a repository that does not belong toblueroboticsand has noDOCKER_USERNAMEsecret, the Docker Hub login, push and inspect steps skip. The build and artifact steps still run, so the e2e jobs work on forks. Onblueroboticsrepositories these steps run as before.Known limits
ubuntu-24.04-arm(Neoverse-V3) cannot run 32-bit programs. There, thedefault-32bitentry skips its tests, prints a warning, and stays green. A re-run gets a real run.armv7l) is not tested.I2C_SMBUSblock transfers are not served. ArduPilot andi2c-toolsdo not use them.Evidence (fork runs)
e2e-vnav.yml: 3 entries green in 3 runs on the final code: 47559164072, 47559203591, 47559206104.e2e-vnav-tests: 47551743679 (all jobs green; the 32-bit entry loaded the arm/v7 core from the artifact). Run 47556169867 (code before the last test-file move): all jobs green, 25 passed per entry.Proposed work
If the answer to question 1 is yes, this POC becomes a chain of PRs. Sizes are lines added and removed. "To review" leaves out the ArduPilot patches and
uv.lock.targets/docker.py,E2E_TARGET)e2e-vnav.yml)PR 3 is large because of the ArduPilot patches (3,649 lines) and
uv.lock(322 lines). If the patches move out of this repository (question 2), PR 3 drops to about 1,900 lines.Other points for reviewers
test-and-deploy.ymlis independent of the vnav target. It can move to its own PR (PR 1 above).e2e-vnav-testsruns on every PR, push and scheduled run. The timing checks are loose on purpose, so runner noise does not make a PR red.