Add USE_FAKE_SDL to mock the data storage layer 37/3537/1
authorLott, Christopher (cl778h) <cl778h@att.com>
Wed, 29 Apr 2020 20:50:06 +0000 (16:50 -0400)
committerLott, Christopher (cl778h) <cl778h@att.com>
Wed, 29 Apr 2020 20:50:06 +0000 (16:50 -0400)
This new environment variable in the Dockerfile exposes existing
functionality in the data module. Default is False, the current behavior.
Set to True to work with A1 Mediator standalone.

Issue-ID: RIC-351
Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
Change-Id: I7efbe325e3c9536181c95eec63662d7a98a29ff4

Dockerfile
a1/data.py
docs/installation-guide.rst
docs/release-notes.rst

index e5eeb1b..d616d33 100644 (file)
@@ -56,6 +56,8 @@ USER a1user
 EXPOSE 10000
 ENV LD_LIBRARY_PATH /usr/local/lib/:/usr/local/lib64
 ENV RMR_SEED_RT /opt/route/local.rt
+# Set to True to run standalone
+ENV USE_FAKE_SDL False
 ENV PYTHONUNBUFFERED 1
 # pip installs console script to ~/.local/bin so PATH is critical
 ENV PATH=/home/a1user/.local/bin:$PATH
index ca0acb3..cd44962 100644 (file)
@@ -17,6 +17,7 @@
 """
 Represents A1s database and database access functions.
 """
+import distutils.util
 import os
 import time
 from threading import Thread
@@ -27,6 +28,7 @@ from a1.exceptions import PolicyTypeNotFound, PolicyInstanceNotFound, PolicyType
 # constants
 INSTANCE_DELETE_NO_RESP_TTL = int(os.environ.get("INSTANCE_DELETE_NO_RESP_TTL", 5))
 INSTANCE_DELETE_RESP_TTL = int(os.environ.get("INSTANCE_DELETE_RESP_TTL", 5))
+USE_FAKE_SDL = bool(distutils.util.strtobool(os.environ.get("USE_FAKE_SDL", "False")))
 A1NS = "A1m_ns"
 TYPE_PREFIX = "a1.policy_type."
 INSTANCE_PREFIX = "a1.policy_instance."
@@ -35,7 +37,9 @@ HANDLER_PREFIX = "a1.policy_handler."
 
 
 mdc_logger = Logger(name=__name__)
-SDL = SDLWrapper()
+if USE_FAKE_SDL:
+    mdc_logger.debug("Using fake SDL")
+SDL = SDLWrapper(use_fake_sdl=USE_FAKE_SDL)
 
 # Internal helpers
 
index abada0f..111058d 100644 (file)
@@ -12,7 +12,7 @@ A1 Installation Guide
 Optional ENV Variables
 ----------------------
 
-You can set the following ENVs to change the A1 behavior:
+You can set the following environment variables when launching a container to change the A1 behavior:
 
 1. ``A1_RMR_RETRY_TIMES``: the number of times failed rmr operations such as timeouts and send failures should be retried before A1 gives up and returns a 503. The default is ``4``.
 
@@ -20,6 +20,8 @@ You can set the following ENVs to change the A1 behavior:
 
 3. ``INSTANCE_DELETE_RESP_TTL``: Please refer to the delete flowchart in docs/; this is ``T2`` there. The default is 5 (seconds). Basically, the number of seconds that a1 waits to remove an instance from the database after a delete is called in the case that downstream apps responded.
 
+4. ``USE_FAKE_SDL``: This allows testing of the A1 feature without a DBaaS SDL container.  The default is False.
+
 K8S
 ---
 The "real" helm chart for A1 is in the LF it/dep repo. That repo holds all of the helm charts for the RIC platform. There is a helm chart in `integration_tests` here for running the integration tests as discussed above.
@@ -38,11 +40,13 @@ Build the image
 Start the container
 ~~~~~~~~~~~~~~~~~~~
 
-A sample RMR routing table is supplied here in file `local.rt` for mounting as a volume:
+The A1 container depends on a companion DBaaS (SDL) container, but if that is not convenient set
+an environment variable as shown below to mock that service.  Also a sample RMR routing table is
+supplied in file `local.rt` for mounting as a volume.  The following command uses both:
 
 ::
 
-   docker run -p 10000:10000 -v /path/to/local.rt:/opt/route/local.rt a1:latest
+   docker run -e USE_FAKE_SDL=True -p 10000:10000 -v /path/to/local.rt:/opt/route/local.rt a1:latest
 
 View container API
 ~~~~~~~~~~~~~~~~~~
@@ -56,8 +60,8 @@ A web user interface generated from the OpenAPI specification can be accessed at
 Check container health
 ~~~~~~~~~~~~~~~~~~~~~~
 
-The following command requests the container health.  This requires a Storage Data Layer
-(SDL) service; expect internal server error if that service is not available/running.
+The following command requests the container health.  Expect an internal server error if the
+Storage Data Layer (SDL) service is not available or has not been mocked as shown above.
 
 ::
 
index f793d02..8febae6 100644 (file)
@@ -23,6 +23,7 @@ and this project adheres to `Semantic Versioning <http://semver.org/>`__.
 * Add tiny RMR routing table for use in demo and test
 * Extend documentation for running a container locally
 * Add documentation of start/init parameters to _RmrLoop class
+* Add new environment variable USE_FAKE_SDL (`RIC-351 <https://jira.o-ran-sc.org/browse/RIC-351>`_)
 
 
 [2.1.7] - 2020-04-28