1 ##############################################################################
2 # Copyright (c) 2018 HUAWEI TECHNOLOGIES CO.,LTD and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
12 from src.step.test_step import TestStep
15 class WorkloadStep(TestStep):
16 __step_type__ = 'workload'
18 def __init__(self, id, name, service, action, args):
19 super(WorkloadStep, self).__init__(
20 self.__step_type__, id, name, service, action, args)
25 if self._callType == "REST":
26 currentDirPath = os.path.dirname(os.path.abspath(__file__))
27 envDirPath = os.path.abspath(
28 os.path.join(currentDirPath, os.pardir, os.pardir, 'env'))
29 envFilePath = os.path.join(
30 envDirPath, "%s.json" % self._service['name'])
31 with open(envFilePath) as f:
32 propDict = json.load(f)
33 self._args['ip'] = propDict['ip']
34 self._args['port'] = propDict['port']
35 self._args['api'] = "%s/%s" % (
36 propDict['api_map']['workload'], self._args['command'])
37 exclude = {'ip', 'port', 'api', 'command', 'method'}
38 self._args['req_body'] = {
39 key: value for key, value in
40 self._args.items() if key not in exclude}
43 print "workload start"