From 6f1cffdc8485a527d8502274fb8eeeb9e5af6e09 Mon Sep 17 00:00:00 2001 From: "Lott, Christopher (cl778h)" Date: Tue, 2 Jun 2020 14:12:07 -0400 Subject: [PATCH] Change qp's RMR listen port to 4560 Correct xApp descriptor tag to be rmr-data Issue-ID: RICAPP-111, RICAPP-113 Signed-off-by: Lott, Christopher (cl778h) Change-Id: If069a5250c08bf5c02ffd4fbba24d60d143aef6d --- container-tag.yaml | 2 +- docs/developers-guide.rst | 4 +++- docs/release-notes.rst | 4 ++++ qp/main.py | 29 ++++++++++++++++++++++------- setup.py | 2 +- tests/fixtures/test_local.rt | 4 ++-- tests/test_qp.py | 2 +- xapp-descriptor/config.json | 10 +++++----- 8 files changed, 39 insertions(+), 18 deletions(-) diff --git a/container-tag.yaml b/container-tag.yaml index 48c5b97..e4b3d71 100644 --- a/container-tag.yaml +++ b/container-tag.yaml @@ -1,4 +1,4 @@ # The Jenkins job uses this string for the tag in the image name # for example nexus3.o-ran-sc.org:10004/my-image-name:my-tag --- -tag: 0.0.1 +tag: 0.0.2 diff --git a/docs/developers-guide.rst b/docs/developers-guide.rst index e19c0c0..861336a 100755 --- a/docs/developers-guide.rst +++ b/docs/developers-guide.rst @@ -19,6 +19,7 @@ This project follows semver. When changes are made, update the version strings i #. ``container-tag.yaml`` #. ``docs/release-notes.rst`` #. ``setup.py`` +#. ``xapp-descriptor/config.json`` Testing RMR Healthcheck @@ -30,7 +31,8 @@ to test that the RMR healthcheck is working. docker build -t qpd:latest -f Dockerfile . docker run -d --net=host -e USE_FAKE_SDL=1 qpd:latest - docker exec -it CONTAINER_ID /usr/local/bin/rmr_probe -h 127.0.0.1:4562 + docker exec -it CONTAINER_ID /usr/local/bin/rmr_probe -h 127.0.0.1:4560 + Unit Testing ------------ diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 66e97b9..c0add43 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -10,6 +10,10 @@ All notable changes to this project will be documented in this file. The format is based on `Keep a Changelog `__ and this project adheres to `Semantic Versioning `__. +[0.0.2] - 2020-06-02 +-------------------- +* Change RMR listen port to 4560 (`RICAPP-111 `_) + [0.0.1] - 2020-05-21 -------------------- * Initial mock version (`RICAPP-107 `_) diff --git a/qp/main.py b/qp/main.py index 2074c19..02e493d 100644 --- a/qp/main.py +++ b/qp/main.py @@ -29,34 +29,45 @@ import os from mdclogpy import Logger from ricxappframe.xapp_frame import RMRXapp, rmr - +# pylint: disable=invalid-name qp_xapp = None logger = Logger(name=__name__) def post_init(self): + """ + Function that runs when xapp initialization is complete + """ self.predict_requests = 0 logger.debug("QP xApp started") def qp_default_handler(self, summary, sbuf): + """ + Function that processes messages for which no handler is defined + """ logger.debug("default handler received message type {}".format(summary[rmr.RMR_MS_MSG_TYPE])) # we don't use rts here; free this self.rmr_free(sbuf) def qp_predict_handler(self, summary, sbuf): + """ + Function that processes messages for type 30001 + """ logger.debug("predict handler received message type {}".format(summary[rmr.RMR_MS_MSG_TYPE])) self.predict_requests += 1 # we don't use rts here; free this self.rmr_free(sbuf) # send a mock message - mock_msg = '{ "12345" : { "310-680-200-555001" : [ 2000000 , 1200000 ] , "310-680-200-555002" : [ 800000 , 400000 ] , "310-680-200-555003" : [ 800000 , 400000 ] } }' - ok = self.rmr_send(mock_msg.encode(), 30002) - if ok: + mock_msg = '{ "12345" : { "310-680-200-555001" : [ 2000000 , 1200000 ], '\ + ' "310-680-200-555002" : [ 800000 , 400000 ], '\ + ' "310-680-200-555003" : [ 800000 , 400000 ] } }' + success = self.rmr_send(mock_msg.encode(), 30002) + if success: logger.debug("predict handler: sent message successfully") else: - logger.warn("predict handler: failed to send message") + logger.warning("predict handler: failed to send message") def start(thread=False): @@ -68,7 +79,7 @@ def start(thread=False): logger.debug("QP xApp starting") global qp_xapp fake_sdl = os.environ.get("USE_FAKE_SDL", None) - qp_xapp = RMRXapp(qp_default_handler, post_init=post_init, use_fake_sdl=True if fake_sdl else False) + qp_xapp = RMRXapp(qp_default_handler, rmr_port=4560, post_init=post_init, use_fake_sdl=bool(fake_sdl)) qp_xapp.register_callback(qp_predict_handler, 30001) qp_xapp.run(thread) @@ -78,9 +89,13 @@ def stop(): can only be called if thread=True when started TODO: could we register a signal handler for Docker SIGTERM that calls this? """ + global qp_xapp qp_xapp.stop() def get_stats(): - # hacky for now, will evolve + """ + hacky for now, will evolve + """ + global qp_xapp return {"PredictRequests": qp_xapp.predict_requests} diff --git a/setup.py b/setup.py index 8c7d905..eb58e77 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ from setuptools import setup, find_packages setup( name="qp", - version="0.0.1", + version="0.0.2", packages=find_packages(exclude=["tests.*", "tests"]), description="Quality-of-Service Predictor Xapp for Traffic Steering", url="https://gerrit.o-ran-sc.org/r/admin/repos/ric-app/qp", diff --git a/tests/fixtures/test_local.rt b/tests/fixtures/test_local.rt index 5c66798..6fcafb5 100644 --- a/tests/fixtures/test_local.rt +++ b/tests/fixtures/test_local.rt @@ -1,6 +1,6 @@ # do NOT use localhost, seems unresolved on jenkins VMs newrt|start -mse| 30001 | -1 | 127.0.0.1:4562 # prediction request from QPD to QP -mse| 60001 | -1 | 127.0.0.1:4562 # other message from QPD to QP +mse| 30001 | -1 | 127.0.0.1:4560 # prediction request from QPD to QP +mse| 60001 | -1 | 127.0.0.1:4560 # other message from QPD to QP mse| 30002 | -1 | 127.0.0.1:4563 # prediction response from QP to TS newrt|end diff --git a/tests/test_qp.py b/tests/test_qp.py index 69ca8d5..cf3a960 100644 --- a/tests/test_qp.py +++ b/tests/test_qp.py @@ -52,7 +52,7 @@ def test_rmr_flow(monkeypatch, qpd_to_qp, qp_prediction): expected_result = {} - # define a mock traffic steering xapp + # define a mock traffic steering xapp that listens on 4563 def mock_ts_default_handler(self, summary, sbuf): pass diff --git a/xapp-descriptor/config.json b/xapp-descriptor/config.json index 157951d..76684ec 100644 --- a/xapp-descriptor/config.json +++ b/xapp-descriptor/config.json @@ -1,22 +1,22 @@ { "xapp_name": "qp", - "version": "0.0.1", + "version": "0.0.2", "containers": [ { "name": "qp", "image": { "registry": "nexus3.o-ran-sc.org:10002", "name": "o-ran-sc/ric-app-qp", - "tag": "0.0.1" + "tag": "0.0.2" } } ], "messaging": { "ports": [ { - "name": "rmr-data-in", + "name": "rmr-data", "container": "qp", - "port": 4562, + "port": 4560, "rxMessages": ["TS_QOE_PRED_REQ"], "txMessages": ["TS_QOE_PREDICTION"], "policies": [], @@ -31,7 +31,7 @@ ] }, "rmr": { - "protPort": "tcp:4562", + "protPort": "tcp:4560", "maxSize": 2072, "numWorkers": 1, "rxMessages": ["TS_QOE_PRED_REQ"], -- 2.16.6