From 1c1cbbf6df7f30ecb807a0a09924072a59bd2071 Mon Sep 17 00:00:00 2001 From: LeoQi Date: Fri, 20 Jul 2018 02:43:38 +0800 Subject: parser script and step class in backend code of testing-scheduler JIRA: BOTTLENECK-234 add the main parse function and base classes of step. Change-Id: Id7554ed065ada84f23b3ca498ffb89c1127850b5 Signed-off-by: Zheng Qibin --- testing-scheduler/server/__init__.py | 8 + testing-scheduler/server/python_modules.txt | 14 + testing-scheduler/server/setup.py | 31 ++ testing-scheduler/server/src/__init__.py | 8 + .../server/src/env/context/context.yaml | 75 +++++ .../server/src/env/service/ansible.yaml | 65 +++++ .../server/src/env/service/greet.yaml | 68 +++++ testing-scheduler/server/src/step/__init__.py | 8 + .../server/src/step/general_test_step.py | 87 ++++++ testing-scheduler/server/src/step/monitor.py | 57 ++++ testing-scheduler/server/src/step/step_manager.py | 41 +++ testing-scheduler/server/src/step/test_step.py | 56 ++++ testing-scheduler/server/src/step/workload.py | 46 +++ testing-scheduler/server/src/test_parser.py | 315 +++++++++++++++++++++ testing-scheduler/server/test/__init__.py | 8 + .../server/test/test_case/logic/tc_logic_00.yaml | 30 ++ .../server/test/test_case/logic/tc_logic_01.yaml | 73 +++++ .../server/test/test_case/logic/tc_logic_02.yaml | 71 +++++ .../server/test/test_case/logic/tc_logic_03.yaml | 86 ++++++ .../server/test/test_case/logic/tc_logic_04.yaml | 70 +++++ .../server/test/test_case/logic/tc_logic_05.yaml | 100 +++++++ .../server/test/test_case/logic/tc_logic_06.yaml | 80 ++++++ .../server/test/test_case/logic/tc_logic_07.yaml | 100 +++++++ .../server/test/test_case/logic/tc_logic_08.yaml | 114 ++++++++ .../test/test_case/logic_in_out/tc_cxt_01.yaml | 47 +++ .../test/test_case/logic_in_out/tc_io_01.yaml | 63 +++++ .../test/test_case/logic_in_out/tc_io_02.yaml | 60 ++++ .../test/test_case/suite_test/tc_suitetest_00.yaml | 27 ++ .../test/test_case/suite_test/tc_suitetest_01.yaml | 27 ++ .../test/test_case/suite_test/tc_suitetest_02.yaml | 27 ++ 30 files changed, 1862 insertions(+) create mode 100644 testing-scheduler/server/__init__.py create mode 100644 testing-scheduler/server/python_modules.txt create mode 100644 testing-scheduler/server/setup.py create mode 100644 testing-scheduler/server/src/__init__.py create mode 100644 testing-scheduler/server/src/env/context/context.yaml create mode 100644 testing-scheduler/server/src/env/service/ansible.yaml create mode 100644 testing-scheduler/server/src/env/service/greet.yaml create mode 100644 testing-scheduler/server/src/step/__init__.py create mode 100644 testing-scheduler/server/src/step/general_test_step.py create mode 100644 testing-scheduler/server/src/step/monitor.py create mode 100644 testing-scheduler/server/src/step/step_manager.py create mode 100644 testing-scheduler/server/src/step/test_step.py create mode 100644 testing-scheduler/server/src/step/workload.py create mode 100644 testing-scheduler/server/src/test_parser.py create mode 100644 testing-scheduler/server/test/__init__.py create mode 100644 testing-scheduler/server/test/test_case/logic/tc_logic_00.yaml create mode 100644 testing-scheduler/server/test/test_case/logic/tc_logic_01.yaml create mode 100644 testing-scheduler/server/test/test_case/logic/tc_logic_02.yaml create mode 100644 testing-scheduler/server/test/test_case/logic/tc_logic_03.yaml create mode 100644 testing-scheduler/server/test/test_case/logic/tc_logic_04.yaml create mode 100644 testing-scheduler/server/test/test_case/logic/tc_logic_05.yaml create mode 100644 testing-scheduler/server/test/test_case/logic/tc_logic_06.yaml create mode 100644 testing-scheduler/server/test/test_case/logic/tc_logic_07.yaml create mode 100644 testing-scheduler/server/test/test_case/logic/tc_logic_08.yaml create mode 100644 testing-scheduler/server/test/test_case/logic_in_out/tc_cxt_01.yaml create mode 100644 testing-scheduler/server/test/test_case/logic_in_out/tc_io_01.yaml create mode 100644 testing-scheduler/server/test/test_case/logic_in_out/tc_io_02.yaml create mode 100644 testing-scheduler/server/test/test_case/suite_test/tc_suitetest_00.yaml create mode 100644 testing-scheduler/server/test/test_case/suite_test/tc_suitetest_01.yaml create mode 100644 testing-scheduler/server/test/test_case/suite_test/tc_suitetest_02.yaml (limited to 'testing-scheduler/server') diff --git a/testing-scheduler/server/__init__.py b/testing-scheduler/server/__init__.py new file mode 100644 index 00000000..e8198009 --- /dev/null +++ b/testing-scheduler/server/__init__.py @@ -0,0 +1,8 @@ +############################################################################## +# 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 +############################################################################## diff --git a/testing-scheduler/server/python_modules.txt b/testing-scheduler/server/python_modules.txt new file mode 100644 index 00000000..62da9c26 --- /dev/null +++ b/testing-scheduler/server/python_modules.txt @@ -0,0 +1,14 @@ +############################################################################## +# 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 +############################################################################## + +flask +flask_cors +pyyaml +pyaml +requests \ No newline at end of file diff --git a/testing-scheduler/server/setup.py b/testing-scheduler/server/setup.py new file mode 100644 index 00000000..398f8763 --- /dev/null +++ b/testing-scheduler/server/setup.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python +############################################################################## +# 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 +############################################################################## +'''This file realize the function of how to setup server of testing-scheduler +to your environment. This use setuptools tool to setup''' + +from setuptools import setup, find_packages + + +setup( + name="testing-scheduler-server", + version="0.1", + packages=find_packages(), + include_package_data=True, + package_data={ + 'src': [ + 'env/context/*.yaml', + 'env/service/*.yaml', + 'conductor_processor/*.json' + ], + 'test': [ + 'test_case/*/*.yaml' + ] + } +) diff --git a/testing-scheduler/server/src/__init__.py b/testing-scheduler/server/src/__init__.py new file mode 100644 index 00000000..e8198009 --- /dev/null +++ b/testing-scheduler/server/src/__init__.py @@ -0,0 +1,8 @@ +############################################################################## +# 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 +############################################################################## diff --git a/testing-scheduler/server/src/env/context/context.yaml b/testing-scheduler/server/src/env/context/context.yaml new file mode 100644 index 00000000..58ed4614 --- /dev/null +++ b/testing-scheduler/server/src/env/context/context.yaml @@ -0,0 +1,75 @@ +############################################################################## +# 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 +############################################################################## + +--- + +hosts: + node26: + name: node26 + ip: 192.168.1.26 + port: 22 + user: root + password: 123456 + + node27: + name: node27 + ip: 192.168.1.27 + port: 22 + user: root + password: 123456 + + node28: + name: node28 + ip: 192.168.1.28 + port: 22 + user: root + password: 123456 + + node29: + name: node29 + ip: 192.168.1.29 + port: 22 + user: root + password: 123456 + + node30: + name: node30 + ip: 192.168.1.30 + port: 22 + user: root + password: 123456 + + node31: + name: node31 + ip: 192.168.1.31 + port: 22 + user: root + password: 123456 + + node32: + name: node32 + ip: 192.168.1.32 + port: 22 + user: root + password: 123456 + + +cassandra: + name: node24 + ip: 192.168.1.24 + port: 22 + user: root + password: 123456 + +sprout: + name: node32 + ip: 192.168.1.32 + port: 22 + user: root + password: 123456 \ No newline at end of file diff --git a/testing-scheduler/server/src/env/service/ansible.yaml b/testing-scheduler/server/src/env/service/ansible.yaml new file mode 100644 index 00000000..7b97602d --- /dev/null +++ b/testing-scheduler/server/src/env/service/ansible.yaml @@ -0,0 +1,65 @@ +############################################################################## +# 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 +############################################################################## + +--- + +ansible: + apis: + - method: POST + name: faultload + params: + - description: call user count + name: call_user + - description: workload time + name: duration + - description: faultload time + name: fault_duration + - description: register speed + name: initial_reg_rate + - description: multiplier + name: multiplier + - description: register user count + name: reg_user + baseuri: faultload + template: + uri: ((baseuri)) + body: + call_user: ((call_user)) + duration: ((duration)) + fault_duration: ((fault_duration)) + initial_reg_rate: ((initial_reg_rate)) + multiplier: ((multiplier)) + reg_user: ((reg_user)) + + - method: POST + name: workload + params: + - description: call user count + name: call_user + - description: workload time + name: duration + - description: register speed + name: initial_reg_rate + - description: multiplier + name: multiplier + - description: register user count + name: reg_user + baseuri: workload + template: + uri: ((baseuri)) + body: + call_user: ((call_user)) + duration: ((duration)) + fault_duration: ((fault_duration)) + initial_reg_rate: ((initial_reg_rate)) + multiplier: ((multiplier)) + reg_user: ((reg_user)) + + ip: 100.64.227.222 + port: 9006 diff --git a/testing-scheduler/server/src/env/service/greet.yaml b/testing-scheduler/server/src/env/service/greet.yaml new file mode 100644 index 00000000..1b21f413 --- /dev/null +++ b/testing-scheduler/server/src/env/service/greet.yaml @@ -0,0 +1,68 @@ +############################################################################## +# 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 +############################################################################## + +--- + +greet: + ip: t-scheduler-server + port: 5312 + apis: + - + name: greet + method: GET + baseuri: greet + params: + - name: name + description: user name + template: + uri: ((baseuri))?name=((name)) + response: + result: int + next: + aa: str + bb: int + - + name: answer + method: POST + baseuri: answer + params: + - name: ping + description: param ping + template: + uri: ((baseuri)) + body: + ping: ((ping)) + + - + name: ten + method: GET + baseuri: ten + template: + uri: ((baseuri)) + + + - + name: switch + method: GET + baseuri: switch + template: + uri: ((baseuri)) + return: + - + result + + - + name: switch_2 + method: GET + baseuri: switch_2 + template: + uri: ((baseuri)) + return: + - + result diff --git a/testing-scheduler/server/src/step/__init__.py b/testing-scheduler/server/src/step/__init__.py new file mode 100644 index 00000000..e8198009 --- /dev/null +++ b/testing-scheduler/server/src/step/__init__.py @@ -0,0 +1,8 @@ +############################################################################## +# 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 +############################################################################## diff --git a/testing-scheduler/server/src/step/general_test_step.py b/testing-scheduler/server/src/step/general_test_step.py new file mode 100644 index 00000000..2f9e8bcc --- /dev/null +++ b/testing-scheduler/server/src/step/general_test_step.py @@ -0,0 +1,87 @@ +############################################################################## +# 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 diff --git a/testing-scheduler/server/src/step/monitor.py b/testing-scheduler/server/src/step/monitor.py new file mode 100644 index 00000000..6deb9e2e --- /dev/null +++ b/testing-scheduler/server/src/step/monitor.py @@ -0,0 +1,57 @@ +############################################################################## +# 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 MonitorStep(TestStep): + __step_type__ = 'monitor' + + def __init__(self, name, service, action, args): + super(MonitorStep, self).__init__(name, service, action, args) + self._argsParse() + self.action() + + def _argsParse(self): + if self._call == "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 setUp(self): + print "monitor setUp" + + def uninstall(self): + print "monitor uninstall" + + def start(self): + print "monitor start...." + + def stop(self): + print "monitor stop" + + +if __name__ == "__main__": + service = {"name": "ansible", "call": "REST"} + monitor = MonitorStep( + "monitor_cpu", service, "start", **{"target": "abc:qq"}) diff --git a/testing-scheduler/server/src/step/step_manager.py b/testing-scheduler/server/src/step/step_manager.py new file mode 100644 index 00000000..8d76c67c --- /dev/null +++ b/testing-scheduler/server/src/step/step_manager.py @@ -0,0 +1,41 @@ +############################################################################## +# 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 sys + + +class TestStepManager(object): + def __init__(self, context): + self._context = context + + currentDirPath = os.path.dirname(os.path.abspath(__file__)) + sys.path.append(currentDirPath) + + excludeFiles = ('__init__.py', 'step_manager.py', 'test_step.py') + for fileName in os.listdir(currentDirPath): + if os.path.isfile(os.path.join(currentDirPath, fileName)) and \ + os.path.splitext(fileName)[1] == '.py' and \ + fileName not in excludeFiles: + __import__(os.path.splitext(fileName)[0]) + + def getStepObj(self, type, id, name, service, action, args): + for subclass in TestStep.__subclasses__(): + if type == subclass.__step_type__: + return subclass(id, name, service, action, args, self._context) + + +if __name__ == "__main__": + tsMgr = TestStepManager() + args = {'command': 'greet', 'method': 'POST', 'args': {'name': 'leo'}} + stepObj = tsMgr.getStepObj('test', 1, 'test_cpu', { + 'name': 'greet', 'call': 'REST'}, 'start', args) + print stepObj + print stepObj.__class__.__mro__ diff --git a/testing-scheduler/server/src/step/test_step.py b/testing-scheduler/server/src/step/test_step.py new file mode 100644 index 00000000..363c4800 --- /dev/null +++ b/testing-scheduler/server/src/step/test_step.py @@ -0,0 +1,56 @@ +############################################################################## +# 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 os + + +class TestStep(object): + def __init__(self, type, id, name, service, action, args, context): + self._type = type + self._id = id + self._name = name + self._serviceName = service['name'] + self._serviceInterface = service['interface'] + self._action = action + self._args = args + self._context = context + + def getId(self): + return self._id + + def getName(self): + return self._name + + def getServiceName(self): + return self._serviceName + + def getCallFunction(self): + return self._callType + + def getArgs(self): + return self._args + + def action(self): + f = getattr(self, self._action) + f() + + def _argsParse(self): + pass + + def _getCurrentDir(self): + return os.path.dirname(__file__) + + def __str__(self): + return str(self.__dict__) + + +if __name__ == "__main__": + args = {'command': 'start'} + stepObj = TestStep('test_cpu', 'ansible', 'REST', **args) + print stepObj diff --git a/testing-scheduler/server/src/step/workload.py b/testing-scheduler/server/src/step/workload.py new file mode 100644 index 00000000..265b9a6b --- /dev/null +++ b/testing-scheduler/server/src/step/workload.py @@ -0,0 +1,46 @@ +############################################################################## +# 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" diff --git a/testing-scheduler/server/src/test_parser.py b/testing-scheduler/server/src/test_parser.py new file mode 100644 index 00000000..7b471517 --- /dev/null +++ b/testing-scheduler/server/src/test_parser.py @@ -0,0 +1,315 @@ +#!/usr/bin/env python + +############################################################################## +# 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 click +import os +import yaml +import json +import collections +from src.step.step_manager import TestStepManager +from src.conductor_processor.workflow import WorkflowFile +from conductorclient.run_new_workflow import WorkflowMgr + +BASE_DIR = os.path.dirname(os.path.abspath(__file__)) +CONDUCTOR_SERVER_ADDR = "http://conductor_conductor-server_1:8080" +STORE_TASK_PATH = "/tmp/generate_task.json" +STORE_WF_PATH = "/tmp/generate_workflow.json" + + +@click.command() +@click.option("--filepath", help="file path of test case") +def cmdParse(filepath): + parse(filepath) + + +def parse(filepath): + filePrefix, fileName = os.path.split(filepath) + print '------------ start to parse the test case:' + \ + '%s ----------------' % fileName + with open(filepath) as f: + yaml_file = yaml.load(f) + parseTestcase(yaml_file['schema'], fileName) + + workflowId = runWorkFlow() + print '------------------- parse executes end -------------------------' + + return workflowId + + +def parseTestcase(schema, tcName='testcase0'): + if schema is None: + return parseLog(False, reason='schema not found.') + steps = schema['steps'] + if steps is None: + return parseLog(False, reason='steps is invalid.') + flows = schema['flows'] + if flows is None: + return parseLog(False, reasion='flows is invalid.') + # steps is a list, step is dict. no json here. + # steps = sorted(steps, sortById) + + # load context + contextDict = {} + contextDir = os.path.join(BASE_DIR, "env", "context", "context.yaml") + with open(contextDir, "r") as f: + contextDict = yaml.load(f) + # + testStepMgr = TestStepManager(contextDict) + + stepObjArr = [] + for step in steps: + if 'args' not in step: + step['args'] = {} + # type and action can be extended, default couple is 'test' & 'start'. + if 'type' not in step: + step['type'] = 'test' + step['action'] = 'start' + + stepObj = testStepMgr.getStepObj( + step['type'], step['id'], step['name'], step['service'], + step['action'], step['args']) + stepObjArr.append(stepObj) + + # generate workflow by 'flow' and 'step' + tcName = os.path.splitext(tcName)[0] + wfFileObj = WorkflowFile(tcName) + workflowDict, taskMetaList = wfFileObj.generateMetaData(flows, stepObjArr) + + with open(STORE_TASK_PATH, 'w') as f: + f.write(json.dumps({'task_group': taskMetaList}, indent=True)) + with open(STORE_WF_PATH, 'w') as f: + f.write(json.dumps(workflowDict, indent=True)) + + +def parseWebTestcase(webTestcase): + print 'parseWebTestcase----------------------------' + + stepList = webTestcase['stepList'] + mainOrdersList = webTestcase['mainOrdersList'] + subflowList = webTestcase['subflowList'] + + parseData = collections.OrderedDict() + parseData['schema'] = collections.OrderedDict() + parseData['schema']['steps'] = [] + parseData['schema']['flows'] = [] + + parseStepList = parseData['schema']['steps'] + parseFlowList = parseData['schema']['flows'] + stepIndexDict = {} + # parse stepList + for index in range(len(stepList)): + stepItem = stepList[index] + parseStep = collections.OrderedDict() + + parseStep['id'] = index + 1 + parseStep['name'] = stepItem['name'] + parseStep['service'] = collections.OrderedDict() + parseStep['service']['name'] = stepItem['service'] + parseStep['service']['interface'] = stepItem['action'] + parseStep['action'] = 'start' + parseStep['args'] = {} + for paramItem in stepItem['params']: + parseStep['args'][paramItem['key']] = transParamString( + paramItem['value']) + + parseStepList.append(parseStep) + stepIndexDict[parseStep['name']] = parseStep['id'] + # parse flows + # parse mainflow + print stepIndexDict + typeDict = {1: 'normal', 2: 'switch', 3: 'parallel'} + mainFlow = collections.OrderedDict() + mainFlow['name'] = 'main' + mainFlow['orders'] = [] + mainFlow['orders'] = parseOrderList( + mainOrdersList, stepIndexDict, typeDict) + parseFlowList.append(mainFlow) + + # parse subflow + for subflowItem in subflowList: + replaceSubflow = collections.OrderedDict() + replaceSubflow['name'] = subflowItem['name'] + replaceSubflow['orders'] = parseOrderList( + subflowItem['orderList'], stepIndexDict, typeDict) + parseFlowList.append(replaceSubflow) + + print 'END parseWebTestcase----------------------------' + return parseData + + +# parse orderlist from web edition to server edition +def parseOrderList(orderList, stepIndexDict, typeDict): + replaceList = [] + for orderItem in orderList: + replaceOrder = collections.OrderedDict() + orderType = typeDict[orderItem['type']] + replaceOrder['type'] = orderType + if orderType == 'normal': + stepId = stepIndexDict[orderItem['step']] + replaceOrder['step'] = stepId + elif orderType == 'switch': + replaceOrder['value'] = orderItem['value'] + replaceOrder['cases'] = collections.OrderedDict() + for caseItem in orderItem['cases']: + caseValue = caseItem['value'] + caseOrderType = caseItem['orderType'] + caseOrderValue = caseItem['orderValue'] + if caseOrderType == "step": + orderInCase = collections.OrderedDict() + orderInCase['type'] = 'normal' + orderInCase['step'] = stepIndexDict[caseOrderValue] + replaceOrder['cases'][caseValue] = [orderInCase] + else: + replaceOrder['cases'][caseValue] = caseOrderValue + else: + replaceOrder['parallel'] = collections.OrderedDict() + pIndex = 1 + for branchItem in orderItem['branches']: + pKey = 'p' + str(pIndex) + branchOrderType = branchItem['orderType'] + branchOrderValue = branchItem['orderValue'] + if branchOrderType == "step": + replaceBranchItem = collections.OrderedDict() + replaceBranchItem['type'] = 'normal' + replaceBranchItem['step'] = stepIndexDict[branchOrderValue] + replaceOrder['parallel'][pKey] = [replaceBranchItem] + else: + replaceOrder['parallel'][pKey] = branchOrderValue + pIndex += 1 + replaceList.append(replaceOrder) + return replaceList + + +def transParamString(val): + if type(val) != str: + return val + if '.' not in val: + if val.isdigit(): + return int(val) + try: + f = float(val) + return f + except ValueError: + return val + + +def getWebTestcase(originTcDict): + print "getWebTestcase----------------------------------" + webTcDict = { + "stepList": [], + "mainOrdersList": [], + "subflowList": [] + } + stepList = webTcDict['stepList'] + subflowList = webTcDict['subflowList'] + if originTcDict is None: + return webTcDict + originContent = originTcDict['schema'] + originSteps = originContent['steps'] + stepIndexDict = {} + # transform steps to stepList + for stepItem in originSteps: + replaceStep = {} + replaceStep['name'] = stepItem['name'] + replaceStep['service'] = stepItem['service']['name'] + replaceStep['action'] = stepItem['service']['interface'] + replaceStep['params'] = [] + if 'args' in stepItem: + for (key, value) in stepItem['args'].items(): + replaceParam = {} + replaceParam['key'] = key + replaceParam['value'] = value + replaceStep['params'].append(replaceParam) + stepList.append(replaceStep) + stepIndexDict[stepItem['id']] = stepItem['name'] + + # transform main flow + originFlows = originContent['flows'] + originMainflow = {} + for flowIndex in range(len(originFlows)): + flowItem = originFlows[flowIndex] + if flowItem['name'] == 'main': + originMainflow = flowItem + originFlows.pop(flowIndex) + break + typeDict = {'normal': 1, 'switch': 2, 'parallel': 3} + webTcDict['mainOrdersList'] = getOrderList( + originMainflow['orders'], stepIndexDict, typeDict) + + # transform subflows + for originSubflow in originFlows: + replaceSubflow = {} + replaceSubflow['name'] = originSubflow['name'] + replaceSubflow['orderList'] = getOrderList( + originSubflow['orders'], stepIndexDict, typeDict) + subflowList.append(replaceSubflow) + + # return web edition of testcase + print "END getWebTestcase----------------------------------" + return webTcDict + + +def getOrderList(originOrderList, stepIndexDict, typeDict): + replaceOrderList = [] + for orderItem in originOrderList: + replaceOrderItem = {} + orderType = orderItem['type'] + replaceOrderItem['type'] = typeDict[orderType] + if orderType == 'normal': + stepName = stepIndexDict[orderItem['step']] + replaceOrderItem['step'] = stepName + elif orderType == 'switch': + replaceOrderItem['value'] = orderItem['value'] + replaceOrderItem['cases'] = [] + for (caseValue, ordersInCase) in orderItem['cases'].items(): + replaceCase = {} + replaceCase['value'] = caseValue + if type(ordersInCase) == list: + replaceCase['orderType'] = 'step' + caseStepName = stepIndexDict[ordersInCase[0]['step']] + replaceCase['orderValue'] = caseStepName + else: + replaceCase['orderType'] = 'flow' + replaceCase['orderValue'] = ordersInCase + replaceOrderItem['cases'].append(replaceCase) + else: + replaceOrderItem['branches'] = [] + for paraIndex in orderItem['parallel']: + paraItem = orderItem['parallel'][paraIndex] + replaceBranch = {} + if type(paraItem) == list: + replaceBranch['orderType'] = 'step' + branchStepName = stepIndexDict[paraItem[0]['step']] + replaceBranch['orderValue'] = branchStepName + else: + replaceBranch['orderType'] = 'flow' + replaceBranch['orderValue'] = paraItem + replaceOrderItem['branches'].append(replaceBranch) + replaceOrderList.append(replaceOrderItem) + + return replaceOrderList + + +def runWorkFlow(): + wfMgr = WorkflowMgr(CONDUCTOR_SERVER_ADDR) + wfMgr.setTaskDefFromFile(STORE_TASK_PATH) + wfMgr.setWorkflowFromFile(STORE_WF_PATH) + inputParam = {'input': 'fake'} + workflowId = wfMgr.startWorkflow(inputParam) + return workflowId + + +def parseLog(flag, **msg): + return {'result': flag, 'message': msg} + + +if __name__ == "__main__": + cmdParse() diff --git a/testing-scheduler/server/test/__init__.py b/testing-scheduler/server/test/__init__.py new file mode 100644 index 00000000..e8198009 --- /dev/null +++ b/testing-scheduler/server/test/__init__.py @@ -0,0 +1,8 @@ +############################################################################## +# 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 +############################################################################## diff --git a/testing-scheduler/server/test/test_case/logic/tc_logic_00.yaml b/testing-scheduler/server/test/test_case/logic/tc_logic_00.yaml new file mode 100644 index 00000000..6a4eeea9 --- /dev/null +++ b/testing-scheduler/server/test/test_case/logic/tc_logic_00.yaml @@ -0,0 +1,30 @@ +############################################################################## +# 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 +############################################################################## + +--- +# description: test conductor basic logic +# this testcase contains a single step for scheduling. + +schema: + steps: + - + id: 1 + name: make_a_greet + service: + name: greet + interface: greet + args: + name: leo + flows: + - + name: main + orders: + - + type: normal + step: 1 \ No newline at end of file diff --git a/testing-scheduler/server/test/test_case/logic/tc_logic_01.yaml b/testing-scheduler/server/test/test_case/logic/tc_logic_01.yaml new file mode 100644 index 00000000..3f8f4f41 --- /dev/null +++ b/testing-scheduler/server/test/test_case/logic/tc_logic_01.yaml @@ -0,0 +1,73 @@ +############################################################################## +# 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 +############################################################################## + +--- +# description: test conductor basic logic +# 5 steps while only 2 in them will be executed. + +schema: + steps: + - + id: 1 + name: make_a_greet + service: + name: greet + interface: greet + args: + name: leo + + - + id: 2 + name: response_the_greet + service: + name: greet + interface: answer + args: + ping: ping_from_leo + + - + id: 3 + name: make_a_greet_3 + service: + name: greet + interface: greet + args: + name: leo_@ + + - + id: 4 + name: make_a_greet_4 + service: + name: greet + interface: greet + args: + name: leo_@ + + - + id: 5 + name: make_a_greet_5 + type: test + service: + name: greet + interface: greet + action: start + args: + name: leo_@ + + + flows: + - + name: main + orders: + - + type: normal + step: 1 + - + type: normal + step: 2 diff --git a/testing-scheduler/server/test/test_case/logic/tc_logic_02.yaml b/testing-scheduler/server/test/test_case/logic/tc_logic_02.yaml new file mode 100644 index 00000000..ce7197d1 --- /dev/null +++ b/testing-scheduler/server/test/test_case/logic/tc_logic_02.yaml @@ -0,0 +1,71 @@ +############################################################################## +# 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 +############################################################################## + +--- +# description: test conductor basic logic of switch +# switch will determine the next case to execute based +# on the "value", and "value" can be assigned by the +# previous step's output. +# The testcase below is an example. +# To referring the step's output, using ((x.y)). +# x is the id of the step, +# y is the output key of the step. + +schema: + steps: + - + id: 1 + name: choose_greet_type + type: test + service: + name: greet + interface: switch + action: start + + - + id: 2 + name: response_the_greet + type: test + service: + name: greet + interface: answer + action: start + args: + ping: ping_from_leo + + - + id: 3 + name: make_a_greet_2 + type: test + service: + name: greet + interface: greet + action: start + args: + name: leo_@ + + flows: + - + name: main + orders: + - + type: normal + step: 1 + - + type: switch + value: ((1.result)) + cases: + A: + - + type: normal + step: 2 + B: + - + type: normal + step: 3 diff --git a/testing-scheduler/server/test/test_case/logic/tc_logic_03.yaml b/testing-scheduler/server/test/test_case/logic/tc_logic_03.yaml new file mode 100644 index 00000000..2cb89430 --- /dev/null +++ b/testing-scheduler/server/test/test_case/logic/tc_logic_03.yaml @@ -0,0 +1,86 @@ +############################################################################## +# 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 +############################################################################## + +--- +# description: test useless sub workflow +# In this testcase, there is a subflow whose name +# is 'flow-1' which will not be executed because no +# other flow refers to it. +# This testcase is used to test that besides main flow, +# whether subflow can be parsed without exception. + +schema: + steps: + - + id: 1 + name: choose_greet_type + type: test + service: + name: greet + interface: switch + action: start + + - + id: 2 + name: response_the_greet + type: test + service: + name: greet + interface: answer + action: start + args: + ping: ping_from_leo + + - + id: 3 + name: make_a_greet_2 + type: test + service: + name: greet + interface: greet + action: start + args: + name: leo_@ + + - + id: 4 + name: make_a_greet_3 + type: test + service: + name: greet + interface: greet + action: start + args: + name: leo_@ + + flows: + - + name: main + orders: + - + type: normal + step: 1 + - + type: switch + value: ((1.result)) + cases: + A: + - + type: normal + step: 2 + B: + - + type: normal + step: 3 + - + name: flow-1 + orders: + - + type: normal + step: 4 diff --git a/testing-scheduler/server/test/test_case/logic/tc_logic_04.yaml b/testing-scheduler/server/test/test_case/logic/tc_logic_04.yaml new file mode 100644 index 00000000..67847ff3 --- /dev/null +++ b/testing-scheduler/server/test/test_case/logic/tc_logic_04.yaml @@ -0,0 +1,70 @@ +############################################################################## +# 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 +############################################################################## + +--- +# description: test conductor basic logic of sub flow. + +schema: + steps: + - + id: 1 + name: choose_greet_type + type: test + service: + name: greet + interface: switch + action: start + + - + id: 2 + name: response_the_greet + type: test + service: + name: greet + interface: answer + action: start + args: + ping: ping_from_leo + + - + id: 3 + name: make_a_greet_2 + type: test + service: + name: greet + interface: greet + action: start + args: + name: leo_@ + + flows: + - + name: main + orders: + - + type: normal + step: 1 + - + type: switch + value: ((1.result)) + cases: + A: flow-1 + B: flow-2 + - + name: flow-1 + orders: + - + type: normal + step: 2 + - + name: flow-2 + orders: + - + type: normal + step: 3 diff --git a/testing-scheduler/server/test/test_case/logic/tc_logic_05.yaml b/testing-scheduler/server/test/test_case/logic/tc_logic_05.yaml new file mode 100644 index 00000000..ac0f81c9 --- /dev/null +++ b/testing-scheduler/server/test/test_case/logic/tc_logic_05.yaml @@ -0,0 +1,100 @@ +############################################################################## +# 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 +############################################################################## + +--- +# description: test conductor basic logic of switch. +# switch nested in switch by using subflow. + +schema: + steps: + - + id: 1 + name: choose_greet_type + type: test + service: + name: greet + interface: switch + action: start + + - + id: 2 + name: response_the_greet + type: test + service: + name: greet + interface: answer + action: start + args: + ping: ping_from_leo + + - + id: 3 + name: choose_greet_type_2 + type: test + service: + name: greet + interface: switch_2 + action: start + + - + id: 4 + name: make_a_greet + type: test + service: + name: greet + interface: greet + action: start + args: + name: leo_@ + + - + id: 5 + name: response_the_greet_2 + type: test + service: + name: greet + interface: answer + action: start + args: + ping: ping_from_leo_2 + + flows: + - + name: main + orders: + - + type: normal + step: 1 + - + type: switch + value: ((1.result)) + cases: + A: + - + type: normal + step: 2 + B: flow-1 + - + name: flow-1 + orders: + - + type: normal + step: 3 + - + type: switch + value: ((3.result)) + cases: + C: + - + type: normal + step: 4 + D: + - + type: normal + step: 5 diff --git a/testing-scheduler/server/test/test_case/logic/tc_logic_06.yaml b/testing-scheduler/server/test/test_case/logic/tc_logic_06.yaml new file mode 100644 index 00000000..7c14d012 --- /dev/null +++ b/testing-scheduler/server/test/test_case/logic/tc_logic_06.yaml @@ -0,0 +1,80 @@ +############################################################################## +# 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 +############################################################################## + +--- +# description: test conductor basic logic of parallel + +schema: + steps: + - + id: 1 + name: choose_greet_type + type: test + service: + name: greet + interface: switch + action: start + + - + id: 2 + name: response_the_greet + type: test + service: + name: greet + interface: answer + action: start + args: + ping: ping_from_leo + + - + id: 3 + name: make_a_greet + type: test + service: + name: greet + interface: greet + action: start + args: + name: leo_@ + + - + id: 4 + name: make_a_greet_2 + type: test + service: + name: greet + interface: greet + action: start + args: + name: leo_@ + + flows: + - + name: main + orders: + - + type: normal + step: 1 + - + type: parallel + parallel: + p1: flow-1 + p2: + - + type: normal + step: 4 + - + name: flow-1 + orders: + - + type: normal + step: 2 + - + type: normal + step: 3 diff --git a/testing-scheduler/server/test/test_case/logic/tc_logic_07.yaml b/testing-scheduler/server/test/test_case/logic/tc_logic_07.yaml new file mode 100644 index 00000000..5fa71227 --- /dev/null +++ b/testing-scheduler/server/test/test_case/logic/tc_logic_07.yaml @@ -0,0 +1,100 @@ +############################################################################## +# 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 +############################################################################## + +--- +# description: test conductor basic logic of parallel + switch + +schema: + steps: + - + id: 1 + name: make_a_greet + type: test + service: + name: greet + interface: greet + action: start + args: + name: leo_@ + - + id: 2 + name: choose_greet_type + type: test + service: + name: greet + interface: switch + action: start + + - + id: 3 + name: response_the_greet + type: test + service: + name: greet + interface: answer + action: start + args: + ping: ping_from_leo + + - + id: 4 + name: make_a_greet + type: test + service: + name: greet + interface: greet + action: start + args: + name: leo_@ + + - + id: 5 + name: make_a_greet_2 + type: test + service: + name: greet + interface: greet + action: start + args: + name: leo_@ + + + flows: + - + name: main + orders: + - + type: normal + step: 1 + - + type: parallel + parallel: + p1: flow-1 + p2: + - + type: normal + step: 5 + - + name: flow-1 + orders: + - + type: normal + step: 2 + - + type: switch + value: ((2.result)) + cases: + A: + - + type: normal + step: 3 + B: + - + type: normal + step: 4 \ No newline at end of file diff --git a/testing-scheduler/server/test/test_case/logic/tc_logic_08.yaml b/testing-scheduler/server/test/test_case/logic/tc_logic_08.yaml new file mode 100644 index 00000000..e5da14f2 --- /dev/null +++ b/testing-scheduler/server/test/test_case/logic/tc_logic_08.yaml @@ -0,0 +1,114 @@ +############################################################################## +# 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 +############################################################################## + +--- +# description: test conductor basic logic of parallel. +# parallel nested in parallel using subflow + +schema: + steps: + - + id: 1 + name: make_a_greet + type: test + service: + name: greet + interface: greet + action: start + args: + name: leo_@ + - + id: 2 + name: choose_greet_type + type: test + service: + name: greet + interface: switch + action: start + + - + id: 3 + name: response_the_greet + type: test + service: + name: greet + interface: answer + action: start + args: + ping: ping_from_leo + + - + id: 4 + name: make_a_greet + type: test + service: + name: greet + interface: greet + action: start + args: + name: leo_@ + + - + id: 5 + name: make_a_greet_2 + type: test + service: + name: greet + interface: greet + action: start + args: + name: leo_@ + + - + id: 6 + name: make_a_greet_3 + type: test + service: + name: greet + interface: greet + action: start + args: + name: leo_@ + + + flows: + - + name: main + orders: + - + type: normal + step: 1 + - + type: parallel + parallel: + p1: flow-p1 + p2: + - + type: normal + step: 6 + - + name: flow-p1 + orders: + - + type: normal + step: 2 + - + type: parallel + parallel: + p1: + - + type: normal + step: 3 + p2: + - + type: normal + step: 4 + - + type: normal + step: 5 \ No newline at end of file diff --git a/testing-scheduler/server/test/test_case/logic_in_out/tc_cxt_01.yaml b/testing-scheduler/server/test/test_case/logic_in_out/tc_cxt_01.yaml new file mode 100644 index 00000000..583bc1c3 --- /dev/null +++ b/testing-scheduler/server/test/test_case/logic_in_out/tc_cxt_01.yaml @@ -0,0 +1,47 @@ +############################################################################## +# 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 +############################################################################## + +--- +# description: test use param of the context +# we can using the context param just like environment variable by +# writting ((context.a.b.c)). +# 'context' is a constant string, +# a, b, c is the key in the context yaml file (src/env/context/context.yaml). + +schema: + steps: + - + id: 1 + name: make_a_greet + service: + name: greet + interface: greet + args: + name: leo + + - + id: 2 + name: response_the_greet + service: + name: greet + interface: answer + args: + ping: ((context.sprout.name)) + + flows: + - + name: main + orders: + - + type: normal + step: 1 + - + type: normal + step: 2 + context: clearwater-conf.yaml diff --git a/testing-scheduler/server/test/test_case/logic_in_out/tc_io_01.yaml b/testing-scheduler/server/test/test_case/logic_in_out/tc_io_01.yaml new file mode 100644 index 00000000..b5ce203f --- /dev/null +++ b/testing-scheduler/server/test/test_case/logic_in_out/tc_io_01.yaml @@ -0,0 +1,63 @@ +############################################################################## +# 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 +############################################################################## + +--- +# description: test switch value used step-1's output. +# to referring the step's output, using ((x.y)). +# x is the id of the step, +# y is the output key of the step. + +schema: + steps: + - + id: 1 + name: get-switch + service: + name: greet + interface: switch + args: + name: leo + + - + id: 2 + name: greet1 + service: + name: greet + interface: answer + args: + ping: ping_from_Leo + + - + id: 3 + name: greet2 + service: + name: greet + interface: answer + args: + ping: ping_from_Leo_2 + + flows: + - + name: main + orders: + - + type: normal + step: 1 + - + type: switch + value: ((1.result)) + cases: + A: + - + type: normal + step: 2 + B: + - + type: normal + step: 3 \ No newline at end of file diff --git a/testing-scheduler/server/test/test_case/logic_in_out/tc_io_02.yaml b/testing-scheduler/server/test/test_case/logic_in_out/tc_io_02.yaml new file mode 100644 index 00000000..804a6791 --- /dev/null +++ b/testing-scheduler/server/test/test_case/logic_in_out/tc_io_02.yaml @@ -0,0 +1,60 @@ +############################################################################## +# 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 +############################################################################## + +--- +# description: test switch and step-2 used step-1's output + +schema: + steps: + - + id: 1 + name: get-switch + service: + name: greet + interface: switch + args: + name: leo + + - + id: 2 + name: greet1 + service: + name: greet + interface: answer + args: + ping: ((1.result)) + + - + id: 3 + name: greet2 + service: + name: greet + interface: answer + args: + ping: ping_from_Leo_2 + + flows: + - + name: main + orders: + - + type: normal + step: 1 + - + type: switch + value: ((1.result)) + cases: + A: + - + type: normal + step: 2 + B: + - + type: normal + step: 3 \ No newline at end of file diff --git a/testing-scheduler/server/test/test_case/suite_test/tc_suitetest_00.yaml b/testing-scheduler/server/test/test_case/suite_test/tc_suitetest_00.yaml new file mode 100644 index 00000000..06f8c4ef --- /dev/null +++ b/testing-scheduler/server/test/test_case/suite_test/tc_suitetest_00.yaml @@ -0,0 +1,27 @@ +############################################################################## +# 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 +############################################################################## + +--- +schema: + steps: + - + id: 1 + name: suitetest_00 + service: + name: greet + interface: ten + args: + name: leo + flows: + - + name: main + orders: + - + type: normal + step: 1 \ No newline at end of file diff --git a/testing-scheduler/server/test/test_case/suite_test/tc_suitetest_01.yaml b/testing-scheduler/server/test/test_case/suite_test/tc_suitetest_01.yaml new file mode 100644 index 00000000..0189e7af --- /dev/null +++ b/testing-scheduler/server/test/test_case/suite_test/tc_suitetest_01.yaml @@ -0,0 +1,27 @@ +############################################################################## +# 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 +############################################################################## + +--- +schema: + steps: + - + id: 1 + name: suitetest_01 + service: + name: greet + interface: ten + args: + name: leo + flows: + - + name: main + orders: + - + type: normal + step: 1 \ No newline at end of file diff --git a/testing-scheduler/server/test/test_case/suite_test/tc_suitetest_02.yaml b/testing-scheduler/server/test/test_case/suite_test/tc_suitetest_02.yaml new file mode 100644 index 00000000..bc689248 --- /dev/null +++ b/testing-scheduler/server/test/test_case/suite_test/tc_suitetest_02.yaml @@ -0,0 +1,27 @@ +############################################################################## +# 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 +############################################################################## + +--- +schema: + steps: + - + id: 1 + name: suitetest_01 + service: + name: greet + interface: greet + args: + name: leo + flows: + - + name: main + orders: + - + type: normal + step: 1 \ No newline at end of file -- cgit 1.2.3-korg