+##############################################################################\r
+# Copyright (c) 2018 HUAWEI TECHNOLOGIES CO.,LTD and others.\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are made available under the terms of the Apache License, Version 2.0\r
+# which accompanies this distribution, and is available at\r
+# http://www.apache.org/licenses/LICENSE-2.0\r
+##############################################################################\r
+\r
+import json\r
+import os\r
+from src.step.test_step import TestStep\r
+\r
+\r
+class WorkloadStep(TestStep):\r
+ __step_type__ = 'workload'\r
+\r
+ def __init__(self, id, name, service, action, args):\r
+ super(WorkloadStep, self).__init__(\r
+ self.__step_type__, id, name, service, action, args)\r
+ self._argsParse()\r
+ self._action()\r
+\r
+ def _argsParse(self):\r
+ if self._callType == "REST":\r
+ currentDirPath = os.path.dirname(os.path.abspath(__file__))\r
+ envDirPath = os.path.abspath(\r
+ os.path.join(currentDirPath, os.pardir, os.pardir, 'env'))\r
+ envFilePath = os.path.join(\r
+ envDirPath, "%s.json" % self._service['name'])\r
+ with open(envFilePath) as f:\r
+ propDict = json.load(f)\r
+ self._args['ip'] = propDict['ip']\r
+ self._args['port'] = propDict['port']\r
+ self._args['api'] = "%s/%s" % (\r
+ propDict['api_map']['workload'], self._args['command'])\r
+ exclude = {'ip', 'port', 'api', 'command', 'method'}\r
+ self._args['req_body'] = {\r
+ key: value for key, value in\r
+ self._args.items() if key not in exclude}\r
+\r
+ def _start(self):\r
+ print "workload start"\r
+\r
+ def _stop(self):\r
+ print "workload stop"\r