Merge branch 'master' into v1.6
This commit is contained in:
commit
fbda7b423f
|
@ -83,10 +83,7 @@ public class MsScenario extends MsTestElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 场景变量
|
// 场景变量
|
||||||
if (CollectionUtils.isNotEmpty(this.getVariables())) {
|
tree.add(arguments(config));
|
||||||
tree.add(arguments(config));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||||
for (MsTestElement el : hashTree) {
|
for (MsTestElement el : hashTree) {
|
||||||
el.toHashTree(tree, el.getHashTree(), config);
|
el.toHashTree(tree, el.getHashTree(), config);
|
||||||
|
@ -101,9 +98,11 @@ public class MsScenario extends MsTestElement {
|
||||||
arguments.setName(name + "Variables");
|
arguments.setName(name + "Variables");
|
||||||
arguments.setProperty(TestElement.TEST_CLASS, Arguments.class.getName());
|
arguments.setProperty(TestElement.TEST_CLASS, Arguments.class.getName());
|
||||||
arguments.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("ArgumentsPanel"));
|
arguments.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("ArgumentsPanel"));
|
||||||
variables.stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue ->
|
if (CollectionUtils.isNotEmpty(this.getVariables())) {
|
||||||
arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=")
|
variables.stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue ->
|
||||||
);
|
arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=")
|
||||||
|
);
|
||||||
|
}
|
||||||
if (config != null && config.getConfig() != null && config.getConfig().getCommonConfig() != null
|
if (config != null && config.getConfig() != null && config.getConfig().getCommonConfig() != null
|
||||||
&& CollectionUtils.isNotEmpty(config.getConfig().getCommonConfig().getVariables())) {
|
&& CollectionUtils.isNotEmpty(config.getConfig().getCommonConfig().getVariables())) {
|
||||||
config.getConfig().getCommonConfig().getVariables().stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue ->
|
config.getConfig().getCommonConfig().getVariables().stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue ->
|
||||||
|
|
|
@ -24,6 +24,7 @@ import io.metersphere.base.mapper.ext.ExtTestPlanScenarioCaseMapper;
|
||||||
import io.metersphere.commons.constants.*;
|
import io.metersphere.commons.constants.*;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.DateUtils;
|
import io.metersphere.commons.utils.DateUtils;
|
||||||
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
import io.metersphere.commons.utils.ServiceUtils;
|
import io.metersphere.commons.utils.ServiceUtils;
|
||||||
import io.metersphere.commons.utils.SessionUtils;
|
import io.metersphere.commons.utils.SessionUtils;
|
||||||
import io.metersphere.i18n.Translator;
|
import io.metersphere.i18n.Translator;
|
||||||
|
@ -260,14 +261,14 @@ public class ApiAutomationService {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createAPIScenarioReportResult(String id, String scenarioId, String scenarioName, String triggerMode, String execType, String projectId, String userID) {
|
private void createScenarioReport(String id, String scenarioId, String scenarioName, String triggerMode, String execType, String projectId, String userID) {
|
||||||
APIScenarioReportResult report = new APIScenarioReportResult();
|
APIScenarioReportResult report = new APIScenarioReportResult();
|
||||||
report.setId(id);
|
report.setId(id);
|
||||||
report.setTestId(id);
|
report.setTestId(id);
|
||||||
if (StringUtils.isNotEmpty(scenarioName)) {
|
if (StringUtils.isNotEmpty(scenarioName)) {
|
||||||
report.setName(scenarioName);
|
report.setName(scenarioName);
|
||||||
} else {
|
} else {
|
||||||
report.setName("零时调试名称");
|
report.setName("场景调试");
|
||||||
}
|
}
|
||||||
report.setCreateTime(System.currentTimeMillis());
|
report.setCreateTime(System.currentTimeMillis());
|
||||||
report.setUpdateTime(System.currentTimeMillis());
|
report.setUpdateTime(System.currentTimeMillis());
|
||||||
|
@ -295,25 +296,21 @@ public class ApiAutomationService {
|
||||||
List<ApiScenarioWithBLOBs> apiScenarios = extApiScenarioMapper.selectIds(request.getScenarioIds());
|
List<ApiScenarioWithBLOBs> apiScenarios = extApiScenarioMapper.selectIds(request.getScenarioIds());
|
||||||
MsTestPlan testPlan = new MsTestPlan();
|
MsTestPlan testPlan = new MsTestPlan();
|
||||||
testPlan.setHashTree(new LinkedList<>());
|
testPlan.setHashTree(new LinkedList<>());
|
||||||
HashTree jmeterTestPlanHashTree = new ListedHashTree();
|
HashTree jmeterHashTree = new ListedHashTree();
|
||||||
String projectID = request.getProjectId();
|
try {
|
||||||
boolean isOne = true;
|
for (ApiScenarioWithBLOBs item : apiScenarios) {
|
||||||
for (ApiScenarioWithBLOBs item : apiScenarios) {
|
MsThreadGroup group = new MsThreadGroup();
|
||||||
MsThreadGroup group = new MsThreadGroup();
|
group.setLabel(item.getName());
|
||||||
group.setLabel(item.getName());
|
|
||||||
// 批量执行的结果直接存储为报告
|
|
||||||
if (isOne) {
|
|
||||||
group.setName(request.getId());
|
|
||||||
isOne = false;
|
|
||||||
} else {
|
|
||||||
group.setName(UUID.randomUUID().toString());
|
group.setName(UUID.randomUUID().toString());
|
||||||
}
|
// 批量执行的结果直接存储为报告
|
||||||
projectID = item.getProjectId();
|
if (apiScenarios.size() == 1) {
|
||||||
try {
|
group.setName(request.getId());
|
||||||
|
}
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
JSONObject element = JSON.parseObject(item.getScenarioDefinition());
|
JSONObject element = JSON.parseObject(item.getScenarioDefinition());
|
||||||
MsScenario scenario = JSONObject.parseObject(item.getScenarioDefinition(), MsScenario.class);
|
MsScenario scenario = JSONObject.parseObject(item.getScenarioDefinition(), MsScenario.class);
|
||||||
|
|
||||||
// 多态JSON普通转换会丢失内容,需要通过 ObjectMapper 获取
|
// 多态JSON普通转换会丢失内容,需要通过 ObjectMapper 获取
|
||||||
if (element != null && StringUtils.isNotEmpty(element.getString("hashTree"))) {
|
if (element != null && StringUtils.isNotEmpty(element.getString("hashTree"))) {
|
||||||
LinkedList<MsTestElement> elements = mapper.readValue(element.getString("hashTree"),
|
LinkedList<MsTestElement> elements = mapper.readValue(element.getString("hashTree"),
|
||||||
|
@ -331,22 +328,23 @@ public class ApiAutomationService {
|
||||||
LinkedList<MsTestElement> scenarios = new LinkedList<>();
|
LinkedList<MsTestElement> scenarios = new LinkedList<>();
|
||||||
scenarios.add(scenario);
|
scenarios.add(scenario);
|
||||||
// 创建场景报告
|
// 创建场景报告
|
||||||
createAPIScenarioReportResult(group.getName(), item.getId(), item.getName(), request.getTriggerMode() == null ? ReportTriggerMode.MANUAL.name() : request.getTriggerMode(),
|
createScenarioReport(group.getName(), item.getId(), item.getName(), request.getTriggerMode() == null ? ReportTriggerMode.MANUAL.name() : request.getTriggerMode(),
|
||||||
request.getExecuteType(), projectID, request.getReportUserID());
|
request.getExecuteType(), item.getProjectId(), request.getReportUserID());
|
||||||
group.setHashTree(scenarios);
|
group.setHashTree(scenarios);
|
||||||
testPlan.getHashTree().add(group);
|
testPlan.getHashTree().add(group);
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
LogUtil.error(ex.getMessage());
|
||||||
}
|
}
|
||||||
testPlan.toHashTree(jmeterTestPlanHashTree, testPlan.getHashTree(), new ParameterConfig());
|
testPlan.toHashTree(jmeterHashTree, testPlan.getHashTree(), new ParameterConfig());
|
||||||
|
|
||||||
String runMode = ApiRunMode.SCENARIO.name();
|
String runMode = ApiRunMode.SCENARIO.name();
|
||||||
if (StringUtils.isNotBlank(request.getRunMode()) && StringUtils.equals(request.getRunMode(), ApiRunMode.SCENARIO_PLAN.name())) {
|
if (StringUtils.isNotBlank(request.getRunMode()) && StringUtils.equals(request.getRunMode(), ApiRunMode.SCENARIO_PLAN.name())) {
|
||||||
runMode = ApiRunMode.SCENARIO_PLAN.name();
|
runMode = ApiRunMode.SCENARIO_PLAN.name();
|
||||||
}
|
}
|
||||||
// 调用执行方法
|
// 调用执行方法
|
||||||
jMeterService.runDefinition(request.getId(), jmeterTestPlanHashTree, request.getReportId(), runMode);
|
jMeterService.runDefinition(request.getId(), jmeterHashTree, request.getReportId(), runMode);
|
||||||
return request.getId();
|
return request.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,7 +369,7 @@ public class ApiAutomationService {
|
||||||
HashTree hashTree = request.getTestElement().generateHashTree(config);
|
HashTree hashTree = request.getTestElement().generateHashTree(config);
|
||||||
// 调用执行方法
|
// 调用执行方法
|
||||||
jMeterService.runDefinition(request.getId(), hashTree, request.getReportId(), ApiRunMode.SCENARIO.name());
|
jMeterService.runDefinition(request.getId(), hashTree, request.getReportId(), ApiRunMode.SCENARIO.name());
|
||||||
createAPIScenarioReportResult(request.getId(), request.getScenarioId(), request.getScenarioName(), ReportTriggerMode.MANUAL.name(), request.getExecuteType(), request.getProjectId(),
|
createScenarioReport(request.getId(), request.getScenarioId(), request.getScenarioName(), ReportTriggerMode.MANUAL.name(), request.getExecuteType(), request.getProjectId(),
|
||||||
SessionUtils.getUserId());
|
SessionUtils.getUserId());
|
||||||
return request.getId();
|
return request.getId();
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,10 +127,12 @@
|
||||||
if (this.request.id && this.request.referenced === 'REF') {
|
if (this.request.id && this.request.referenced === 'REF') {
|
||||||
let requestResult = this.request.requestResult;
|
let requestResult = this.request.requestResult;
|
||||||
let url = this.request.refType && this.request.refType === 'CASE' ? "/api/testcase/get/" : "/api/definition/get/";
|
let url = this.request.refType && this.request.refType === 'CASE' ? "/api/testcase/get/" : "/api/definition/get/";
|
||||||
|
let enable = this.request.enable;
|
||||||
this.$get(url + this.request.id, response => {
|
this.$get(url + this.request.id, response => {
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
Object.assign(this.request, JSON.parse(response.data.request));
|
Object.assign(this.request, JSON.parse(response.data.request));
|
||||||
this.request.name = response.data.name;
|
this.request.name = response.data.name;
|
||||||
|
this.request.enable = enable;
|
||||||
if (response.data.path && response.data.path != null) {
|
if (response.data.path && response.data.path != null) {
|
||||||
this.request.path = response.data.path;
|
this.request.path = response.data.path;
|
||||||
this.request.url = response.data.path;
|
this.request.url = response.data.path;
|
||||||
|
|
|
@ -111,7 +111,6 @@
|
||||||
condition: {},
|
condition: {},
|
||||||
currentScenario: {},
|
currentScenario: {},
|
||||||
schedule: {},
|
schedule: {},
|
||||||
selectAll: false,
|
|
||||||
selection: [],
|
selection: [],
|
||||||
tableData: [],
|
tableData: [],
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
|
@ -120,6 +119,7 @@
|
||||||
reportId: "",
|
reportId: "",
|
||||||
batchReportId: "",
|
batchReportId: "",
|
||||||
content: {},
|
content: {},
|
||||||
|
selectAll: false,
|
||||||
infoDb: false,
|
infoDb: false,
|
||||||
runVisible: false,
|
runVisible: false,
|
||||||
planVisible: false,
|
planVisible: false,
|
||||||
|
@ -246,9 +246,6 @@
|
||||||
this.batchReportId = run.id;
|
this.batchReportId = run.id;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
selectAllChange() {
|
|
||||||
this.handleCommand("table");
|
|
||||||
},
|
|
||||||
select(selection) {
|
select(selection) {
|
||||||
this.selection = selection.map(s => s.id);
|
this.selection = selection.map(s => s.id);
|
||||||
this.$emit('selection', selection);
|
this.$emit('selection', selection);
|
||||||
|
|
|
@ -452,7 +452,7 @@
|
||||||
},
|
},
|
||||||
outsideClick(e) {
|
outsideClick(e) {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
this.operatingElements = ELEMENTS.get("ALL");
|
this.showAll();
|
||||||
},
|
},
|
||||||
addComponent(type) {
|
addComponent(type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -594,7 +594,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
pushApiOrCase(data, refType, referenced) {
|
pushApiOrCase(data, refType, referenced) {
|
||||||
data.forEach(item => {
|
data.forEach(item => {
|
||||||
this.setApiParameter(item, refType, referenced);
|
this.setApiParameter(item, refType, referenced);
|
||||||
});
|
});
|
||||||
|
@ -885,6 +885,7 @@
|
||||||
height: calc(100vh - 196px);
|
height: calc(100vh - 196px);
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ms-scenario-input {
|
.ms-scenario-input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue