--------------------
* Send alarm on SDL failure (`RICAPP-117 <https://jira.o-ran-sc.org/browse/RICAPP-117>`_)
* Define configuration properties in xapp-descriptor controls section with JSON schema
+* Add configuration-change handler method that logs the event
* Requires RMR at version 4.1.2 or later
* Requires xapp-frame-py at version 1.3.0 or later
self.alarm_sdl = None
+def handle_config_change(self, config):
+ """
+ Function that runs at start and on every configuration file change.
+ """
+ self.logger.debug("handle_config_change: config: {}".format(config))
+
+
def default_handler(self, summary, sbuf):
"""
Function that processes messages for which no handler is defined
"""
global rmr_xapp
fake_sdl = getenv("USE_FAKE_SDL", None)
- rmr_xapp = RMRXapp(default_handler, rmr_port=4560, post_init=post_init, use_fake_sdl=bool(fake_sdl))
+ rmr_xapp = RMRXapp(default_handler,
+ config_handler=handle_config_change,
+ rmr_port=4560,
+ post_init=post_init,
+ use_fake_sdl=bool(fake_sdl))
rmr_xapp.register_callback(steering_req_handler, 30000)
rmr_xapp.run(thread)
+# ==================================================================================
+# 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.
+# ==================================================================================
import pytest
mock_ts_xapp = None
mock_qp_xapp = None
+# tox.ini sets env var to this value
+config_file_path = "/tmp/config.json"
"""
these tests are not currently parallelizable (do not use this tox flag)
"""
+def init_config_file():
+ with open(config_file_path, "w") as file:
+ file.write('{ "example_int" : 0 }')
+
+
+def write_config_file():
+ # generate an inotify/config event
+ with open(config_file_path, "w") as file:
+ file.write('{ "example_int" : 1 }')
+
+
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
# patch
monkeypatch.setattr("qpdriver.main.post_init", fake_post_init)
+ # establish config
+ init_config_file()
+
# start qpd
main.start(thread=True)
+ # wait a bit then update config
+ time.sleep(3)
+ write_config_file()
+
def test_rmr_flow(monkeypatch, qpd_to_qp, qpd_to_qp_bad_cell):
"""
RMR_SEED_RT = tests/fixtures/test_local.rt
RMR_ASYNC_CONN = 0
USE_FAKE_SDL = 1
+ CONFIG_FILE = /tmp/config.json
# add -s after pytest to stream the logs as they come in, rather than saving for the end
commands =