Message-summary dict keys are defined in the rmr module.
Use them instead of hardcoding strings.
Add Dockerfile to support unit testing on machines that don't have
the RMR library, such as macs.
Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
Change-Id: I1d9ec036f41acd564b777f31cb2643e8b0ea5f37
# Test report
xunit-reports
coverage-reports
+
+# Eclipse
+.project
+.pydevproject
+.settings
--- /dev/null
+# ==================================================================================
+# Copyright (c) 2020 AT&T Intellectual Property.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ==================================================================================
+FROM python:3.8-alpine
+
+# sdl uses hiredis which needs gcc
+RUN apk update && apk add gcc musl-dev
+
+# copy rmr libraries from builder image in lieu of an Alpine package
+COPY --from=nexus3.o-ran-sc.org:10002/o-ran-sc/bldr-alpine3-rmr:4.0.5 /usr/local/lib64/librmr* /usr/local/lib64/
+
+# Upgrade pip, install tox
+RUN pip install --upgrade pip && pip install tox
+
+# copies
+COPY setup.py tox.ini LICENSE.txt /tmp/
+COPY qpdriver/ /tmp/qpdriver
+COPY tests/ /tmp/tests
+RUN pip install /tmp
+
+# Run the unit tests
+WORKDIR /tmp
+RUN tox -e code,flake8
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.
+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
+
+Unit Testing
+------------
+
+Running the unit tests requires the python packages ``tox`` and ``pytest``.
+
+The RMR library is also required during unit tests. If running directly from tox
+(outside a Docker container), install RMR according to its instructions.
+
+Upon completion, view the test coverage like this:
+
+::
+
+ tox
+ open htmlcov/index.html
+
+Alternatively, if you cannot install RMR locally, you can run the unit
+tests in Docker. This is somewhat less nice because you don't get the
+pretty HTML report on coverage.
+
+::
+
+ docker build --no-cache -f Dockerfile-Unit-Test .
and this project adheres to `Semantic Versioning <http://semver.org/>`__.
-[1.0.5] - 2020-05-07
+[1.0.5] - 2020-05-08
--------------------
* Upgrade to RMR version 4.0.5
* Upgrade to framework version 1.1.0
+* Use constants from rmr module instead of hardcoded strings
+* Add Dockerfile-Unit-Test to support testing
[1.0.4] - 2020-05-05
# ==================================================================================
import json
from os import getenv
-from ricxappframe.xapp_frame import RMRXapp
+from ricxappframe.xapp_frame import RMRXapp, rmr
from qpdriver import data
from qpdriver.exceptions import UENotFound
def default_handler(self, summary, sbuf):
self.def_hand_called += 1
- self.logger.info("QP Driver received an unexpected message of type: {}, dropping.".format(summary["message type"]))
+ self.logger.info("QP Driver received an unexpected message of type: {}, dropping.".format(summary[rmr.RMR_MS_MSG_TYPE]))
self.rmr_free(sbuf)
self.traffic_steering_requests += 1
ue_list = []
try:
- req = json.loads(summary["payload"]) # input should be a json encoded as bytes
+ req = json.loads(summary[rmr.RMR_MS_PAYLOAD]) # input should be a json encoded as bytes
ue_list = req["UEPredictionSet"]
except (json.decoder.JSONDecodeError, KeyError):
self.logger.debug("Received a TS Request but it was malformed!")
[flake8]
extend-ignore = E501,E741,E731
+[testenv:clm]
+# use pip to gather dependencies with versions for CLM analysis
+whitelist_externals = sh
+commands = sh -c 'pip freeze > requirements.txt'
+
# doc jobs
[testenv:docs]
whitelist_externals = echo