Merge branch 'master' of https://github.com/metersphere/metersphere
This commit is contained in:
commit
d24d7e5144
|
@ -68,7 +68,10 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
|
|
|
@ -10,4 +10,10 @@ public class RunCaseRequest {
|
|||
private String caseId;
|
||||
|
||||
private String reportId;
|
||||
|
||||
private String runMode;
|
||||
|
||||
private String environmentId;
|
||||
|
||||
private String testPlanId;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import io.metersphere.api.dto.definition.request.ParameterConfig;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.jmeter.extractor.JSR223PostProcessor;
|
||||
import org.apache.jmeter.extractor.RegexExtractor;
|
||||
import org.apache.jmeter.extractor.XPath2Extractor;
|
||||
import org.apache.jmeter.extractor.json.jsonpath.JSONPostProcessor;
|
||||
|
@ -14,6 +15,8 @@ import org.apache.jmeter.testelement.TestElement;
|
|||
import org.apache.jorphan.collections.HashTree;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
@ -32,24 +35,34 @@ public class MsExtract extends MsTestElement {
|
|||
}
|
||||
|
||||
private void addRequestExtractors(HashTree samplerHashTree) {
|
||||
StringJoiner extract = new StringJoiner(";");
|
||||
|
||||
if (CollectionUtils.isNotEmpty(this.getRegex())) {
|
||||
this.getRegex().stream().filter(MsExtractRegex::isValid).forEach(extractRegex ->
|
||||
samplerHashTree.add(regexExtractor(extractRegex))
|
||||
samplerHashTree.add(regexExtractor(extractRegex, extract))
|
||||
);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(this.getXpath())) {
|
||||
this.getXpath().stream().filter(MsExtractCommon::isValid).forEach(extractXPath ->
|
||||
samplerHashTree.add(xPath2Extractor(extractXPath))
|
||||
samplerHashTree.add(xPath2Extractor(extractXPath, extract))
|
||||
);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(this.getJson())) {
|
||||
this.getJson().stream().filter(MsExtractCommon::isValid).forEach(extractJSONPath ->
|
||||
samplerHashTree.add(jsonPostProcessor(extractJSONPath))
|
||||
samplerHashTree.add(jsonPostProcessor(extractJSONPath, extract))
|
||||
);
|
||||
}
|
||||
if (Optional.ofNullable(extract).orElse(extract).length() > 0) {
|
||||
JSR223PostProcessor shell = new JSR223PostProcessor();
|
||||
shell.setEnabled(true);
|
||||
shell.setName(this.getName());
|
||||
shell.setProperty("script", "io.metersphere.api.jmeter.JMeterVars.addVars(prev.hashCode(),vars," + "\"" + extract.toString() + "\"" + ");");
|
||||
samplerHashTree.add(shell);
|
||||
}
|
||||
}
|
||||
|
||||
private RegexExtractor regexExtractor(MsExtractRegex extractRegex) {
|
||||
private RegexExtractor regexExtractor(MsExtractRegex extractRegex, StringJoiner extract) {
|
||||
|
||||
RegexExtractor extractor = new RegexExtractor();
|
||||
extractor.setEnabled(true);
|
||||
extractor.setName(extractRegex.getVariable() + " RegexExtractor");
|
||||
|
@ -62,10 +75,12 @@ public class MsExtract extends MsTestElement {
|
|||
extractor.setMatchNumber(-1);
|
||||
}
|
||||
extractor.setTemplate("$1$");
|
||||
extract.add(extractor.getRefName());
|
||||
|
||||
return extractor;
|
||||
}
|
||||
|
||||
private XPath2Extractor xPath2Extractor(MsExtractXPath extractXPath) {
|
||||
private XPath2Extractor xPath2Extractor(MsExtractXPath extractXPath, StringJoiner extract) {
|
||||
XPath2Extractor extractor = new XPath2Extractor();
|
||||
extractor.setEnabled(true);
|
||||
extractor.setName(extractXPath.getVariable() + " XPath2Extractor");
|
||||
|
@ -76,10 +91,11 @@ public class MsExtract extends MsTestElement {
|
|||
if (extractXPath.isMultipleMatching()) {
|
||||
extractor.setMatchNumber(-1);
|
||||
}
|
||||
extract.add(extractor.getRefName());
|
||||
return extractor;
|
||||
}
|
||||
|
||||
private JSONPostProcessor jsonPostProcessor(MsExtractJSONPath extractJSONPath) {
|
||||
private JSONPostProcessor jsonPostProcessor(MsExtractJSONPath extractJSONPath, StringJoiner extract) {
|
||||
JSONPostProcessor extractor = new JSONPostProcessor();
|
||||
extractor.setEnabled(true);
|
||||
extractor.setName(extractJSONPath.getVariable() + " JSONExtractor");
|
||||
|
@ -90,6 +106,7 @@ public class MsExtract extends MsTestElement {
|
|||
if (extractJSONPath.isMultipleMatching()) {
|
||||
extractor.setMatchNumbers("-1");
|
||||
}
|
||||
extract.add(extractor.getRefNames());
|
||||
return extractor;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,8 +109,11 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
sampler.setFollowRedirects(this.isFollowRedirects());
|
||||
sampler.setUseKeepAlive(true);
|
||||
sampler.setDoMultipart(this.isDoMultipartPost());
|
||||
|
||||
config.setConfig(getEnvironmentConfig(useEnvironment));
|
||||
if(config != null && config.getConfig() != null){
|
||||
config.setConfig(config.getConfig());
|
||||
}else{
|
||||
config.setConfig(getEnvironmentConfig(useEnvironment));
|
||||
}
|
||||
|
||||
// 添加环境中的公共变量
|
||||
Arguments arguments = this.addArguments(config);
|
||||
|
|
|
@ -4,10 +4,7 @@ import io.metersphere.api.dto.scenario.request.RequestType;
|
|||
import io.metersphere.api.service.*;
|
||||
import io.metersphere.base.domain.ApiScenarioReport;
|
||||
import io.metersphere.base.domain.ApiTestReport;
|
||||
import io.metersphere.commons.constants.APITestStatus;
|
||||
import io.metersphere.commons.constants.ApiRunMode;
|
||||
import io.metersphere.commons.constants.NoticeConstants;
|
||||
import io.metersphere.commons.constants.TestPlanTestCaseStatus;
|
||||
import io.metersphere.commons.constants.*;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.dto.BaseSystemConfigDTO;
|
||||
|
@ -16,6 +13,7 @@ import io.metersphere.notice.sender.NoticeModel;
|
|||
import io.metersphere.notice.service.NoticeSendService;
|
||||
import io.metersphere.service.SystemParameterService;
|
||||
import io.metersphere.track.service.TestPlanTestCaseService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jmeter.assertions.AssertionResult;
|
||||
import org.apache.jmeter.protocol.http.sampler.HTTPSampleResult;
|
||||
|
@ -165,7 +163,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
|||
apiReportService.complete(testResult, report);
|
||||
} else if (StringUtils.equals(this.runMode, ApiRunMode.DELIMIT.name())) {
|
||||
// 调试操作,不需要存储结果
|
||||
if (StringUtils.isBlank(debugReportId)) {
|
||||
if (!StringUtils.isBlank(debugReportId)) {
|
||||
apiDefinitionService.addResult(testResult);
|
||||
} else {
|
||||
apiDefinitionService.addResult(testResult);
|
||||
|
@ -235,12 +233,12 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
|||
String failedContext = "";
|
||||
String subject = "";
|
||||
String event = "";
|
||||
if (StringUtils.equals(NoticeConstants.Mode.API, report.getTriggerMode())) {
|
||||
if (StringUtils.equals(ReportTriggerMode.API.name(), report.getTriggerMode())) {
|
||||
successContext = "接口测试 API任务通知:'" + report.getName() + "'执行成功" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + url;
|
||||
failedContext = "接口测试 API任务通知:'" + report.getName() + "'执行失败" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + url;
|
||||
subject = Translator.get("task_notification_jenkins");
|
||||
}
|
||||
if (StringUtils.equals(NoticeConstants.Mode.SCHEDULE, report.getTriggerMode())) {
|
||||
if (StringUtils.equals(ReportTriggerMode.SCHEDULE.name(), report.getTriggerMode())) {
|
||||
successContext = "接口测试定时任务通知:'" + report.getName() + "'执行成功" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + url;
|
||||
failedContext = "接口测试定时任务通知:'" + report.getName() + "'执行失败" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + url;
|
||||
subject = Translator.get("task_notification");
|
||||
|
@ -303,20 +301,14 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
|||
responseResult.setResponseSize(result.getResponseData().length);
|
||||
responseResult.setResponseTime(result.getTime());
|
||||
responseResult.setResponseMessage(result.getResponseMessage());
|
||||
|
||||
if (JMeterVars.get(result.hashCode()) != null) {
|
||||
List<String> vars = new LinkedList<>();
|
||||
JMeterVars.get(result.hashCode()).entrySet().parallelStream().reduce(vars, (first, second) -> {
|
||||
first.add(second.getKey() + ":" + second.getValue());
|
||||
return first;
|
||||
}, (first, second) -> {
|
||||
if (first == second) {
|
||||
return first;
|
||||
}
|
||||
first.addAll(second);
|
||||
return first;
|
||||
});
|
||||
responseResult.setVars(StringUtils.join(vars, "\n"));
|
||||
if (JMeterVars.get(result.hashCode()) != null && CollectionUtils.isNotEmpty(JMeterVars.get(result.hashCode()).entrySet())) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (Map.Entry<String, Object> entry : JMeterVars.get(result.hashCode()).entrySet()) {
|
||||
builder.append(entry.getKey()).append(":").append(entry.getValue()).append("\n");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(builder)) {
|
||||
responseResult.setVars(builder.toString());
|
||||
}
|
||||
JMeterVars.remove(result.hashCode());
|
||||
}
|
||||
for (AssertionResult assertionResult : result.getAssertionResults()) {
|
||||
|
|
|
@ -91,7 +91,6 @@ public class JMeterService {
|
|||
public void runDefinition(String testId, HashTree testPlan, String debugReportId, String runMode) {
|
||||
try {
|
||||
init();
|
||||
JMeterVars.addJSR223PostProcessor(testPlan);
|
||||
addBackendListener(testId, debugReportId, runMode, testPlan);
|
||||
LocalRunner runner = new LocalRunner(testPlan);
|
||||
runner.run();
|
||||
|
|
|
@ -409,6 +409,9 @@ public class ApiAutomationService {
|
|||
if (StringUtils.isNotBlank(request.getRunMode()) && StringUtils.equals(request.getRunMode(), ApiRunMode.SCENARIO_PLAN.name())) {
|
||||
runMode = ApiRunMode.SCENARIO_PLAN.name();
|
||||
}
|
||||
if (StringUtils.isNotBlank(request.getRunMode()) && StringUtils.equals(request.getRunMode(), ApiRunMode.DELIMIT.name())) {
|
||||
runMode = ApiRunMode.DELIMIT.name();
|
||||
}
|
||||
// 调用执行方法
|
||||
jMeterService.runDefinition(request.getId(), generateHashTree(apiScenarios, request, true), request.getReportId(), runMode);
|
||||
return request.getId();
|
||||
|
|
|
@ -13,13 +13,11 @@ import io.metersphere.api.dto.definition.request.MsTestPlan;
|
|||
import io.metersphere.api.dto.definition.request.MsThreadGroup;
|
||||
import io.metersphere.api.dto.definition.request.ParameterConfig;
|
||||
import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
|
||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||
import io.metersphere.api.dto.scenario.request.RequestType;
|
||||
import io.metersphere.api.jmeter.JMeterService;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.ApiDefinitionExecResultMapper;
|
||||
import io.metersphere.base.mapper.ApiDefinitionMapper;
|
||||
import io.metersphere.base.mapper.ApiTestCaseMapper;
|
||||
import io.metersphere.base.mapper.ApiTestFileMapper;
|
||||
import io.metersphere.base.mapper.*;
|
||||
import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtTestPlanApiCaseMapper;
|
||||
|
@ -73,7 +71,9 @@ public class ApiTestCaseService {
|
|||
@Resource
|
||||
private JMeterService jMeterService;
|
||||
@Resource
|
||||
private ApiDefinitionExecResultMapper apiDefinitionExecResultMapper;
|
||||
private ApiDefinitionExecResultMapper apiDefinitionExecResultMapper;
|
||||
@Resource
|
||||
TestPlanApiCaseMapper testPlanApiCaseMapper;
|
||||
|
||||
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||
|
||||
|
@ -84,10 +84,10 @@ public class ApiTestCaseService {
|
|||
|
||||
public List<ApiTestCaseDTO> listSimple(ApiTestCaseRequest request) {
|
||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
||||
if(request.isSelectThisWeedData()){
|
||||
if (request.isSelectThisWeedData()) {
|
||||
Map<String, Date> weekFirstTimeAndLastTime = DateUtils.getWeedFirstTimeAndLastTime(new Date());
|
||||
Date weekFirstTime = weekFirstTimeAndLastTime.get("firstTime");
|
||||
if(weekFirstTime!=null){
|
||||
if (weekFirstTime != null) {
|
||||
request.setCreateTime(weekFirstTime.getTime());
|
||||
}
|
||||
}
|
||||
|
@ -435,6 +435,7 @@ public class ApiTestCaseService {
|
|||
|
||||
public String run(RunCaseRequest request) {
|
||||
ApiTestCaseWithBLOBs testCaseWithBLOBs = apiTestCaseMapper.selectByPrimaryKey(request.getCaseId());
|
||||
|
||||
// 多态JSON普通转换会丢失内容,需要通过 ObjectMapper 获取
|
||||
if (testCaseWithBLOBs != null && StringUtils.isNotEmpty(testCaseWithBLOBs.getRequest())) {
|
||||
try {
|
||||
|
@ -442,7 +443,16 @@ public class ApiTestCaseService {
|
|||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
MsTestElement element = mapper.readValue(testCaseWithBLOBs.getRequest(), new TypeReference<MsTestElement>() {
|
||||
});
|
||||
element.setName(request.getCaseId());
|
||||
if(StringUtils.isBlank(request.getEnvironmentId())){
|
||||
TestPlanApiCaseExample example = new TestPlanApiCaseExample();
|
||||
example.createCriteria().andTestPlanIdEqualTo(request.getTestPlanId()).andApiCaseIdEqualTo(request.getCaseId());
|
||||
List<TestPlanApiCase> list=testPlanApiCaseMapper.selectByExample(example);
|
||||
request.setEnvironmentId(list.get(0).getEnvironmentId());
|
||||
element.setName(list.get(0).getId());
|
||||
}else{
|
||||
element.setName(request.getCaseId());
|
||||
}
|
||||
|
||||
// 测试计划
|
||||
MsTestPlan testPlan = new MsTestPlan();
|
||||
testPlan.setHashTree(new LinkedList<>());
|
||||
|
@ -457,10 +467,14 @@ public class ApiTestCaseService {
|
|||
hashTrees.add(element);
|
||||
group.setHashTree(hashTrees);
|
||||
testPlan.getHashTree().add(group);
|
||||
|
||||
testPlan.toHashTree(jmeterHashTree, testPlan.getHashTree(), new ParameterConfig());
|
||||
|
||||
String runMode = ApiRunMode.DELIMIT.name();
|
||||
ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class);
|
||||
ApiTestEnvironmentWithBLOBs environment = environmentService.get(request.getEnvironmentId());
|
||||
ParameterConfig parameterConfig=new ParameterConfig();
|
||||
if (environment != null && environment.getConfig() != null) {
|
||||
parameterConfig.setConfig( JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class));
|
||||
}
|
||||
testPlan.toHashTree(jmeterHashTree, testPlan.getHashTree(), parameterConfig);
|
||||
String runMode = request.getRunMode();
|
||||
// 调用执行方法
|
||||
jMeterService.runDefinition(request.getReportId(), jmeterHashTree, request.getReportId(), runMode);
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ public class HistoricalDataUpgradeService {
|
|||
ifController.setType("IfController");
|
||||
ifController.setName("IfController");
|
||||
ifController.setIndex(index + "");
|
||||
ifController.setHashTree(new LinkedList<>());
|
||||
ifController.setResourceId(UUID.randomUUID().toString());
|
||||
}
|
||||
// 等待控制器
|
||||
|
@ -93,6 +94,7 @@ public class HistoricalDataUpgradeService {
|
|||
BeanUtils.copyBean(constantTimer, request.getTimer());
|
||||
constantTimer.setType("ConstantTimer");
|
||||
constantTimer.setIndex(index + "");
|
||||
constantTimer.setHashTree(new LinkedList<>());
|
||||
constantTimer.setResourceId(UUID.randomUUID().toString());
|
||||
testElements.add(constantTimer);
|
||||
}
|
||||
|
@ -119,7 +121,6 @@ public class HistoricalDataUpgradeService {
|
|||
if (StringUtils.isEmpty(element.getName())) {
|
||||
element.setName(request1.getPath());
|
||||
}
|
||||
|
||||
element.setType("HTTPSamplerProxy");
|
||||
}
|
||||
if (request instanceof DubboRequest) {
|
||||
|
@ -147,6 +148,7 @@ public class HistoricalDataUpgradeService {
|
|||
}
|
||||
element.setIndex(index + "");
|
||||
element.setResourceId(UUID.randomUUID().toString());
|
||||
element.setHashTree(new LinkedList<>());
|
||||
LinkedList<MsTestElement> msTestElements = new LinkedList<>();
|
||||
// 断言规则
|
||||
if (request.getAssertions() != null && ((request.getAssertions().getDuration() != null && request.getAssertions().getDuration().getValue() > 0) ||
|
||||
|
@ -157,6 +159,7 @@ public class HistoricalDataUpgradeService {
|
|||
msAssertions.setType("Assertions");
|
||||
msAssertions.setIndex(index + "");
|
||||
msAssertions.setResourceId(UUID.randomUUID().toString());
|
||||
msAssertions.setHashTree(new LinkedList<>());
|
||||
msTestElements.add(msAssertions);
|
||||
}
|
||||
// 提取规则
|
||||
|
@ -166,6 +169,7 @@ public class HistoricalDataUpgradeService {
|
|||
MsExtract extract = JSON.parseObject(extractJson, MsExtract.class);
|
||||
extract.setType("Extract");
|
||||
extract.setIndex(index + "");
|
||||
extract.setHashTree(new LinkedList<>());
|
||||
extract.setResourceId(UUID.randomUUID().toString());
|
||||
msTestElements.add(extract);
|
||||
}
|
||||
|
@ -175,6 +179,7 @@ public class HistoricalDataUpgradeService {
|
|||
MsJSR223PreProcessor preProcessor = JSON.parseObject(preJson, MsJSR223PreProcessor.class);
|
||||
preProcessor.setType("JSR223PreProcessor");
|
||||
preProcessor.setIndex(index + "");
|
||||
preProcessor.setHashTree(new LinkedList<>());
|
||||
preProcessor.setResourceId(UUID.randomUUID().toString());
|
||||
msTestElements.add(preProcessor);
|
||||
}
|
||||
|
@ -184,6 +189,7 @@ public class HistoricalDataUpgradeService {
|
|||
MsJSR223PostProcessor preProcessor = JSON.parseObject(preJson, MsJSR223PostProcessor.class);
|
||||
preProcessor.setType("JSR223PostProcessor");
|
||||
preProcessor.setIndex(index + "");
|
||||
preProcessor.setHashTree(new LinkedList<>());
|
||||
preProcessor.setResourceId(UUID.randomUUID().toString());
|
||||
msTestElements.add(preProcessor);
|
||||
}
|
||||
|
|
|
@ -105,7 +105,8 @@
|
|||
</sql>
|
||||
|
||||
<select id="getTestCaseByNotInReview" resultType="io.metersphere.base.domain.TestCase">
|
||||
select test_case.id, test_case.name, test_case.priority, test_case.type, test_case.review_status from test_case as test_case
|
||||
select test_case.id, test_case.name, test_case.priority, test_case.type, test_case.review_status from test_case
|
||||
as test_case
|
||||
left join test_case_review_test_case as T2 on test_case.id=T2.case_id and T2.review_id =#{request.reviewId}
|
||||
<where>
|
||||
<if test="request.combine != null">
|
||||
|
@ -159,7 +160,8 @@
|
|||
</select>
|
||||
|
||||
<select id="getTestCaseByNotInPlan" resultType="io.metersphere.base.domain.TestCase">
|
||||
select test_case.id, test_case.name, test_case.priority, test_case.type, test_case.review_status from test_case as test_case
|
||||
select test_case.id, test_case.name, test_case.priority, test_case.type, test_case.review_status from test_case
|
||||
as test_case
|
||||
left join test_plan_test_case as T2 on test_case.id=T2.case_id and T2.plan_id =#{request.planId}
|
||||
<where>
|
||||
<if test="request.combine != null">
|
||||
|
@ -265,7 +267,8 @@
|
|||
</select>
|
||||
|
||||
<select id="list" resultType="io.metersphere.track.dto.TestCaseDTO">
|
||||
select <include refid="io.metersphere.base.mapper.TestCaseMapper.Base_Column_List"/>
|
||||
select
|
||||
<include refid="io.metersphere.base.mapper.TestCaseMapper.Base_Column_List"/>
|
||||
from test_case
|
||||
<where>
|
||||
<if test="request.combine != null">
|
||||
|
@ -275,7 +278,8 @@
|
|||
</include>
|
||||
</if>
|
||||
<if test="request.name != null">
|
||||
and (test_case.name like CONCAT('%', #{request.name},'%') or test_case.num like CONCAT('%', #{request.name},'%'))
|
||||
and (test_case.name like CONCAT('%', #{request.name},'%') or test_case.num like CONCAT('%',
|
||||
#{request.name},'%'))
|
||||
</if>
|
||||
<if test="request.nodeIds != null and request.nodeIds.size() > 0">
|
||||
and test_case.node_id in
|
||||
|
@ -342,16 +346,23 @@
|
|||
</where>
|
||||
UNION ALL
|
||||
select id,name,project_id,"scenario" as type from api_scenario
|
||||
|
||||
<where>
|
||||
<if test="request.projectId!=null">
|
||||
and project_id= #{request.projectId}
|
||||
</if>
|
||||
</where>
|
||||
and api_scenario.status!='Trash'
|
||||
UNION ALL
|
||||
select id,name,project_id,"definition" as type from api_test_case
|
||||
select b.id,b.name,b.project_id,"definition" as type from api_test_case b
|
||||
inner join
|
||||
api_definition a
|
||||
on
|
||||
b.api_definition_id = a.id
|
||||
and a.status != 'Trash'
|
||||
<where>
|
||||
<if test="request.projectId!=null">
|
||||
and project_id= #{request.projectId}
|
||||
and b.project_id= #{request.projectId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
@ -378,7 +389,11 @@
|
|||
</select>
|
||||
|
||||
<select id="getMaxNumByProjectId" resultType="io.metersphere.base.domain.TestCase">
|
||||
SELECT * FROM test_case WHERE test_case.project_id = #{projectId} ORDER BY num DESC LIMIT 1;
|
||||
SELECT *
|
||||
FROM test_case
|
||||
WHERE test_case.project_id = #{projectId}
|
||||
ORDER BY num DESC
|
||||
LIMIT 1;
|
||||
</select>
|
||||
|
||||
<select id="checkIsHave" resultType="int">
|
||||
|
|
|
@ -366,6 +366,15 @@
|
|||
</if>
|
||||
</where>
|
||||
UNION ALL
|
||||
select load_test.id as id,"perform" as type,load_test.name as name,test_plan_load_case.status from test_plan_load_case inner join
|
||||
load_test on
|
||||
test_plan_load_case.load_case_id =load_test.id
|
||||
<where>
|
||||
<if test="request.planId != null">
|
||||
and test_plan_load_case.test_plan_id = #{request.planId}
|
||||
</if>
|
||||
</where>
|
||||
UNION ALL
|
||||
SELECT test_case.test_id as id,test_case.type as type,test_case.name,test_plan_test_case.status
|
||||
from test_plan_test_case left join test_case on test_plan_test_case.case_id =test_case.id
|
||||
<where>
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package io.metersphere.commons.consumer;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.metersphere.Application;
|
||||
import io.metersphere.base.domain.LoadTestReport;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import org.apache.kafka.clients.consumer.ConsumerRecord;
|
||||
import org.reflections8.Reflections;
|
||||
import org.springframework.kafka.annotation.KafkaListener;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
public class LoadTestConsumer {
|
||||
public static final String CONSUME_ID = "load-test-data";
|
||||
|
||||
@KafkaListener(id = CONSUME_ID, topics = "${kafka.test.topic}", groupId = "${spring.kafka.consumer.group-id}")
|
||||
public void consume(ConsumerRecord<?, String> record) {
|
||||
LoadTestReport loadTestReport = JSON.parseObject(record.value(), LoadTestReport.class);
|
||||
Reflections reflections = new Reflections(Application.class);
|
||||
Set<Class<? extends LoadTestFinishEvent>> subTypes = reflections.getSubTypesOf(LoadTestFinishEvent.class);
|
||||
subTypes.forEach(s -> {
|
||||
try {
|
||||
CommonBeanFactory.getBean(s).execute(loadTestReport);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package io.metersphere.commons.consumer;
|
||||
|
||||
import io.metersphere.base.domain.LoadTestReport;
|
||||
|
||||
public interface LoadTestFinishEvent {
|
||||
void execute(LoadTestReport loadTestReport);
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
package io.metersphere.performance.notice;
|
||||
|
||||
import io.metersphere.base.domain.LoadTestReportWithBLOBs;
|
||||
import io.metersphere.base.mapper.LoadTestReportMapper;
|
||||
import io.metersphere.base.domain.LoadTestReport;
|
||||
import io.metersphere.commons.constants.NoticeConstants;
|
||||
import io.metersphere.commons.constants.PerformanceTestStatus;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.commons.constants.ReportTriggerMode;
|
||||
import io.metersphere.commons.consumer.LoadTestFinishEvent;
|
||||
import io.metersphere.dto.BaseSystemConfigDTO;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import io.metersphere.notice.sender.NoticeModel;
|
||||
|
@ -13,65 +13,30 @@ import io.metersphere.service.SystemParameterService;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
@Component
|
||||
public class PerformanceNoticeTask {
|
||||
public class PerformanceNoticeEvent implements LoadTestFinishEvent {
|
||||
@Resource
|
||||
private SystemParameterService systemParameterService;
|
||||
@Resource
|
||||
private LoadTestReportMapper loadTestReportMapper;
|
||||
@Resource
|
||||
private NoticeSendService noticeSendService;
|
||||
|
||||
private final ExecutorService executorService = Executors.newFixedThreadPool(20);
|
||||
|
||||
private boolean isRunning = false;
|
||||
|
||||
@PreDestroy
|
||||
public void preDestroy() {
|
||||
isRunning = false;
|
||||
}
|
||||
|
||||
public void registerNoticeTask(LoadTestReportWithBLOBs loadTestReport) {
|
||||
isRunning = true;
|
||||
executorService.submit(() -> {
|
||||
LogUtil.info("性能测试定时任务");
|
||||
while (isRunning) {
|
||||
LoadTestReportWithBLOBs loadTestReportFromDatabase = loadTestReportMapper.selectByPrimaryKey(loadTestReport.getId());
|
||||
if (StringUtils.equalsAny(loadTestReportFromDatabase.getStatus(),
|
||||
PerformanceTestStatus.Completed.name(), PerformanceTestStatus.Error.name())) {
|
||||
sendNotice(loadTestReportFromDatabase);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
//查询定时任务是否关闭
|
||||
Thread.sleep(1000 * 10);// 检查 loadtest 的状态
|
||||
} catch (InterruptedException e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void sendNotice(LoadTestReportWithBLOBs loadTestReport) {
|
||||
public void sendNotice(LoadTestReport loadTestReport) {
|
||||
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
|
||||
String url = baseSystemConfigDTO.getUrl() + "/#/performance/report/view/" + loadTestReport.getId();
|
||||
String successContext = "";
|
||||
String failedContext = "";
|
||||
String subject = "";
|
||||
String event = "";
|
||||
if (StringUtils.equals(NoticeConstants.Mode.API, loadTestReport.getTriggerMode())) {
|
||||
if (StringUtils.equals(ReportTriggerMode.API.name(), loadTestReport.getTriggerMode())) {
|
||||
successContext = "性能测试 API任务通知:" + loadTestReport.getName() + "执行成功" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + url;
|
||||
failedContext = "性能测试 API任务通知:" + loadTestReport.getName() + "执行失败" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + url;
|
||||
subject = Translator.get("task_notification_jenkins");
|
||||
}
|
||||
if (StringUtils.equals(NoticeConstants.Mode.SCHEDULE, loadTestReport.getTriggerMode())) {
|
||||
if (StringUtils.equals(ReportTriggerMode.SCHEDULE.name(), loadTestReport.getTriggerMode())) {
|
||||
successContext = "性能测试定时任务通知:" + loadTestReport.getName() + "执行成功" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + url;
|
||||
failedContext = "性能测试定时任务通知:" + loadTestReport.getName() + "执行失败" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + url;
|
||||
subject = Translator.get("task_notification");
|
||||
|
@ -102,4 +67,15 @@ public class PerformanceNoticeTask {
|
|||
.build();
|
||||
noticeSendService.send(loadTestReport.getTriggerMode(), noticeModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LoadTestReport loadTestReport) {
|
||||
if (StringUtils.equals(ReportTriggerMode.API.name(), loadTestReport.getTriggerMode())
|
||||
|| StringUtils.equals(ReportTriggerMode.SCHEDULE.name(), loadTestReport.getTriggerMode())) {
|
||||
if (StringUtils.equalsAny(loadTestReport.getStatus(),
|
||||
PerformanceTestStatus.Completed.name(), PerformanceTestStatus.Error.name())) {
|
||||
sendNotice(loadTestReport);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,7 +21,6 @@ import io.metersphere.i18n.Translator;
|
|||
import io.metersphere.job.sechedule.PerformanceTestJob;
|
||||
import io.metersphere.performance.engine.Engine;
|
||||
import io.metersphere.performance.engine.EngineFactory;
|
||||
import io.metersphere.performance.notice.PerformanceNoticeTask;
|
||||
import io.metersphere.service.FileService;
|
||||
import io.metersphere.service.QuotaService;
|
||||
import io.metersphere.service.ScheduleService;
|
||||
|
@ -75,8 +74,6 @@ public class PerformanceTestService {
|
|||
@Resource
|
||||
private TestCaseService testCaseService;
|
||||
@Resource
|
||||
private PerformanceNoticeTask performanceNoticeTask;
|
||||
@Resource
|
||||
private TestResourcePoolMapper testResourcePoolMapper;
|
||||
|
||||
public List<LoadTestDTO> list(QueryTestPlanRequest request) {
|
||||
|
@ -240,10 +237,6 @@ public class PerformanceTestService {
|
|||
|
||||
startEngine(loadTest, engine, request.getTriggerMode());
|
||||
|
||||
LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(engine.getReportId());
|
||||
if (StringUtils.equals(NoticeConstants.Mode.API, loadTestReport.getTriggerMode()) || StringUtils.equals(NoticeConstants.Mode.SCHEDULE, loadTestReport.getTriggerMode())) {
|
||||
performanceNoticeTask.registerNoticeTask(loadTestReport);
|
||||
}
|
||||
return engine.getReportId();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,12 +22,12 @@ public class ApiKeyFilter extends AnonymousFilter {
|
|||
if (LogUtil.getLogger().isDebugEnabled()) {
|
||||
LogUtil.getLogger().debug("user auth: " + userId);
|
||||
}
|
||||
SecurityUtils.getSubject().login(new MsUserToken(userId, ApiKeySessionHandler.random, "APIKEY"));
|
||||
SecurityUtils.getSubject().login(new MsUserToken(userId, ApiKeySessionHandler.random, "LOCAL"));
|
||||
}
|
||||
} else {
|
||||
if (ApiKeyHandler.isApiKeyCall(WebUtils.toHttp(request))) {
|
||||
String userId = ApiKeyHandler.getUser(WebUtils.toHttp(request));
|
||||
SecurityUtils.getSubject().login(new MsUserToken(userId, ApiKeySessionHandler.random, "APIKEY"));
|
||||
SecurityUtils.getSubject().login(new MsUserToken(userId, ApiKeySessionHandler.random, "LOCAL"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,9 @@ spring.datasource.hikari.pool-name=DatebookHikariCP
|
|||
spring.datasource.hikari.max-lifetime=1800000
|
||||
spring.datasource.hikari.connection-timeout=30000
|
||||
spring.datasource.hikari.connection-test-query=SELECT 1
|
||||
|
||||
#kafka
|
||||
spring.kafka.bootstrap-servers=${kafka.bootstrap-servers}
|
||||
spring.kafka.consumer.group-id=metersphere_group_id
|
||||
# mybatis
|
||||
mybatis.configuration.cache-enabled=true
|
||||
mybatis.configuration.lazy-loading-enabled=false
|
||||
|
|
|
@ -156,11 +156,11 @@
|
|||
<!--等待控制器-->
|
||||
<ms-constant-timer :timer="data" :node="node" v-if="data.type==='ConstantTimer'" @remove="remove" @copyRow="copyRow"/>
|
||||
<!--自定义脚本-->
|
||||
<ms-jsr233-processor v-if="data.type==='JSR223Processor'" @remove="remove" @copyRow="copyRow" :title="$t('api_test.automation.customize_script')" :jsr223-processor="data" :node="node"/>
|
||||
<ms-jsr233-processor :draggable="true" v-if="data.type==='JSR223Processor'" @remove="remove" @copyRow="copyRow" :title="$t('api_test.automation.customize_script')" :jsr223-processor="data" :node="node"/>
|
||||
<!--前置脚本-->
|
||||
<ms-jsr233-processor v-if="data.type==='JSR223PreProcessor'" @remove="remove" @copyRow="copyRow" :title="$t('api_test.definition.request.pre_script')" :jsr223-processor="data" :node="node"/>
|
||||
<ms-jsr233-processor :draggable="true" v-if="data.type==='JSR223PreProcessor'" @remove="remove" @copyRow="copyRow" :title="$t('api_test.definition.request.pre_script')" :jsr223-processor="data" :node="node"/>
|
||||
<!--后置脚本-->
|
||||
<ms-jsr233-processor v-if="data.type==='JSR223PostProcessor'" @remove="remove" @copyRow="copyRow" :title="$t('api_test.definition.request.post_script')" :jsr223-processor="data" :node="node"/>
|
||||
<ms-jsr233-processor :draggable="true" v-if="data.type==='JSR223PostProcessor'" @remove="remove" @copyRow="copyRow" :title="$t('api_test.definition.request.post_script')" :jsr223-processor="data" :node="node"/>
|
||||
<!--断言规则-->
|
||||
<ms-api-assertions :draggable="true" @suggestClick="suggestClick(node)" :response="response" v-if="data.type==='Assertions'" @remove="remove" @copyRow="copyRow" :assertions="data" :node="node"/>
|
||||
<!--提取规则-->
|
||||
|
@ -665,7 +665,7 @@
|
|||
let obj = JSON.parse(JSON.stringify(row));
|
||||
obj.resourceId = getUUID();
|
||||
if (obj.name) {
|
||||
obj.name = obj.name + '_copy';
|
||||
obj.name = obj.name + '_copy';
|
||||
}
|
||||
hashTree.push(obj);
|
||||
this.sort();
|
||||
|
|
|
@ -29,63 +29,63 @@
|
|||
</div>
|
||||
|
||||
<el-collapse-transition>
|
||||
<div v-if="data.active && showCollapse" draggable>
|
||||
<div v-if="data.active && showCollapse" :draggable="draggable">
|
||||
<el-divider></el-divider>
|
||||
<slot></slot>
|
||||
<slot></slot>
|
||||
</div>
|
||||
</el-collapse-transition>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "ApiBaseComponent",
|
||||
data() {
|
||||
return {
|
||||
isShowInput: false
|
||||
export default {
|
||||
name: "ApiBaseComponent",
|
||||
data() {
|
||||
return {
|
||||
isShowInput: false
|
||||
}
|
||||
},
|
||||
props: {
|
||||
draggable: Boolean,
|
||||
data: {
|
||||
type: Object,
|
||||
default() {
|
||||
return {}
|
||||
},
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
default() {
|
||||
return "#B8741A"
|
||||
}
|
||||
},
|
||||
props: {
|
||||
draggable: Boolean,
|
||||
data: {
|
||||
type: Object,
|
||||
default() {
|
||||
return {}
|
||||
},
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
default() {
|
||||
return "#B8741A"
|
||||
}
|
||||
},
|
||||
backgroundColor: {
|
||||
type: String,
|
||||
default() {
|
||||
return "#F9F1EA"
|
||||
}
|
||||
},
|
||||
showCollapse: {
|
||||
type: Boolean,
|
||||
default() {
|
||||
return true
|
||||
}
|
||||
},
|
||||
title: String
|
||||
},
|
||||
methods: {
|
||||
active() {
|
||||
this.$set(this.data, 'active', !this.data.active);
|
||||
this.$emit('active');
|
||||
},
|
||||
copyRow() {
|
||||
this.$emit('copy');
|
||||
},
|
||||
remove() {
|
||||
this.$emit('remove');
|
||||
backgroundColor: {
|
||||
type: String,
|
||||
default() {
|
||||
return "#F9F1EA"
|
||||
}
|
||||
},
|
||||
showCollapse: {
|
||||
type: Boolean,
|
||||
default() {
|
||||
return true
|
||||
}
|
||||
},
|
||||
title: String
|
||||
},
|
||||
methods: {
|
||||
active() {
|
||||
this.$set(this.data, 'active', !this.data.active);
|
||||
this.$emit('active');
|
||||
},
|
||||
copyRow() {
|
||||
this.$emit('copy');
|
||||
},
|
||||
remove() {
|
||||
this.$emit('remove');
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
@copy="copyRow"
|
||||
@remove="remove"
|
||||
:data="extract"
|
||||
:draggable="draggable"
|
||||
color="#015478"
|
||||
background-color="#E6EEF2"
|
||||
:title="$t('api_test.definition.request.extract_param')">
|
||||
|
@ -46,6 +47,7 @@
|
|||
import MsApiJsonpathSuggest from "../assertion/ApiJsonpathSuggest";
|
||||
import {ExtractJSONPath} from "../../../test/model/ScenarioModel";
|
||||
import ApiBaseComponent from "../../../automation/scenario/common/ApiBaseComponent";
|
||||
|
||||
export default {
|
||||
name: "MsApiExtract",
|
||||
components: {
|
||||
|
@ -66,6 +68,10 @@
|
|||
isReadOnly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
draggable: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
@ -139,15 +145,18 @@
|
|||
font-size: 13px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.extract-item {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.extract-add {
|
||||
padding: 10px;
|
||||
border: #DCDFE6 solid 1px;
|
||||
margin: 5px 0;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
/deep/ .el-card__body {
|
||||
padding: 15px;
|
||||
}
|
||||
|
|
|
@ -7,13 +7,24 @@
|
|||
:destroy-on-close="true"
|
||||
show-close
|
||||
@closed="handleClose" v-loading="loading">
|
||||
<el-form :model="ruleForm" label-position="right" label-width="80px" size="small" :rules="rule">
|
||||
<el-form-item :label="$t('test_track.module.module')" prop="apiScenarioModuleId">
|
||||
<el-select size="small" style="width: 80%" v-model="apiScenarioModuleId">
|
||||
<el-option v-for="item in moduleOptions" :key="item.id" :label="item.path" :value="item.id"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<ms-node-tree
|
||||
v-loading="result.loading"
|
||||
:tree-nodes="data"
|
||||
@add="add"
|
||||
:type="'edit'"
|
||||
@edit="edit"
|
||||
@drag="drag"
|
||||
@remove="remove"
|
||||
@nodeSelectEvent="nodeChange"
|
||||
ref="nodeTree">
|
||||
|
||||
<template v-slot:header>
|
||||
<el-input :placeholder="$t('test_track.module.search')" v-model="condition.filterText" size="small">
|
||||
</el-input>
|
||||
</template>
|
||||
|
||||
</ms-node-tree>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<ms-dialog-footer
|
||||
@cancel="oneClickOperationVisible = false"
|
||||
|
@ -28,31 +39,32 @@
|
|||
import MsApiReportStatus from "../report/ApiReportStatus";
|
||||
import MsApiReportDialog from "./ApiReportDialog";
|
||||
import {getUUID, getCurrentProjectID} from "@/common/js/utils";
|
||||
import SelectMenu from "../../track/common/SelectMenu";
|
||||
import MsNodeTree from "../../track/common/NodeTree";
|
||||
import {buildNodePath} from "../definition/model/NodeTree";
|
||||
|
||||
|
||||
export default {
|
||||
name: "MsUpgrade",
|
||||
components: {
|
||||
MsApiReportDialog, MsApiReportStatus, MsApiScenarioConfig, MsDialogFooter
|
||||
MsApiReportDialog, MsApiReportStatus, MsApiScenarioConfig,
|
||||
MsDialogFooter,
|
||||
MsNodeTree,
|
||||
SelectMenu,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
oneClickOperationVisible: false,
|
||||
apiScenarioModuleId: "",
|
||||
moduleOptions: [],
|
||||
ruleForm: {},
|
||||
loading: false,
|
||||
rule: {
|
||||
apiScenarioModuleId: [
|
||||
{required: true, message: this.$t('test_track.module.module'), trigger: 'blur'},
|
||||
],
|
||||
}
|
||||
result: {},
|
||||
data: [],
|
||||
condition: {
|
||||
filterText: "",
|
||||
trashEnable: false
|
||||
},
|
||||
currentModule: undefined,
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.initModule();
|
||||
},
|
||||
props: {
|
||||
selectIds: {
|
||||
type: Set
|
||||
|
@ -64,8 +76,14 @@
|
|||
type: Set
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'condition.filterText'(val) {
|
||||
this.$refs.nodeTree.filter(val);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
openOneClickOperation() {
|
||||
this.initModule();
|
||||
this.oneClickOperationVisible = true;
|
||||
},
|
||||
getPath(id) {
|
||||
|
@ -75,9 +93,13 @@
|
|||
return path[0].path;
|
||||
},
|
||||
confirm() {
|
||||
if (!this.currentModule) {
|
||||
this.$warning("请选择一个模块");
|
||||
return;
|
||||
}
|
||||
this.loading = true;
|
||||
let arr = Array.from(this.selectIds);
|
||||
let obj = {testIds: arr, projectId: getCurrentProjectID(), modulePath: this.getPath(this.apiScenarioModuleId), moduleId: this.apiScenarioModuleId};
|
||||
let obj = {testIds: arr, projectId: getCurrentProjectID(), modulePath: this.getPath(this.currentModule.id), moduleId: this.currentModule.id};
|
||||
this.$post("/api/historicalDataUpgrade", obj, response => {
|
||||
this.loading = false;
|
||||
this.$success(this.$t('organization.integration.successful_operation'));
|
||||
|
@ -100,6 +122,69 @@
|
|||
handleClose() {
|
||||
this.ruleForm = {}
|
||||
},
|
||||
edit(param) {
|
||||
param.projectId = getCurrentProjectID();
|
||||
param.protocol = this.condition.protocol;
|
||||
this.$post("/api/automation/module/edit", param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.initModule();
|
||||
this.refresh();
|
||||
}, (error) => {
|
||||
this.initModule();
|
||||
});
|
||||
},
|
||||
add(param) {
|
||||
param.projectId = getCurrentProjectID();
|
||||
param.protocol = this.condition.protocol;
|
||||
this.$post("/api/automation/module/add", param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.initModule();
|
||||
}, (error) => {
|
||||
this.initModule();
|
||||
});
|
||||
},
|
||||
remove(nodeIds) {
|
||||
this.$post("/api/automation/module/delete", nodeIds, () => {
|
||||
this.initModule();
|
||||
this.refresh();
|
||||
}, (error) => {
|
||||
this.initModule();
|
||||
});
|
||||
},
|
||||
drag(param, list) {
|
||||
this.$post("/api/automation/module/drag", param, () => {
|
||||
this.$post("/api/automation/module/pos", list, () => {
|
||||
this.initModule();
|
||||
});
|
||||
}, (error) => {
|
||||
this.initModule();
|
||||
});
|
||||
},
|
||||
nodeChange(node, nodeIds, pNodes) {
|
||||
this.currentModule = node.data;
|
||||
this.condition.trashEnable = false;
|
||||
if (node.data.id === 'root') {
|
||||
this.$emit("nodeSelectEvent", node, [], pNodes);
|
||||
} else {
|
||||
this.$emit("nodeSelectEvent", node, nodeIds, pNodes);
|
||||
}
|
||||
},
|
||||
saveAsEdit(data) {
|
||||
this.$emit('saveAsEdit', data);
|
||||
},
|
||||
refresh() {
|
||||
this.$emit("refreshTable");
|
||||
},
|
||||
addScenario() {
|
||||
if (!getCurrentProjectID()) {
|
||||
this.$warning(this.$t('commons.check_project_tip'));
|
||||
return;
|
||||
}
|
||||
this.$refs.basisScenario.open(this.currentModule);
|
||||
},
|
||||
enableTrash() {
|
||||
this.condition.trashEnable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue