From d5ae5e58995151dfa0664fcaa2c0e2b5b48b779d Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Tue, 26 Apr 2022 17:34:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E6=80=A7=E8=83=BD=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=9C=AA=E6=89=A7?= =?UTF-8?q?=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1012775 --user=李玉号 【测试跟踪】测试计划关联性能测试,设置定时任务,执行完没生成测试报告 https://www.tapd.cn/55049933/s/1148393 --- .../api/dto/automation/parse/ApiScenarioImportUtil.java | 2 +- .../io/metersphere/api/service/ApiAutomationService.java | 6 +++--- .../io/metersphere/api/service/ApiDefinitionService.java | 6 +++--- .../performance/service/PerformanceTestService.java | 1 + .../src/main/java/io/metersphere/service/QuotaService.java | 4 ++-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/automation/parse/ApiScenarioImportUtil.java b/backend/src/main/java/io/metersphere/api/dto/automation/parse/ApiScenarioImportUtil.java index d2684be30c..72cc6f6688 100644 --- a/backend/src/main/java/io/metersphere/api/dto/automation/parse/ApiScenarioImportUtil.java +++ b/backend/src/main/java/io/metersphere/api/dto/automation/parse/ApiScenarioImportUtil.java @@ -171,7 +171,7 @@ public class ApiScenarioImportUtil { public static ApiDefinitionResult structureApiDefinitionByJson(int i,ApiDefinitionService apiDefinitionService,JSONObject object, String versionId, String projectId,ApiDefinitionMapper apiDefinitionMapper,MapdefinitionMap) { ApiDefinitionResult test = new ApiDefinitionResult(); - apiDefinitionService.checkQuota(); + apiDefinitionService.checkQuota(projectId); String protocal = object.getString("protocal"); if (StringUtils.equals(protocal, "DUBBO")) { test.setMethod("dubbo://"); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 6458165df3..c00c99ee5d 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -236,7 +236,7 @@ public class ApiAutomationService { } public ApiScenario create(SaveApiScenarioRequest request, List bodyFiles, List scenarioFiles) { - checkQuota(); + checkQuota(request.getProjectId()); request.setId(UUID.randomUUID().toString()); if (request.getScenarioDefinition() == null) { MsScenario msScenario = new MsScenario(); @@ -272,10 +272,10 @@ public class ApiAutomationService { return scenario; } - private void checkQuota() { + private void checkQuota(String projectId) { QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class); if (quotaService != null) { - quotaService.checkAPIAutomationQuota(); + quotaService.checkAPIAutomationQuota(projectId); } } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index d125d8e634..bb8517fb60 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -316,7 +316,7 @@ public class ApiDefinitionService { } public ApiDefinitionWithBLOBs create(SaveApiDefinitionRequest request, List bodyFiles) { - checkQuota(); + checkQuota(request.getProjectId()); if (StringUtils.equals(request.getProtocol(), "DUBBO")) { request.setMethod("dubbo://"); } @@ -345,10 +345,10 @@ public class ApiDefinitionService { return getBLOBs(returnModel.getId()); } - public void checkQuota() { + public void checkQuota(String projectId) { QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class); if (quotaService != null) { - quotaService.checkAPIDefinitionQuota(); + quotaService.checkAPIDefinitionQuota(projectId); } } diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java index 9fc6c7f2dd..cbe8932445 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -536,6 +536,7 @@ public class PerformanceTestService { RunTestPlanRequest checkRequest = new RunTestPlanRequest(); QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class); checkRequest.setLoadConfiguration(testReport.getLoadConfiguration()); + checkRequest.setProjectId(testReport.getProjectId()); if (quotaService != null) { quotaService.checkLoadTestQuota(checkRequest, false); String projectId = testReport.getProjectId(); diff --git a/backend/src/main/java/io/metersphere/service/QuotaService.java b/backend/src/main/java/io/metersphere/service/QuotaService.java index 7f08241e29..1de2e9bc21 100644 --- a/backend/src/main/java/io/metersphere/service/QuotaService.java +++ b/backend/src/main/java/io/metersphere/service/QuotaService.java @@ -17,12 +17,12 @@ public interface QuotaService { /** * api配额检查 */ - void checkAPIDefinitionQuota(); + void checkAPIDefinitionQuota(String projectId); /** * api配额检查 */ - void checkAPIAutomationQuota(); + void checkAPIAutomationQuota(String projectId); /** * 性能测试配额检查