From e32043f58a2450b6a5986dc2a01f64f8b22c3992 Mon Sep 17 00:00:00 2001 From: "Yang (Gabriel) Yu" Date: Tue, 4 Sep 2018 21:02:27 +0800 Subject: Change naming and veriy test-scheduler function Changes: 1. Testing-scheduler -> Test-scheduler 2. lots of windows breaks '\r' and '^M' in files, batch changes to unix breaks '$' 3. Add ui/build Change-Id: I1f2c98ab9348460d4e68bfbfab664dae82b761ba Signed-off-by: Yang (Gabriel) Yu --- .../server/src/step/general_test_step.py | 87 ---------------------- 1 file changed, 87 deletions(-) delete mode 100644 testing-scheduler/server/src/step/general_test_step.py (limited to 'testing-scheduler/server/src/step/general_test_step.py') diff --git a/testing-scheduler/server/src/step/general_test_step.py b/testing-scheduler/server/src/step/general_test_step.py deleted file mode 100644 index 2f9e8bcc..00000000 --- a/testing-scheduler/server/src/step/general_test_step.py +++ /dev/null @@ -1,87 +0,0 @@ -############################################################################## -# 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 -############################################################################## - -from src.step.test_step import TestStep -import os -import yaml -import re - - -class GeneralTestStep(TestStep): - __step_type__ = "test" - - def __init__(self, id, name, service, action, args, context): - super(GeneralTestStep, self).__init__( - self.__step_type__, id, name, service, action, args, context) - self._stepParse() - self.action() - - def _contextTransform(self, argsDict): - for (k, v) in argsDict.items(): - if isinstance(v, str): - if re.match('^\(\(context\..*\)\)', v): - v = v[10:-2] - layers = v.split(".") - contextData = self._context - for layer in layers: - contextData = contextData[layer] - argsDict[k] = contextData - elif isinstance(v, dict): - self._contextTransform(v) - - def _stepParse(self): - self._args_temp = self._args - self._args = {} - - # transform the service config - envFilePath = os.path.join( - self._getCurrentDir(), "..", "env", - "service", self._serviceName + ".yaml") - requestParam = {} - with open(envFilePath, 'r') as f: - conf = yaml.load(f) - conf = conf[self._serviceName] - for apiItem in conf["apis"]: - if apiItem['name'] == self._serviceInterface: - interfaceConf = apiItem - if interfaceConf is None: - return - - # transform the args config - self._contextTransform(self._args_temp) - - interfaceUri = interfaceConf['baseuri'] + \ - interfaceConf['template']['uri'][11:] - interfaceUri = "http://%s:%s/%s" % ( - conf['ip'], conf['port'], interfaceUri) - requestParam['uri'] = self._uriTransform(interfaceUri) - - requestParam['method'] = interfaceConf['method'] - if requestParam["method"] == "POST": - requestParam['body'] = interfaceConf['template']['body'] - self._paramTransform(requestParam['body'], self._args_temp) - self._args['http_request'] = requestParam - - def _uriTransform(self, uri): - return re.sub("\(\(.*?\)\)", self._uriResReplace, uri) - - def _uriResReplace(self, match): - matchTrim = match.group()[2:-2] - return self._args_temp[matchTrim] - - def _paramTransform(self, argsTemplate, argsDict): - for (k, v) in argsTemplate.items(): - if isinstance(v, str): - if re.match('^\(\(.*\)\)', v): - argsTemplate[k] = argsDict[v[2:-2]] - elif isinstance(v, dict): - self._paramTransform(v, argsDict) - - def start(self): - pass -- cgit 1.2.3-korg