From a8d624c0502c241feadcfba71ba1442b22d9908b Mon Sep 17 00:00:00 2001 From: Satoshi Fujii Date: Fri, 15 Oct 2021 06:55:11 +0000 Subject: Fix microsec timestamp not properly handled Current heartbeat service assumes lastEpochMicrosec timestamp in VES notification is represented as milli-seconds, but some devices sends micro-sec timestamp in the field. In that case, the heartbeat notification was not working due to timestamp comparison was not done properly. Signed-off-by: Satoshi Fujii Issue-ID: DCAEGEN2-2940 Change-Id: Id7c9241de70cb3ff7ee59cf1e2c60089ff96a42b --- Changelog.md | 1 + miss_htbt_service/htbtworker.py | 3 +++ tests/test1.json | 2 +- tests/test2.json | 4 ++-- tests/test3.json | 4 ++-- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Changelog.md b/Changelog.md index a737ec8..faa6057 100644 --- a/Changelog.md +++ b/Changelog.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - [DCAEGEN2-2939] Removed unused code (config\_notif.py) ### Fixed - [DCAEGEN2-2832] Pod become unready state +- [DCAEGEN2-2940] Microsec timestamp not properly handled - [DCAEGEN2-2944] cbs polling process startup failure diff --git a/miss_htbt_service/htbtworker.py b/miss_htbt_service/htbtworker.py index 467b2b7..6fbda2d 100644 --- a/miss_htbt_service/htbtworker.py +++ b/miss_htbt_service/htbtworker.py @@ -125,6 +125,9 @@ def process_msg(jsfile, user_name, password, ip_address, port_num, db_name): jitem = json.loads(item) srcname = (jitem['event']['commonEventHeader']['sourceName']) lastepo = (jitem['event']['commonEventHeader']['lastEpochMicrosec']) + # if lastEpochMicrosec looks like microsec, align it with millisec + if lastepo > 1000000000000000: + lastepo = int(lastepo / 1000) seqnum = (jitem['event']['commonEventHeader']['sequence']) eventName = (jitem['event']['commonEventHeader']['eventName']) except Exception as err: diff --git a/tests/test1.json b/tests/test1.json index 0390a91..8d105e2 100644 --- a/tests/test1.json +++ b/tests/test1.json @@ -1 +1 @@ -{ "event": { "commonEventHeader": { "vesEventListenerVersion": "7.0.2", "domain": "heartbeat", "eventId": "mvfs10", "eventName": "Heartbeat_vDNS", "lastEpochMicrosec": 1548313727714, "priority": "Normal", "reportingEntityName": "ibcx0001vm002oam001", "sequence": 1000, "sourceName": "SOURCE_NAME1", "startEpochMicrosec": 1548313727714, "version": "4.0.2", "reportingEntityId": "cc305d54-75b4-431b-adb2-eb6b9e541234", "sourceId": "VNFA_SRC1", "eventType": "platform", "nfcNamingCode": "VNFA", "nfNamingCode": "VNFA", "timeZoneOffset": "UTC-05:30" }, "heartbeatFields": { "heartbeatInterval": 20, "heartbeatFieldsVersion": "3.0" } } } +{ "event": { "commonEventHeader": { "vesEventListenerVersion": "7.0.2", "domain": "heartbeat", "eventId": "mvfs10", "eventName": "Heartbeat_vDNS", "lastEpochMicrosec": 1548313727714000, "priority": "Normal", "reportingEntityName": "ibcx0001vm002oam001", "sequence": 1000, "sourceName": "SOURCE_NAME1", "startEpochMicrosec": 1548313727714000, "version": "4.0.2", "reportingEntityId": "cc305d54-75b4-431b-adb2-eb6b9e541234", "sourceId": "VNFA_SRC1", "eventType": "platform", "nfcNamingCode": "VNFA", "nfNamingCode": "VNFA", "timeZoneOffset": "UTC-05:30" }, "heartbeatFields": { "heartbeatInterval": 20, "heartbeatFieldsVersion": "3.0" } } } diff --git a/tests/test2.json b/tests/test2.json index 3a2f5c5..b582111 100644 --- a/tests/test2.json +++ b/tests/test2.json @@ -5,12 +5,12 @@ "domain": "heartbeat", "eventId": "mvfs10", "eventName": "Heartbeat_vFW", - "lastEpochMicrosec": 1544165792763, + "lastEpochMicrosec": 1544165792763000, "priority": "Normal", "reportingEntityName": "ibcx0001vm002oam001", "sequence": 1000, "sourceName": "SOURCE_NAME2", - "startEpochMicrosec": 1544165792763, + "startEpochMicrosec": 1544165792763000, "version": "4.0.2", "reportingEntityId": "cc305d54-75b4-431b-adb2-eb6b9e541234", "sourceId": "VNFB_SRC5", diff --git a/tests/test3.json b/tests/test3.json index 9030267..0eaf6c1 100644 --- a/tests/test3.json +++ b/tests/test3.json @@ -5,12 +5,12 @@ "domain": "heartbeat", "eventId": "mvfs10", "eventName": "Heartbeat_vFW", - "lastEpochMicrosec": 1548313727714, + "lastEpochMicrosec": 1548313727714000, "priority": "Normal", "reportingEntityName": "ibcx0001vm002oam001", "sequence": 1000, "sourceName": "SOURCE_NAME3", - "startEpochMicrosec": 1548313727714, + "startEpochMicrosec": 1548313727714000, "version": "4.0.2", "reportingEntityId": "cc305d54-75b4-431b-adb2-eb6b9e541234", "sourceId": "VNFA_SRC3", -- cgit 1.2.3-korg