From 056f5cf1a8d01a9951c70d1b598ecbbfb0db2189 Mon Sep 17 00:00:00 2001 From: wenyann Date: Wed, 9 Jun 2021 17:47:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E7=94=A8=E4=BE=8B=E5=92=8C=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E7=9A=84=E8=AF=B7=E6=B1=82=E5=8F=82=E6=95=B0=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=BC=98=E5=8C=96=20post=E8=AF=B7=E6=B1=82=20?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E9=80=89=E4=B8=AD=E8=AF=B7=E6=B1=82=E4=BD=93?= =?UTF-8?q?=20get=E5=92=8Cdelete=E9=BB=98=E8=AE=A4=E9=80=89=E4=B8=ADQUERY?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../track/controller/TestPlanController.java | 2 +- .../request/testplan/TestplanRunRequest.java | 16 ++++++++-------- .../track/service/TestPlanReportService.java | 2 +- .../track/service/TestPlanService.java | 13 +++++++++++-- .../request/http/ApiHttpRequestForm.vue | 4 +++- 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java index 0b2eb9cb64..c07fc33a1c 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java @@ -160,6 +160,6 @@ public class TestPlanController { api.setMode(testplanRunRequest.getMode()); api.setResourcePoolId(testplanRunRequest.getResourcePoolId()); String apiRunConfig = JSONObject.toJSONString(api); - testPlanService.run(testplanRunRequest.getTestPlanID(), testplanRunRequest.getProjectID(), testplanRunRequest.getUserId(), testplanRunRequest.getTriggerMode(), apiRunConfig); + testPlanService.run(testplanRunRequest.getTestPlanId(), testplanRunRequest.getProjectId(), testplanRunRequest.getUserId(), testplanRunRequest.getTriggerMode(), apiRunConfig); } } diff --git a/backend/src/main/java/io/metersphere/track/request/testplan/TestplanRunRequest.java b/backend/src/main/java/io/metersphere/track/request/testplan/TestplanRunRequest.java index 1ee6f31dda..b092dac739 100644 --- a/backend/src/main/java/io/metersphere/track/request/testplan/TestplanRunRequest.java +++ b/backend/src/main/java/io/metersphere/track/request/testplan/TestplanRunRequest.java @@ -7,14 +7,14 @@ import lombok.Setter; @Getter @Setter public class TestplanRunRequest { - private String testPlanID; - private String projectID; + private String testPlanId; + private String projectId; private String userId; - private String triggerMode; - private String mode; - private String reportType; - private String onSampleError; - private String runWithinResourcePool; - private String resourcePoolId; + private String triggerMode;//触发方式 + private String mode;//运行模式 + private String reportType;//报告展示方式 + private String onSampleError;//是否失败停止 + private String runWithinResourcePool;//是否选择资源池 + private String resourcePoolId;//资源池Id } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java index d10461d0d8..3d0370fccf 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -382,7 +382,7 @@ public class TestPlanReportService { testPlanMapper.updateByPrimaryKeySelective(testPlan); } - if (StringUtils.equalsAny(report.getTriggerMode(), ReportTriggerMode.SCHEDULE.name())) { + if (StringUtils.equals(report.getTriggerMode(), ReportTriggerMode.API.name()) || StringUtils.equals(report.getTriggerMode(), ReportTriggerMode.SCHEDULE.name())) { //发送通知 sendMessage(report); } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index a0b09e6562..bf615342af 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -1058,7 +1058,11 @@ public class TestPlanService { RunTestPlanRequest performanceRequest = new RunTestPlanRequest(); performanceRequest.setId(caseID); performanceRequest.setTestPlanLoadId(caseID); - performanceRequest.setTriggerMode(ReportTriggerMode.TEST_PLAN_SCHEDULE.name()); + if (StringUtils.equals(ReportTriggerMode.API.name(), triggerMode)) { + performanceRequest.setTriggerMode(ReportTriggerMode.API.name()); + } else { + performanceRequest.setTriggerMode(ReportTriggerMode.TEST_PLAN_SCHEDULE.name()); + } String reportId = null; try { reportId = performanceTestService.run(performanceRequest); @@ -1091,6 +1095,7 @@ public class TestPlanService { if (!performaneReportIDList.isEmpty()) { //性能测试时保存性能测试报告ID,在结果返回时用于捕捉并进行 testPlanReportService.updatePerformanceInfo(testPlanReport, performaneReportIDList, ReportTriggerMode.SCHEDULE.name()); + } @@ -1114,7 +1119,11 @@ public class TestPlanService { scenarioRequest.setId(senarionReportID); scenarioRequest.setReportId(senarionReportID); scenarioRequest.setProjectId(projectID); - scenarioRequest.setTriggerMode(ReportTriggerMode.SCHEDULE.name()); + if (StringUtils.equals(triggerMode, ReportTriggerMode.API.name())) { + scenarioRequest.setTriggerMode(ReportTriggerMode.API.name()); + } else { + scenarioRequest.setTriggerMode(ReportTriggerMode.SCHEDULE.name()); + } scenarioRequest.setExecuteType(ExecuteType.Saved.name()); Map> testPlanScenarioIdMap = new HashMap<>(); testPlanScenarioIdMap.put(testPlanID, planScenarioIdMap); diff --git a/frontend/src/business/components/api/definition/components/request/http/ApiHttpRequestForm.vue b/frontend/src/business/components/api/definition/components/request/http/ApiHttpRequestForm.vue index ce188ec0cc..f6da672adc 100644 --- a/frontend/src/business/components/api/definition/components/request/http/ApiHttpRequestForm.vue +++ b/frontend/src/business/components/api/definition/components/request/http/ApiHttpRequestForm.vue @@ -110,6 +110,7 @@ MsApiAssertions }, props: { + method: String, request: {}, response: {}, showScript: { @@ -144,7 +145,7 @@ } }; return { - activeName: "headers", + activeName: this.request.method === "POST" ? "body" : "parameters", rules: { name: [ {max: 300, message: this.$t('commons.input_limit', [1, 300]), trigger: 'blur'} @@ -187,6 +188,7 @@ }) }, init() { + if (!this.request.body) { this.request.body = new Body(); }