Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
77a1235ff6
|
@ -20,9 +20,6 @@ import lombok.EqualsAndHashCode;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.jmeter.config.Arguments;
|
import org.apache.jmeter.config.Arguments;
|
||||||
import org.apache.jmeter.config.CSVDataSet;
|
|
||||||
import org.apache.jmeter.config.RandomVariableConfig;
|
|
||||||
import org.apache.jmeter.modifiers.CounterConfig;
|
|
||||||
import org.apache.jmeter.save.SaveService;
|
import org.apache.jmeter.save.SaveService;
|
||||||
import org.apache.jmeter.testelement.TestElement;
|
import org.apache.jmeter.testelement.TestElement;
|
||||||
import org.apache.jorphan.collections.HashTree;
|
import org.apache.jorphan.collections.HashTree;
|
||||||
|
@ -68,7 +65,8 @@ public class MsScenario extends MsTestElement {
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
ApiScenarioWithBLOBs scenario = apiAutomationService.getApiScenario(this.getId());
|
ApiScenarioWithBLOBs scenario = apiAutomationService.getApiScenario(this.getId());
|
||||||
JSONObject element = JSON.parseObject(scenario.getScenarioDefinition());
|
JSONObject element = JSON.parseObject(scenario.getScenarioDefinition());
|
||||||
hashTree = mapper.readValue(element.getString("hashTree"), new TypeReference<LinkedList<MsTestElement>>() {});
|
hashTree = mapper.readValue(element.getString("hashTree"), new TypeReference<LinkedList<MsTestElement>>() {
|
||||||
|
});
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -88,9 +86,9 @@ public class MsScenario extends MsTestElement {
|
||||||
}
|
}
|
||||||
// 场景变量和环境变量
|
// 场景变量和环境变量
|
||||||
tree.add(arguments(config));
|
tree.add(arguments(config));
|
||||||
addCsvDataSet(tree);
|
this.addCsvDataSet(tree, variables);
|
||||||
addCounter(tree);
|
this.addCounter(tree, variables);
|
||||||
addRandom(tree);
|
this.addRandom(tree, variables);
|
||||||
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);
|
||||||
|
@ -133,71 +131,5 @@ public class MsScenario extends MsTestElement {
|
||||||
return arguments;
|
return arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addCsvDataSet(HashTree tree) {
|
|
||||||
if (CollectionUtils.isNotEmpty(this.getVariables())) {
|
|
||||||
List<ScenarioVariable> list = variables.stream().filter(ScenarioVariable::isCSVValid).collect(Collectors.toList());
|
|
||||||
if (CollectionUtils.isNotEmpty(list)) {
|
|
||||||
list.forEach(item -> {
|
|
||||||
CSVDataSet csvDataSet = new CSVDataSet();
|
|
||||||
csvDataSet.setEnabled(true);
|
|
||||||
csvDataSet.setProperty(TestElement.TEST_CLASS, CSVDataSet.class.getName());
|
|
||||||
csvDataSet.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
|
||||||
csvDataSet.setName(item.getName());
|
|
||||||
csvDataSet.setProperty("fileEncoding", item.getEncoding());
|
|
||||||
csvDataSet.setProperty("variableNames", item.getName());
|
|
||||||
if (CollectionUtils.isNotEmpty(item.getFiles())) {
|
|
||||||
csvDataSet.setProperty("filename", BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName());
|
|
||||||
}
|
|
||||||
csvDataSet.setIgnoreFirstLine(false);
|
|
||||||
csvDataSet.setProperty("delimiter", item.getDelimiter());
|
|
||||||
csvDataSet.setComment(item.getDescription());
|
|
||||||
tree.add(csvDataSet);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addCounter(HashTree tree) {
|
|
||||||
if (CollectionUtils.isNotEmpty(this.getVariables())) {
|
|
||||||
List<ScenarioVariable> list = variables.stream().filter(ScenarioVariable::isCounterValid).collect(Collectors.toList());
|
|
||||||
if (CollectionUtils.isNotEmpty(list)) {
|
|
||||||
list.forEach(item -> {
|
|
||||||
CounterConfig counterConfig = new CounterConfig();
|
|
||||||
counterConfig.setEnabled(true);
|
|
||||||
counterConfig.setProperty(TestElement.TEST_CLASS, CounterConfig.class.getName());
|
|
||||||
counterConfig.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("CounterConfigGui"));
|
|
||||||
counterConfig.setName(item.getName());
|
|
||||||
counterConfig.setStart(item.getStartNumber());
|
|
||||||
counterConfig.setEnd(item.getEndNumber());
|
|
||||||
counterConfig.setVarName(item.getName());
|
|
||||||
counterConfig.setIncrement(item.getIncrement());
|
|
||||||
counterConfig.setFormat(item.getValue());
|
|
||||||
counterConfig.setComment(item.getDescription());
|
|
||||||
tree.add(counterConfig);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addRandom(HashTree tree) {
|
|
||||||
if (CollectionUtils.isNotEmpty(this.getVariables())) {
|
|
||||||
List<ScenarioVariable> list = variables.stream().filter(ScenarioVariable::isRandom).collect(Collectors.toList());
|
|
||||||
if (CollectionUtils.isNotEmpty(list)) {
|
|
||||||
list.forEach(item -> {
|
|
||||||
RandomVariableConfig randomVariableConfig = new RandomVariableConfig();
|
|
||||||
randomVariableConfig.setEnabled(true);
|
|
||||||
randomVariableConfig.setProperty(TestElement.TEST_CLASS, RandomVariableConfig.class.getName());
|
|
||||||
randomVariableConfig.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
|
||||||
randomVariableConfig.setName(item.getName());
|
|
||||||
randomVariableConfig.setProperty("variableName", item.getName());
|
|
||||||
randomVariableConfig.setProperty("outputFormat", item.getValue());
|
|
||||||
randomVariableConfig.setProperty("minimumValue", item.getMinNumber());
|
|
||||||
randomVariableConfig.setProperty("maximumValue", item.getMaxNumber());
|
|
||||||
randomVariableConfig.setComment(item.getDescription());
|
|
||||||
tree.add(randomVariableConfig);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
|
||||||
import io.metersphere.api.dto.definition.request.sampler.MsJDBCSampler;
|
import io.metersphere.api.dto.definition.request.sampler.MsJDBCSampler;
|
||||||
import io.metersphere.api.dto.definition.request.sampler.MsTCPSampler;
|
import io.metersphere.api.dto.definition.request.sampler.MsTCPSampler;
|
||||||
import io.metersphere.api.dto.definition.request.timer.MsConstantTimer;
|
import io.metersphere.api.dto.definition.request.timer.MsConstantTimer;
|
||||||
|
import io.metersphere.api.dto.definition.request.variable.ScenarioVariable;
|
||||||
import io.metersphere.api.dto.scenario.KeyValue;
|
import io.metersphere.api.dto.scenario.KeyValue;
|
||||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||||
import io.metersphere.api.service.ApiDefinitionService;
|
import io.metersphere.api.service.ApiDefinitionService;
|
||||||
|
@ -33,6 +34,9 @@ import io.metersphere.commons.utils.LogUtil;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.jmeter.config.Arguments;
|
import org.apache.jmeter.config.Arguments;
|
||||||
|
import org.apache.jmeter.config.CSVDataSet;
|
||||||
|
import org.apache.jmeter.config.RandomVariableConfig;
|
||||||
|
import org.apache.jmeter.modifiers.CounterConfig;
|
||||||
import org.apache.jmeter.protocol.http.control.AuthManager;
|
import org.apache.jmeter.protocol.http.control.AuthManager;
|
||||||
import org.apache.jmeter.save.SaveService;
|
import org.apache.jmeter.save.SaveService;
|
||||||
import org.apache.jmeter.testelement.TestElement;
|
import org.apache.jmeter.testelement.TestElement;
|
||||||
|
@ -42,6 +46,7 @@ import org.apache.jorphan.collections.ListedHashTree;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type")
|
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type")
|
||||||
@JsonSubTypes({
|
@JsonSubTypes({
|
||||||
|
@ -91,6 +96,7 @@ public abstract class MsTestElement {
|
||||||
@JSONField(ordinal = 10)
|
@JSONField(ordinal = 10)
|
||||||
private LinkedList<MsTestElement> hashTree;
|
private LinkedList<MsTestElement> hashTree;
|
||||||
|
|
||||||
|
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||||
// 公共环境逐层传递,如果自身有环境 以自身引用环境为准否则以公共环境作为请求环境
|
// 公共环境逐层传递,如果自身有环境 以自身引用环境为准否则以公共环境作为请求环境
|
||||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
||||||
for (MsTestElement el : hashTree) {
|
for (MsTestElement el : hashTree) {
|
||||||
|
@ -166,6 +172,74 @@ public abstract class MsTestElement {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void addCsvDataSet(HashTree tree,List<ScenarioVariable> variables) {
|
||||||
|
if (CollectionUtils.isNotEmpty(variables)) {
|
||||||
|
List<ScenarioVariable> list = variables.stream().filter(ScenarioVariable::isCSVValid).collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
|
list.forEach(item -> {
|
||||||
|
CSVDataSet csvDataSet = new CSVDataSet();
|
||||||
|
csvDataSet.setEnabled(true);
|
||||||
|
csvDataSet.setProperty(TestElement.TEST_CLASS, CSVDataSet.class.getName());
|
||||||
|
csvDataSet.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
||||||
|
csvDataSet.setName(item.getName());
|
||||||
|
csvDataSet.setProperty("fileEncoding", item.getEncoding());
|
||||||
|
csvDataSet.setProperty("variableNames", item.getName());
|
||||||
|
if (CollectionUtils.isNotEmpty(item.getFiles())) {
|
||||||
|
csvDataSet.setProperty("filename", BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName());
|
||||||
|
}
|
||||||
|
csvDataSet.setIgnoreFirstLine(false);
|
||||||
|
csvDataSet.setProperty("delimiter", item.getDelimiter());
|
||||||
|
csvDataSet.setComment(item.getDescription());
|
||||||
|
tree.add(csvDataSet);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addCounter(HashTree tree,List<ScenarioVariable> variables) {
|
||||||
|
if (CollectionUtils.isNotEmpty(variables)) {
|
||||||
|
List<ScenarioVariable> list = variables.stream().filter(ScenarioVariable::isCounterValid).collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
|
list.forEach(item -> {
|
||||||
|
CounterConfig counterConfig = new CounterConfig();
|
||||||
|
counterConfig.setEnabled(true);
|
||||||
|
counterConfig.setProperty(TestElement.TEST_CLASS, CounterConfig.class.getName());
|
||||||
|
counterConfig.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("CounterConfigGui"));
|
||||||
|
counterConfig.setName(item.getName());
|
||||||
|
counterConfig.setStart(item.getStartNumber());
|
||||||
|
counterConfig.setEnd(item.getEndNumber());
|
||||||
|
counterConfig.setVarName(item.getName());
|
||||||
|
counterConfig.setIncrement(item.getIncrement());
|
||||||
|
counterConfig.setFormat(item.getValue());
|
||||||
|
counterConfig.setComment(item.getDescription());
|
||||||
|
tree.add(counterConfig);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addRandom(HashTree tree,List<ScenarioVariable> variables) {
|
||||||
|
if (CollectionUtils.isNotEmpty(variables)) {
|
||||||
|
List<ScenarioVariable> list = variables.stream().filter(ScenarioVariable::isRandom).collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
|
list.forEach(item -> {
|
||||||
|
RandomVariableConfig randomVariableConfig = new RandomVariableConfig();
|
||||||
|
randomVariableConfig.setEnabled(true);
|
||||||
|
randomVariableConfig.setProperty(TestElement.TEST_CLASS, RandomVariableConfig.class.getName());
|
||||||
|
randomVariableConfig.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
||||||
|
randomVariableConfig.setName(item.getName());
|
||||||
|
randomVariableConfig.setProperty("variableName", item.getName());
|
||||||
|
randomVariableConfig.setProperty("outputFormat", item.getValue());
|
||||||
|
randomVariableConfig.setProperty("minimumValue", item.getMinNumber());
|
||||||
|
randomVariableConfig.setProperty("maximumValue", item.getMaxNumber());
|
||||||
|
randomVariableConfig.setComment(item.getDescription());
|
||||||
|
tree.add(randomVariableConfig);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,12 @@ public class MsLoopController extends MsTestElement {
|
||||||
config.setStepType("LOOP");
|
config.setStepType("LOOP");
|
||||||
|
|
||||||
final HashTree groupTree = controller(tree);
|
final HashTree groupTree = controller(tree);
|
||||||
|
if (CollectionUtils.isNotEmpty(config.getVariables())) {
|
||||||
|
this.addCsvDataSet(groupTree, config.getVariables());
|
||||||
|
this.addCounter(groupTree, config.getVariables());
|
||||||
|
this.addRandom(groupTree, config.getVariables());
|
||||||
|
}
|
||||||
|
|
||||||
// 循环下都增加一个计数器,用于结果统计
|
// 循环下都增加一个计数器,用于结果统计
|
||||||
groupTree.add(addCounterConfig());
|
groupTree.add(addCounterConfig());
|
||||||
// 不打开执行成功后轮询功能,则成功后就停止循环
|
// 不打开执行成功后轮询功能,则成功后就停止循环
|
||||||
|
|
|
@ -27,6 +27,7 @@ import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.*;
|
import io.metersphere.commons.utils.*;
|
||||||
import io.metersphere.i18n.Translator;
|
import io.metersphere.i18n.Translator;
|
||||||
import io.metersphere.job.sechedule.ApiScenarioTestJob;
|
import io.metersphere.job.sechedule.ApiScenarioTestJob;
|
||||||
|
import io.metersphere.job.sechedule.TestPlanTestJob;
|
||||||
import io.metersphere.service.ScheduleService;
|
import io.metersphere.service.ScheduleService;
|
||||||
import io.metersphere.track.dto.TestPlanDTO;
|
import io.metersphere.track.dto.TestPlanDTO;
|
||||||
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
|
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
|
||||||
|
@ -630,8 +631,14 @@ public class ApiAutomationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addOrUpdateApiScenarioCronJob(Schedule request) {
|
private void addOrUpdateApiScenarioCronJob(Schedule request) {
|
||||||
scheduleService.addOrUpdateCronJob(
|
if(StringUtils.equals(request.getGroup(),ScheduleGroup.TEST_PLAN_TEST.name())){
|
||||||
request, ApiScenarioTestJob.getJobKey(request.getResourceId()), ApiScenarioTestJob.getTriggerKey(request.getResourceId()), ApiScenarioTestJob.class);
|
scheduleService.addOrUpdateCronJob(
|
||||||
|
request, TestPlanTestJob.getJobKey(request.getResourceId()), TestPlanTestJob.getTriggerKey(request.getResourceId()), TestPlanTestJob.class);
|
||||||
|
}else{
|
||||||
|
scheduleService.addOrUpdateCronJob(
|
||||||
|
request, ApiScenarioTestJob.getJobKey(request.getResourceId()), ApiScenarioTestJob.getTriggerKey(request.getResourceId()), ApiScenarioTestJob.class);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public JmxInfoDTO genPerformanceTestJmx(RunScenarioRequest request) throws Exception {
|
public JmxInfoDTO genPerformanceTestJmx(RunScenarioRequest request) throws Exception {
|
||||||
|
|
|
@ -133,7 +133,6 @@ public class TestPlanTestJob extends MsScheduleJob {
|
||||||
performanceRequest.setId(caseID);
|
performanceRequest.setId(caseID);
|
||||||
performanceRequest.setTestPlanLoadId(caseID);
|
performanceRequest.setTestPlanLoadId(caseID);
|
||||||
performanceRequest.setTriggerMode(ReportTriggerMode.TEST_PLAN_SCHEDULE.name());
|
performanceRequest.setTriggerMode(ReportTriggerMode.TEST_PLAN_SCHEDULE.name());
|
||||||
|
|
||||||
String reportId = null;
|
String reportId = null;
|
||||||
try {
|
try {
|
||||||
reportId = performanceTestService.run(performanceRequest);
|
reportId = performanceTestService.run(performanceRequest);
|
||||||
|
@ -148,6 +147,11 @@ public class TestPlanTestJob extends MsScheduleJob {
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
//更新关联处的报告
|
||||||
|
TestPlanLoadCase loadCase = new TestPlanLoadCaseDTO();
|
||||||
|
loadCase.setId(id);
|
||||||
|
loadCase.setLoadReportId(reportId);
|
||||||
|
testPlanLoadCaseService.update(loadCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!performaneReportIDList.isEmpty()){
|
if(!performaneReportIDList.isEmpty()){
|
||||||
|
|
|
@ -150,6 +150,7 @@ public class TestPlanService {
|
||||||
public List<TestPlan> getTestPlanByName(String name) {
|
public List<TestPlan> getTestPlanByName(String name) {
|
||||||
TestPlanExample example = new TestPlanExample();
|
TestPlanExample example = new TestPlanExample();
|
||||||
example.createCriteria().andWorkspaceIdEqualTo(SessionUtils.getCurrentWorkspaceId())
|
example.createCriteria().andWorkspaceIdEqualTo(SessionUtils.getCurrentWorkspaceId())
|
||||||
|
.andProjectIdEqualTo(SessionUtils.getCurrentProjectId())
|
||||||
.andNameEqualTo(name);
|
.andNameEqualTo(name);
|
||||||
return testPlanMapper.selectByExample(example);
|
return testPlanMapper.selectByExample(example);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
v-if="!readOnly"
|
v-if="!readOnly"
|
||||||
class="tag-input el-input"
|
class="tag-input el-input"
|
||||||
v-model="newTag"
|
v-model="newTag"
|
||||||
placeholder="输入回车添加"
|
placeholder="$t('commons.tag_tip)"
|
||||||
@keydown.delete.stop="removeLastTag"
|
@keydown.delete.stop="removeLastTag"
|
||||||
@keydown="addNew"
|
@keydown="addNew"
|
||||||
@blur="addNew"/>
|
@blur="addNew"/>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<el-form :model="editData" label-position="right" label-width="80px" size="small" ref="form">
|
<el-form :model="editData" label-position="right" label-width="80px" size="small" ref="form">
|
||||||
<el-form-item :label="$t('api_test.variable_name')" prop="name">
|
<el-form-item :label="$t('api_test.variable_name')" prop="name">
|
||||||
<el-input v-model="editData.name" :placeholder="$t('api_test.variable_name')"></el-input>
|
<el-input v-model="editData.name" :placeholder="$t('api_test.variable_name')" ref="nameInput"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item :label="$t('commons.description')" prop="description">
|
<el-form-item :label="$t('commons.description')" prop="description">
|
||||||
|
@ -25,6 +25,17 @@
|
||||||
props: {
|
props: {
|
||||||
editData: {},
|
editData: {},
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.nameInput.focus();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
editData() {
|
||||||
|
this.$refs.nameInput.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
<div style="margin:20px">
|
<div style="margin:20px">
|
||||||
<el-button style="margin-right:10px" @click="deleteVariable">{{$t('commons.delete')}}</el-button>
|
<el-button style="margin-right:10px" @click="deleteVariable">{{$t('commons.delete')}}</el-button>
|
||||||
|
|
||||||
<el-dropdown split-button type="primary" @command="handleClick" placement="top-end">
|
<el-dropdown split-button type="primary" @command="handleClick" @click="handleClick('CONSTANT')" placement="top-end">
|
||||||
{{$t('commons.add')}}
|
{{$t('commons.add')}}
|
||||||
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-menu slot="dropdown">
|
||||||
<el-dropdown-item command="CONSTANT">常量</el-dropdown-item>
|
<el-dropdown-item command="CONSTANT">常量</el-dropdown-item>
|
||||||
|
|
|
@ -77,16 +77,16 @@
|
||||||
document.removeEventListener("keydown", this.createCtrlSHandle);
|
document.removeEventListener("keydown", this.createCtrlSHandle);
|
||||||
},
|
},
|
||||||
createCtrlSHandle(event) {
|
createCtrlSHandle(event) {
|
||||||
if(this.$refs.httpApi) {
|
if (this.$refs.httpApi) {
|
||||||
handleCtrlSEvent(event, this.$refs.httpApi.saveApi);
|
handleCtrlSEvent(event, this.$refs.httpApi.saveApi);
|
||||||
}
|
}
|
||||||
else if(this.$refs.tcpApi) {
|
else if (this.$refs.tcpApi) {
|
||||||
handleCtrlSEvent(event, this.$refs.tcpApi.saveApi);
|
handleCtrlSEvent(event, this.$refs.tcpApi.saveApi);
|
||||||
}
|
}
|
||||||
else if(this.$refs.dubboApi) {
|
else if (this.$refs.dubboApi) {
|
||||||
handleCtrlSEvent(event, this.$refs.dubboApi.saveApi);
|
handleCtrlSEvent(event, this.$refs.dubboApi.saveApi);
|
||||||
}
|
}
|
||||||
else if(this.$refs.sqlApi) {
|
else if (this.$refs.sqlApi) {
|
||||||
handleCtrlSEvent(event, this.$refs.sqlApi.saveApi);
|
handleCtrlSEvent(event, this.$refs.sqlApi.saveApi);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -192,27 +192,10 @@
|
||||||
let bodyFiles = this.getBodyUploadFiles(data);
|
let bodyFiles = this.getBodyUploadFiles(data);
|
||||||
this.$fileUpload(this.reqUrl, null, bodyFiles, data, () => {
|
this.$fileUpload(this.reqUrl, null, bodyFiles, data, () => {
|
||||||
this.$success(this.$t('commons.save_success'));
|
this.$success(this.$t('commons.save_success'));
|
||||||
if (this.reqUrl.endsWith('/create')) {
|
|
||||||
this.saveTestCase(data);
|
|
||||||
}
|
|
||||||
this.reqUrl = "/api/definition/update";
|
this.reqUrl = "/api/definition/update";
|
||||||
this.$emit('saveApi', data);
|
this.$emit('saveApi', data);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
saveTestCase(row) {
|
|
||||||
let tmp = {request: JSON.parse(JSON.stringify(row.request))};
|
|
||||||
tmp.projectId = getCurrentProjectID();
|
|
||||||
tmp.active = true;
|
|
||||||
tmp.priority = "P0";
|
|
||||||
tmp.name = row.name;
|
|
||||||
tmp.request.path = row.path;
|
|
||||||
tmp.request.method = row.method;
|
|
||||||
tmp.apiDefinitionId = row.id;
|
|
||||||
let bodyFiles = this.getBodyUploadFiles(tmp);
|
|
||||||
let url = "/api/testcase/create";
|
|
||||||
this.$fileUpload(url, null, bodyFiles, tmp, (response) => {
|
|
||||||
});
|
|
||||||
},
|
|
||||||
setParameters(data) {
|
setParameters(data) {
|
||||||
data.projectId = this.projectId;
|
data.projectId = this.projectId;
|
||||||
this.request.name = this.currentApi.name;
|
this.request.name = this.currentApi.name;
|
||||||
|
|
|
@ -108,7 +108,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {_getBodyUploadFiles, getCurrentProjectID} from "../../../../../../common/js/utils";
|
import {_getBodyUploadFiles, getCurrentProjectID, getUUID} from "@/common/js/utils";
|
||||||
import {PRIORITY, RESULT_MAP} from "../../model/JsonData";
|
import {PRIORITY, RESULT_MAP} from "../../model/JsonData";
|
||||||
import MsTag from "../../../../common/components/MsTag";
|
import MsTag from "../../../../common/components/MsTag";
|
||||||
import MsTipButton from "../../../../common/components/MsTipButton";
|
import MsTipButton from "../../../../common/components/MsTipButton";
|
||||||
|
@ -236,7 +236,32 @@
|
||||||
this.saveTestCase(row);
|
this.saveTestCase(row);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
saveTestCase(row) {
|
setParameters(data) {
|
||||||
|
data.projectId = getCurrentProjectID();
|
||||||
|
data.request.name = data.name;
|
||||||
|
if (data.protocol === "DUBBO" || data.protocol === "dubbo://") {
|
||||||
|
data.request.protocol = "dubbo://";
|
||||||
|
} else {
|
||||||
|
data.request.protocol = data.protocol;
|
||||||
|
}
|
||||||
|
data.id = data.request.id;
|
||||||
|
if (!data.method) {
|
||||||
|
data.method = data.protocol;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
saveApi(row) {
|
||||||
|
let data = this.api;
|
||||||
|
data.name = this.apiCase.name;
|
||||||
|
this.setParameters(data);
|
||||||
|
let bodyFiles = this.getBodyUploadFiles(data);
|
||||||
|
this.$fileUpload("/api/definition/create", null, bodyFiles, data, () => {
|
||||||
|
if (row) {
|
||||||
|
this.api.saved = false;
|
||||||
|
this.saveCase(row);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
saveCase(row) {
|
||||||
let tmp = JSON.parse(JSON.stringify(row));
|
let tmp = JSON.parse(JSON.stringify(row));
|
||||||
this.isShowInput = false;
|
this.isShowInput = false;
|
||||||
if (this.validate(tmp)) {
|
if (this.validate(tmp)) {
|
||||||
|
@ -267,6 +292,14 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
saveTestCase(row) {
|
||||||
|
if (this.api.saved) {
|
||||||
|
this.saveApi(row);
|
||||||
|
} else {
|
||||||
|
this.saveCase(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
showInput(row) {
|
showInput(row) {
|
||||||
// row.type = "create";
|
// row.type = "create";
|
||||||
this.isShowInput = true;
|
this.isShowInput = true;
|
||||||
|
@ -293,7 +326,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
showExecResult(item) {
|
showExecResult(item) {
|
||||||
item.active = false;
|
item.active = true;
|
||||||
item.isActive = true;
|
item.isActive = true;
|
||||||
},
|
},
|
||||||
getBodyUploadFiles(row) {
|
getBodyUploadFiles(row) {
|
||||||
|
|
|
@ -144,6 +144,12 @@
|
||||||
this.getApiTest(true);
|
this.getApiTest(true);
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
},
|
},
|
||||||
|
saveApiAndCase(api) {
|
||||||
|
this.visible = true;
|
||||||
|
this.api = api;
|
||||||
|
console.log(api)
|
||||||
|
this.addCase();
|
||||||
|
},
|
||||||
setEnvironment(environment) {
|
setEnvironment(environment) {
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
},
|
},
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
<div v-if="scenario">
|
<div v-if="scenario">
|
||||||
<el-button style="float: right;margin: 20px" type="primary" @click="handleCommand('save_as')"> {{$t('commons.save')}}</el-button>
|
<el-button style="float: right;margin: 20px" type="primary" @click="handleCommand('save_as')"> {{$t('commons.save')}}</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- 加载用例 -->
|
||||||
|
<ms-api-case-list :loaded="false" ref="caseList"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -40,10 +43,11 @@
|
||||||
import MsRequestResultTail from "../response/RequestResultTail";
|
import MsRequestResultTail from "../response/RequestResultTail";
|
||||||
import MsBasisParameters from "../request/dubbo/BasisParameters";
|
import MsBasisParameters from "../request/dubbo/BasisParameters";
|
||||||
import MsJmxStep from "../step/JmxStep";
|
import MsJmxStep from "../step/JmxStep";
|
||||||
|
import MsApiCaseList from "../case/ApiCaseList";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ApiConfig",
|
name: "ApiConfig",
|
||||||
components: {MsRequestResultTail, MsResponseResult, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters, MsJmxStep},
|
components: {MsRequestResultTail, MsResponseResult, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters, MsJmxStep, MsApiCaseList},
|
||||||
props: {
|
props: {
|
||||||
currentProtocol: String,
|
currentProtocol: String,
|
||||||
scenario: Boolean,
|
scenario: Boolean,
|
||||||
|
@ -120,7 +124,11 @@
|
||||||
saveAs() {
|
saveAs() {
|
||||||
let obj = {request: this.request};
|
let obj = {request: this.request};
|
||||||
obj.request.id = getUUID();
|
obj.request.id = getUUID();
|
||||||
this.$emit('saveAs', obj);
|
obj.saved = true;
|
||||||
|
obj.protocol = this.currentProtocol;
|
||||||
|
obj.status = "Underway";
|
||||||
|
obj.method = this.currentProtocol;
|
||||||
|
this.$refs.caseList.saveApiAndCase(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,8 @@
|
||||||
<div v-if="scenario">
|
<div v-if="scenario">
|
||||||
<el-button style="float: right;margin: 20px" type="primary" @click="handleCommand('save_as')"> {{$t('commons.save')}}</el-button>
|
<el-button style="float: right;margin: 20px" type="primary" @click="handleCommand('save_as')"> {{$t('commons.save')}}</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- 加载用例 -->
|
||||||
|
<ms-api-case-list :loaded="false" ref="caseList"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -56,10 +58,11 @@
|
||||||
import MsRequestResultTail from "../response/RequestResultTail";
|
import MsRequestResultTail from "../response/RequestResultTail";
|
||||||
import MsJmxStep from "../step/JmxStep";
|
import MsJmxStep from "../step/JmxStep";
|
||||||
import {KeyValue} from "../../model/ApiTestModel";
|
import {KeyValue} from "../../model/ApiTestModel";
|
||||||
|
import MsApiCaseList from "../case/ApiCaseList";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ApiConfig",
|
name: "ApiConfig",
|
||||||
components: {MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun, MsJmxStep},
|
components: {MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun, MsJmxStep, MsApiCaseList},
|
||||||
props: {
|
props: {
|
||||||
currentProtocol: String,
|
currentProtocol: String,
|
||||||
testCase: {},
|
testCase: {},
|
||||||
|
@ -92,6 +95,7 @@
|
||||||
runData: [],
|
runData: [],
|
||||||
reportId: "",
|
reportId: "",
|
||||||
reqOptions: REQ_METHOD,
|
reqOptions: REQ_METHOD,
|
||||||
|
createCase: "",
|
||||||
request: {},
|
request: {},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -156,13 +160,17 @@
|
||||||
saveAs() {
|
saveAs() {
|
||||||
this.$refs['debugForm'].validate((valid) => {
|
this.$refs['debugForm'].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.debugForm.id = null;
|
|
||||||
this.request.id = getUUID();
|
this.request.id = getUUID();
|
||||||
|
this.request.method = this.debugForm.method;
|
||||||
|
this.request.path = this.debugForm.path;
|
||||||
|
this.protocol = this.currentProtocol;
|
||||||
|
this.debugForm.id = this.request.id;
|
||||||
this.debugForm.request = this.request;
|
this.debugForm.request = this.request;
|
||||||
this.debugForm.userId = getCurrentUser().id;
|
this.debugForm.userId = getCurrentUser().id;
|
||||||
this.debugForm.status = "Underway";
|
this.debugForm.status = "Underway";
|
||||||
this.debugForm.protocol = this.currentProtocol;
|
this.debugForm.protocol = this.currentProtocol;
|
||||||
this.$emit('saveAs', this.debugForm);
|
this.debugForm.saved = true;
|
||||||
|
this.$refs.caseList.saveApiAndCase(this.debugForm);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -170,10 +178,13 @@
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
urlChange() {
|
urlChange() {
|
||||||
if (!this.debugForm.url || this.debugForm.url.indexOf('?') === -1) return;
|
if (!this.debugForm.url) return;
|
||||||
let url = this.getURL(this.addProtocol(this.debugForm.url));
|
let url = this.getURL(this.addProtocol(this.debugForm.url));
|
||||||
if (url) {
|
if (url) {
|
||||||
this.debugForm.url = decodeURIComponent(this.debugForm.url.substr(0, this.debugForm.url.indexOf("?")));
|
if (this.debugForm.url.indexOf('?') != -1) {
|
||||||
|
this.debugForm.url = decodeURIComponent(this.debugForm.url.substr(0, this.debugForm.url.indexOf("?")));
|
||||||
|
}
|
||||||
|
this.debugForm.path = url.pathname;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
addProtocol(url) {
|
addProtocol(url) {
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
<div v-if="scenario">
|
<div v-if="scenario">
|
||||||
<el-button style="float: right;margin: 20px" type="primary" @click="handleCommand('save_as')"> {{$t('commons.save')}}</el-button>
|
<el-button style="float: right;margin: 20px" type="primary" @click="handleCommand('save_as')"> {{$t('commons.save')}}</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- 加载用例 -->
|
||||||
|
<ms-api-case-list :loaded="false" ref="caseList"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -43,10 +45,11 @@
|
||||||
import MsRequestResultTail from "../response/RequestResultTail";
|
import MsRequestResultTail from "../response/RequestResultTail";
|
||||||
import MsBasisParameters from "../request/database/BasisParameters";
|
import MsBasisParameters from "../request/database/BasisParameters";
|
||||||
import MsJmxStep from "../step/JmxStep";
|
import MsJmxStep from "../step/JmxStep";
|
||||||
|
import MsApiCaseList from "../case/ApiCaseList";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ApiConfig",
|
name: "ApiConfig",
|
||||||
components: {MsRequestResultTail, MsResponseResult, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters, MsJmxStep},
|
components: {MsRequestResultTail, MsResponseResult, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters, MsJmxStep,MsApiCaseList},
|
||||||
props: {
|
props: {
|
||||||
currentProtocol: String,
|
currentProtocol: String,
|
||||||
scenario: Boolean,
|
scenario: Boolean,
|
||||||
|
@ -123,7 +126,11 @@
|
||||||
saveAs() {
|
saveAs() {
|
||||||
let obj = {request: this.request};
|
let obj = {request: this.request};
|
||||||
obj.request.id = getUUID();
|
obj.request.id = getUUID();
|
||||||
this.$emit('saveAs', obj);
|
obj.saved = true;
|
||||||
|
obj.protocol = this.currentProtocol;
|
||||||
|
obj.status = "Underway";
|
||||||
|
obj.method = this.currentProtocol;
|
||||||
|
this.$refs.caseList.saveApiAndCase(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,9 @@
|
||||||
<div v-if="scenario">
|
<div v-if="scenario">
|
||||||
<el-button style="float: right;margin: 20px" type="primary" @click="handleCommand('save_as')"> {{$t('commons.save')}}</el-button>
|
<el-button style="float: right;margin: 20px" type="primary" @click="handleCommand('save_as')"> {{$t('commons.save')}}</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- 加载用例 -->
|
||||||
|
<ms-api-case-list :loaded="false" ref="caseList"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
@ -53,13 +56,15 @@
|
||||||
import MsRequestResultTail from "../response/RequestResultTail";
|
import MsRequestResultTail from "../response/RequestResultTail";
|
||||||
import TcpBasisParameters from "../request/tcp/TcpBasisParameters";
|
import TcpBasisParameters from "../request/tcp/TcpBasisParameters";
|
||||||
import MsJmxStep from "../step/JmxStep";
|
import MsJmxStep from "../step/JmxStep";
|
||||||
|
import MsApiCaseList from "../case/ApiCaseList";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ApiConfig",
|
name: "ApiConfig",
|
||||||
components: {
|
components: {
|
||||||
MsJmxStep,
|
MsJmxStep,
|
||||||
TcpBasisParameters,
|
TcpBasisParameters,
|
||||||
MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun},
|
MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun, MsApiCaseList
|
||||||
|
},
|
||||||
props: {
|
props: {
|
||||||
currentProtocol: String,
|
currentProtocol: String,
|
||||||
scenario: Boolean,
|
scenario: Boolean,
|
||||||
|
@ -135,8 +140,16 @@
|
||||||
},
|
},
|
||||||
saveAs() {
|
saveAs() {
|
||||||
let obj = {request: this.request};
|
let obj = {request: this.request};
|
||||||
|
obj.request.server = this.debugForm.server;
|
||||||
|
obj.request.port = this.debugForm.port;
|
||||||
|
obj.server = this.debugForm.server;
|
||||||
|
obj.port = this.debugForm.port;
|
||||||
obj.request.id = getUUID();
|
obj.request.id = getUUID();
|
||||||
this.$emit('saveAs', obj);
|
obj.saved = true;
|
||||||
|
obj.protocol = this.currentProtocol;
|
||||||
|
obj.status = "Underway";
|
||||||
|
obj.method = this.currentProtocol;
|
||||||
|
this.$refs.caseList.saveApiAndCase(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,6 +132,7 @@ export default {
|
||||||
batch_add: "Batch add",
|
batch_add: "Batch add",
|
||||||
check_project_tip: "Create or select the project first",
|
check_project_tip: "Create or select the project first",
|
||||||
auth_redirect_tip: 'Jump to the authentication source page for authentication',
|
auth_redirect_tip: 'Jump to the authentication source page for authentication',
|
||||||
|
tag_tip: "Enter Enter to Add Label",
|
||||||
table: {
|
table: {
|
||||||
select_tip: "Item {0} data is selected"
|
select_tip: "Item {0} data is selected"
|
||||||
},
|
},
|
||||||
|
|
|
@ -133,6 +133,7 @@ export default {
|
||||||
batch_add: "批量添加",
|
batch_add: "批量添加",
|
||||||
check_project_tip: "请先创建或选择项目",
|
check_project_tip: "请先创建或选择项目",
|
||||||
auth_redirect_tip: '即将跳转到认证源页面进行认证',
|
auth_redirect_tip: '即将跳转到认证源页面进行认证',
|
||||||
|
tag_tip: "输入回车添加标签",
|
||||||
table: {
|
table: {
|
||||||
select_tip: "已选中 {0} 条数据"
|
select_tip: "已选中 {0} 条数据"
|
||||||
},
|
},
|
||||||
|
|
|
@ -133,6 +133,7 @@ export default {
|
||||||
batch_add: "批量添加",
|
batch_add: "批量添加",
|
||||||
check_project_tip: "請先創建或選擇項目",
|
check_project_tip: "請先創建或選擇項目",
|
||||||
auth_redirect_tip: '即將跳轉到認證源頁面進行認證',
|
auth_redirect_tip: '即將跳轉到認證源頁面進行認證',
|
||||||
|
tag_tip: "輸入回車添加標簽",
|
||||||
table: {
|
table: {
|
||||||
select_tip: "已选中 {0} 条数据"
|
select_tip: "已选中 {0} 条数据"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue