From a542ddc6a149e5562377d9a1e9b35910f03200ba Mon Sep 17 00:00:00 2001 From: Tommy Carpenter Date: Fri, 3 Apr 2020 11:35:09 -0400 Subject: [PATCH] Changes: * Docker now builds with an empty route file so rmr starts; it will not even start properly without this * Change how fake_sdl is activated for docker convienence * Create dev guide file * Add instructions on how to test the rmr healthcheck in a running container * Update to xapp frame 0.7.0 (which has rmr healthchecks) Issue-ID: RICAPP-92 Change-Id: Ib0cd06870ba1bfc51ee8749c040d0b4c65f8c4fa Signed-off-by: Tommy Carpenter --- Dockerfile | 3 +++ docs/developers-guide.rst | 23 +++++++++++++++++++++++ docs/index.rst | 1 + docs/release-notes.rst | 11 +++++++++++ qpdriver/main.py | 6 ++++-- setup.py | 4 ++-- tests/fixtures/local.rt | 2 ++ tests/test_qpd.py | 2 +- tox.ini | 1 + 9 files changed, 48 insertions(+), 5 deletions(-) create mode 100755 docs/developers-guide.rst create mode 100644 tests/fixtures/local.rt diff --git a/Dockerfile b/Dockerfile index 2426581..18fbe32 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,10 @@ FROM python:3.8-alpine # RMR setup RUN mkdir -p /opt/route/ COPY --from=nexus3.o-ran-sc.org:10004/bldr-alpine3-go:5-a3.11-nng-rmr3 /usr/local/lib64/librmr_si.so /usr/local/lib64/librmr_si.so +COPY --from=nexus3.o-ran-sc.org:10004/bldr-alpine3-go:5-a3.11-nng-rmr3 /usr/local/bin/health_ck /usr/local/bin/health_ck ENV LD_LIBRARY_PATH /usr/local/lib/:/usr/local/lib64 +COPY tests/fixtures/local.rt /opt/route/local.rt +ENV RMR_SEED_RT /opt/route/local.rt # sdl needs gcc RUN apk update && apk add gcc musl-dev diff --git a/docs/developers-guide.rst b/docs/developers-guide.rst new file mode 100755 index 0000000..705c9c8 --- /dev/null +++ b/docs/developers-guide.rst @@ -0,0 +1,23 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. SPDX-License-Identifier: CC-BY-4.0 +.. Copyright (C) 2020 AT&T Intellectual Property + + +Developers Guide +================= + +.. contents:: + :depth: 3 + :local: + +Testing RMR Healthcheck +----------------------- +The following instructions should deploy the QP Driver container in bare docker, and allow you 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/health_ck -h 127.0.0.1:4562 + + diff --git a/docs/index.rst b/docs/index.rst index 8fe809b..7cb8aa6 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -13,6 +13,7 @@ Welcome to O-RAN SC qp-driver Documentation overview.rst release-notes.rst installation-guide.rst + developers-guide.rst * :ref:`genindex` * :ref:`modindex` diff --git a/docs/release-notes.rst b/docs/release-notes.rst index b7b9077..e793295 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -14,6 +14,17 @@ and this project adheres to `Semantic Versioning `__. :depth: 3 :local: +[1.0.1] - 4/3/2020 +------------------ +:: + + * Docker now builds with an empty route file so rmr starts; it will not even start properly without this + * Change how fake_sdl is activated for docker convienence + * Create dev guide file + * Add instructions on how to test the rmr healthcheck in a running container + * Update to xapp frame 0.7.0 (which has rmr healthchecks) + + [1.0.0] - 4/1/2020 ------------------ :: diff --git a/qpdriver/main.py b/qpdriver/main.py index 6407b91..5052353 100644 --- a/qpdriver/main.py +++ b/qpdriver/main.py @@ -17,6 +17,7 @@ qpdriver entrypoint module # limitations under the License. # ================================================================================== import json +from os import getenv from ricxappframe.xapp_frame import RMRXapp from qpdriver import data from qpdriver.exceptions import UENotFound @@ -75,14 +76,15 @@ def steering_req_handler(self, summary, sbuf): self.logger.debug("Received a TS Request for a UE that does not exist!") -def start(thread=False, use_fake_sdl=False): +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. """ global rmr_xapp - rmr_xapp = RMRXapp(default_handler, post_init=post_init, rmr_port=4562, use_fake_sdl=use_fake_sdl) + fake_sdl = getenv("USE_FAKE_SDL", None) + rmr_xapp = RMRXapp(default_handler, post_init=post_init, use_fake_sdl=True if fake_sdl else False) rmr_xapp.register_callback(steering_req_handler, 30000) rmr_xapp.run(thread) diff --git a/setup.py b/setup.py index 0e70fd2..39bd3f7 100644 --- a/setup.py +++ b/setup.py @@ -17,12 +17,12 @@ from setuptools import setup, find_packages setup( name="qpdriver", - version="1.0.0", + version="1.0.1", packages=find_packages(exclude=["tests.*", "tests"]), author="Tommy Carpenter", description="QP Driver Xapp for traffic steering", url="https://gerrit.o-ran-sc.org/r/admin/repos/ric-app/qp-driver", - install_requires=["ricxappframe>=0.6.0"], + install_requires=["ricxappframe>=0.7.0"], entry_points={"console_scripts": ["start.py=qpdriver.main:start"]}, # adds a magical entrypoint for Docker license="Apache 2.0", data_files=[("", ["LICENSE.txt"])], diff --git a/tests/fixtures/local.rt b/tests/fixtures/local.rt new file mode 100644 index 0000000..70046b3 --- /dev/null +++ b/tests/fixtures/local.rt @@ -0,0 +1,2 @@ +newrt|start +newrt|end diff --git a/tests/test_qpd.py b/tests/test_qpd.py index 0bc3071..23f6b50 100644 --- a/tests/test_qpd.py +++ b/tests/test_qpd.py @@ -44,7 +44,7 @@ def test_init_xapp(monkeypatch, ue_metrics, cell_metrics_1, cell_metrics_2, cell monkeypatch.setattr("qpdriver.main.post_init", fake_post_init) # start qpd - main.start(thread=True, use_fake_sdl=True) + main.start(thread=True) def test_rmr_flow(monkeypatch, qpd_to_qp, qpd_to_qp_bad_cell): diff --git a/tox.ini b/tox.ini index e9fe0d0..276b22d 100644 --- a/tox.ini +++ b/tox.ini @@ -27,6 +27,7 @@ setenv = LD_LIBRARY_PATH = /usr/local/lib/:/usr/local/lib64 RMR_SEED_RT = tests/fixtures/test_local.rt RMR_ASYNC_CONN = 0 + USE_FAKE_SDL = 1 commands = pytest -v --cov qpdriver --cov-report xml --cov-report term-missing --cov-report html --cov-fail-under=70 -- 2.16.6