Development
This project uses a Docker image to containerize the development environment.
SDK setup
clone the repository
build the SDK image via
./sdk/build.shstart the SDK via
./sdk/run.shIn the SDK, install the image via
pdm install -p yarpc
Testing
While there exist some unit tests for yarpc,
that can be run via yarpc/run_tests.sh,
most of the functionality is tested via behave tests.
The interface definitions in tests/definitions are used
to generate mock, service and client code covering all features
supported by yarpc.
For each supported language, there exists a service that will
connect to the defined client interface and forward the signals,
method calls and properties to its own D-Bus interface.
The behave tests then use the generated mocks to connect to the service and test the interfaces:
Behave Service under test Behave
BackendServiceMock <-> [BackendClient <-> Service ] <-> ClientMock
The interface code can be generated by running tests/generate.sh.
The behave tests can be run via tests/run_tests.sh.
Manual Testing
For manual testing, the BackendServiceMock can also be started manually via pdm run -p tests/python_mocks mock.
The SDK contains d-feet to call D-Bus methods and interact with properties and bustle to monitor signals.
Adding support for a new language
Add language support to the SDK
If the new language needs additional libraries, compilers or other tools, install them in the
sdk/Dockerfile.Run bootstrapping script
Start the SDK and run the
sdk/add_language.shscript and answer the questions.This will create skeleton entries for the new language in
yarpc/languagesfor the generation of the languagetestsfor the service used in the behave teststests/definitionsfor the output to be generatedtests/behave-testsfor the behave tests of this languagedocs/source/chapters/outputsfor the documentation of this language
It will also add the behave tests to the
run_tests.shscript and the CI workflow.Adjust the skeleton entries
Document dependencies (such as the library used for D-Bus) and additional options for the output of your language
Adjust the templates, json schema and
Languageclass for your language (see Language folder)Flesh out the app in
tests/<language>_service, so it can be compiled and started using therun.sh(and optionallybuild.sh) script
Implement the generator
Look at the first not-yet implemented interface in
tests/definitionsImplement the functionality in the templates of your language
Run the
tests/generate.shscriptImplement the D-Bus interface in your service using the generated code, so that the interface of your service mirrors the backend interface it connects to
Run the behave test for the respective interface to check whether it works
Repeat from (a) until all interfaces are implemented
Language folder
Yarpc will automatically load all languages found in the languages folder of its package.
These languages consist of a folder with the same name as the key used for them in the YAML interface
definitions.
The folder contains
The
__init__.pycontaining theLanguageclass TheLanguageclass determines which templates are used for which objects and how the resulting output should be named and the mapping of D-Bus types to types of this language.The
schema.jsonjsonschema for this language. This determines the format of the output for this language. Modify it to add additional keys (e.g. for namespaces or mocks)The templates referenced in the
Languageclass