From e03fb236e449b1216020710fb7e970c480bcd97e Mon Sep 17 00:00:00 2001 From: AgAngle <1323481023@qq.com> Date: Tue, 15 Oct 2024 10:53:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E6=89=A7=E8=A1=8C=EF=BC=8C?= =?UTF-8?q?=E6=98=8E=E7=BB=86=E7=9A=84=E6=8A=A5=E5=91=8A=E8=80=97=E6=97=B6?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=9C=89=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1046028 --user=陈建星 [接口测试]github#32918测试计划报告中的单场景报告中的“报告总耗时”指标统计错误 https://www.tapd.cn/55049933/s/1591890 --- .../sdk/dto/pool/ResourcePoolNodeMetric.java | 27 +++++++++++++++++++ .../service/ApiExecuteResourceService.java | 4 +-- .../service/definition/ApiReportService.java | 15 +++++++++++ .../scenario/ApiScenarioReportService.java | 14 ++++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/pool/ResourcePoolNodeMetric.java diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/pool/ResourcePoolNodeMetric.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/pool/ResourcePoolNodeMetric.java new file mode 100644 index 0000000000..b3c706b8e8 --- /dev/null +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/pool/ResourcePoolNodeMetric.java @@ -0,0 +1,27 @@ +package io.metersphere.sdk.dto.pool; + +import lombok.Data; + +/** + * @Author: jianxing + * @CreateTime: 2024-10-14 18:28 + */ +@Data +public class ResourcePoolNodeMetric { + /** + * 并发数 + */ + private Integer concurrentNumber; + /** + * 已占用的并发数 + */ + private Integer occupiedConcurrentNumber; + /** + * CPU使用率 + */ + private Double CPUUsage; + /** + * 内存使用率 + */ + private Double memoryUsage; +} diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiExecuteResourceService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiExecuteResourceService.java index c80e9570d1..4d27be3923 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiExecuteResourceService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiExecuteResourceService.java @@ -57,9 +57,9 @@ public class ApiExecuteResourceService { // 非调试执行,更新报告状态 switch (apiExecuteResourceType) { case API_SCENARIO, TEST_PLAN_API_SCENARIO, PLAN_RUN_API_SCENARIO -> - apiScenarioReportService.updateReportStatus(reportId, ExecStatus.RUNNING.name()); + apiScenarioReportService.updateReportRunningStatus(reportId); case API_CASE, TEST_PLAN_API_CASE, PLAN_RUN_API_CASE -> - apiReportService.updateReportStatus(reportId, ExecStatus.RUNNING.name()); + apiReportService.updateReportRunningStatus(reportId); default -> throw new MSException("不支持的资源类型: " + request.getResourceType()); } } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiReportService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiReportService.java index 08023e2c20..a7097d5138 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiReportService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiReportService.java @@ -250,6 +250,21 @@ public class ApiReportService { return apiReportDetails; } + /** + * 更新执行中的用例报告 + * + * @param reportId + */ + public void updateReportRunningStatus(String reportId) { + ApiReport apiReport = new ApiReport(); + apiReport.setId(reportId); + apiReport.setExecStatus(ExecStatus.RUNNING.name()); + apiReport.setStartTime(System.currentTimeMillis()); + apiReport.setUpdateTime(System.currentTimeMillis()); + apiReportMapper.updateByPrimaryKeySelective(apiReport); + } + + /** * 更新执行中的用例报告 * diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioReportService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioReportService.java index 1ea3cb603d..acf8318c00 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioReportService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioReportService.java @@ -371,6 +371,20 @@ public class ApiScenarioReportService { return apiReportDetails; } + /** + * 更新进行中的报告状态和开始执行时间 + * + * @param reportId + */ + public void updateReportRunningStatus(String reportId) { + ApiScenarioReport scenarioReport = new ApiScenarioReport(); + scenarioReport.setId(reportId); + scenarioReport.setExecStatus(ExecStatus.RUNNING.name()); + scenarioReport.setStartTime(System.currentTimeMillis()); + scenarioReport.setUpdateTime(System.currentTimeMillis()); + apiScenarioReportMapper.updateByPrimaryKeySelective(scenarioReport); + } + /** * 更新执行中的场景报告 *