blob: 036acfbbbe44600bf5e6afbd95910ab784a62e31 [file] [log] [blame]
Lott, Christopher (cl778h)2407cdc2020-04-29 09:58:37 -04001.. This work is licensed under a Creative Commons Attribution 4.0 International License.
Lott, Christopher (cl778h)ca170d32020-05-12 15:05:59 -04002.. SPDX-License-Identifier: CC-BY-4.0
3.. Copyright (C) 2020 AT&T Intellectual Property
Lott, Christopher (cl778h)2407cdc2020-04-29 09:58:37 -04004
5Developer Guide
6===============
7
Lott, Christopher (cl778h)ca170d32020-05-12 15:05:59 -04008This document explains how to maintain the RIC Xapp framework.
9Information for users of this framework (i.e., Xapp developers) is in the User Guide.
10
Lott, Christopher (cl778h)bbc90282020-05-07 08:39:49 -040011Tech Stack
12----------
13
ehietala12486342022-06-15 12:21:41 +030014The framework requires Python version 3.8 or later, and depends on
Lott, Christopher (cl778h)bbc90282020-05-07 08:39:49 -040015these packages provided by the O-RAN-SC project and third parties:
16
17* msgpack
18* mdclogpy
19* ricsdl
yc999.jang750eb5b2021-06-10 19:04:18 +090020* protobuf
Lott, Christopher (cl778h)bbc90282020-05-07 08:39:49 -040021
Lott, Christopher (cl778h)2407cdc2020-04-29 09:58:37 -040022
23Version bumping the framework
24-----------------------------
25
26This project follows semver. When changes are made, the versions are in:
27
Lott, Christopher (cl778h)bbc90282020-05-07 08:39:49 -040028#. ``docs/release-notes.rst``
29#. ``setup.py``
Lott, Christopher (cl778h)2407cdc2020-04-29 09:58:37 -040030
31Version bumping RMR
32-------------------
33
Lott, Christopher (cl778h)bbc90282020-05-07 08:39:49 -040034These items in this repo must be kept in sync with the RMR version:
35
36#. Dockerfile-Unit-Test
37#. examples/Dockerfile-Ping
38#. examples/Dockerfile-Pong
39#. ``rmr-version.yaml`` controls what version of RMR is installed for
40 unit testing in Jenkins CI
Lott, Christopher (cl778h)2407cdc2020-04-29 09:58:37 -040041
Naman Guptabac18952021-06-03 21:49:17 +053042Registration/Deregistartion of Xapp
43-----------------------------------
44
45For registration and deregistration of Xapp following items need to be defined:
46
47#. CONFIG_FILE_PATH variable as a environment variable in Dockerfile if running
48 Xapp as a docker container or in configmap in case of Xapp as a pod.
49#. Copy the xappConfig.json into the docker image in Dockerfile.
50
ehietala12486342022-06-15 12:21:41 +030051Example Xapp
52------------
53
54Director examples has many examples for creating the xapp having features like:
55* REST subscription interface
56* symptomdata handler
57* rmr send/receive
58* REST healthy and ready response handler
59* REST config handler
60
61List of xapps:
62* ping_xapp.py and ping_xapp.py using RMR to send and receive
63* xapp_symptomdata.py for subscribing the symptomdata event
64* xapp_test.py for both symptomdata, RMR recveice, k8s healthy service and REST subscription
65
66xapp_test.py
67------------
68
69Test xapp can be run by creating the docker container or as standalone process. For testing restserversimu.py
70has been made to emulate the REST subscription request responses and responding the symptomdata dynamic registration
71reponse. When running the xapp_test you need to create the RMR static routing file so that the rmr initialization
72will return (otherwise it will wait for rtmgr connection).
73
74Test xapp has as well the config file in descriptor/config-file.json where your can adjust the local runtime
75environment for subscriptions and symptomdata lwsd service ip address.
76
77Subsciprion interface url has the submgr service endpoint : ``http://service-ricplt-submgr-http.ricplt:8088/``
78Symptomdata registration url set to lwsd service url : ``http://service-ricplt-lwsd-http.ricplt:8080/ric/v1/lwsd``
79
80In case of using restserversimu.py for testing configure your host ip address, for example 192.168.1.122 port 8090:
81
82Subsciprion interface url has the submgr service endpoint : ``http://192.168.1.122:9000/``
83Symptomdata registration url set to lwsd service url : ``http://192.168.1.122:9000/ric/v1/lwsd``
84
85Then start the restserversimu:
86
87export PYTHONPATH=./
88python3 examples/restserversimu.py -port 9000 -address 192.168.1.122
89
90and then the xapp_test:
91
92export PYTHONPATH=./
93export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
94export RMR_SEED_RT=examples/descriptor/xapp-test.rt
95export RMR_SRC_ID="192.168.1.122"
96python3 examples/xapp_test.py -config examples/descriptor/config-file.json -port 8888 -xapp xapp-test -service xapp-test
97
98If you like to implement the kubernetes healthy service responder, you can follow the example how to use the
99xapp_rest.py defined rest hander. Basically you can initiate the REST service listener and add the handlers (examples in
100xapp_tets.py).
101
102Subscription REST interface
103---------------------------
104
105api/xapp_rest_api.yaml defines interface and it has been used to generate the swagger api calls.
106
107Generating the swagger client model:
108docker run --rm -v ${PWD}:/local -u $(id -u ${USER}):$(id -g ${USER}) swaggerapi/swagger-codegen-cli generate -i /local/api/xapp_rest_api.yaml -l python -o /local/out
109
110swagger-codegen-cli generated code result needs to be adjusted to have the ricxappframe prefix.
111Replace the module name to have the ricxappframe prefix:
112
113find ./out/swagger_client -type f -exec sed -i -e 's/swagger_client/ricxappframe\.swagger_client/g' {} \;
114
115Then copy the generated ./out/swagger_client directory to ./ricxappframe/subsclient directory:
116
117cp -r ./out/swagger_client/* ./ricxappframe/subsclient
Lott, Christopher (cl778h)2407cdc2020-04-29 09:58:37 -0400118
119Unit Testing
120------------
121
Lott, Christopher (cl778h)bbc90282020-05-07 08:39:49 -0400122Running the unit tests requires the python packages ``tox`` and ``pytest``.
123
124The RMR library is also required during unit tests. If running directly from tox
125(outside a Docker container), install RMR according to its instructions.
126
127Upon completion, view the test coverage like this:
Lott, Christopher (cl778h)2407cdc2020-04-29 09:58:37 -0400128
129::
130
Lott, Christopher (cl778h)bbc90282020-05-07 08:39:49 -0400131 tox
132 open htmlcov/index.html
133
134Alternatively, if you cannot install RMR locally, you can run the unit
135tests in Docker. This is somewhat less nice because you don't get the
136pretty HTML report on coverage.
137
138::
139
140 docker build --no-cache -f Dockerfile-Unit-Test .