Commit 78dc81c7 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 049f6412
...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise): ...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise):
for f in iter_logrotate_file_handle(self.netconf_log, 'rb'): for f in iter_logrotate_file_handle(self.netconf_log, 'rb'):
for line in iter_reverse_lines(f): 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) alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None)
if alarm_notif and alarm_notif['fault-id'] == '102': if alarm_notif and alarm_notif['fault-id'] == '102':
if alarm_notif['is-cleared'] == 'false': if alarm_notif['is-cleared'] == 'false':
......
...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise): ...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise):
for f in iter_logrotate_file_handle(self.netconf_log, 'rb'): for f in iter_logrotate_file_handle(self.netconf_log, 'rb'):
for line in iter_reverse_lines(f): 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) alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None)
if alarm_notif and alarm_notif['fault-id'] == '103': if alarm_notif and alarm_notif['fault-id'] == '103':
if alarm_notif['is-cleared'] == 'false': if alarm_notif['is-cleared'] == 'false':
......
...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise): ...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise):
for f in iter_logrotate_file_handle(self.netconf_log, 'rb'): for f in iter_logrotate_file_handle(self.netconf_log, 'rb'):
for line in iter_reverse_lines(f): 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) alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None)
if alarm_notif and alarm_notif['fault-id'] == '9': if alarm_notif and alarm_notif['fault-id'] == '9':
if alarm_notif['is-cleared'] == 'false': if alarm_notif['is-cleared'] == 'false':
......
...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise): ...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise):
for f in iter_logrotate_file_handle(self.netconf_log, 'rb'): for f in iter_logrotate_file_handle(self.netconf_log, 'rb'):
for line in iter_reverse_lines(f): 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) alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None)
if alarm_notif and alarm_notif['fault-id'] == '101': if alarm_notif and alarm_notif['fault-id'] == '101':
if alarm_notif['is-cleared'] == 'false': if alarm_notif['is-cleared'] == 'false':
......
...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise): ...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise):
for f in iter_logrotate_file_handle(self.netconf_log, 'rb'): for f in iter_logrotate_file_handle(self.netconf_log, 'rb'):
for line in iter_reverse_lines(f): 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) alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None)
if alarm_notif and alarm_notif['fault-id'] == '18': if alarm_notif and alarm_notif['fault-id'] == '18':
if alarm_notif['is-cleared'] == 'false': if alarm_notif['is-cleared'] == 'false':
......
...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise): ...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise):
for f in iter_logrotate_file_handle(self.netconf_log, 'rb'): for f in iter_logrotate_file_handle(self.netconf_log, 'rb'):
for line in iter_reverse_lines(f): 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) alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None)
if alarm_notif and alarm_notif['fault-id'] == '9': if alarm_notif and alarm_notif['fault-id'] == '9':
if alarm_notif['is-cleared'] == 'false': if alarm_notif['is-cleared'] == 'false':
......
...@@ -48,7 +48,7 @@ def get_json_log_data_interval(json_log_file, interval): ...@@ -48,7 +48,7 @@ def get_json_log_data_interval(json_log_file, interval):
data_list = [] data_list = []
for f in iter_logrotate_file_handle(json_log_file, 'rb'): for f in iter_logrotate_file_handle(json_log_file, 'rb'):
for line in iter_reverse_lines(f): for line in iter_reverse_lines(f):
l = json.loads(line.decode().replace("'", '"')) l = json.loads(line)
timestamp = dateparser.parse(l['time']) timestamp = dateparser.parse(l['time'])
if (current_time - timestamp).total_seconds() > interval: if (current_time - timestamp).total_seconds() > interval:
return data_list return data_list
...@@ -62,7 +62,7 @@ def get_json_log_latest_timestamp(json_log_file): ...@@ -62,7 +62,7 @@ def get_json_log_latest_timestamp(json_log_file):
""" """
for f in iter_logrotate_file_handle(json_log_file, 'rb'): for f in iter_logrotate_file_handle(json_log_file, 'rb'):
for line in iter_reverse_lines(f): for line in iter_reverse_lines(f):
l = json.loads(line.decode().replace("'", '"')) l = json.loads(line)
return dateparser.parse(l['time']).timestamp() return dateparser.parse(l['time']).timestamp()
return 0 return 0
......
...@@ -41,9 +41,9 @@ class TestCheckBasebandLatency(TestPromisePluginMixin): ...@@ -41,9 +41,9 @@ class TestCheckBasebandLatency(TestPromisePluginMixin):
super(TestCheckBasebandLatency, self).setUp() super(TestCheckBasebandLatency, self).setUp()
self.amarisoft_stats_log = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'amarisoft_stats.json.log') 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: 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}}} 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}}}
{"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=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=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, (datetime.now() - timedelta(seconds=5)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], 5.0,
......
...@@ -49,8 +49,8 @@ class TestCheckLopcommPACurrentSuccess(TestPromisePluginMixin): ...@@ -49,8 +49,8 @@ class TestCheckLopcommPACurrentSuccess(TestPromisePluginMixin):
def test_promise_success(self): def test_promise_success(self):
with open(self.netconf_log, 'w+') as f: 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'}}}} 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'}}}}""" % ( {"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=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).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): ...@@ -62,8 +62,8 @@ class TestCheckLopcommPACurrentSuccess(TestPromisePluginMixin):
def test_promise_fail(self): def test_promise_fail(self):
with open(self.netconf_log, 'w+') as f: 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'}}}} 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'}}}}""" % ( {"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=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
)) ))
...@@ -73,4 +73,4 @@ class TestCheckLopcommPACurrentSuccess(TestPromisePluginMixin): ...@@ -73,4 +73,4 @@ class TestCheckLopcommPACurrentSuccess(TestPromisePluginMixin):
self.configureLauncher() self.configureLauncher()
with self.assertRaises(PromiseError): with self.assertRaises(PromiseError):
self.launcher.run() self.launcher.run()
self.assertEqual("PA Over Current Alarm is on, affected objects are: {'name': 'PA0'}", self.getPromiseResult(self.promise_name)['result']['message']) self.assertEqual('PA Over Current Alarm is on, affected objects are: {"name": "PA0"}', self.getPromiseResult(self.promise_name)['result']['message'])
...@@ -49,8 +49,8 @@ class TestCheckLopcommPAOutputPowerSuccess(TestPromisePluginMixin): ...@@ -49,8 +49,8 @@ class TestCheckLopcommPAOutputPowerSuccess(TestPromisePluginMixin):
def test_promise_success(self): def test_promise_success(self):
with open(self.netconf_log, 'w+') as f: 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'}}}} 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'}}}}""" % ( {"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=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).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): ...@@ -62,8 +62,8 @@ class TestCheckLopcommPAOutputPowerSuccess(TestPromisePluginMixin):
def test_promise_fail(self): def test_promise_fail(self):
with open(self.netconf_log, 'w+') as f: 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'}}}} 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'}}}}""" % ( {"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=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
)) ))
...@@ -73,4 +73,4 @@ class TestCheckLopcommPAOutputPowerSuccess(TestPromisePluginMixin): ...@@ -73,4 +73,4 @@ class TestCheckLopcommPAOutputPowerSuccess(TestPromisePluginMixin):
self.configureLauncher() self.configureLauncher()
with self.assertRaises(PromiseError): with self.assertRaises(PromiseError):
self.launcher.run() self.launcher.run()
self.assertEqual("PA Over Output Power Alarm is on, affected objects are: {'name': 'PA0'}", self.getPromiseResult(self.promise_name)['result']['message']) self.assertEqual('PA Over Output Power Alarm is on, affected objects are: {"name": "PA0"}', self.getPromiseResult(self.promise_name)['result']['message'])
...@@ -49,8 +49,8 @@ class TestCheckLopcommRSSISuccess(TestPromisePluginMixin): ...@@ -49,8 +49,8 @@ class TestCheckLopcommRSSISuccess(TestPromisePluginMixin):
def test_promise_success(self): def test_promise_success(self):
with open(self.netconf_log, 'w+') as f: 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'}}}} 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'}}}}""" % ( {"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=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).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): ...@@ -62,8 +62,8 @@ class TestCheckLopcommRSSISuccess(TestPromisePluginMixin):
def test_promise_fail(self): def test_promise_fail(self):
with open(self.netconf_log, 'w+') as f: 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'}}}} 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'}}}}""" % ( {"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=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
)) ))
...@@ -73,4 +73,4 @@ class TestCheckLopcommRSSISuccess(TestPromisePluginMixin): ...@@ -73,4 +73,4 @@ class TestCheckLopcommRSSISuccess(TestPromisePluginMixin):
self.configureLauncher() self.configureLauncher()
with self.assertRaises(PromiseError): with self.assertRaises(PromiseError):
self.launcher.run() self.launcher.run()
self.assertEqual("RSSI Imbalance alarm & RX Diversity Lost alarm is on, affected objects are: {'name': 'RF Module'}", self.getPromiseResult(self.promise_name)['result']['message']) self.assertEqual('RSSI Imbalance alarm & RX Diversity Lost alarm is on, affected objects are: {"name": "RF Module"}', self.getPromiseResult(self.promise_name)['result']['message'])
...@@ -49,8 +49,8 @@ class TestCheckLopcommSyncSuccess(TestPromisePluginMixin): ...@@ -49,8 +49,8 @@ class TestCheckLopcommSyncSuccess(TestPromisePluginMixin):
def test_promise_success(self): def test_promise_success(self):
with open(self.netconf_log, 'w+') as f: 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'}}}} 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'}}}}""" % ( {"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=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).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): ...@@ -62,8 +62,8 @@ class TestCheckLopcommSyncSuccess(TestPromisePluginMixin):
def test_promise_fail(self): def test_promise_fail(self):
with open(self.netconf_log, 'w+') as f: 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'}}}} 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'}}}}""" % ( {"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=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).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): ...@@ -49,8 +49,8 @@ class TestCheckLopcommVSWRSuccess(TestPromisePluginMixin):
def test_promise_success(self): def test_promise_success(self):
with open(self.netconf_log, 'w+') as f: 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'}}}} 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'}}}}""" % ( {"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=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).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): ...@@ -62,8 +62,8 @@ class TestCheckLopcommVSWRSuccess(TestPromisePluginMixin):
def test_promise_fail(self): def test_promise_fail(self):
with open(self.netconf_log, 'w+') as f: 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'}}}} 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'}}}}""" % ( {"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=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
)) ))
...@@ -73,4 +73,4 @@ class TestCheckLopcommVSWRSuccess(TestPromisePluginMixin): ...@@ -73,4 +73,4 @@ class TestCheckLopcommVSWRSuccess(TestPromisePluginMixin):
self.configureLauncher() self.configureLauncher()
with self.assertRaises(PromiseError): with self.assertRaises(PromiseError):
self.launcher.run() self.launcher.run()
self.assertEqual("VSWR alarm is on, affected objects are: {'name': 'Antport1'}", self.getPromiseResult(self.promise_name)['result']['message']) self.assertEqual('VSWR alarm is on, affected objects are: {"name": "Antport1"}', self.getPromiseResult(self.promise_name)['result']['message'])
...@@ -41,9 +41,9 @@ class TestCheckRXSaturated(TestPromisePluginMixin): ...@@ -41,9 +41,9 @@ class TestCheckRXSaturated(TestPromisePluginMixin):
super(TestCheckRXSaturated, self).setUp() super(TestCheckRXSaturated, self).setUp()
self.amarisoft_stats_log = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'amarisoft_stats.json.log') 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: 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}]}}} 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}]}}}
{"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=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=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, (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