GSO: Add export of results to json files.
[csit.git] / resources / libraries / python / model / ExportJson.py
index b0e0158..73e8224 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2022 Cisco and/or its affiliates.
+# Copyright (c) 2023 Cisco and/or its affiliates.
 # 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:
@@ -23,12 +23,14 @@ as serialization might have introduced subtle errors.
 import datetime
 import os.path
 
+from binascii import b2a_base64
 from dateutil.parser import parse
 from robot.api import logger
 from robot.libraries.BuiltIn import BuiltIn
+from zlib import compress
 
 from resources.libraries.python.Constants import Constants
-from resources.libraries.python.jumpavg.AvgStdevStats import AvgStdevStats
+from resources.libraries.python.jumpavg import AvgStdevStats
 from resources.libraries.python.model.ExportResult import (
     export_dut_type_and_version, export_tg_type_and_version
 )
@@ -65,11 +67,11 @@ class ExportJson():
         if u"DEVICETEST" in tags:
             test_type = u"device"
         elif u"LDP_NGINX" in tags:
-            test_type = u"vsap"
+            test_type = u"hoststack"
         elif u"HOSTSTACK" in tags:
             test_type = u"hoststack"
         elif u"GSO_TRUE" in tags or u"GSO_FALSE" in tags:
-            test_type = u"gso"
+            test_type = u"mrr"
         elif u"RECONF" in tags:
             test_type = u"reconf"
         # The remaining 3 options could also apply to DPDK and TRex tests.
@@ -357,6 +359,11 @@ class ExportJson():
         Results are used to avoid future post processing, making it more
         efficient to consume.
         """
+        if self.data["telemetry"]:
+            telemetry_encode = "\n".join(self.data["telemetry"]).encode()
+            telemetry_compress = compress(telemetry_encode, level=9)
+            telemetry_base64 = b2a_base64(telemetry_compress, newline=False)
+            self.data["telemetry"] = [telemetry_base64.decode()]
         if u"result" not in self.data:
             return
         result_node = self.data[u"result"]