Merge "Bugfix: task_id parameter from API can not pass to yardstick core"
[yardstick.git] / yardstick / benchmark / scenarios / networking / netperf_node.py
index a76982b..fd9fa0a 100755 (executable)
@@ -7,9 +7,13 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 # bulk data test and req/rsp test are supported
-import pkg_resources
+from __future__ import absolute_import
+from __future__ import print_function
+
 import logging
-import json
+
+import pkg_resources
+from oslo_serialization import jsonutils
 
 import yardstick.ssh as ssh
 from yardstick.benchmark.scenarios import base
@@ -57,7 +61,7 @@ class NetperfNode(base.Scenario):
         self.setup_done = False
 
     def setup(self):
-        '''scenario setup'''
+        """scenario setup"""
         self.target_script = pkg_resources.resource_filename(
             'yardstick.benchmark.scenarios.networking',
             NetperfNode.TARGET_SCRIPT)
@@ -152,7 +156,7 @@ class NetperfNode(base.Scenario):
         if status:
             raise RuntimeError(stderr)
 
-        result.update(json.loads(stdout))
+        result.update(jsonutils.loads(stdout))
 
         if result['mean_latency'] == '':
             raise RuntimeError(stdout)
@@ -168,13 +172,13 @@ class NetperfNode(base.Scenario):
                 (mean_latency, sla_max_mean_latency)
 
     def teardown(self):
-        '''remove netperf from nodes after test'''
+        """remove netperf from nodes after test"""
         self.server.execute("sudo bash netperf_remove.sh")
         self.client.execute("sudo bash netperf_remove.sh")
 
 
 def _test():    # pragma: no cover
-    '''internal test function'''
+    """internal test function"""
     ctx = {
         "host": {
             "ip": "192.168.10.10",
@@ -200,7 +204,8 @@ def _test():    # pragma: no cover
 
     netperf = NetperfNode(args, ctx)
     netperf.run(result)
-    print result
+    print(result)
+
 
 if __name__ == '__main__':
     _test()