fix(测试跟踪): 测试计划关联用例后更新测试计划状态
This commit is contained in:
parent
f49df9f353
commit
cfbe544131
|
@ -15,7 +15,7 @@ import java.util.List;
|
||||||
@RestController
|
@RestController
|
||||||
public class TestPlanController {
|
public class TestPlanController {
|
||||||
@Resource
|
@Resource
|
||||||
private RemoteTestPlanService testPlanService;
|
private RemoteTestPlanService remoteTestPlanService;
|
||||||
|
|
||||||
public static final List<String> EXCLUDE_APIS = new ArrayList<>(2) {{
|
public static final List<String> EXCLUDE_APIS = new ArrayList<>(2) {{
|
||||||
add("test/plan/api/case");
|
add("test/plan/api/case");
|
||||||
|
@ -25,13 +25,13 @@ public class TestPlanController {
|
||||||
@GetMapping("/**")
|
@GetMapping("/**")
|
||||||
public List getStageOption(HttpServletRequest request) {
|
public List getStageOption(HttpServletRequest request) {
|
||||||
excludeApi(request.getRequestURI());
|
excludeApi(request.getRequestURI());
|
||||||
return testPlanService.get(request.getRequestURI());
|
return remoteTestPlanService.get(request.getRequestURI());
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/**")
|
@PostMapping("/**")
|
||||||
public List getPage(HttpServletRequest request, @RequestBody QueryTestPlanRequest params) {
|
public List getPage(HttpServletRequest request, @RequestBody QueryTestPlanRequest params) {
|
||||||
excludeApi(request.getRequestURI());
|
excludeApi(request.getRequestURI());
|
||||||
return testPlanService.post(request.getRequestURI(), params);
|
return remoteTestPlanService.post(request.getRequestURI(), params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,7 +16,6 @@ import io.metersphere.api.dto.plan.TestPlanApiCaseBatchRequest;
|
||||||
import io.metersphere.api.dto.plan.TestPlanApiCaseInfoDTO;
|
import io.metersphere.api.dto.plan.TestPlanApiCaseInfoDTO;
|
||||||
import io.metersphere.api.exec.api.ApiCaseExecuteService;
|
import io.metersphere.api.exec.api.ApiCaseExecuteService;
|
||||||
import io.metersphere.api.exec.api.ApiExecuteService;
|
import io.metersphere.api.exec.api.ApiExecuteService;
|
||||||
import io.metersphere.api.exec.scenario.ApiScenarioEnvService;
|
|
||||||
import io.metersphere.base.domain.*;
|
import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.mapper.ApiDefinitionExecResultMapper;
|
import io.metersphere.base.mapper.ApiDefinitionExecResultMapper;
|
||||||
import io.metersphere.base.mapper.ApiTestCaseMapper;
|
import io.metersphere.base.mapper.ApiTestCaseMapper;
|
||||||
|
@ -40,6 +39,7 @@ import io.metersphere.service.definition.ApiDefinitionExecResultService;
|
||||||
import io.metersphere.service.definition.ApiDefinitionService;
|
import io.metersphere.service.definition.ApiDefinitionService;
|
||||||
import io.metersphere.service.definition.ApiModuleService;
|
import io.metersphere.service.definition.ApiModuleService;
|
||||||
import io.metersphere.service.definition.ApiTestCaseService;
|
import io.metersphere.service.definition.ApiTestCaseService;
|
||||||
|
import io.metersphere.service.plan.remote.TestPlanService;
|
||||||
import org.apache.commons.collections.MapUtils;
|
import org.apache.commons.collections.MapUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
|
@ -94,9 +94,6 @@ public class TestPlanApiCaseService {
|
||||||
ExtApiDefinitionExecResultMapper extApiDefinitionExecResultMapper;
|
ExtApiDefinitionExecResultMapper extApiDefinitionExecResultMapper;
|
||||||
@Lazy
|
@Lazy
|
||||||
@Resource
|
@Resource
|
||||||
private ApiScenarioEnvService apiScenarioEnvService;
|
|
||||||
@Lazy
|
|
||||||
@Resource
|
|
||||||
private ApiModuleService apiModuleService;
|
private ApiModuleService apiModuleService;
|
||||||
@Resource
|
@Resource
|
||||||
BaseProjectService baseProjectService;
|
BaseProjectService baseProjectService;
|
||||||
|
@ -104,6 +101,8 @@ public class TestPlanApiCaseService {
|
||||||
private ApiDefinitionExecResultMapper apiDefinitionExecResultMapper;
|
private ApiDefinitionExecResultMapper apiDefinitionExecResultMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ApiExecuteService apiExecuteService;
|
private ApiExecuteService apiExecuteService;
|
||||||
|
@Resource
|
||||||
|
private TestPlanService testPlanService;
|
||||||
|
|
||||||
public TestPlanApiCase getInfo(String caseId, String testPlanId) {
|
public TestPlanApiCase getInfo(String caseId, String testPlanId) {
|
||||||
TestPlanApiCaseExample example = new TestPlanApiCaseExample();
|
TestPlanApiCaseExample example = new TestPlanApiCaseExample();
|
||||||
|
@ -586,15 +585,7 @@ public class TestPlanApiCaseService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo check
|
testPlanService.statusReset(request.getPlanId());
|
||||||
// TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getPlanId());
|
|
||||||
// if (StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Prepare.name())
|
|
||||||
// || StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Completed.name())) {
|
|
||||||
// testPlan.setStatus(TestPlanStatus.Underway.name());
|
|
||||||
// testPlan.setActualStartTime(System.currentTimeMillis()); // 将状态更新为进行中时,开始时间也要更新
|
|
||||||
// testPlan.setActualEndTime(null);
|
|
||||||
// testPlanMapper.updateByPrimaryKey(testPlan);
|
|
||||||
// }
|
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,8 +593,8 @@ public class TestPlanApiCaseService {
|
||||||
TestPlanApiCase t = new TestPlanApiCase();
|
TestPlanApiCase t = new TestPlanApiCase();
|
||||||
Long nextApiOrder = ServiceUtils.getNextOrder(planId, extTestPlanApiCaseMapper::getLastOrder);
|
Long nextApiOrder = ServiceUtils.getNextOrder(planId, extTestPlanApiCaseMapper::getLastOrder);
|
||||||
for (String id : ids) {
|
for (String id : ids) {
|
||||||
ApiTestCaseWithBLOBs apitest = apiTestCaseMapper.selectByPrimaryKey(id);
|
ApiTestCaseWithBLOBs apiTest = apiTestCaseMapper.selectByPrimaryKey(id);
|
||||||
if (null != apitest) {
|
if (null != apiTest) {
|
||||||
t.setId(UUID.randomUUID().toString());
|
t.setId(UUID.randomUUID().toString());
|
||||||
t.setTestPlanId(planId);
|
t.setTestPlanId(planId);
|
||||||
t.setApiCaseId(id);
|
t.setApiCaseId(id);
|
||||||
|
|
|
@ -11,10 +11,8 @@ import io.metersphere.api.dto.automation.*;
|
||||||
import io.metersphere.api.dto.plan.*;
|
import io.metersphere.api.dto.plan.*;
|
||||||
import io.metersphere.api.exec.scenario.ApiScenarioEnvService;
|
import io.metersphere.api.exec.scenario.ApiScenarioEnvService;
|
||||||
import io.metersphere.base.domain.*;
|
import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.mapper.ApiDefinitionExecResultMapper;
|
|
||||||
import io.metersphere.base.mapper.ApiScenarioMapper;
|
import io.metersphere.base.mapper.ApiScenarioMapper;
|
||||||
import io.metersphere.base.mapper.ApiTestEnvironmentMapper;
|
import io.metersphere.base.mapper.ApiTestEnvironmentMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
|
|
||||||
import io.metersphere.base.mapper.ext.ExtApiScenarioModuleMapper;
|
import io.metersphere.base.mapper.ext.ExtApiScenarioModuleMapper;
|
||||||
import io.metersphere.base.mapper.plan.TestPlanApiScenarioMapper;
|
import io.metersphere.base.mapper.plan.TestPlanApiScenarioMapper;
|
||||||
import io.metersphere.base.mapper.plan.ext.ExtTestPlanApiCaseMapper;
|
import io.metersphere.base.mapper.plan.ext.ExtTestPlanApiCaseMapper;
|
||||||
|
@ -40,6 +38,7 @@ import io.metersphere.service.BaseProjectService;
|
||||||
import io.metersphere.service.BaseUserService;
|
import io.metersphere.service.BaseUserService;
|
||||||
import io.metersphere.service.ServiceUtils;
|
import io.metersphere.service.ServiceUtils;
|
||||||
import io.metersphere.service.definition.ApiDefinitionExecResultService;
|
import io.metersphere.service.definition.ApiDefinitionExecResultService;
|
||||||
|
import io.metersphere.service.plan.remote.TestPlanService;
|
||||||
import io.metersphere.service.scenario.ApiScenarioModuleService;
|
import io.metersphere.service.scenario.ApiScenarioModuleService;
|
||||||
import io.metersphere.service.scenario.ApiScenarioReportService;
|
import io.metersphere.service.scenario.ApiScenarioReportService;
|
||||||
import io.metersphere.service.scenario.ApiScenarioService;
|
import io.metersphere.service.scenario.ApiScenarioService;
|
||||||
|
@ -89,10 +88,6 @@ public class TestPlanScenarioCaseService {
|
||||||
@Resource
|
@Resource
|
||||||
private TestPlanApiCaseService testPlanApiCaseService;
|
private TestPlanApiCaseService testPlanApiCaseService;
|
||||||
@Resource
|
@Resource
|
||||||
private ExtApiDefinitionExecResultMapper extApiDefinitionExecResultMapper;
|
|
||||||
@Resource
|
|
||||||
private ApiDefinitionExecResultMapper apiDefinitionExecResultMapper;
|
|
||||||
@Resource
|
|
||||||
private ApiScenarioEnvService apiScenarioEnvService;
|
private ApiScenarioEnvService apiScenarioEnvService;
|
||||||
@Resource
|
@Resource
|
||||||
private ApiDefinitionExecResultService apiDefinitionExecResultService;
|
private ApiDefinitionExecResultService apiDefinitionExecResultService;
|
||||||
|
@ -105,6 +100,8 @@ public class TestPlanScenarioCaseService {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Resource
|
@Resource
|
||||||
private ApiScenarioModuleService apiScenarioModuleService;
|
private ApiScenarioModuleService apiScenarioModuleService;
|
||||||
|
@Resource
|
||||||
|
private TestPlanService testPlanService;
|
||||||
|
|
||||||
public List<ApiScenarioDTO> list(TestPlanScenarioRequest request) {
|
public List<ApiScenarioDTO> list(TestPlanScenarioRequest request) {
|
||||||
request.setProjectId(null);
|
request.setProjectId(null);
|
||||||
|
@ -221,6 +218,7 @@ public class TestPlanScenarioCaseService {
|
||||||
nextOrder += ServiceUtils.ORDER_STEP;
|
nextOrder += ServiceUtils.ORDER_STEP;
|
||||||
testPlanApiScenarioMapper.insert(testPlanApiScenario);
|
testPlanApiScenarioMapper.insert(testPlanApiScenario);
|
||||||
}
|
}
|
||||||
|
testPlanService.statusReset(request.getPlanId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int delete(String id) {
|
public int delete(String id) {
|
||||||
|
@ -465,10 +463,9 @@ public class TestPlanScenarioCaseService {
|
||||||
TestPlanApiScenario scenario = testPlanApiScenarioMapper.selectByPrimaryKey(id);
|
TestPlanApiScenario scenario = testPlanApiScenarioMapper.selectByPrimaryKey(id);
|
||||||
if (scenario != null) {
|
if (scenario != null) {
|
||||||
ApiScenarioWithBLOBs testCase = apiScenarioMapper.selectByPrimaryKey(scenario.getApiScenarioId());
|
ApiScenarioWithBLOBs testCase = apiScenarioMapper.selectByPrimaryKey(scenario.getApiScenarioId());
|
||||||
// todo check
|
TestPlan testPlan = testPlanService.get(scenario.getTestPlanId());
|
||||||
// TestPlan testPlan = testPlanMapper.selectByPrimaryKey(scenario.getTestPlanId());
|
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), testPlan.getProjectId(), testCase.getName(), scenario.getCreateUser(), new LinkedList<>());
|
||||||
// OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), testPlan.getProjectId(), testCase.getName(), scenario.getCreateUser(), new LinkedList<>());
|
return JSON.toJSONString(details);
|
||||||
// return JSON.toJSONString(details);
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -686,6 +683,7 @@ public class TestPlanScenarioCaseService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
testPlanService.statusReset(planId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyPlan(String sourcePlanId, String targetPlanId) {
|
public void copyPlan(String sourcePlanId, String targetPlanId) {
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package io.metersphere.service.plan.remote;
|
||||||
|
|
||||||
|
import io.metersphere.base.domain.TestPlan;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TestPlanService extends TrackService {
|
||||||
|
|
||||||
|
private static final String BASE_UEL = "/test/plan";
|
||||||
|
|
||||||
|
public TestPlan get(String id) {
|
||||||
|
return microService.getForData(serviceName, BASE_UEL + "/get/" + id, TestPlan.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void statusReset(String id) {
|
||||||
|
microService.getForData(serviceName, BASE_UEL + "/status/reset/" + id);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package io.metersphere.service.plan.remote;
|
||||||
|
|
||||||
|
import io.metersphere.commons.constants.MicroServiceName;
|
||||||
|
import io.metersphere.service.RemoteService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public class TrackService extends RemoteService {
|
||||||
|
|
||||||
|
public TrackService() {
|
||||||
|
super(MicroServiceName.TEST_TRACK);
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,6 +22,7 @@ import io.metersphere.plan.request.LoadCaseReportBatchRequest;
|
||||||
import io.metersphere.plan.request.LoadCaseReportRequest;
|
import io.metersphere.plan.request.LoadCaseReportRequest;
|
||||||
import io.metersphere.plan.request.LoadCaseRequest;
|
import io.metersphere.plan.request.LoadCaseRequest;
|
||||||
import io.metersphere.plan.request.RunBatchTestPlanRequest;
|
import io.metersphere.plan.request.RunBatchTestPlanRequest;
|
||||||
|
import io.metersphere.plan.service.remote.TestPlanService;
|
||||||
import io.metersphere.request.*;
|
import io.metersphere.request.*;
|
||||||
import io.metersphere.service.*;
|
import io.metersphere.service.*;
|
||||||
import io.metersphere.xpack.resourcepool.service.ValidQuotaResourcePoolService;
|
import io.metersphere.xpack.resourcepool.service.ValidQuotaResourcePoolService;
|
||||||
|
@ -41,8 +42,6 @@ import java.util.stream.Collectors;
|
||||||
@Service
|
@Service
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public class TestPlanLoadCaseService {
|
public class TestPlanLoadCaseService {
|
||||||
// @Resource
|
|
||||||
// TestPlanMapper testPlanMapper;
|
|
||||||
@Resource
|
@Resource
|
||||||
private TestPlanLoadCaseMapper testPlanLoadCaseMapper;
|
private TestPlanLoadCaseMapper testPlanLoadCaseMapper;
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -57,8 +56,8 @@ public class TestPlanLoadCaseService {
|
||||||
private ExtLoadTestReportMapper extLoadTestReportMapper;
|
private ExtLoadTestReportMapper extLoadTestReportMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private LoadTestMapper loadTestMapper;
|
private LoadTestMapper loadTestMapper;
|
||||||
// @Resource
|
@Resource
|
||||||
// private TestPlanService testPlanService;
|
private TestPlanService testPlanService;
|
||||||
@Resource
|
@Resource
|
||||||
private MetricQueryService metricQueryService;
|
private MetricQueryService metricQueryService;
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -135,14 +134,8 @@ public class TestPlanLoadCaseService {
|
||||||
testPlanLoadCaseMapper.insert(t);
|
testPlanLoadCaseMapper.insert(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getTestPlanId());
|
testPlanService.statusReset(request.getTestPlanId());
|
||||||
// if (StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Prepare.name())
|
|
||||||
// || StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Completed.name())) {
|
|
||||||
// testPlan.setStatus(TestPlanStatus.Underway.name());
|
|
||||||
// testPlan.setActualStartTime(System.currentTimeMillis()); // 将状态更新为进行中时,开始时间也要更新
|
|
||||||
// testPlan.setActualEndTime(null);
|
|
||||||
// testPlanMapper.updateByPrimaryKey(testPlan);
|
|
||||||
// }
|
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
if (sqlSession != null && sqlSessionFactory != null) {
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
@ -281,13 +274,12 @@ public class TestPlanLoadCaseService {
|
||||||
public String getLogDetails(String id) {
|
public String getLogDetails(String id) {
|
||||||
TestPlanLoadCase bloBs = testPlanLoadCaseMapper.selectByPrimaryKey(id);
|
TestPlanLoadCase bloBs = testPlanLoadCaseMapper.selectByPrimaryKey(id);
|
||||||
if (bloBs != null) {
|
if (bloBs != null) {
|
||||||
// todo
|
TestPlan testPlan = testPlanService.get(bloBs.getTestPlanId());
|
||||||
// TestPlan testPlan = testPlanMapper.selectByPrimaryKey(bloBs.getTestPlanId());
|
LoadTest test = loadTestMapper.selectByPrimaryKey(bloBs.getLoadCaseId());
|
||||||
// LoadTest test = loadTestMapper.selectByPrimaryKey(bloBs.getLoadCaseId());
|
if (test != null && testPlan != null) {
|
||||||
// if (test != null && testPlan != null) {
|
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), testPlan.getProjectId(), test.getName(), bloBs.getCreateUser(), new LinkedList<>());
|
||||||
// OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), testPlan.getProjectId(), test.getName(), bloBs.getCreateUser(), new LinkedList<>());
|
return JSON.toJSONString(details);
|
||||||
// return JSON.toJSONString(details);
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -297,14 +289,13 @@ public class TestPlanLoadCaseService {
|
||||||
caseExample.createCriteria().andIdIn(ids);
|
caseExample.createCriteria().andIdIn(ids);
|
||||||
List<TestPlanLoadCase> cases = testPlanLoadCaseMapper.selectByExample(caseExample);
|
List<TestPlanLoadCase> cases = testPlanLoadCaseMapper.selectByExample(caseExample);
|
||||||
if (CollectionUtils.isNotEmpty(cases)) {
|
if (CollectionUtils.isNotEmpty(cases)) {
|
||||||
// todo
|
LoadTestExample example = new LoadTestExample();
|
||||||
// LoadTestExample example = new LoadTestExample();
|
example.createCriteria().andIdIn(cases.stream().map(TestPlanLoadCase::getLoadCaseId).collect(Collectors.toList()));
|
||||||
// example.createCriteria().andIdIn(cases.stream().map(TestPlanLoadCase::getLoadCaseId).collect(Collectors.toList()));
|
List<LoadTest> loadTests = loadTestMapper.selectByExample(example);
|
||||||
// List<LoadTest> loadTests = loadTestMapper.selectByExample(example);
|
List<String> names = loadTests.stream().map(LoadTest::getName).collect(Collectors.toList());
|
||||||
// List<String> names = loadTests.stream().map(LoadTest::getName).collect(Collectors.toList());
|
TestPlan testPlan = testPlanService.get(cases.get(0).getTestPlanId());
|
||||||
// TestPlan testPlan = testPlanMapper.selectByPrimaryKey(cases.get(0).getTestPlanId());
|
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(ids), testPlan.getProjectId(), String.join(",", names), testPlan.getCreator(), new LinkedList<>());
|
||||||
// OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(ids), testPlan.getProjectId(), String.join(",", names), testPlan.getCreator(), new LinkedList<>());
|
return JSON.toJSONString(details);
|
||||||
// return JSON.toJSONString(details);
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -318,11 +309,10 @@ public class TestPlanLoadCaseService {
|
||||||
example.createCriteria().andIdIn(cases.stream().map(TestPlanLoadCase::getLoadCaseId).collect(Collectors.toList()));
|
example.createCriteria().andIdIn(cases.stream().map(TestPlanLoadCase::getLoadCaseId).collect(Collectors.toList()));
|
||||||
List<LoadTest> loadTests = loadTestMapper.selectByExample(example);
|
List<LoadTest> loadTests = loadTestMapper.selectByExample(example);
|
||||||
if (CollectionUtils.isNotEmpty(loadTests)) {
|
if (CollectionUtils.isNotEmpty(loadTests)) {
|
||||||
// todo
|
List<String> names = loadTests.stream().map(LoadTest::getName).collect(Collectors.toList());
|
||||||
// List<String> names = loadTests.stream().map(LoadTest::getName).collect(Collectors.toList());
|
TestPlan testPlan = testPlanService.get(cases.get(0).getTestPlanId());
|
||||||
// TestPlan testPlan = testPlanMapper.selectByPrimaryKey(cases.get(0).getTestPlanId());
|
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(ids), testPlan.getProjectId(), String.join(",", names), testPlan.getCreator(), new LinkedList<>());
|
||||||
// OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(ids), testPlan.getProjectId(), String.join(",", names), testPlan.getCreator(), new LinkedList<>());
|
return JSON.toJSONString(details);
|
||||||
// return JSON.toJSONString(details);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package io.metersphere.plan.service.remote;
|
||||||
|
|
||||||
|
import io.metersphere.base.domain.TestPlan;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TestPlanService extends TrackService {
|
||||||
|
|
||||||
|
private static final String BASE_UEL = "/test/plan";
|
||||||
|
|
||||||
|
public TestPlan get(String id) {
|
||||||
|
return microService.getForData(serviceName, BASE_UEL + "/get/" + id, TestPlan.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void statusReset(String id) {
|
||||||
|
microService.getForData(serviceName, BASE_UEL + "/status/reset/" + id);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package io.metersphere.plan.service.remote;
|
||||||
|
|
||||||
|
import io.metersphere.commons.constants.MicroServiceName;
|
||||||
|
import io.metersphere.service.RemoteService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public class TrackService extends RemoteService {
|
||||||
|
|
||||||
|
public TrackService() {
|
||||||
|
super(MicroServiceName.TEST_TRACK);
|
||||||
|
}
|
||||||
|
}
|
|
@ -348,4 +348,8 @@ public class TestPlanController {
|
||||||
return testPlanRerunService.rerun(request);
|
return testPlanRerunService.rerun(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/status/reset/{planId}")
|
||||||
|
public void resetStatus(@PathVariable String planId) {
|
||||||
|
testPlanService.resetStatus(planId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -281,12 +281,11 @@ public class TestPlanService {
|
||||||
testPlan.setActualStartTime(System.currentTimeMillis());
|
testPlan.setActualStartTime(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
int i;
|
|
||||||
if (testPlan.getName() == null) {// 若是点击该测试计划,则仅更新了updateTime,其它字段全为null,使用updateByPrimaryKeySelective
|
if (testPlan.getName() == null) {// 若是点击该测试计划,则仅更新了updateTime,其它字段全为null,使用updateByPrimaryKeySelective
|
||||||
i = testPlanMapper.updateByPrimaryKeySelective(testPlan);
|
testPlanMapper.updateByPrimaryKeySelective(testPlan);
|
||||||
} else { // 有修改字段的调用,为保证将某些时间置null的情况,使用updateByPrimaryKey
|
} else { // 有修改字段的调用,为保证将某些时间置null的情况,使用updateByPrimaryKey
|
||||||
baseScheduleService.updateNameByResourceID(testPlan.getId(), testPlan.getName());// 同步更新该测试的定时任务的name
|
baseScheduleService.updateNameByResourceID(testPlan.getId(), testPlan.getName());// 同步更新该测试的定时任务的name
|
||||||
i = testPlanMapper.updateByPrimaryKeyWithBLOBs(testPlan); // 更新
|
testPlanMapper.updateByPrimaryKeyWithBLOBs(testPlan); // 更新
|
||||||
}
|
}
|
||||||
return testPlanMapper.selectByPrimaryKey(testPlan.getId());
|
return testPlanMapper.selectByPrimaryKey(testPlan.getId());
|
||||||
}
|
}
|
||||||
|
@ -329,7 +328,7 @@ public class TestPlanService {
|
||||||
|
|
||||||
public void calcTestPlanRate(List<TestPlanDTOWithMetric> testPlans) {
|
public void calcTestPlanRate(List<TestPlanDTOWithMetric> testPlans) {
|
||||||
// 速度太慢 todo
|
// 速度太慢 todo
|
||||||
testPlans.forEach(testPlan -> calcTestPlanRate(testPlan));
|
testPlans.forEach(this::calcTestPlanRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void calcTestPlanRate(TestPlanDTOWithMetric testPlan) {
|
public void calcTestPlanRate(TestPlanDTOWithMetric testPlan) {
|
||||||
|
@ -579,13 +578,7 @@ public class TestPlanService {
|
||||||
|
|
||||||
caseTestRelevance(request, testCaseIds);
|
caseTestRelevance(request, testCaseIds);
|
||||||
|
|
||||||
if (StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Prepare.name())
|
resetStatus(testPlan.getId());
|
||||||
|| StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Completed.name())) {
|
|
||||||
testPlan.setStatus(TestPlanStatus.Underway.name());
|
|
||||||
testPlan.setActualStartTime(System.currentTimeMillis()); // 将状态更新为进行中时,开始时间也要更新
|
|
||||||
testPlan.setActualEndTime(null);
|
|
||||||
testPlanMapper.updateByPrimaryKey(testPlan);
|
|
||||||
}
|
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
if (sqlSession != null && sqlSessionFactory != null) {
|
if (sqlSession != null && sqlSessionFactory != null) {
|
||||||
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
@ -856,7 +849,6 @@ public class TestPlanService {
|
||||||
uiScenarioReportMap = this.executeUiScenarioCase(planReportId, testPlanID, projectID, runModeConfig, triggerMode, userId, reportInfoDTO.getUiScenarioIdMap());
|
uiScenarioReportMap = this.executeUiScenarioCase(planReportId, testPlanID, projectID, runModeConfig, triggerMode, userId, reportInfoDTO.getUiScenarioIdMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (apiCaseReportMap != null && scenarioReportMap != null && loadCaseReportMap != null && uiScenarioReportMap != null) todo 需要判断?
|
|
||||||
LoggerUtil.info("开始生成测试计划报告内容 " + planReportId);
|
LoggerUtil.info("开始生成测试计划报告内容 " + planReportId);
|
||||||
testPlanReportService.createTestPlanReportContentReportIds(planReportId, apiCaseReportMap, scenarioReportMap, loadCaseReportMap, uiScenarioReportMap);
|
testPlanReportService.createTestPlanReportContentReportIds(planReportId, apiCaseReportMap, scenarioReportMap, loadCaseReportMap, uiScenarioReportMap);
|
||||||
|
|
||||||
|
@ -1846,4 +1838,15 @@ public class TestPlanService {
|
||||||
baseScheduleService.addSchedule(schedule);
|
baseScheduleService.addSchedule(schedule);
|
||||||
baseScheduleService.addOrUpdateCronJob(request, jobKey, triggerKey, clazz);
|
baseScheduleService.addOrUpdateCronJob(request, jobKey, triggerKey, clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetStatus(String planId) {
|
||||||
|
TestPlan testPlan = get(planId);
|
||||||
|
if (StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Prepare.name())
|
||||||
|
|| StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Completed.name())) {
|
||||||
|
testPlan.setStatus(TestPlanStatus.Underway.name());
|
||||||
|
testPlan.setActualStartTime(System.currentTimeMillis()); // 将状态更新为进行中时,开始时间也要更新
|
||||||
|
testPlan.setActualEndTime(null);
|
||||||
|
testPlanMapper.updateByPrimaryKey(testPlan);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,42 +171,9 @@ public class TestReviewTestCaseService {
|
||||||
|
|
||||||
public TestReviewCaseDTO get(String reviewId) {
|
public TestReviewCaseDTO get(String reviewId) {
|
||||||
TestReviewCaseDTO testReviewCaseDTO = extTestReviewCaseMapper.get(reviewId);
|
TestReviewCaseDTO testReviewCaseDTO = extTestReviewCaseMapper.get(reviewId);
|
||||||
// List<TestCaseTestDTO> testCaseTestDTOS = extTestPlanTestCaseMapper.listTestCaseTest(testReviewCaseDTO.getCaseId());
|
|
||||||
// testCaseTestDTOS.forEach(dto -> {
|
|
||||||
// setTestName(dto);
|
|
||||||
// });
|
|
||||||
// testReviewCaseDTO.setList(testCaseTestDTOS);
|
|
||||||
return testReviewCaseDTO;
|
return testReviewCaseDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo check
|
|
||||||
// private void setTestName(TestCaseTestDTO dto) {
|
|
||||||
// String type = dto.getTestType();
|
|
||||||
// String id = dto.getTestId();
|
|
||||||
// switch (type) {
|
|
||||||
// case "performance":
|
|
||||||
// LoadTest loadTest = loadTestMapper.selectByPrimaryKey(id);
|
|
||||||
// if (loadTest != null) {
|
|
||||||
// dto.setTestName(loadTest.getName());
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// case "testcase":
|
|
||||||
// ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = apiTestCaseMapper.selectByPrimaryKey(id);
|
|
||||||
// if (apiTestCaseWithBLOBs != null) {
|
|
||||||
// dto.setTestName(apiTestCaseWithBLOBs.getName());
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// case "automation":
|
|
||||||
// ApiScenarioWithBLOBs apiScenarioWithBLOBs = apiScenarioMapper.selectByPrimaryKey(id);
|
|
||||||
// if (apiScenarioWithBLOBs != null) {
|
|
||||||
// dto.setTestName(apiScenarioWithBLOBs.getName());
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// default:
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void editTestCaseBatchStatus(TestReviewCaseBatchRequest request) {
|
public void editTestCaseBatchStatus(TestReviewCaseBatchRequest request) {
|
||||||
ServiceUtils.getSelectAllIds(request, request.getCondition(),
|
ServiceUtils.getSelectAllIds(request, request.getCondition(),
|
||||||
(query) -> extTestReviewCaseMapper.selectTestCaseIds((QueryCaseReviewRequest) query));
|
(query) -> extTestReviewCaseMapper.selectTestCaseIds((QueryCaseReviewRequest) query));
|
||||||
|
|
Loading…
Reference in New Issue