Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .github/workflows/build_and_test_autosd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

name: Build and Test AutoSD

on:
pull_request:
paths:
- 'autosd/**'
workflow_dispatch:

jobs:
build:
name: build-and-test-autosd
runs-on: ubuntu-latest
defaults:
run:
working-directory: autosd/build

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Bazel
uses: bazel-contrib/setup-bazel@0.9.1

- name: Install System Dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y podman curl qemu-system

- name: Install AIB Tools
run: |
curl -o auto-image-builder.sh "https://gitlab.com/CentOS/automotive/src/automotive-image-builder/-/raw/main/auto-image-builder.sh"
chmod +x auto-image-builder.sh

curl -o automotive-image-runner "https://gitlab.com/CentOS/automotive/src/automotive-image-builder/-/raw/main/automotive-image-runner"
chmod +x automotive-image-runner

- name: Build lola-demo.aib.yml
run: |
sudo ./auto-image-builder.sh build \
--distro autosd10 \
--mode package \
--target qemu \
--export qcow2 \
--define-file vars.yml \
--define-file vars-devel.yml \
lola-demo.aib.yml \
disk.qcow2

sudo chown $(id -u) disk.qcow2

mv disk.qcow2 ../disk.qcow2

- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: Test QEMU image
run: |
sshcmd() {
sshpass -p "$SSH_PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 root@localhost $@
}
./scripts/run_qemu
sshcmd 'cat /etc/os-release'
sleep 10
sshcmd 'bluechictl start agent-qm lola-ipc-sub.service'
sleep 5
sshcmd '/usr/local/bin/lola-ipc-test'
working-directory: ./autosd
env:
SSH_PASSWORD: password
Empty file added autosd/BUILD.bazel
Empty file.
17 changes: 17 additions & 0 deletions autosd/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
module(
name = "score_ri_autosd",
version = "0.0.1",
compatibility_level = 0,
)
6 changes: 6 additions & 0 deletions autosd/build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
_build/
outputs/
auto-image-builder.sh

*.qcow2
*.img
95 changes: 95 additions & 0 deletions autosd/build/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
AutoSD MCO LoLa Demo
====================

## Background and Basic Info

