From 633291eb6156a38cefa1e164092d9c16368a63d6 Mon Sep 17 00:00:00 2001 From: "Lott, Christopher (cl778h)" Date: Tue, 12 May 2020 17:06:28 -0400 Subject: [PATCH] Decode values from SDL as JSON Bump version to 1.0.6 Issue-ID: RICAPP-104 Signed-off-by: Lott, Christopher (cl778h) Change-Id: I1c29cf664820ed2273215298923456dd5d31eb2e --- container-tag.yaml | 2 +- docs/developers-guide.rst | 11 +++++++++++ docs/release-notes.rst | 5 +++++ qpdriver/data.py | 24 ++++++++++++++++-------- setup.py | 2 +- tests/test_qpd.py | 18 +++++++++++------- 6 files changed, 45 insertions(+), 17 deletions(-) diff --git a/container-tag.yaml b/container-tag.yaml index ce4dca5..5a214fe 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.5 +tag: 1.0.6 diff --git a/docs/developers-guide.rst b/docs/developers-guide.rst index da078ff..26379ff 100755 --- a/docs/developers-guide.rst +++ b/docs/developers-guide.rst @@ -10,6 +10,17 @@ Developers Guide :depth: 3 :local: + +Version bumping the Xapp +------------------------ + +This project follows semver. When changes are made, update the version strings in: + +#. ``container-tag.yaml`` +#. ``docs/release-notes.rst`` +#. ``setup.py`` + + Testing RMR Healthcheck ----------------------- The following instructions should deploy the QP Driver container in bare docker, and allow you diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 5b91566..d198bcb 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -11,6 +11,11 @@ The format is based on `Keep a Changelog `__ and this project adheres to `Semantic Versioning `__. +[1.0.6] - 2020-05-12 +-------------------- +* Decode values from SDL as JSON (`RICAPP-104 `_) + + [1.0.5] - 2020-05-08 -------------------- diff --git a/qpdriver/data.py b/qpdriver/data.py index 00c1290..72fc2cc 100644 --- a/qpdriver/data.py +++ b/qpdriver/data.py @@ -1,6 +1,3 @@ -""" -qpdriver module responsible for SDL queries and data merging -""" # ================================================================================== # Copyright (c) 2020 AT&T Intellectual Property. # @@ -16,6 +13,11 @@ qpdriver module responsible for SDL queries and data merging # See the License for the specific language governing permissions and # limitations under the License. # ================================================================================== + +""" +qpdriver module responsible for SDL queries and data merging +""" +import json from qpdriver.exceptions import UENotFound # namespaces @@ -67,9 +69,11 @@ def form_qp_pred_req(xapp_ref, ueid): Note that a single request to qp driver may have many UEs in a list, however since a new message needs to be sent for each one, the calling function iterates over that list, rather than doing it here. """ - ue_data = xapp_ref.sdl_get(UE_NS, ueid, usemsgpack=False) - if not ue_data: + ue_data_bytes = xapp_ref.sdl_get(UE_NS, ueid, usemsgpack=False) + if not ue_data_bytes: raise UENotFound() + # input should be a json encoded as bytes + ue_data = json.loads(ue_data_bytes.decode()) serving_cid = ue_data["ServingCellID"] @@ -91,11 +95,15 @@ def form_qp_pred_req(xapp_ref, ueid): # form the Cell Measurements for cid in cell_ids: - cellm = xapp_ref.sdl_get(CELL_NS, cid, usemsgpack=False) + cellm_bytes = xapp_ref.sdl_get(CELL_NS, cid, usemsgpack=False) + + if cellm_bytes: # if None, then we omit that cell from this array - if cellm: # if cellm is None, then we omit that cell from this array + # input should be a json encoded as bytes + cellm = json.loads(cellm_bytes.decode()) - # if we were really under performance strain here we could delete from the orig instead of copying but this code is far simpler + # if we were really under performance strain here we could delete + # from the orig instead of copying but this code is far simpler cell_data = {k: cellm[k] for k in CELL_KEY_LIST} # these keys get dropped into *each* cell diff --git a/setup.py b/setup.py index 81daddf..8eb737a 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ from setuptools import setup, find_packages setup( name="qpdriver", - version="1.0.5", + version="1.0.6", packages=find_packages(exclude=["tests.*", "tests"]), author="Tommy Carpenter", description="QP Driver Xapp for traffic steering", diff --git a/tests/test_qpd.py b/tests/test_qpd.py index 23f6b50..ebd90cb 100644 --- a/tests/test_qpd.py +++ b/tests/test_qpd.py @@ -25,20 +25,22 @@ mock_qp_predictor = None """ these tests are not currently parallelizable (do not use this tox flag) I would use setup_module, however that can't take monkeypatch fixtures - Currently looking for the best way to make this better: https://stackoverflow.com/questions/60886013/python-monkeypatch-in-pytest-setup-module + Currently looking for the best way to make this better: + https://stackoverflow.com/questions/60886013/python-monkeypatch-in-pytest-setup-module """ def test_init_xapp(monkeypatch, ue_metrics, cell_metrics_1, cell_metrics_2, cell_metrics_3, ue_metrics_with_bad_cell): # monkeypatch post_init to set the data we want in SDL + # the metrics arguments are JSON (dict) objects def fake_post_init(self): self.def_hand_called = 0 self.traffic_steering_requests = 0 - self.sdl_set(data.UE_NS, "12345", ue_metrics, usemsgpack=False) - self.sdl_set(data.UE_NS, "8675309", ue_metrics_with_bad_cell, usemsgpack=False) - self.sdl_set(data.CELL_NS, "310-680-200-555001", cell_metrics_1, usemsgpack=False) - self.sdl_set(data.CELL_NS, "310-680-200-555002", cell_metrics_2, usemsgpack=False) - self.sdl_set(data.CELL_NS, "310-680-200-555003", cell_metrics_3, usemsgpack=False) + self.sdl_set(data.UE_NS, "12345", json.dumps(ue_metrics).encode(), usemsgpack=False) + self.sdl_set(data.UE_NS, "8675309", json.dumps(ue_metrics_with_bad_cell).encode(), usemsgpack=False) + self.sdl_set(data.CELL_NS, "310-680-200-555001", json.dumps(cell_metrics_1).encode(), usemsgpack=False) + self.sdl_set(data.CELL_NS, "310-680-200-555002", json.dumps(cell_metrics_2).encode(), usemsgpack=False) + self.sdl_set(data.CELL_NS, "310-680-200-555003", json.dumps(cell_metrics_3).encode(), usemsgpack=False) # patch monkeypatch.setattr("qpdriver.main.post_init", fake_post_init) @@ -50,7 +52,9 @@ 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 predictor, then it starts up a + mock traffic steering which will immediately send requests + to the running qp driver] """ expected_result = {} -- 2.16.6