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); + } + /** * 更新执行中的场景报告 *