parent
61ac90e6ef
commit
41d72d1c57
|
@ -491,11 +491,36 @@ public class TestPlanReportService {
|
||||||
return testPlanReport;
|
return testPlanReport;
|
||||||
}
|
}
|
||||||
boolean isSendMessage = false;
|
boolean isSendMessage = false;
|
||||||
TestPlanReportContentWithBLOBs content = null;
|
|
||||||
if (testPlanReport != null) {
|
if (testPlanReport != null) {
|
||||||
|
testPlanReport.setIsApiCaseExecuting(false);
|
||||||
|
testPlanReport.setIsScenarioExecuting(false);
|
||||||
|
testPlanReport.setIsPerformanceExecuting(false);
|
||||||
|
testPlanReport.setIsUiScenarioExecuting(false);
|
||||||
|
|
||||||
if (StringUtils.equalsIgnoreCase(testPlanReport.getStatus(), ExecuteResult.TEST_PLAN_RUNNING.toString())) {
|
if (StringUtils.equalsIgnoreCase(testPlanReport.getStatus(), ExecuteResult.TEST_PLAN_RUNNING.toString())) {
|
||||||
isSendMessage = true;
|
isSendMessage = true;
|
||||||
}
|
}
|
||||||
|
TestPlanReportContentWithBLOBs content = null;
|
||||||
|
try {
|
||||||
|
HttpHeaderUtils.runAsUser("admin");
|
||||||
|
testPlanReport.setStatus(status);
|
||||||
|
content = this.initTestPlanContent(testPlanReport, status);
|
||||||
|
} catch (Exception e) {
|
||||||
|
HttpHeaderUtils.clearUser();
|
||||||
|
testPlanReport.setStatus(status);
|
||||||
|
LogUtil.error("统计测试计划状态失败!", e);
|
||||||
|
} finally {
|
||||||
|
testPlanReportMapper.updateByPrimaryKey(testPlanReport);
|
||||||
|
testPlanMessageService.checkTestPlanStatusAndSendMessage(testPlanReport, content, isSendMessage);
|
||||||
|
this.executeTestPlanByQueue(testPlanReportId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return testPlanReport;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TestPlanReportContentWithBLOBs initTestPlanContent(TestPlanReport testPlanReport, String status) throws Exception {
|
||||||
|
TestPlanReportContentWithBLOBs content = null;
|
||||||
//初始化测试计划包含组件信息
|
//初始化测试计划包含组件信息
|
||||||
int[] componentIndexArr = new int[]{1, 3, 4};
|
int[] componentIndexArr = new int[]{1, 3, 4};
|
||||||
testPlanReport.setComponents(JSON.toJSONString(componentIndexArr));
|
testPlanReport.setComponents(JSON.toJSONString(componentIndexArr));
|
||||||
|
@ -512,7 +537,7 @@ public class TestPlanReportService {
|
||||||
}
|
}
|
||||||
|
|
||||||
TestPlanReportContentExample contentExample = new TestPlanReportContentExample();
|
TestPlanReportContentExample contentExample = new TestPlanReportContentExample();
|
||||||
contentExample.createCriteria().andTestPlanReportIdEqualTo(testPlanReportId);
|
contentExample.createCriteria().andTestPlanReportIdEqualTo(testPlanReport.getTestPlanId());
|
||||||
List<TestPlanReportContentWithBLOBs> contents = testPlanReportContentMapper.selectByExampleWithBLOBs(contentExample);
|
List<TestPlanReportContentWithBLOBs> contents = testPlanReportContentMapper.selectByExampleWithBLOBs(contentExample);
|
||||||
if (CollectionUtils.isNotEmpty(contents)) {
|
if (CollectionUtils.isNotEmpty(contents)) {
|
||||||
content = contents.get(0);
|
content = contents.get(0);
|
||||||
|
@ -521,22 +546,11 @@ public class TestPlanReportService {
|
||||||
extTestPlanReportMapper.setApiBaseCountAndPassRateIsNullById(content.getId());
|
extTestPlanReportMapper.setApiBaseCountAndPassRateIsNullById(content.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
//更新测试计划并发送通知
|
|
||||||
testPlanReport.setIsApiCaseExecuting(false);
|
|
||||||
testPlanReport.setIsScenarioExecuting(false);
|
|
||||||
testPlanReport.setIsPerformanceExecuting(false);
|
|
||||||
testPlanReport.setIsUiScenarioExecuting(false);
|
|
||||||
//计算测试计划状态
|
//计算测试计划状态
|
||||||
|
|
||||||
try {
|
|
||||||
if (StringUtils.equalsIgnoreCase(status, TestPlanReportStatus.COMPLETED.name())) {
|
if (StringUtils.equalsIgnoreCase(status, TestPlanReportStatus.COMPLETED.name())) {
|
||||||
testPlanReport.setStatus(TestPlanReportStatus.SUCCESS.name());
|
testPlanReport.setStatus(TestPlanReportStatus.SUCCESS.name());
|
||||||
HttpHeaderUtils.runAsUser("admin");
|
|
||||||
testPlanService.checkStatus(testPlanReport.getTestPlanId());
|
testPlanService.checkStatus(testPlanReport.getTestPlanId());
|
||||||
} else {
|
|
||||||
testPlanReport.setStatus(status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (content != null) {
|
if (content != null) {
|
||||||
//更新content表对结束日期
|
//更新content表对结束日期
|
||||||
if (!StringUtils.equalsAnyIgnoreCase(testPlanReport.getStatus(), APITestStatus.Rerunning.name())) {
|
if (!StringUtils.equalsAnyIgnoreCase(testPlanReport.getStatus(), APITestStatus.Rerunning.name())) {
|
||||||
|
@ -546,10 +560,11 @@ public class TestPlanReportService {
|
||||||
this.initTestPlanReportBaseCount(testPlanReport, content);
|
this.initTestPlanReportBaseCount(testPlanReport, content);
|
||||||
testPlanReportContentMapper.updateByExampleSelective(content, contentExample);
|
testPlanReportContentMapper.updateByExampleSelective(content, contentExample);
|
||||||
}
|
}
|
||||||
} finally {
|
return content;
|
||||||
HttpHeaderUtils.clearUser();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void executeTestPlanByQueue(String testPlanReportId) {
|
||||||
TestPlanExecutionQueueExample testPlanExecutionQueueExample = new TestPlanExecutionQueueExample();
|
TestPlanExecutionQueueExample testPlanExecutionQueueExample = new TestPlanExecutionQueueExample();
|
||||||
testPlanExecutionQueueExample.createCriteria().andReportIdEqualTo(testPlanReportId);
|
testPlanExecutionQueueExample.createCriteria().andReportIdEqualTo(testPlanReportId);
|
||||||
List<TestPlanExecutionQueue> planExecutionQueues = testPlanExecutionQueueMapper.selectByExample(testPlanExecutionQueueExample);
|
List<TestPlanExecutionQueue> planExecutionQueues = testPlanExecutionQueueMapper.selectByExample(testPlanExecutionQueueExample);
|
||||||
|
@ -561,18 +576,12 @@ public class TestPlanReportService {
|
||||||
testPlanExecutionQueueMapper.deleteByExample(testPlanExecutionQueueExample);
|
testPlanExecutionQueueMapper.deleteByExample(testPlanExecutionQueueExample);
|
||||||
}
|
}
|
||||||
|
|
||||||
testPlanReportMapper.updateByPrimaryKey(testPlanReport);
|
|
||||||
//发送通知
|
|
||||||
testPlanMessageService.checkTestPlanStatusAndSendMessage(testPlanReport, content, isSendMessage);
|
|
||||||
|
|
||||||
if (runMode != null && StringUtils.equalsIgnoreCase(runMode, RunModeConstants.SERIAL.name()) && resourceId != null) {
|
if (runMode != null && StringUtils.equalsIgnoreCase(runMode, RunModeConstants.SERIAL.name()) && resourceId != null) {
|
||||||
TestPlanExecutionQueueExample queueExample = new TestPlanExecutionQueueExample();
|
TestPlanExecutionQueueExample queueExample = new TestPlanExecutionQueueExample();
|
||||||
queueExample.createCriteria().andReportIdIsNotNull().andResourceIdEqualTo(resourceId);
|
queueExample.createCriteria().andReportIdIsNotNull().andResourceIdEqualTo(resourceId);
|
||||||
queueExample.setOrderByClause("`num` ASC");
|
queueExample.setOrderByClause("`num` ASC");
|
||||||
List<TestPlanExecutionQueue> planExecutionQueueList = testPlanExecutionQueueMapper.selectByExample(queueExample);
|
List<TestPlanExecutionQueue> planExecutionQueueList = testPlanExecutionQueueMapper.selectByExample(queueExample);
|
||||||
if (CollectionUtils.isEmpty(planExecutionQueueList)) {
|
if (CollectionUtils.isNotEmpty(planExecutionQueueList)) {
|
||||||
return testPlanReport;
|
|
||||||
}
|
|
||||||
TestPlanExecutionQueue testPlanExecutionQueue = planExecutionQueueList.get(0);
|
TestPlanExecutionQueue testPlanExecutionQueue = planExecutionQueueList.get(0);
|
||||||
TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(testPlanExecutionQueue.getTestPlanId());
|
TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(testPlanExecutionQueue.getTestPlanId());
|
||||||
Map jsonObject = JSON.parseMap(testPlan.getRunModeConfig());
|
Map jsonObject = JSON.parseMap(testPlan.getRunModeConfig());
|
||||||
|
@ -591,9 +600,7 @@ public class TestPlanReportService {
|
||||||
HttpHeaderUtils.clearUser();
|
HttpHeaderUtils.clearUser();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return testPlanReport;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initTestPlanReportBaseCount(TestPlanReport testPlanReport, TestPlanReportContentWithBLOBs reportContent) {
|
private void initTestPlanReportBaseCount(TestPlanReport testPlanReport, TestPlanReportContentWithBLOBs reportContent) {
|
||||||
|
|
Loading…
Reference in New Issue