Skip to content

Commit

Permalink
DDS2VAL migration
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbosch committed Feb 1, 2024
1 parent 9174965 commit 7f09909
Show file tree
Hide file tree
Showing 46 changed files with 268 additions and 275 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check_license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
# required to grab the history of the PR
fetch-depth: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,34 @@
# * SPDX-License-Identifier: Apache-2.0
# ********************************************************************************/

name: kuksa_dds_feeder
name: kuksa_dds_provider

on:
push:
branches: [ main ]
pull_request:
paths:
- ".github/workflows/kuksa_dds_feeder.yml"
- "dds2val/**"
workflow_dispatch:

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
check-dds-feeder:
name: "Check DDS feeder"
check-dds-provider:
name: "Check DDS provider"
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Retrieve build binaries
uses: actions/download-artifact@v3
with:
path: ${{github.workspace}}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
Expand All @@ -57,18 +54,18 @@ jobs:
string: ${{ github.repository }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: build linux/amd64 docker image
id: image_build_amd64
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
pull: true
push: false
outputs: |
type=oci,dest=./dds2val_amd64.tar
context: ./dds2val
file: ./dds2val/Dockerfile
context: .
file: ./Dockerfile
build-args: |
TARGETPLATFORM=linux/amd64
tags: ${{ github.sha }}
Expand All @@ -84,14 +81,14 @@ jobs:

- name: build linux/arm64 docker image
id: image_build_arm64
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
pull: true
push: false
outputs: |
type=oci,dest=./dds2val_arm64.tar
context: ./dds2val
file: ./dds2val/Dockerfile
context: .
file: ./Dockerfile
build-args: |
TARGETPLATFORM=linux/arm64
TARGETARCH=arm64
Expand All @@ -100,15 +97,14 @@ jobs:
org.opencontainers.image.source=https://github.com/${{steps.repository-name-adjusted.outputs.lowercase}}
- name: Temporarily save linux/arm64 Docker image
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Container image
path: ${{github.workspace}}/dds2val_arm64.tar
retention-days: 1

- name: Run dds tests
run: |
cd dds2val
# Note - if relying on kuksa-client pre-releases you must use --pre on the line below
pip3 install --no-cache-dir -r requirements/requirements.txt -r requirements/requirements-kml.txt -r requirements/requirements-test.txt
./ddsproviderlib/idls/generate_py_dataclass.sh
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# required to grab the history of the PR
fetch-depth: 0
- uses: actions/setup-python@v3
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- uses: pre-commit/[email protected]
with:
extra_args: --color=always --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}
2 changes: 1 addition & 1 deletion dds2val/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ RUN staticx ddsprovider ddsprovider-exe
# Runner stage, to copy in the virtual environment and the app
FROM scratch

LABEL org.opencontainers.image.source="https://github.com/eclipse/kuksa.val.feeders"
LABEL org.opencontainers.image.source="https://github.com/eclipse-kuksa/kuksa-dds-provider"

LABEL org.opencontainers.image.licenses="APACHE-2.0"

Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt → LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
109 changes: 99 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,105 @@
# Kuksa Feeders
# KUKSA DDS Provider

![kuksa.val Logo](./doc/img/logo.png)