This demo build an AutoSD image using [Automotive-Image-Builder](https://gitlab.com/CentOS/automotive/src/automotive-image-builder).
This image comes pre-populated with the S-core's [communication](https://github.com/eclipse-score/communication) project packaged as RPM in a [COPR](https://copr.fedorainfracloud.org/coprs/pingou/score-playground/) repository as well as the [QM](https://github.com/containers/qm) project.

The image is pre-configured to allow the communication project to send and receive messages within the root partition but also between the root partition and the QM partition.


Some things to know about this demo:
- The RPM packaging, currently, doesn't rely on Bazel. This is something that is being fixed, but in the current stage it is not there yet.
- Baselibs and communication have had to get some patches, some of which have already been sent upstream:
- Missing headers: https://github.com/eclipse-score/communication/pull/64
- Missing headers: https://github.com/eclipse-score/baselibs/pull/19
- Compilation issues on newer GCC + support for Linux ARM64: https://github.com/eclipse-score/baselibs/pull/22
- Fix dangling references and compiler warnings for newer GCC: https://github.com/eclipse-score/communication/pull/68
- Fix Google benchmark main function scope: https://github.com/eclipse-score/communication/pull/67
- Other changes have not yet been sent upstream:
- Add the ability to configure the path where communication opens the shared memory segments: https://github.com/eclipse-score/communication/commit/127a64f07f48e1d69783dc20f217da813115dbe6 (not the final version of this change)

The goal of this last commit is to avoid having to mount the entire `/dev/shm` into the QM partition and instead mount just a subfolder: `/dev/shm/lola_qm`.


## Building It

A linux system is required to build this image but Ubuntu
and an OCI compliant container manager (docker, podman) should be enough.

Download the builder script:

```
$ curl -o auto-image-builder.sh \
"https://gitlab.com/CentOS/automotive/src/automotive-image-builder/-/raw/main/auto-image-builder.sh"
$ chmod +x automotive-image-builder
```

Build a qemu image by running:

```
sudo ./auto-image-builder.sh build \
--define-file vars-devel.yml \
--target qemu \
--export qcow2 \
--distro autosd10 lola-demo.aib.yml \
autosd10-lola-x86_64.qcow2
```

Change the image perms (if needed) since `sudo` was used:

```
sudo chown $(logname) autosd10-lola-x86_64.qcow2
```

## Running/Testing the Demo

You can run the qcow2 image with your qemu tool of choice and login into the image (either directly or over ssh)
with `root / password` (developer access defined by `vars-devel`).

The image contains Systemd service defintions for LoLa, in both host and QM environemnts:

- lola-ipc-sub.service
- lola-ipc-pub.service

They can be used in the same environment or between them, to exemplify its mixed critical orchestration integration.

For example, to run the publisher in the host environment while receiving messages in the QM one:


Start the subscriber in the QM partition:

```
# start the service
podman exec -it qm systemctl start lola-ipc-sub

# check status
podman exec -it qm systemctl status lola-ipc-sub

# get logs
podman exec -it qm journalctl -u lola-ipc-sub.service
```


Start a publisher in the host environment:

```
systemctl start lola-ipc-pub
```

Check the QM process logs again with:

```
podman exec -it qm journalctl -u lola-ipc-sub.service
```
15 changes: 15 additions & 0 deletions autosd/build/files/bluechi-agent-main.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
[bluechi-agent]
NodeName=agent-main
ControllerAddress=unix:path=/run/bluechi/bluechi.sock
15 changes: 15 additions & 0 deletions autosd/build/files/bluechi-agent-qm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
[bluechi-agent]
NodeName=agent-qm
ControllerAddress=unix:path=/run/bluechi/bluechi.sock
26 changes: 26 additions & 0 deletions autosd/build/files/bluechi-controller.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
[bluechi-controller]
ControllerPort=2020
UseTCP=true
UseUDS=true
LogLevel=DEBUG
AllowedNodeNames=agent-main,agent-qm

[node agent-main]
Allowed=true
AllowDependenciesOn=agent-main,agent-qm

[node agent-qm]
Allowed=true
AllowDependenciesOn=agent-main,agent-qm
27 changes: 27 additions & 0 deletions autosd/build/files/lola-ipc-pub.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
[Unit]
Description=LoLa IPC Publisher
After=network.target

[Service]
Type=simple
WorkingDirectory=/usr/share/score-communication/examples/ipc_bridge/etc/
ExecStart=/usr/bin/ipc_bridge_cpp --mode skeleton --num-cycles 5 --cycle-time 1000 --service_instance_manifest mw_com_config.json
Restart=on-failure
RestartSec=5
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

26 changes: 26 additions & 0 deletions autosd/build/files/lola-ipc-sub.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
[Unit]
Requires=bluechi-proxy@agent-main_lola-ipc-pub.service
Description=LoLa IPC Subscriber
After=network.target

[Service]
WorkingDirectory=/usr/share/score-communication/examples/ipc_bridge/etc/
ExecStart=/usr/bin/ipc_bridge_cpp --mode proxy --num-cycles 5 --cycle-time 1000 --service_instance_manifest mw_com_config.json
Restart=on-failure
RestartSec=5
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
40 changes: 40 additions & 0 deletions autosd/build/files/lola-ipc-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
#!/bin/bash
set -e

BOOTSTRAP=${1:-false}
BOOSTRAP=$(echo "${BOOTSTRAP}" | tr '[:upper:]' '[:lower:]')

if [[ "${BOOTSTRAP}" == "true" ]]; then
podman exec -it qm systemctl start lola-ipc-sub.service
systemctl start lola-ipc-pub.service

sleep 60
fi

# check publisher logs
journalctl -u lola-ipc-pub | cat | grep -qE 'Sending sample: [0-9]+'
if [ "$?" -ne "0" ]; then
echo Could not match 'Sending sample: [0-9]+' from lola-ipc-pub.service logs.
exit $?
fi

# check subscriber logs
podman exec -it qm journalctl -u lola-ipc-sub.service | cat | grep -qE 'Received sample: [0-9]+'
if [ "$?" -ne "0" ]; then
echo Could not match 'Received sample: [0-9]+' from lola-ipc-sub.service logs
exit $?
fi

exit 0
21 changes: 21 additions & 0 deletions autosd/build/files/lola-ipc-test.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
[Unit]
Requires=bluechi-proxy@agent-qm_lola-ipc-sub.service
Requires=bluechi-proxy@agent-main_lola-ipc-pub.service
After=proxy@agent-main_lola-ipc-pub.service

[Service]
Type=oneshot
ExecStart=/bin/bash /usr/local/bin/lola-ipc-test
RemainAfterExit=yes
Loading