BugFix: Adopt to latest result structure while parsing the results 03/28503/3
authorDeepak S <deepak.s@linux.intel.com>
Sun, 12 Feb 2017 23:34:57 +0000 (15:34 -0800)
committerDeepak S <deepak.s@linux.intel.com>
Mon, 13 Feb 2017 02:52:02 +0000 (18:52 -0800)
Change-Id: I298ea69c86019936585df4bae30ce8ea12d179f4
Signed-off-by: Deepak S <deepak.s@linux.intel.com>
tests/unit/cmd/test_NSBperf.py
yardstick/cmd/NSBperf.py

index a14c084..5bd248a 100644 (file)
@@ -40,7 +40,8 @@ class TestYardstickNSCli(unittest.TestCase):
     def test_generate_final_report(self):
         yardstick_ns_cli = YardstickNSCli()
         test_case = "tc_baremetal_rfc2544_ipv4_1flow_1518B.yaml"
-        subprocess.call(["touch", "/tmp/yardstick.out"])
+        if os.path.isfile("/tmp/yardstick.out"):
+            os.remove('/tmp/yardstick.out')
         self.assertIsNone(yardstick_ns_cli.generate_final_report(test_case))
 
     def test_generate_kpi_results(self):
index dd96b7f..8f493dd 100755 (executable)
@@ -24,7 +24,7 @@ import argparse
 import json
 import subprocess
 import signal
-
+from oslo_serialization import jsonutils
 
 from six.moves import input
 
@@ -126,10 +126,11 @@ class YardstickNSCli(object):
         if os.path.isfile("/tmp/yardstick.out"):
             lines = []
             with open("/tmp/yardstick.out") as infile:
-                lines = infile.readlines()
+                lines = jsonutils.load(infile)
 
             if lines:
-                tc_res = json.loads(lines.pop(len(lines) - 1))
+                lines = lines['result']
+                tc_res = lines.pop(len(lines) - 1)
                 for key, value in tc_res["benchmark"]["data"].items():
                     self.generate_kpi_results(key, value)
                     self.generate_nfvi_results(value)