This are data feeders for VSS based systems. The feeders here work with [KUKSA.val](https://github.com/eclipse/kuksa.val)
The KUKSA DDS provider provides data from an DDS middleware/API. For further understanding of the DDS middleware/API see [this](https://www.dds-foundation.org/what-is-dds-3/).
The DDS provider only works with the KUKSA Databroker. The KUKSA C++ Server is not supported.

## How to build

### local build

1. `python3 -m venv env && source env/bin/activate`
2. `pip install -r requirements/requirements.txt`
3. `chmod u+x ddsproviderlib/idls/generate_py_dataclass.sh`
4. `./ddsproviderlib/idls/generate_py_dataclass.sh`

### build image (suggested)

1. `docker build -f Dockerfile --progress=plain --build-arg TARGETPLATFORM=linux/amd64 -t ddsprovider:latest .`

### KML replay

*This requires that you already have created the virtual environment as described in "local build" above*

1. `source env/bin/activate`
2. `pip install -r requirements/requirements-kml.txt`
3. `cd kml && python3 dds_kmlreplay.py directions.kml`

## How to run

Choose from local build or containerization via docker.
These steps are necessary:

1. Run an instance of databroker aka: `docker run -it --rm --net=host ghcr.io/eclipse/kuksa.val/databroker:master`
2. Start the KML replay with an active local python virtual environment (see [KML replay section](#kml-replay))
3. Start the DDS provider with either: `docker run --rm -it --net=host ddsprovider:latest` or with an active local python virtual environment: `python3 ddsprovider.py`

## Configure the DDS provider

Configuration for the DDS provider is solved through setting environment variables. Have a look at the table below.

| Environment variable | default value | description |
| ----------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| VDB_ADDRESS | 127.0.0.1 | Address where to look for KUKSA.val Databroker |
| VDB_PORT | 55555 | On which port the KUKSA.val Databroker is expected. |
| MAPPING_FILE | mapping/latest/mapping.yml | Place of mapping file from DDS to VSS |
| TOKEN | None | JWT token which will get used to authorize to databroker; You can set on linux through `export TOKEN=$(< PATH_TO_kuksa.val/jwt/provide-all.token)` or `export TOKEN=<content of a file>`|
| VDB_ROOT_CA_PATH | None | Path to root CA. If defined the client will attempt to use a secure connection and identify the server using this certificate. |
| VDB_TLS_SERVER_NAME | None | TLS server name, may be needed if addressing a server by IP-name |
| VEHICLEDATABROKER_DAPR_APP_ID | None | DAPR ID for Vehicle App to look for. For more information to Vehicle Apps visit [Velocitas](https://eclipse-velocitas.github.io/velocitas-docs/) |
| DAPR_GRPC_PORT | None | If [DAPR](https://dapr.io/) gets used port of DAPR Sidecar. Overwrites VDB_PORT variable. Deprecated - please use VDB_PORT instead |

## Overall sequence

```mermaid
sequenceDiagram
title DDS on SDV
box LightBlue Container-1
participant databroker
end
dddsprovider -->> databroker : grpc_connect
alt on connection
ddsprovider -->> databroker : register_datapoints
ddsprovider -->> DDS_network : subscribe to topics
ddspublisher1 -->> DDS_network : publish dds message
ddspublisher2 -->> DDS_network : publish dds message
end
box LightBlue Container-2
participant ddspublisher1
end
box LightBlue Container-3
participant ddspublisher2
end
alt on data reception
ddsprovider -->> databroker : update_datapoint
end
```

## How to run the tests

The steps below shows how to run the tests in a virtual python environment.

1. create virtual python environment (`python3 -m venv testEnv && source testEnv/bin/activate && pip install -r requirements/requirements.txt -r requirements/requirements-test.txt -r requirements/requirements-kml.txt`)
2. Enter virtual python environment: `source testEnv/bin/activate`
3. Generate data class: `./ddsproviderlib/idls/generate_py_dataclass.sh`
4. Run tests: `pytest --html=report.html --self-contained-html --cov=. tests/* --cov-report html --cov-report xml`
5. Leave virtual python environment: `deactivate`

## TLS

If connecting to a KUKSA.val Databroker that require a secure connection you must specify which root certificate to
use to identify the Server by the `VDB_ROOT_CA_PATH` variable. If your (test) setup use the KUKSA.val example
certificates you must give [CA.pem](https://github.com/eclipse/kuksa.val/blob/master/kuksa_certificates/CA.pem)
as root CA. The server name must match the name in the certificate provided by KUKSA.val Databroker.
Due to a limitation in the gRPC client, if connecting by IP-address you may need to give a name listed in the certificate
by the `VDB_TLS_SERVER_NAME` variable. The example server certificate lists the names `Server` and `localhost`,
so one of those names needs to be specified if connecting to `127.0.0.1`. An example is shown below:

Name | Description
---- | -----------
[GPS feeder](./gps2val) | GPS data source for KUKSA.val Server and KUKSA.val Databroker
[CAN Provider (DBC feeder)](https://github.com/eclipse-kuksa/kuksa-can-provider) | DBC feeder for for KUKSA.val Server and KUKSA.val Databroker *- NOTE: Moved to new repo!*
[SOME/IP feeder](./someip2val) | SOME/IP feeder for KUKSA.val Databroker
[DDS Provider](./dds2val) | DDS provider for KUKSA.val Databroker
[Replay](./replay) | KUKSA.val Server replay script for previously recorded files, created by providing KUKSA.val Server with `--record` argument
[CSV provider](./csv_provider) | Script to replay VSS signals to KUKSA.val Databroker as defined in a CSV-file
```
VDB_ROOT_CA_PATH=/home/user/kuksa.val/kuksa_certificates/CA.pem VDB_TLS_SERVER_NAME=Server python3 ddsprovider.py
```

## Pre-commit set up
This repository is set up to use [pre-commit](https://pre-commit.com/) hooks.
Expand Down
94 changes: 0 additions & 94 deletions dds2val/README.md

This file was deleted.

38 changes: 0 additions & 38 deletions dds2val/ddsproviderlib/idls/NavSatStatus.idl

This file was deleted.

Loading

0 comments on commit 7f09909

Please sign in to comment.