Skip to content

Latest commit

 

History

History
167 lines (112 loc) · 4.51 KB

DEVELOPMENT.md

File metadata and controls

167 lines (112 loc) · 4.51 KB

OTA client development

THIS DOCUMENT IS FOR INTERNAL DEVELOPER ONLY.

This document describes how to run and test OTA client and how to maintain the repository. In this document, Ubuntu 20.04 is used for both running and development environment.

Python version

Python3.8 or higher is required. Please make sure the python3 is appropriate version.

$ python3 --version
Python 3.8.10

How to run OTA client on the target ECU

Appropriate partitioning and configurations are required. See docs/README.md.

Installation guide is available at docs/INSTALLATION.md.

Run otaclient directly

# with virtualenv activated
python3 -m otaclient
# or
python3 -m otaclient.app

Run otaclient installed at custom location

If we install the otaclient to custom directory instead of the default location, we must indicate python the path to the install location.

method 1: indicate path by PYTHONPATH

# we have to append the /opt/ota to the PYTHONPATH, to tell the
# python interpreter to search otaclient package under /opt/ota, instead of
# using the one install under <virtualenv>/lib/python3.8/site-packages

# with venv activated:
PYTHONPATH=/opt/ota python3 -m otaclient
# or
PYTHONPATH=/opt/ota python3 -m otaclient.app

method 2: change working dir to the install location

# change work dir to /opt/ota
cd /opt/ota

# with venv activated:
# NOTE:python will insert current working dir at index 0 in `sys.path`
# under /opt/ota folder, so that python will first use otaclient under /opt/ota
python3 -m otaclient
# or
python3 -m otaclient.app

How to test OTA client on the development PC

Build the image for testing

Build the ota-test_base image for running tests under a container as follow:

docker-compose -f docker/docker-compose_tests.yml build

This ota-test_base image contains a copy of pre-build minimum ota-image under /ota-image folder, and pre-installed dependencies needed for running and testing OTA client.

Run all tests at once

docker-compose -f docker/docker-compose_tests.yml run --rm tester

Run specific tests manually by override the command

Directly execute pytest is also possible by override the command:

docker-compose -f docker/docker-compose_tests.yml run --rm tester \
   python3 -m pytest /ota-client/tests/<specific_test_file> [<test_file_2> [...]]

Run specific tests manually by dropping to bash shell

Directly drop to bash shell in the test base container as follow:

docker-compose -f docker/docker-compose_tests.yml run --rm tester bash

And then run specific tests as you want:

# inside the container
python3 -m pytest /ota-client/tests/<specific_test_file> [<test_file_2> [...]]

How to update protobuf

OTA client service is using protobuf interface. After updating the protobuf files under proto/*.proto, some operations are required.

Updating otaclient/app/proto/otaclient_v2_pb2*py

The protobuf definition for python implementation under otaclient/app/proto directory should be updated.

python3 -m grpc_tools.protoc -I./proto --python_out=app --grpc_python_out=app ./proto/otaclient_v2.proto

Updating protobuf whl

The whl package for the OTA client user implemented in python should be updated.

How to build protobuf whl

  1. Edit and update version in proto/VERSION.

  2. Build whl as follows:

    cd proto
    make
  3. After build, whl file is generated in proto/whl directory.

How to install protobuf whl

You can install protobuf whl with pip command.

python3 -m pip install https://raw.githubusercontent.com/tier4/ota-client/main/proto/whl/otaclient_pb2-xxxxx-py3-none-any.whl

If you're using requirement.txt, add the following line into the requirements.txt.

https://raw.githubusercontent.com/tier4/ota-client/main/proto/whl/otaclient_pb2-xxxxx-py3-none-any.whl

Note that xxxxx above should be replaced by the actual file name.

How to import protobuf package

$ python3
Python 3.8.10 (default, Nov 26 2021, 20:14:08)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from otaclient_pb2.v2 import otaclient_pb2
>>> from otaclient_pb2.v2 import otaclient_pb2_grpc

Updating docs/SERVICES.md

The protobuf document docs/SERVICES.md should be updated by protoc-gen-doc tool.

docker run --rm -v $(pwd)/docs:/out -v $(pwd)/proto:/protos pseudomuto/protoc-gen-doc --doc_opt=markdown,SERVICES.md