From 579b2b5d567718f9bac5d6eabbe48b4abef24df9 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Fri, 16 Dec 2022 23:40:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E4=B8=B2=E8=A1=8C=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E4=B8=AA=E5=BC=80=E5=A7=8B=E4=B8=8D=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1020888 --user=宋天阳 【测试跟踪】批量执行两个测试计划失败,状态一直是running,超时结束后报告为空-打开报告卡死 https://www.tapd.cn/55049933/s/1316575 --- .../plan/service/TestPlanReportService.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java index 4817f3ff5f..d3706eaafa 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java @@ -560,7 +560,7 @@ public class TestPlanReportService { resourceId = planExecutionQueues.get(0).getResourceId(); testPlanExecutionQueueMapper.deleteByExample(testPlanExecutionQueueExample); } - + testPlanReportMapper.updateByPrimaryKey(testPlanReport); //发送通知 testPlanMessageService.checkTestPlanStatusAndSendMessage(testPlanReport, content, isSendMessage); @@ -579,7 +579,17 @@ public class TestPlanReportService { TestPlanRequestUtil.changeStringToBoolean(jsonObject); TestPlanRunRequest runRequest = JSON.parseObject(JSON.toJSONString(jsonObject), TestPlanRunRequest.class); runRequest.setReportId(testPlanExecutionQueue.getReportId()); - testPlanService.runPlan(runRequest); + runRequest.setTestPlanId(testPlan.getId()); + try { + HttpHeaderUtils.runAsUser("admin"); + //如果运行测试计划的过程中出现异常,则整个事务会回滚。 删除队列的事务也不会提交,也不会执行后面的测试计划 + testPlanService.runPlan(runRequest); + } catch (Exception e) { + LogUtil.error("执行队列中的下一个测试计划失败! ", e); + this.finishedTestPlanReport(runRequest.getReportId(), TestPlanReportStatus.FAILED.name()); + } finally { + HttpHeaderUtils.clearUser(); + } } }