refactor(测试计划): 计划关联关系更新方法事务调整
This commit is contained in:
parent
9aa325e512
commit
ae675915fe
|
@ -7,7 +7,6 @@ import io.metersphere.base.mapper.ApiScenarioMapper;
|
|||
import io.metersphere.base.mapper.TestPlanApiCaseMapper;
|
||||
import io.metersphere.base.mapper.TestPlanApiScenarioMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
@ -22,18 +21,18 @@ public class TestPlanResourceService {
|
|||
private ApiScenarioMapper apiScenarioMapper;
|
||||
|
||||
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public void updatePlanScenario(TestPlanApiScenario testPlanApiScenario){
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updatePlanScenario(TestPlanApiScenario testPlanApiScenario) {
|
||||
testPlanApiScenarioMapper.updateByPrimaryKeySelective(testPlanApiScenario);
|
||||
}
|
||||
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public void updatePlanCase(TestPlanApiCase testPlanApiCase){
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updatePlanCase(TestPlanApiCase testPlanApiCase) {
|
||||
tstPlanApiCaseMapper.updateByPrimaryKeySelective(testPlanApiCase);
|
||||
}
|
||||
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public void updateScenario(ApiScenario apiScenario){
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateScenario(ApiScenario apiScenario) {
|
||||
apiScenarioMapper.updateByPrimaryKey(apiScenario);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,17 +5,25 @@ import io.metersphere.api.jmeter.FixedCapacityUtils;
|
|||
import io.metersphere.cache.JMeterEngineCache;
|
||||
import io.metersphere.commons.constants.APITestStatus;
|
||||
import io.metersphere.commons.utils.BeanUtils;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.dto.JmeterRunRequestDTO;
|
||||
import io.metersphere.dto.ResultDTO;
|
||||
import io.metersphere.utils.LoggerUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
|
||||
@Service
|
||||
public class RemakeReportService {
|
||||
@Resource
|
||||
@Lazy
|
||||
private ApiExecutionQueueService apiExecutionQueueService;
|
||||
@Resource
|
||||
@Lazy
|
||||
private TestResultService testResultService;
|
||||
|
||||
public void testEnded(JmeterRunRequestDTO request, String errorMsg) {
|
||||
try {
|
||||
ResultDTO dto = new ResultDTO();
|
||||
|
@ -37,15 +45,15 @@ public class RemakeReportService {
|
|||
String consoleMsg = FixedCapacityUtils.getJmeterLogger(dto.getReportId(), true);
|
||||
dto.setConsole(consoleMsg + "\n" + errorMsg);
|
||||
// 整体执行结束更新资源状态
|
||||
CommonBeanFactory.getBean(TestResultService.class).testEnded(dto);
|
||||
testResultService.testEnded(dto);
|
||||
|
||||
if (StringUtils.isNotEmpty(dto.getQueueId())) {
|
||||
CommonBeanFactory.getBean(ApiExecutionQueueService.class).queueNext(dto);
|
||||
apiExecutionQueueService.queueNext(dto);
|
||||
}
|
||||
// 更新测试计划报告
|
||||
if (StringUtils.isNotEmpty(dto.getTestPlanReportId())) {
|
||||
LoggerUtil.info("Check Processing Test Plan report status:" + dto.getQueueId() + "," + dto.getTestId(), dto.getReportId());
|
||||
CommonBeanFactory.getBean(ApiExecutionQueueService.class).testPlanReportTestEnded(dto.getTestPlanReportId());
|
||||
apiExecutionQueueService.testPlanReportTestEnded(dto.getTestPlanReportId());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LoggerUtil.error("回归报告异常", request.getReportId(), e);
|
||||
|
|
Loading…
Reference in New Issue