Commit b578b8cd authored by Kirill Smelkov's avatar Kirill Smelkov

Adjust Amarisoft-related promises and tests to treat `data` in `*.json.log` as JSON

Hello up there,

This merge-requests primarily adjusts promises code to treat `data` field in `*.json.log` as real JSON. It is counterpart to slapos!1447 .

- patch 1 syncs tests to current state of ORS SR;
- patch 2 removes replacement of `'` with `"` in input data;
- patch 3 removes UTF-8 decoding when input is fed to json.loads.

Please see individual patches for details.

Kirill

/cc @jhuge, @lu.xu, @tomo, @xavier_thompson, @Daetalus, @jerome
/reviewed-on !120 and slapos!1447
parents 0982927e eeaa4007
Pipeline #30797 passed with stage
in 0 seconds
......@@ -22,8 +22,6 @@ import socket
from datetime import datetime
from xml.sax.saxutils import escape
from slapos.util import bytes2str
OPML_START = """<?xml version="1.0" encoding="UTF-8"?>
<!-- OPML generated by SlapOS -->
<opml version="1.1">
......@@ -233,7 +231,7 @@ class Monitoring(object):
print("ERROR: Timeout with %r while downloading monitor config at %s " % (e, url))
else:
try:
monitor_dict = json.loads(bytes2str(response.read()))
monitor_dict = json.loads(response.read())
monitor_title = monitor_dict.get('title', 'Unknown Instance')
success = True
except ValueError as e:
......
......@@ -29,7 +29,7 @@ class RunPromise(JSONPromise):
for f in iter_logrotate_file_handle(self.netconf_log, 'rb'):
for line in iter_reverse_lines(f):
l = json.loads(line.decode().replace("'", '"'))
l = json.loads(line)
alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None)
if alarm_notif and alarm_notif['fault-id'] == '102':
if alarm_notif['is-cleared'] == 'false':
......
......@@ -29,7 +29,7 @@ class RunPromise(JSONPromise):
for f in iter_logrotate_file_handle(self.netconf_log, 'rb'):
for line in iter_reverse_lines(f):
l = json.loads(line.decode().replace("'", '"'))
l = json.loads(line)
alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None)
if alarm_notif and alarm_notif['fault-id'] == '103':
if alarm_notif['is-cleared'] == 'false':
......
......@@ -29,7 +29,7 @@ class RunPromise(JSONPromise):
for f in iter_logrotate_file_handle(self.netconf_log, 'rb'):
for line in iter_reverse_lines(f):
l = json.loads(line.decode().replace("'", '"'))
l = json.loads(line)
alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None)
if alarm_notif and alarm_notif['fault-id'] == '9':
if alarm_notif['is-cleared'] == 'false':
......
......@@ -29,7 +29,7 @@ class RunPromise(JSONPromise):
for f in iter_logrotate_file_handle(self.netconf_log, 'rb'):
for line in iter_reverse_lines(f):
l = json.loads(line.decode().replace("'", '"'))
l = json.loads(line)
alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None)
if alarm_notif and alarm_notif['fault-id'] == '101':
if alarm_notif['is-cleared'] == 'false':
......
......@@ -29,7 +29,7 @@ class RunPromise(JSONPromise):
for f in iter_logrotate_file_handle(self.netconf_log, 'rb'):
for line in iter_reverse_lines(f):
l = json.loads(line.decode().replace("'", '"'))
l = json.loads(line)
alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None)
if alarm_notif and alarm_notif['fault-id'] == '18':
if alarm_notif['is-cleared'] == 'false':
......
......@@ -29,7 +29,7 @@ class RunPromise(JSONPromise):
for f in iter_logrotate_file_handle(self.netconf_log, 'rb'):
for line in iter_reverse_lines(f):
l = json.loads(line.decode().replace("'", '"'))
l = json.loads(line)
alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None)
if alarm_notif and alarm_notif['fault-id'] == '9':
if alarm_notif['is-cleared'] == 'false':
......
......@@ -47,7 +47,7 @@ def get_json_log_data_interval(json_log_file, interval):
data_list = []
for f in iter_logrotate_file_handle(json_log_file, 'rb'):
for line in iter_reverse_lines(f):
l = json.loads(line.decode().replace("'", '"'))
l = json.loads(line)
timestamp = dateparser.parse(l['time'])
if (current_time - timestamp).total_seconds() > interval:
return data_list
......@@ -61,7 +61,7 @@ def get_json_log_latest_timestamp(json_log_file):
"""
for f in iter_logrotate_file_handle(json_log_file, 'rb'):
for line in iter_reverse_lines(f):
l = json.loads(line.decode().replace("'", '"'))
l = json.loads(line)
return dateparser.parse(l['time']).timestamp()
return 0
......
......@@ -92,7 +92,7 @@ ipv4 = 10.0.151.118
pkg_resources.resource_string(
'slapos.monitor',
'doc/monitor_instance.schema.json')
self.monitor_instance_schema = json.loads(monitor_schema_string.decode('utf-8'))
self.monitor_instance_schema = json.loads(monitor_schema_string)
self.monitor_config_dict = dict(
......
......@@ -41,9 +41,9 @@ class TestCheckBasebandLatency(TestPromisePluginMixin):
super(TestCheckBasebandLatency, self).setUp()
self.amarisoft_stats_log = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'amarisoft_stats.json.log')
with open(self.amarisoft_stats_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "Samples stats", "data": {'rf': {'rxtx_delay_min': %f}}}
{"time": "%s", "log_level": "INFO", "message": "Samples stats", "data": {'rf': {'rxtx_delay_min': %f}}}
{"time": "%s", "log_level": "INFO", "message": "Samples stats", "data": {'rf': {'rxtx_delay_min': %f}}}""" % (
f.write("""{"time": "%s", "log_level": "INFO", "message": "Samples stats", "data": {"rf": {"rxtx_delay_min": %f}}}
{"time": "%s", "log_level": "INFO", "message": "Samples stats", "data": {"rf": {"rxtx_delay_min": %f}}}
{"time": "%s", "log_level": "INFO", "message": "Samples stats", "data": {"rf": {"rxtx_delay_min": %f}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], 7.0,
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], 2.0,
(datetime.now() - timedelta(seconds=5)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], 5.0,
......
......@@ -49,8 +49,8 @@ class TestCheckLopcommLOFSuccess(TestPromisePluginMixin):
def test_promise_success(self):
with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '102', 'fault-source': 'Radio Module', 'affected-objects': {'name': 'Radio Module'}, 'fault-severity': 'CRITICAL', 'is-cleared': 'false', 'fault-text': 'LOF Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '102', 'fault-source': 'Radio Module', 'affected-objects': {'name': 'Radio Module'}, 'fault-severity': 'CRITICAL', 'is-cleared': 'true', 'fault-text': 'LOF Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}""" % (
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "102", "fault-source": "Radio Module", "affected-objects": {"name": "Radio Module"}, "fault-severity": "CRITICAL", "is-cleared": "false", "fault-text": "LOF Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "102", "fault-source": "Radio Module", "affected-objects": {"name": "Radio Module"}, "fault-severity": "CRITICAL", "is-cleared": "true", "fault-text": "LOF Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
))
......@@ -62,8 +62,8 @@ class TestCheckLopcommLOFSuccess(TestPromisePluginMixin):
def test_promise_fail(self):
with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '102', 'fault-source': 'Radio Module', 'affected-objects': {'name': 'Radio Module'}, 'fault-severity': 'CRITICAL', 'is-cleared': 'true', 'fault-text': 'LOF Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '102', 'fault-source': 'Radio Module', 'affected-objects': {'name': 'Radio Module'}, 'fault-severity': 'CRITICAL', 'is-cleared': 'false', 'fault-text': 'LOF Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}""" % (
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "102", "fault-source": "Radio Module", "affected-objects": {"name": "Radio Module"}, "fault-severity": "CRITICAL", "is-cleared": "true", "fault-text": "LOF Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "102", "fault-source": "Radio Module", "affected-objects": {"name": "Radio Module"}, "fault-severity": "CRITICAL", "is-cleared": "false", "fault-text": "LOF Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
))
......
......@@ -49,8 +49,8 @@ class TestCheckLopcommPACurrentSuccess(TestPromisePluginMixin):
def test_promise_success(self):
with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '103', 'fault-source': 'PA0', 'affected-objects': {'name': 'PA0'}, 'fault-severity': 'MINOR', 'is-cleared': 'false', 'fault-text': 'PA 1 Over Current Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '103', 'fault-source': 'PA0', 'affected-objects': {'name': 'PA0'}, 'fault-severity': 'MINOR', 'is-cleared': 'true', 'fault-text': 'PA 1 Over Current Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}""" % (
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "103", "fault-source": "PA0", "affected-objects": {"name": "PA0"}, "fault-severity": "MINOR", "is-cleared": "false", "fault-text": "PA 1 Over Current Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "103", "fault-source": "PA0", "affected-objects": {"name": "PA0"}, "fault-severity": "MINOR", "is-cleared": "true", "fault-text": "PA 1 Over Current Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
))
......@@ -62,8 +62,8 @@ class TestCheckLopcommPACurrentSuccess(TestPromisePluginMixin):
def test_promise_fail(self):
with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '103', 'fault-source': 'PA0', 'affected-objects': {'name': 'PA0'}, 'fault-severity': 'MINOR', 'is-cleared': 'true', 'fault-text': 'PA 1 Over Current Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '103', 'fault-source': 'PA0', 'affected-objects': {'name': 'PA0'}, 'fault-severity': 'MINOR', 'is-cleared': 'false', 'fault-text': 'PA 1 Over Current Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}""" % (
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "103", "fault-source": "PA0", "affected-objects": {"name": "PA0"}, "fault-severity": "MINOR", "is-cleared": "true", "fault-text": "PA 1 Over Current Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "103", "fault-source": "PA0", "affected-objects": {"name": "PA0"}, "fault-severity": "MINOR", "is-cleared": "false", "fault-text": "PA 1 Over Current Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
))
......
......@@ -49,8 +49,8 @@ class TestCheckLopcommPAOutputPowerSuccess(TestPromisePluginMixin):
def test_promise_success(self):
with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '9', 'fault-source': 'PA0', 'affected-objects': {'name': 'PA0'}, 'fault-severity': 'MINOR', 'is-cleared': 'false', 'fault-text': 'PA 1 Over Output Power Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '9', 'fault-source': 'PA0', 'affected-objects': {'name': 'PA0'}, 'fault-severity': 'MINOR', 'is-cleared': 'true', 'fault-text': 'PA 1 Over Output Power Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}""" % (
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "9", "fault-source": "PA0", "affected-objects": {"name": "PA0"}, "fault-severity": "MINOR", "is-cleared": "false", "fault-text": "PA 1 Over Output Power Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "9", "fault-source": "PA0", "affected-objects": {"name": "PA0"}, "fault-severity": "MINOR", "is-cleared": "true", "fault-text": "PA 1 Over Output Power Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
))
......@@ -62,8 +62,8 @@ class TestCheckLopcommPAOutputPowerSuccess(TestPromisePluginMixin):
def test_promise_fail(self):
with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '9', 'fault-source': 'PA0', 'affected-objects': {'name': 'PA0'}, 'fault-severity': 'MINOR', 'is-cleared': 'true', 'fault-text': 'PA 1 Over Output Power Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '9', 'fault-source': 'PA0', 'affected-objects': {'name': 'PA0'}, 'fault-severity': 'MINOR', 'is-cleared': 'false', 'fault-text': 'PA 1 Over Output Power Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}""" % (
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "9", "fault-source": "PA0", "affected-objects": {"name": "PA0"}, "fault-severity": "MINOR", "is-cleared": "true", "fault-text": "PA 1 Over Output Power Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "9", "fault-source": "PA0", "affected-objects": {"name": "PA0"}, "fault-severity": "MINOR", "is-cleared": "false", "fault-text": "PA 1 Over Output Power Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
))
......
......@@ -49,8 +49,8 @@ class TestCheckLopcommRSSISuccess(TestPromisePluginMixin):
def test_promise_success(self):
with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '101', 'fault-source': 'RF Module', 'affected-objects': {'name': 'RF Module'}, 'fault-severity': 'MINOR', 'is-cleared': 'false', 'fault-text': 'RSSI Imbalance alarm & RX Diversity Lost Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '101', 'fault-source': 'RF Module', 'affected-objects': {'name': 'RF Module'}, 'fault-severity': 'MINOR', 'is-cleared': 'true', 'fault-text': 'RSSI Imbalance alarm & RX Diversity Lost Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}""" % (
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "101", "fault-source": "RF Module", "affected-objects": {"name": "RF Module"}, "fault-severity": "MINOR", "is-cleared": "false", "fault-text": "RSSI Imbalance alarm & RX Diversity Lost Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "101", "fault-source": "RF Module", "affected-objects": {"name": "RF Module"}, "fault-severity": "MINOR", "is-cleared": "true", "fault-text": "RSSI Imbalance alarm & RX Diversity Lost Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
))
......@@ -62,8 +62,8 @@ class TestCheckLopcommRSSISuccess(TestPromisePluginMixin):
def test_promise_fail(self):
with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '101', 'fault-source': 'RF Module', 'affected-objects': {'name': 'RF Module'}, 'fault-severity': 'MINOR', 'is-cleared': 'true', 'fault-text': 'RSSI Imbalance alarm & RX Diversity Lost Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '101', 'fault-source': 'RF Module', 'affected-objects': {'name': 'RF Module'}, 'fault-severity': 'MINOR', 'is-cleared': 'false', 'fault-text': 'RSSI Imbalance alarm & RX Diversity Lost Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}""" % (
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "101", "fault-source": "RF Module", "affected-objects": {"name": "RF Module"}, "fault-severity": "MINOR", "is-cleared": "true", "fault-text": "RSSI Imbalance alarm & RX Diversity Lost Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "101", "fault-source": "RF Module", "affected-objects": {"name": "RF Module"}, "fault-severity": "MINOR", "is-cleared": "false", "fault-text": "RSSI Imbalance alarm & RX Diversity Lost Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
))
......
......@@ -49,8 +49,8 @@ class TestCheckLopcommSyncSuccess(TestPromisePluginMixin):
def test_promise_success(self):
with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-01T01:34:04Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '18', 'fault-source': 'Radio Module', 'affected-objects': {'name': 'Radio Module'}, 'fault-severity': 'MAJOR', 'is-cleared': 'false', 'fault-text': 'Synchronization Error Alarm', 'event-time': '1970-01-01T01:34:04Z'}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-01T01:34:28Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '18', 'fault-source': 'Radio Module', 'affected-objects': {'name': 'Radio Module'}, 'fault-severity': 'MAJOR', 'is-cleared': 'true', 'fault-text': 'Synchronization Error Alarm', 'event-time': '1970-01-01T01:34:28Z'}}}}""" % (
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-01T01:34:04Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "18", "fault-source": "Radio Module", "affected-objects": {"name": "Radio Module"}, "fault-severity": "MAJOR", "is-cleared": "false", "fault-text": "Synchronization Error Alarm", "event-time": "1970-01-01T01:34:04Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-01T01:34:28Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "18", "fault-source": "Radio Module", "affected-objects": {"name": "Radio Module"}, "fault-severity": "MAJOR", "is-cleared": "true", "fault-text": "Synchronization Error Alarm", "event-time": "1970-01-01T01:34:28Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
))
......@@ -62,8 +62,8 @@ class TestCheckLopcommSyncSuccess(TestPromisePluginMixin):
def test_promise_fail(self):
with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-01T01:34:04Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '18', 'fault-source': 'Radio Module', 'affected-objects': {'name': 'Radio Module'}, 'fault-severity': 'MAJOR', 'is-cleared': 'false', 'fault-text': 'Synchronization Error Alarm', 'event-time': '1970-01-01T01:34:04Z'}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-01T01:34:28Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '18', 'fault-source': 'Radio Module', 'affected-objects': {'name': 'Radio Module'}, 'fault-severity': 'MAJOR', 'is-cleared': 'false', 'fault-text': 'Synchronization Error Alarm', 'event-time': '1970-01-01T01:34:28Z'}}}}""" % (
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-01T01:34:04Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "18", "fault-source": "Radio Module", "affected-objects": {"name": "Radio Module"}, "fault-severity": "MAJOR", "is-cleared": "false", "fault-text": "Synchronization Error Alarm", "event-time": "1970-01-01T01:34:04Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-01T01:34:28Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "18", "fault-source": "Radio Module", "affected-objects": {"name": "Radio Module"}, "fault-severity": "MAJOR", "is-cleared": "false", "fault-text": "Synchronization Error Alarm", "event-time": "1970-01-01T01:34:28Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
))
......
......@@ -49,8 +49,8 @@ class TestCheckLopcommVSWRSuccess(TestPromisePluginMixin):
def test_promise_success(self):
with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '9', 'fault-source': 'Antport1', 'affected-objects': {'name': 'Antport1'}, 'fault-severity': 'MAJOR', 'is-cleared': 'false', 'fault-text': 'PA 1 VSWR Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '9', 'fault-source': 'Antport1', 'affected-objects': {'name': 'Antport1'}, 'fault-severity': 'MAJOR', 'is-cleared': 'true', 'fault-text': 'PA 1 VSWR Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}""" % (
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "9", "fault-source": "Antport1", "affected-objects": {"name": "Antport1"}, "fault-severity": "MAJOR", "is-cleared": "false", "fault-text": "PA 1 VSWR Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "9", "fault-source": "Antport1", "affected-objects": {"name": "Antport1"}, "fault-severity": "MAJOR", "is-cleared": "true", "fault-text": "PA 1 VSWR Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
))
......@@ -62,8 +62,8 @@ class TestCheckLopcommVSWRSuccess(TestPromisePluginMixin):
def test_promise_fail(self):
with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '9', 'fault-source': 'Antport1', 'affected-objects': {'name': 'Antport1'}, 'fault-severity': 'MAJOR', 'is-cleared': 'true', 'fault-text': 'PA 1 VSWR Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '9', 'fault-source': 'Antport1', 'affected-objects': {'name': 'Antport1'}, 'fault-severity': 'MAJOR', 'is-cleared': 'false', 'fault-text': 'PA 1 VSWR Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}""" % (
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "9", "fault-source": "Antport1", "affected-objects": {"name": "Antport1"}, "fault-severity": "MAJOR", "is-cleared": "true", "fault-text": "PA 1 VSWR Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "9", "fault-source": "Antport1", "affected-objects": {"name": "Antport1"}, "fault-severity": "MAJOR", "is-cleared": "false", "fault-text": "PA 1 VSWR Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
))
......
......@@ -41,9 +41,9 @@ class TestCheckRXSaturated(TestPromisePluginMixin):
super(TestCheckRXSaturated, self).setUp()
self.amarisoft_stats_log = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'amarisoft_stats.json.log')
with open(self.amarisoft_stats_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "Samples stats", "data": {'samples': {'rx': [{'max': %f}, {'max': %f}]}}}
{"time": "%s", "log_level": "INFO", "message": "Samples stats", "data": {'samples': {'rx': [{'max': %f}, {'max': %f}]}}}
{"time": "%s", "log_level": "INFO", "message": "Samples stats", "data": {'samples': {'rx': [{'max': %f}, {'max': %f}]}}}""" % (
f.write("""{"time": "%s", "log_level": "INFO", "message": "Samples stats", "data": {"samples": {"rx": [{"max": %f}, {"max": %f}]}}}
{"time": "%s", "log_level": "INFO", "message": "Samples stats", "data": {"samples": {"rx": [{"max": %f}, {"max": %f}]}}}
{"time": "%s", "log_level": "INFO", "message": "Samples stats", "data": {"samples": {"rx": [{"max": %f}, {"max": %f}]}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], -5.0, -6.0,
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], -2.0, -3.0,
(datetime.now() - timedelta(seconds=5)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], -9.0, -7.0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment