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.
Python3.8 or higher is required. Please make sure the python3
is appropriate version.
$ python3 --version
Python 3.8.10
Appropriate partitioning and configurations are required. See docs/README.md.
Installation guide is available at docs/INSTALLATION.md.
# with virtualenv activated
python3 -m otaclient
# or
python3 -m otaclient.app
If we install the otaclient to custom directory instead of the default location, we must indicate python the path to the install location.
# 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
# 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
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.
docker-compose -f docker/docker-compose_tests.yml run --rm tester
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> [...]]
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> [...]]
OTA client service is using protobuf interface.
After updating the protobuf files under proto/*.proto
, some operations are required.
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
The whl package for the OTA client user implemented in python should be updated.
-
Edit and update version in proto/VERSION.
-
Build whl as follows:
cd proto make
-
After build, whl file is generated in proto/whl directory.
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.
$ 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
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