Merge "Bux: task_id parameter from API can not pass to yardstick core"
[yardstick.git] / yardstick / benchmark / scenarios / compute / cyclictest.py
index a6c4d95..ae1d373 100644 (file)
@@ -6,12 +6,16 @@
 # which accompanies this distribution, and is available at
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
-import pkg_resources
+from __future__ import absolute_import
+from __future__ import print_function
+
 import logging
-import json
+import os
 import re
 import time
-import os
+
+import pkg_resources
+from oslo_serialization import jsonutils
 
 import yardstick.ssh as ssh
 from yardstick.benchmark.scenarios import base
@@ -137,7 +141,7 @@ class Cyclictest(base.Scenario):
                 self._connect_guest()
 
     def setup(self):
-        '''scenario setup'''
+        """scenario setup"""
         setup_options = self.scenario_cfg["setup_options"]
         host_setup_seqs = setup_options["host_setup_seqs"]
         guest_setup_seqs = setup_options["guest_setup_seqs"]
@@ -154,8 +158,8 @@ class Cyclictest(base.Scenario):
         self.target_script = pkg_resources.resource_filename(
             "yardstick.benchmark.scenarios.compute",
             Cyclictest.TARGET_SCRIPT)
-        self.guest.run("cat > ~/cyclictest_benchmark.sh",
-                       stdin=open(self.target_script, "rb"))
+        self.guest._put_file_shell(
+            self.target_script, '~/cyclictest_benchmark.sh')
 
         self.setup_done = True
 
@@ -183,7 +187,7 @@ class Cyclictest(base.Scenario):
         if status:
             raise RuntimeError(stderr)
 
-        result.update(json.loads(stdout))
+        result.update(jsonutils.loads(stdout))
 
         if "sla" in self.scenario_cfg:
             sla_error = ""
@@ -201,7 +205,7 @@ class Cyclictest(base.Scenario):
 
 
 def _test():    # pragma: no cover
-    '''internal test function'''
+    """internal test function"""
     key_filename = pkg_resources.resource_filename("yardstick.resources",
                                                    "files/yardstick_key")
     ctx = {
@@ -236,7 +240,8 @@ def _test():    # pragma: no cover
 
     cyclictest = Cyclictest(args, ctx)
     cyclictest.run(result)
-    print result
+    print(result)
+
 
 if __name__ == '__main__':    # pragma: no cover
     _test()