fix locust in testsuite

This commit is contained in:
debugtalk
2018-12-21 20:48:55 +08:00
parent 2f445135e9
commit e507e69e89
4 changed files with 48 additions and 12 deletions

View File

@@ -244,21 +244,27 @@ def prepare_locust_tests(path):
parsed_tests_mapping = parser.parse_tests(tests_mapping)
functions = parsed_tests_mapping.get("project_mapping", {}).get("functions", {})
testcase = parsed_tests_mapping["testcases"][0]
items = testcase.get("teststeps", [])
tests = []
for item in items:
if "config" in item:
# embeded testcase
weight = item["config"].get("weight", 1)
else:
# API test
weight = item.get("weight", 1)
# implement weight for tests
for _ in range(weight):
tests.append(item)
for testcase in parsed_tests_mapping["testcases"]:
testcase_weight = testcase.get("config", {}).get("weight", 1)
items = testcase.get("teststeps", [])
testcase_tests = []
for item in items:
if "config" in item:
# embeded testcase
weight = item["config"].get("weight", 1)
else:
# API test
weight = item.get("weight", 1)
# implement weight for tests
for _ in range(weight):
testcase_tests.append(item)
tests.extend(testcase_tests * testcase_weight)
return {
"functions": functions,

View File

@@ -942,6 +942,9 @@ def __get_parsed_testsuite_testcases(testcases, testsuite_config, project_mappin
parsed_testcase["path"] = testcase["testcase"]
parsed_testcase["config"]["name"] = testcase_name
if "weight" in testcase:
parsed_testcase["config"]["weight"] = testcase["weight"]
# base_url priority: testcase config > testsuite config
parsed_testcase["config"].setdefault("base_url", testsuite_base_url)