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