From 4f40776f7c16650f1a65b0f583a2b9ccf7229562 Mon Sep 17 00:00:00 2001 From: "Lott, Christopher (cl778h)" Date: Fri, 22 May 2020 15:35:14 -0400 Subject: [PATCH] Revise static route table to support testing Correct typo in xapp descriptor for txMessages Issue-ID: RICAPP-108 Signed-off-by: Lott, Christopher (cl778h) Change-Id: I75af5a2cff460d5f6d29efb8fbc41820051bff03 --- .gitattributes | 21 +++++++++++++++++++++ .gitreview | 13 ++++++------- container-tag.yaml | 2 +- docs/release-notes.rst | 5 +++++ qpdriver/exceptions.py | 6 +++--- qpdriver/main.py | 18 ++++++++++-------- setup.py | 2 +- tests/fixtures/local.rt | 1 + tests/test_qpd.py | 36 ++++++++++++++++++------------------ xapp-descriptor/config.json | 6 +++--- 10 files changed, 69 insertions(+), 41 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..38b6a85 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,21 @@ +# https://help.github.com/articles/dealing-with-line-endings/ + +# Set the default behavior, in case people don't have core.autocrlf set. +* text=auto + +# Explicitly declare text files you want to always be normalized +# and converted to native line endings on checkout. +*.css text +*.htm text diff=html +*.html text diff=html +*.java text diff=java +*.js text +*.jsp text +*.less text +*.properties text +*.sql text +*.xml text + +# Denote all files that are truly binary and should not be modified. +*.png binary +*.jpg binary diff --git a/.gitreview b/.gitreview index ae4f061..52c3add 100644 --- a/.gitreview +++ b/.gitreview @@ -1,7 +1,6 @@ - - [gerrit] - host=gerrit.o-ran-sc.org - port=29418 - project=ric-app/qp-driver - defaultbranch=master - \ No newline at end of file +[gerrit] +host=gerrit.o-ran-sc.org +port=29418 +project=ric-app/qp-driver +defaultbranch=master +defaultremote=origin diff --git a/container-tag.yaml b/container-tag.yaml index de4adea..ee6d321 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: 1.0.7 +tag: 1.0.8 diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 323ab37..7546efc 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -10,6 +10,11 @@ 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 `__. +[1.0.8] - 2020-05-22 +-------------------- +* Revise static route table (`RICAPP-108 `_) + + [1.0.7] - 2020-05-15 -------------------- * Include xapp descriptor json in repo (`RICAPP-97 `_) diff --git a/qpdriver/exceptions.py b/qpdriver/exceptions.py index 8184cc5..9c83d3e 100644 --- a/qpdriver/exceptions.py +++ b/qpdriver/exceptions.py @@ -1,6 +1,3 @@ -""" -custom logic exceptions -""" # ================================================================================== # Copyright (c) 2020 AT&T Intellectual Property. # @@ -16,6 +13,9 @@ custom logic exceptions # See the License for the specific language governing permissions and # limitations under the License. # ================================================================================== +""" +custom logic exceptions +""" class UENotFound(BaseException): diff --git a/qpdriver/main.py b/qpdriver/main.py index 000d3a5..1fbf95f 100644 --- a/qpdriver/main.py +++ b/qpdriver/main.py @@ -26,7 +26,8 @@ from qpdriver.exceptions import UENotFound RMR Messages #define TS_UE_LIST 30000 #define TS_QOE_PRED_REQ 30001 -30000 is the message QPD receives, sends out 30001 to QP + #define TS_QOE_PREDICTION 30002 +30000 is the message type QPD receives; sends out type 30001, which should be routed to QP. """ @@ -46,9 +47,10 @@ def default_handler(self, summary, sbuf): def steering_req_handler(self, summary, sbuf): """ - This is the main handler for this xapp, which handles the traffic steering requests. + This is the main handler for this xapp, which handles traffic steering requests. Traffic steering requests predictions on a set of UEs. - QP Driver (this) fetches a set of data, merges it together in a deterministic way, then sends a new message out to the QP predictor Xapp. + This app fetches a set of data, merges it together in a deterministic way, + then sends a new message out to the QP predictor Xapp. The incoming message that this function handles looks like: {“UEPredictionSet” : [“UEId1”,”UEId2”,”UEId3”]} @@ -64,23 +66,23 @@ def steering_req_handler(self, summary, sbuf): # we don't use rts here; free this self.rmr_free(sbuf) - # iterate over the ues and send a request each, if it is a valid UE, to QPP + # iterate over the UEs and send a request for each, if it is a valid UE, to QP for ueid in ue_list: try: to_qpp = data.form_qp_pred_req(self, ueid) payload = json.dumps(to_qpp).encode() ok = self.rmr_send(payload, 30001) if not ok: - self.logger.debug("QP Driver was unable to send to QP Predictor!") + self.logger.debug("QP Driver was unable to send to QP!") except UENotFound: self.logger.debug("Received a TS Request for a UE that does not exist!") def start(thread=False): """ - this is a convienence function that allows this xapp to run in Docker for "real" (no thread, real SDL) - but also easily modified for unit testing (e.g., use_fake_sdl) - the defaults for this function are for the Dockerized xapp. + This is a convenience function that allows this xapp to run in Docker + for "real" (no thread, real SDL), but also easily modified for unit testing + (e.g., use_fake_sdl). The defaults for this function are for the Dockerized xapp. """ global rmr_xapp fake_sdl = getenv("USE_FAKE_SDL", None) diff --git a/setup.py b/setup.py index 423a37a..fa52d60 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ from setuptools import setup, find_packages setup( name="qpdriver", - version="1.0.7", + version="1.0.8", packages=find_packages(exclude=["tests.*", "tests"]), author="Tommy Carpenter", description="QP Driver Xapp for traffic steering", diff --git a/tests/fixtures/local.rt b/tests/fixtures/local.rt index 70046b3..fa06be6 100644 --- a/tests/fixtures/local.rt +++ b/tests/fixtures/local.rt @@ -1,2 +1,3 @@ newrt|start +rte|30001|service-ricxapp-qp-rmr.ricxapp.svc.cluster.local:4562 newrt|end diff --git a/tests/test_qpd.py b/tests/test_qpd.py index ebd90cb..ac72c2c 100644 --- a/tests/test_qpd.py +++ b/tests/test_qpd.py @@ -19,8 +19,8 @@ from contextlib import suppress from qpdriver import main, data from ricxappframe.xapp_frame import Xapp, RMRXapp -mock_traffic_steering = None -mock_qp_predictor = None +mock_ts_xapp = None +mock_qp_xapp = None """ these tests are not currently parallelizable (do not use this tox flag) @@ -52,31 +52,30 @@ def test_init_xapp(monkeypatch, ue_metrics, cell_metrics_1, cell_metrics_2, cell def test_rmr_flow(monkeypatch, qpd_to_qp, qpd_to_qp_bad_cell): """ this flow mocks out the xapps on both sides of QP driver. - It first stands up a mock qp predictor, then it starts up a - mock traffic steering which will immediately send requests - to the running qp driver] + It first stands up a mock qp, then it starts up a mock ts + which will immediately send requests to the running qp driver. """ expected_result = {} # define a mock qp predictor - def default_handler(self, summary, sbuf): + def mock_qp_default_handler(self, summary, sbuf): pass - def qp_driver_handler(self, summary, sbuf): + def mock_qp_predict_handler(self, summary, sbuf): nonlocal expected_result # closures ftw pay = json.loads(summary["payload"]) expected_result[pay["PredictionUE"]] = pay - global mock_qp_predictor - mock_qp_predictor = RMRXapp(default_handler, rmr_port=4666, use_fake_sdl=True) - mock_qp_predictor.register_callback(qp_driver_handler, 30001) - mock_qp_predictor.run(thread=True) + global mock_qp_xapp + mock_qp_xapp = RMRXapp(mock_qp_default_handler, rmr_port=4666, use_fake_sdl=True) + mock_qp_xapp.register_callback(mock_qp_predict_handler, 30001) + mock_qp_xapp.run(thread=True) time.sleep(1) # define a mock traffic steering xapp - def entry(self): + def mock_ts_entry(self): # make sure a bad steering request doesn't blow up in qpd val = "notevenjson".encode() @@ -96,9 +95,9 @@ def test_rmr_flow(monkeypatch, qpd_to_qp, qpd_to_qp_bad_cell): val = json.dumps({"test send 60001": 2}).encode() self.rmr_send(val, 60001) - global mock_traffic_steering - mock_traffic_steering = Xapp(entrypoint=entry, rmr_port=4564, use_fake_sdl=True) - mock_traffic_steering.run() # this will return since entry isn't a loop + global mock_ts_xapp + mock_ts_xapp = Xapp(entrypoint=mock_ts_entry, rmr_port=4564, use_fake_sdl=True) + mock_ts_xapp.run() # this will return since entry isn't a loop time.sleep(1) @@ -110,11 +109,12 @@ def teardown_module(): """ this is like a "finally"; the name of this function is pytest magic safer to put down here since certain failures above can lead to pytest never returning - for example if an exception gets raised before stop is called in any test function above, pytest will hang forever + for example if an exception gets raised before stop is called in any test function above, + pytest will hang forever """ with suppress(Exception): - mock_traffic_steering.stop() + mock_ts_xapp.stop() with suppress(Exception): - mock_qp_predictor.stop() + mock_qp_xapp.stop() with suppress(Exception): main.stop() diff --git a/xapp-descriptor/config.json b/xapp-descriptor/config.json index 9458208..451e995 100644 --- a/xapp-descriptor/config.json +++ b/xapp-descriptor/config.json @@ -7,7 +7,7 @@ "image": { "registry": "nexus3.o-ran-sc.org:10002", "name": "o-ran-sc/ric-app-qp-driver", - "tag": "1.0.7" + "tag": "1.0.8" } } ], @@ -18,7 +18,7 @@ "container": "qpdriver", "port": 4562, "rxMessages": ["TS_UE_LIST"], - "txMessages": [ "TS_QUE_PRED_REQ" ], + "txMessages": [ "TS_QOE_PRED_REQ" ], "policies": [], "description": "rmr receive data port for qpdriver" }, @@ -34,7 +34,7 @@ "protPort": "tcp:4562", "maxSize": 2072, "numWorkers": 1, - "txMessages": ["TS_QUE_PRED_REQ"], + "txMessages": ["TS_QOE_PRED_REQ"], "rxMessages": ["TS_UE_LIST"], "policies": [] } -- 2.16.6