From 806772a339d68fd6baa3c4189165bf123c0aee4d Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Thu, 25 Mar 2021 14:54:59 +0800 Subject: [PATCH 01/17] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA)?= =?UTF-8?q?:=20=E4=BF=AE=E5=A4=8DplanId=E5=8F=AF=E8=83=BD=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E8=B0=83=E7=94=A8=E5=90=8E=E5=8F=B0=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../track/plan/view/comonents/api/TestPlanApiCaseList.vue | 3 +++ .../plan/view/comonents/functional/FunctionalTestCaseList.vue | 3 +++ .../track/plan/view/comonents/load/TestPlanLoadCaseList.vue | 3 +++ 3 files changed, 9 insertions(+) diff --git a/frontend/src/business/components/track/plan/view/comonents/api/TestPlanApiCaseList.vue b/frontend/src/business/components/track/plan/view/comonents/api/TestPlanApiCaseList.vue index 4de7dd0303..4fab18c445 100644 --- a/frontend/src/business/components/track/plan/view/comonents/api/TestPlanApiCaseList.vue +++ b/frontend/src/business/components/track/plan/view/comonents/api/TestPlanApiCaseList.vue @@ -524,6 +524,9 @@ export default { }); }, autoCheckStatus() { // 检查执行结果,自动更新计划状态 + if (!this.planId) { + return; + } this.$post('/test/plan/autoCheck/' + this.planId, (response) => { }); }, diff --git a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue index b3e25ac688..3913a5eb37 100644 --- a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue +++ b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue @@ -484,6 +484,9 @@ export default { getLabel(this, TEST_PLAN_FUNCTION_TEST_CASE); }, autoCheckStatus() { + if (!this.planId) { + return; + } this.$post('/test/plan/autoCheck/' + this.planId, (response) => { }); }, diff --git a/frontend/src/business/components/track/plan/view/comonents/load/TestPlanLoadCaseList.vue b/frontend/src/business/components/track/plan/view/comonents/load/TestPlanLoadCaseList.vue index a6ecaf0e0b..7f38eb878a 100644 --- a/frontend/src/business/components/track/plan/view/comonents/load/TestPlanLoadCaseList.vue +++ b/frontend/src/business/components/track/plan/view/comonents/load/TestPlanLoadCaseList.vue @@ -251,6 +251,9 @@ export default { }, autoCheckStatus() { + if (!this.planId) { + return; + } this.$post('/test/plan/autoCheck/' + this.planId, (response) => { }); }, From 8328cab574b1aa18a71c2140b2c2b775130a0547 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Thu, 25 Mar 2021 15:44:06 +0800 Subject: [PATCH 02/17] chore: sync --- frontend/src/business/components/xpack | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/business/components/xpack b/frontend/src/business/components/xpack index 07951ba17a..2115bd28a9 160000 --- a/frontend/src/business/components/xpack +++ b/frontend/src/business/components/xpack @@ -1 +1 @@ -Subproject commit 07951ba17aef6f29e50cfd68e40de3266f9a60cd +Subproject commit 2115bd28a90854d2b6276a90878934715498c584 From 1c773f83de6e27dc822829d13c1ec50de6aa5157 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Thu, 25 Mar 2021 16:57:15 +0800 Subject: [PATCH 03/17] =?UTF-8?q?fix:=20=E5=B0=9D=E8=AF=95=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E8=A1=A8=E6=A0=BC=E5=9B=BA=E5=AE=9A=E5=88=97=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=E9=94=99=E4=B9=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/api/automation/scenario/ApiScenarioList.vue | 2 +- .../api/definition/components/list/ApiCaseSimpleList.vue | 2 +- .../components/api/definition/components/list/ApiList.vue | 2 +- .../business/components/track/case/components/TestCaseList.vue | 2 +- .../plan/view/comonents/functional/FunctionalTestCaseList.vue | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue index e71ae9f2fb..d9ac4011ba 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue @@ -433,7 +433,7 @@ this.result.loading = false; this.unSelection = data.listObject.map(s => s.id); if (this.$refs.scenarioTable) { - this.$refs.scenarioTable.doLayout() + setTimeout(this.$refs.scenarioTable.doLayout,500) } }); } diff --git a/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue b/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue index 53f89a01de..48f4e2e212 100644 --- a/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue +++ b/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue @@ -340,7 +340,7 @@ export default { } }) if (this.$refs.caseTable) { - this.$refs.caseTable.doLayout() + setTimeout(this.$refs.caseTable.doLayout,500) } }); } diff --git a/frontend/src/business/components/api/definition/components/list/ApiList.vue b/frontend/src/business/components/api/definition/components/list/ApiList.vue index 58c0da0cb6..46ffe54bea 100644 --- a/frontend/src/business/components/api/definition/components/list/ApiList.vue +++ b/frontend/src/business/components/api/definition/components/list/ApiList.vue @@ -464,7 +464,7 @@ } }) if (this.$refs.apiDefinitionTable) { - this.$refs.apiDefinitionTable.doLayout() + setTimeout(this.$refs.apiDefinitionTable.doLayout, 500) } }); diff --git a/frontend/src/business/components/track/case/components/TestCaseList.vue b/frontend/src/business/components/track/case/components/TestCaseList.vue index b17b65da5e..2b0ec84d70 100644 --- a/frontend/src/business/components/track/case/components/TestCaseList.vue +++ b/frontend/src/business/components/track/case/components/TestCaseList.vue @@ -399,7 +399,7 @@ export default { item.tags = JSON.parse(item.tags); }) if (this.$refs.table) { - this.$refs.table.doLayout() + setTimeout(this.$refs.table.doLayout,500) } }); diff --git a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue index 3913a5eb37..b3682c0801 100644 --- a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue +++ b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue @@ -477,7 +477,7 @@ export default { } this.selectRows.clear(); if (this.$refs.table) { - this.$refs.table.doLayout() + setTimeout(this.$refs.table.doLayout,500) } }); } From 321a35aeabef14792047a6d9070fad0ee8944c54 Mon Sep 17 00:00:00 2001 From: "song.tianyang" Date: Thu, 25 Mar 2021 16:59:09 +0800 Subject: [PATCH 04/17] =?UTF-8?q?fix:=20=E6=96=87=E6=A1=A3=E4=B8=8D?= =?UTF-8?q?=E8=B6=85=E8=BF=875=E4=B8=AA=E6=95=B0=E6=8D=AE=E6=97=B6?= =?UTF-8?q?=E4=B8=8B=E6=BB=9A=E5=87=BA=E7=8E=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 文档不超过5个数据时下滚出现问题 --- .../definition/components/document/ApiDocumentAnchor.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/business/components/api/definition/components/document/ApiDocumentAnchor.vue b/frontend/src/business/components/api/definition/components/document/ApiDocumentAnchor.vue index 194605f3ad..5b28afe295 100644 --- a/frontend/src/business/components/api/definition/components/document/ApiDocumentAnchor.vue +++ b/frontend/src/business/components/api/definition/components/document/ApiDocumentAnchor.vue @@ -643,7 +643,7 @@ export default { if(lastIndex < this.currentApiIndexInApiShowArray){ //上移 - if(this.needAsyncSelect){ + // if(this.needAsyncSelect){ //进行判断:是否还需要为apiShowArray 增加数据。 由于在当前数据前后最多展现2条数据, //可得: apiStepIndex-1- 2 < apiInfoArray,需要添加数据 let dataIndex = this.apiStepIndex -3; @@ -657,11 +657,11 @@ export default { if(this.apiShowArray.length > (this.currentApiIndexInApiShowArray+3)){ this.apiShowArray.pop(); } - } + // } this.apiStepIndex --; }else if(lastIndex > this.currentApiIndexInApiShowArray){ //下滚 - if(this.needAsyncSelect){ + // if(this.needAsyncSelect){ //进行判断:是否还需要为apiShowArray 增加数据。 由于在当前数据前后最多展现2条数据, //可得: apiStepIndex+1+ 2 < apiInfoArray,需要添加数据 let dataIndex = this.apiStepIndex +3; @@ -678,7 +678,7 @@ export default { let itemHeight = this.$refs.apiDocInfoDivItem[0].offsetHeight+10; this.$refs.apiDocInfoDiv.scrollTop = (apiDocDivScrollTop-itemHeight); } - } + // } this.apiStepIndex ++; } } From 01799cd93707b181d82c0135db746c46d2e921e6 Mon Sep 17 00:00:00 2001 From: wenyann <64353056+wenyann@users.noreply.github.com> Date: Thu, 25 Mar 2021 17:02:36 +0800 Subject: [PATCH 05/17] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E8=AE=A1=E5=88=92=E6=97=A0=E6=B3=95=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/ApiTestCaseController.java | 16 ++++++++++---- .../api/jmeter/APIBackendListenerClient.java | 8 +++---- .../api/service/ApiTestCaseService.java | 10 ++++++++- .../track/service/TestPlanApiCaseService.java | 22 +++++++++---------- 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java b/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java index 3affea3472..9a3fe96e37 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java @@ -7,12 +7,12 @@ import io.metersphere.api.dto.definition.*; import io.metersphere.api.service.ApiTestCaseService; import io.metersphere.base.domain.ApiTestCase; import io.metersphere.base.domain.ApiTestCaseWithBLOBs; -import io.metersphere.commons.constants.ApiRunMode; import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.SessionUtils; import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest; +import io.metersphere.track.service.TestPlanApiCaseService; import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresRoles; import org.springframework.web.bind.annotation.*; @@ -29,7 +29,8 @@ public class ApiTestCaseController { @Resource private ApiTestCaseService apiTestCaseService; - + @Resource + private TestPlanApiCaseService testPlanApiCaseService; @PostMapping("/list") public List list(@RequestBody ApiTestCaseRequest request) { request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); @@ -48,6 +49,12 @@ public class ApiTestCaseController { return null; } } + @GetMapping("/getStateByTestPlan/{id}") + public String getStateByTestPlan(@PathVariable String id ) { + String status=testPlanApiCaseService.getState(id); + return status; + + } @PostMapping("/list/{goPage}/{pageSize}") public Pager> listSimple(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) { @@ -131,7 +138,8 @@ public class ApiTestCaseController { return apiTestCaseService.run(request); } @GetMapping(value = "/jenkins/exec/result/{id}") - public String getExecResult(@PathVariable String id) { - return apiTestCaseService.getExecResult(id); + public String getExecResult(@PathVariable String id) { + return apiTestCaseService.getExecResult(id); + } } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java index d4e00b2cda..1c3889d6bf 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java @@ -1,12 +1,10 @@ package io.metersphere.api.jmeter; -import io.metersphere.api.dto.definition.ApiTestCaseInfo; import io.metersphere.api.dto.scenario.request.RequestType; import io.metersphere.api.service.*; import io.metersphere.base.domain.ApiDefinitionExecResult; import io.metersphere.base.domain.ApiScenarioReport; import io.metersphere.base.domain.ApiTestReport; -import io.metersphere.base.domain.TestPlanReport; import io.metersphere.commons.constants.*; import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.LogUtil; @@ -16,7 +14,6 @@ import io.metersphere.notice.sender.NoticeModel; import io.metersphere.notice.service.NoticeSendService; import io.metersphere.service.SystemParameterService; import io.metersphere.track.service.TestPlanReportService; -import io.metersphere.track.service.TestPlanService; import io.metersphere.track.service.TestPlanTestCaseService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -250,7 +247,10 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl } } - sendTask(report, reportUrl, testResult); + if (StringUtils.equals(ReportTriggerMode.API.name(), report.getTriggerMode())||StringUtils.equals(ReportTriggerMode.SCHEDULE.name(), report.getTriggerMode())) { + sendTask(report, reportUrl, testResult); + } + } private static void sendTask(ApiTestReport report, String reportUrl, TestResult testResult) { diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java index 12730c5308..aa7f0724a4 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -19,6 +19,7 @@ import io.metersphere.api.jmeter.JMeterService; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.ext.*; +import io.metersphere.commons.constants.ApiRunMode; import io.metersphere.commons.constants.TestPlanStatus; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.*; @@ -551,7 +552,14 @@ public class ApiTestCaseService { } public String run(RunCaseRequest request) { - ApiTestCaseWithBLOBs testCaseWithBLOBs = apiTestCaseMapper.selectByPrimaryKey(request.getCaseId()); + ApiTestCaseWithBLOBs testCaseWithBLOBs=new ApiTestCaseWithBLOBs(); + if(StringUtils.equals(request.getRunMode(), ApiRunMode.JENKINS_API_PLAN.name())){ + testCaseWithBLOBs= apiTestCaseMapper.selectByPrimaryKey(request.getReportId()); + request.setCaseId(request.getReportId()); + }else{ + testCaseWithBLOBs= apiTestCaseMapper.selectByPrimaryKey(request.getCaseId()); + + } // 多态JSON普通转换会丢失内容,需要通过 ObjectMapper 获取 if (testCaseWithBLOBs != null && StringUtils.isNotEmpty(testCaseWithBLOBs.getRequest())) { try { diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanApiCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanApiCaseService.java index df789f41ad..ad98f6fb27 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanApiCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanApiCaseService.java @@ -1,21 +1,13 @@ package io.metersphere.track.service; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.api.dto.definition.ApiTestCaseDTO; import io.metersphere.api.dto.definition.ApiTestCaseRequest; -import io.metersphere.api.dto.definition.RunDefinitionRequest; import io.metersphere.api.dto.definition.TestPlanApiCaseDTO; -import io.metersphere.api.dto.definition.request.MsTestElement; -import io.metersphere.api.dto.definition.request.MsTestPlan; -import io.metersphere.api.dto.definition.request.MsThreadGroup; import io.metersphere.api.service.ApiDefinitionExecResultService; import io.metersphere.api.service.ApiDefinitionService; import io.metersphere.api.service.ApiTestCaseService; -import io.metersphere.base.domain.ApiTestCaseExample; -import io.metersphere.base.domain.ApiTestCaseWithBLOBs; import io.metersphere.base.domain.TestPlanApiCase; import io.metersphere.base.domain.TestPlanApiCaseExample; import io.metersphere.base.mapper.TestPlanApiCaseMapper; @@ -25,15 +17,16 @@ import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.ServiceUtils; import io.metersphere.commons.utils.SessionUtils; import io.metersphere.track.request.testcase.TestPlanApiCaseBatchRequest; -import org.apache.jmeter.testelement.TestElement; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; -import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; @Service @Transactional(rollbackFor = Exception.class) @@ -150,4 +143,11 @@ public class TestPlanApiCaseService { }); } } + + public String getState(String id) { + TestPlanApiCaseExample example = new TestPlanApiCaseExample(); + example.createCriteria().andApiCaseIdEqualTo(id); + return testPlanApiCaseMapper.selectByExample(example).get(0).getStatus(); + + } } From 24c9b5d0a19b8260d746e32908d3c1dae7943996 Mon Sep 17 00:00:00 2001 From: "song.tianyang" Date: Thu, 25 Mar 2021 17:02:59 +0800 Subject: [PATCH 06/17] =?UTF-8?q?fix:=20=E6=96=87=E6=A1=A3=E4=B8=8D?= =?UTF-8?q?=E8=B6=85=E8=BF=875=E4=B8=AA=E6=95=B0=E6=8D=AE=E6=97=B6?= =?UTF-8?q?=E4=B8=8B=E6=BB=9A=E5=87=BA=E7=8E=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 文档不超过5个数据时下滚出现问题 --- .../definition/components/document/ApiDocumentAnchor.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/business/components/api/definition/components/document/ApiDocumentAnchor.vue b/frontend/src/business/components/api/definition/components/document/ApiDocumentAnchor.vue index 194605f3ad..5b28afe295 100644 --- a/frontend/src/business/components/api/definition/components/document/ApiDocumentAnchor.vue +++ b/frontend/src/business/components/api/definition/components/document/ApiDocumentAnchor.vue @@ -643,7 +643,7 @@ export default { if(lastIndex < this.currentApiIndexInApiShowArray){ //上移 - if(this.needAsyncSelect){ + // if(this.needAsyncSelect){ //进行判断:是否还需要为apiShowArray 增加数据。 由于在当前数据前后最多展现2条数据, //可得: apiStepIndex-1- 2 < apiInfoArray,需要添加数据 let dataIndex = this.apiStepIndex -3; @@ -657,11 +657,11 @@ export default { if(this.apiShowArray.length > (this.currentApiIndexInApiShowArray+3)){ this.apiShowArray.pop(); } - } + // } this.apiStepIndex --; }else if(lastIndex > this.currentApiIndexInApiShowArray){ //下滚 - if(this.needAsyncSelect){ + // if(this.needAsyncSelect){ //进行判断:是否还需要为apiShowArray 增加数据。 由于在当前数据前后最多展现2条数据, //可得: apiStepIndex+1+ 2 < apiInfoArray,需要添加数据 let dataIndex = this.apiStepIndex +3; @@ -678,7 +678,7 @@ export default { let itemHeight = this.$refs.apiDocInfoDivItem[0].offsetHeight+10; this.$refs.apiDocInfoDiv.scrollTop = (apiDocDivScrollTop-itemHeight); } - } + // } this.apiStepIndex ++; } } From f0492e1346d6ade41d98344f827afa4abf0a4aba Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 25 Mar 2021 17:23:30 +0800 Subject: [PATCH 07/17] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E6=94=B9=E5=9C=BA=E6=99=AF=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E5=90=8D=E7=A7=B0=E9=95=BF=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/resources/db/migration/V79__v1.8.1_release.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 backend/src/main/resources/db/migration/V79__v1.8.1_release.sql diff --git a/backend/src/main/resources/db/migration/V79__v1.8.1_release.sql b/backend/src/main/resources/db/migration/V79__v1.8.1_release.sql new file mode 100644 index 0000000000..8c15c4fe47 --- /dev/null +++ b/backend/src/main/resources/db/migration/V79__v1.8.1_release.sql @@ -0,0 +1,2 @@ +-- api_scenario_report modify column length +ALTER TABLE api_scenario_report MODIFY COLUMN name VARCHAR(300); \ No newline at end of file From c43a258780916d05ff2c779e8ccf5ff25b623a67 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 25 Mar 2021 17:53:26 +0800 Subject: [PATCH 08/17] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8Djmx=E5=AF=BC=E5=87=BA=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E4=BD=93=E6=95=B0=E6=8D=AE=E7=B1=BB=E5=9E=8B=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/automation/parse/MsJmeterParser.java | 10 ++++++++-- .../java/io/metersphere/api/dto/scenario/Body.java | 1 + frontend/src/business/components/xpack | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java b/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java index 914ef1eef0..0ce4456848 100644 --- a/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java +++ b/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java @@ -137,7 +137,7 @@ public class MsJmeterParser extends ApiImportAbstractParser { HTTPSamplerProxy source = (HTTPSamplerProxy) key; BeanUtils.copyBean(samplerProxy, source); if (source != null && source.getHTTPFiles().length > 0) { - samplerProxy.getBody().setBinary(new ArrayList<>()); + samplerProxy.getBody().initBinary(); samplerProxy.getBody().setType(Body.FORM_DATA); List keyValues = new LinkedList<>(); for (HTTPFileArg arg : source.getHTTPFiles()) { @@ -153,7 +153,12 @@ public class MsJmeterParser extends ApiImportAbstractParser { keyValue.setFiles(files); keyValues.add(keyValue); } - samplerProxy.getBody().setKvs(keyValues); + if (source.getPostBodyRaw() && CollectionUtils.isNotEmpty(keyValues)) { + samplerProxy.getBody().setType(Body.RAW); + samplerProxy.getBody().setRaw(keyValues.get(0).getValue()); + } else { + samplerProxy.getBody().setKvs(keyValues); + } } samplerProxy.setProtocol(RequestType.HTTP); samplerProxy.setPort(source.getPort() + ""); @@ -173,6 +178,7 @@ public class MsJmeterParser extends ApiImportAbstractParser { samplerProxy.setArguments(keyValues); } } + samplerProxy.getBody().initBinary(); } samplerProxy.setPath(""); samplerProxy.setMethod(source.getMethod()); diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java b/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java index f3f484b747..cabfccc0c4 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java @@ -74,6 +74,7 @@ public class Body { } } KeyValue keyValue = new KeyValue("", "JSON-SCHEMA", this.getRaw(), true, true); + sampler.setPostBodyRaw(true); keyValue.setEnable(true); keyValue.setEncode(false); body.add(keyValue); diff --git a/frontend/src/business/components/xpack b/frontend/src/business/components/xpack index 2115bd28a9..07951ba17a 160000 --- a/frontend/src/business/components/xpack +++ b/frontend/src/business/components/xpack @@ -1 +1 @@ -Subproject commit 2115bd28a90854d2b6276a90878934715498c584 +Subproject commit 07951ba17aef6f29e50cfd68e40de3266f9a60cd From 683430ec8d89c5a45709428d85f5e2a169eb8ab3 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Thu, 25 Mar 2021 18:11:58 +0800 Subject: [PATCH 09/17] =?UTF-8?q?refactor:=20jmeter=20=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/pom.xml b/backend/pom.xml index 55853f97ac..3af82d43e6 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -17,7 +17,7 @@ UTF-8 1.6.0 1.8 - 5.2.1 + 5.4.1 1.1.3 2.7.8 20.1.0 From d6a0feb4faaf454778aed26276105c4a097c00d0 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 25 Mar 2021 18:13:53 +0800 Subject: [PATCH 10/17] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8Djmx=E5=AF=BC=E5=85=A5=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E9=80=89=E9=A1=B9=E4=B8=8D=E8=83=BD=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/automation/parse/MsJmeterParser.java | 10 ++++------ .../java/io/metersphere/api/dto/scenario/Body.java | 8 ++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java b/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java index 0ce4456848..7cb52c524c 100644 --- a/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java +++ b/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java @@ -136,6 +136,8 @@ public class MsJmeterParser extends ApiImportAbstractParser { try { HTTPSamplerProxy source = (HTTPSamplerProxy) key; BeanUtils.copyBean(samplerProxy, source); + samplerProxy.setRest(new ArrayList(){{this.add(new KeyValue());}}); + samplerProxy.setArguments(new ArrayList(){{this.add(new KeyValue());}}); if (source != null && source.getHTTPFiles().length > 0) { samplerProxy.getBody().initBinary(); samplerProxy.getBody().setType(Body.FORM_DATA); @@ -153,12 +155,7 @@ public class MsJmeterParser extends ApiImportAbstractParser { keyValue.setFiles(files); keyValues.add(keyValue); } - if (source.getPostBodyRaw() && CollectionUtils.isNotEmpty(keyValues)) { - samplerProxy.getBody().setType(Body.RAW); - samplerProxy.getBody().setRaw(keyValues.get(0).getValue()); - } else { - samplerProxy.getBody().setKvs(keyValues); - } + samplerProxy.getBody().setKvs(keyValues); } samplerProxy.setProtocol(RequestType.HTTP); samplerProxy.setPort(source.getPort() + ""); @@ -168,6 +165,7 @@ public class MsJmeterParser extends ApiImportAbstractParser { source.getArguments().getArgumentsAsMap().forEach((k, v) -> { samplerProxy.getBody().setRaw(v); }); + samplerProxy.getBody().initKvs(); } else { List keyValues = new LinkedList<>(); source.getArguments().getArgumentsAsMap().forEach((k, v) -> { diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java b/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java index cabfccc0c4..4ae0e7d279 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java @@ -66,12 +66,8 @@ public class Body { sampler.setDoMultipart(true); } } else { - if (!this.isJson()) { - sampler.setPostBodyRaw(true); - } else { - if (StringUtils.isNotEmpty(this.format) && "JSON-SCHEMA".equals(this.format) && this.getJsonSchema() != null) { - this.raw = JSONSchemaGenerator.getJson(com.alibaba.fastjson.JSON.toJSONString(this.getJsonSchema())); - } + if (StringUtils.isNotEmpty(this.format) && "JSON-SCHEMA".equals(this.format) && this.getJsonSchema() != null) { + this.raw = JSONSchemaGenerator.getJson(com.alibaba.fastjson.JSON.toJSONString(this.getJsonSchema())); } KeyValue keyValue = new KeyValue("", "JSON-SCHEMA", this.getRaw(), true, true); sampler.setPostBodyRaw(true); From 150cb57836abe617e1abddfae520ddf5ff0085ec Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 25 Mar 2021 18:19:42 +0800 Subject: [PATCH 11/17] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8D=20csv=20=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/api/dto/definition/request/MsTestElement.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java index 5fa9333809..a7563bf58a 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java @@ -213,7 +213,7 @@ public abstract class MsTestElement { csvDataSet.setName(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName()); csvDataSet.setProperty("fileEncoding", StringUtils.isEmpty(item.getEncoding()) ? "UTF-8" : item.getEncoding()); if (CollectionUtils.isNotEmpty(item.getFiles())) { - if (!config.isOperating() && new File(BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName()).exists()) { + if (!config.isOperating() && !new File(BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName()).exists()) { MSException.throwException(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName() + ":[ CSV文件不存在 ]"); } csvDataSet.setProperty("filename", BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName()); From e3e799acf988b2906a491e87e1d721db7517707b Mon Sep 17 00:00:00 2001 From: "song.tianyang" Date: Thu, 25 Mar 2021 18:25:21 +0800 Subject: [PATCH 12/17] =?UTF-8?q?fix:=20=E6=8E=A5=E5=8F=A3=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E8=AF=B7=E6=B1=82=E5=86=85=E5=AE=B9=E4=B8=BA=20XML=20?= =?UTF-8?q?RAW=20=E6=A0=BC=E5=BC=8F=E6=97=B6=E6=96=87=E6=A1=A3=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 接口定义请求内容为 XML RAW 格式时文档模式报错 --- .../api/service/ApiDocumentService.java | 375 ++++++++++-------- 1 file changed, 204 insertions(+), 171 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDocumentService.java b/backend/src/main/java/io/metersphere/api/service/ApiDocumentService.java index 01ab101153..5a161efdc6 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDocumentService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDocumentService.java @@ -86,216 +86,240 @@ public class ApiDocumentService { apiInfoDTO.setStatus(apiModel.getStatus()); if (apiModel.getRequest() != null) { - JSONObject requestJsonObj = JSONObject.parseObject(apiModel.getRequest()); - //head赋值conversionModelToDTO - if (requestJsonObj.containsKey("headers")) { - JSONArray requestHeadDataArr = new JSONArray(); - //head赋值 - JSONArray headArr = requestJsonObj.getJSONArray("headers"); - for (int index = 0; index < headArr.size(); index++) { - JSONObject headObj = headArr.getJSONObject(index); - if (headObj.containsKey("name") && headObj.containsKey("value")) { - requestHeadDataArr.add(headObj); + JSONObject requestObj = this.genJSONObject(apiModel.getRequest()); + if(requestObj!=null){ + if (requestObj.containsKey("headers")) { + JSONArray requestHeadDataArr = new JSONArray(); + //head赋值 + JSONArray headArr = requestObj.getJSONArray("headers"); + for (int index = 0; index < headArr.size(); index++) { + JSONObject headObj = headArr.getJSONObject(index); + if (headObj.containsKey("name") && headObj.containsKey("value")) { + requestHeadDataArr.add(headObj); + } } + apiInfoDTO.setRequestHead(requestHeadDataArr.toJSONString()); } - apiInfoDTO.setRequestHead(requestHeadDataArr.toJSONString()); - } - //url参数赋值 - JSONArray urlParamArr = new JSONArray(); - if (requestJsonObj.containsKey("arguments")) { - //urlParam -- query赋值 - JSONArray headArr = requestJsonObj.getJSONArray("arguments"); - for (int index = 0; index < headArr.size(); index++) { - JSONObject headObj = headArr.getJSONObject(index); - if (headObj.containsKey("name") && headObj.containsKey("value")) { - urlParamArr.add(headObj); - } - } - } - if (requestJsonObj.containsKey("rest")) { - //urlParam -- rest赋值 - JSONArray headArr = requestJsonObj.getJSONArray("rest"); - for (int index = 0; index < headArr.size(); index++) { - JSONObject headObj = headArr.getJSONObject(index); - if (headObj.containsKey("name") && headObj.containsKey("value")) { - urlParamArr.add(headObj); - } - } - } - apiInfoDTO.setUrlParams(urlParamArr.toJSONString()); - //请求体参数类型 - if (requestJsonObj.containsKey("body")) { - JSONObject bodyObj = requestJsonObj.getJSONObject("body"); - if (bodyObj.containsKey("type")) { - String type = bodyObj.getString("type"); - if (StringUtils.equals(type, "WWW_FORM")) { - apiInfoDTO.setRequestBodyParamType("x-www-from-urlencoded"); - } else if (StringUtils.equals(type, "Form Data")) { - apiInfoDTO.setRequestBodyParamType("form-data"); - } else { - apiInfoDTO.setRequestBodyParamType(type); - } + //url参数赋值 + JSONArray urlParamArr = new JSONArray(); + if (requestObj.containsKey("arguments")) { + try{ + JSONArray headArr = requestObj.getJSONArray("arguments"); + for (int index = 0; index < headArr.size(); index++) { - if (StringUtils.equals(type, "JSON")) { - //判断是否是JsonSchema - boolean isJsonSchema = false; - if (bodyObj.containsKey("format")) { - String foramtValue = String.valueOf(bodyObj.get("format")); - if (StringUtils.equals("JSON-SCHEMA", foramtValue)) { - isJsonSchema = true; - } - } - if (isJsonSchema) { - apiInfoDTO.setRequestBodyParamType("JSON-SCHEMA"); - apiInfoDTO.setJsonSchemaBody(bodyObj); - } else { - if (bodyObj.containsKey("raw")) { - String raw = bodyObj.getString("raw"); - apiInfoDTO.setRequestBodyStrutureData(raw); - //转化jsonObje 或者 jsonArray - this.setPreviewData(previewJsonArray, raw); - } - } - } else if (StringUtils.equalsAny(type, "XML", "Raw")) { - if (bodyObj.containsKey("raw")) { - String raw = bodyObj.getString("raw"); - apiInfoDTO.setRequestBodyStrutureData(raw); - JSONObject previewObj = JSONObject.parseObject(raw); - this.setPreviewData(previewJsonArray, raw); - } - } else if (StringUtils.equalsAny(type, "Form Data", "WWW_FORM")) { - if (bodyObj.containsKey("kvs")) { - JSONArray bodyParamArr = new JSONArray(); - JSONArray kvsArr = bodyObj.getJSONArray("kvs"); - Map previewObjMap = new LinkedHashMap<>(); - for (int i = 0; i < kvsArr.size(); i++) { - JSONObject kv = kvsArr.getJSONObject(i); - if (kv.containsKey("name") && kv.containsKey("value")) { - bodyParamArr.add(kv); - previewObjMap.put(String.valueOf(kv.get("name")), String.valueOf(kv.get("value"))); + JSONObject headObj = headArr.getJSONObject(index); + if (headObj.containsKey("name") && headObj.containsKey("value")) { + urlParamArr.add(headObj); } - } - this.setPreviewData(previewJsonArray, JSONObject.toJSONString(previewObjMap)); - apiInfoDTO.setRequestBodyFormData(bodyParamArr.toJSONString()); } - } else if (StringUtils.equals(type, "BINARY")) { - if (bodyObj.containsKey("binary")) { - List> bodyParamList = new ArrayList<>(); - JSONArray kvsArr = bodyObj.getJSONArray("binary"); + }catch (Exception e){ + } + } + if (requestObj.containsKey("rest")) { + try{ + //urlParam -- rest赋值 + JSONArray headArr = requestObj.getJSONArray("rest"); + for (int index = 0; index < headArr.size(); index++) { + JSONObject headObj = headArr.getJSONObject(index); + if (headObj.containsKey("name") && headObj.containsKey("value")) { + urlParamArr.add(headObj); + } + } + }catch (Exception e){ + } + } + apiInfoDTO.setUrlParams(urlParamArr.toJSONString()); + //请求体参数类型 + if (requestObj.containsKey("body")) { + try{ + JSONObject bodyObj = requestObj.getJSONObject("body"); + if (bodyObj.containsKey("type")) { + String type = bodyObj.getString("type"); + if (StringUtils.equals(type, "WWW_FORM")) { + apiInfoDTO.setRequestBodyParamType("x-www-from-urlencoded"); + } else if (StringUtils.equals(type, "Form Data")) { + apiInfoDTO.setRequestBodyParamType("form-data"); + } else { + apiInfoDTO.setRequestBodyParamType(type); + } - Map previewObjMap = new LinkedHashMap<>(); - for (int i = 0; i < kvsArr.size(); i++) { - JSONObject kv = kvsArr.getJSONObject(i); - if (kv.containsKey("description") && kv.containsKey("files")) { - Map bodyMap = new HashMap<>(); - String name = kv.getString("description"); - JSONArray fileArr = kv.getJSONArray("files"); - String value = ""; - for (int j = 0; j < fileArr.size(); j++) { - JSONObject fileObj = fileArr.getJSONObject(j); - if (fileObj.containsKey("name")) { - value += fileObj.getString("name") + " ;"; + if (StringUtils.equals(type, "JSON")) { + //判断是否是JsonSchema + boolean isJsonSchema = false; + if (bodyObj.containsKey("format")) { + String foramtValue = String.valueOf(bodyObj.get("format")); + if (StringUtils.equals("JSON-SCHEMA", foramtValue)) { + isJsonSchema = true; + } + } + if (isJsonSchema) { + apiInfoDTO.setRequestBodyParamType("JSON-SCHEMA"); + apiInfoDTO.setJsonSchemaBody(bodyObj); + } else { + if (bodyObj.containsKey("raw")) { + String raw = bodyObj.getString("raw"); + apiInfoDTO.setRequestBodyStrutureData(raw); + //转化jsonObje 或者 jsonArray + this.setPreviewData(previewJsonArray, raw); + } + } + } else if (StringUtils.equalsAny(type, "XML", "Raw")) { + if (bodyObj.containsKey("raw")) { + String raw = bodyObj.getString("raw"); + apiInfoDTO.setRequestBodyStrutureData(raw); + this.setPreviewData(previewJsonArray, raw); + } + } else if (StringUtils.equalsAny(type, "Form Data", "WWW_FORM")) { + if (bodyObj.containsKey("kvs")) { + JSONArray bodyParamArr = new JSONArray(); + JSONArray kvsArr = bodyObj.getJSONArray("kvs"); + Map previewObjMap = new LinkedHashMap<>(); + for (int i = 0; i < kvsArr.size(); i++) { + JSONObject kv = kvsArr.getJSONObject(i); + if (kv.containsKey("name") && kv.containsKey("value")) { + bodyParamArr.add(kv); + previewObjMap.put(String.valueOf(kv.get("name")), String.valueOf(kv.get("value"))); } } - bodyMap.put("name", name); - bodyMap.put("value", value); - bodyMap.put("contentType", "File"); - bodyParamList.add(bodyMap); + this.setPreviewData(previewJsonArray, JSONObject.toJSONString(previewObjMap)); + apiInfoDTO.setRequestBodyFormData(bodyParamArr.toJSONString()); + } + } else if (StringUtils.equals(type, "BINARY")) { + if (bodyObj.containsKey("binary")) { + List> bodyParamList = new ArrayList<>(); + JSONArray kvsArr = bodyObj.getJSONArray("binary"); - previewObjMap.put(String.valueOf(name), String.valueOf(value)); + Map previewObjMap = new LinkedHashMap<>(); + for (int i = 0; i < kvsArr.size(); i++) { + JSONObject kv = kvsArr.getJSONObject(i); + if (kv.containsKey("description") && kv.containsKey("files")) { + Map bodyMap = new HashMap<>(); + String name = kv.getString("description"); + JSONArray fileArr = kv.getJSONArray("files"); + String value = ""; + for (int j = 0; j < fileArr.size(); j++) { + JSONObject fileObj = fileArr.getJSONObject(j); + if (fileObj.containsKey("name")) { + value += fileObj.getString("name") + " ;"; + } + } + bodyMap.put("name", name); + bodyMap.put("value", value); + bodyMap.put("contentType", "File"); + bodyParamList.add(bodyMap); + previewObjMap.put(String.valueOf(name), String.valueOf(value)); + + } + } + this.setPreviewData(previewJsonArray, JSONObject.toJSONString(previewObjMap)); + apiInfoDTO.setRequestBodyFormData(JSONArray.toJSONString(bodyParamList)); } } - this.setPreviewData(previewJsonArray, JSONObject.toJSONString(previewObjMap)); - apiInfoDTO.setRequestBodyFormData(JSONArray.toJSONString(bodyParamList)); } + }catch (Exception e){ + } + } } } //赋值响应头 if (apiModel.getResponse() != null) { - JSONObject responseJsonObj = JSONObject.parseObject(apiModel.getResponse()); + JSONObject responseJsonObj = this.genJSONObject(apiModel.getResponse()); if (responseJsonObj!=null && responseJsonObj.containsKey("headers")) { - JSONArray responseHeadDataArr = new JSONArray(); - JSONArray headArr = responseJsonObj.getJSONArray("headers"); - for (int index = 0; index < headArr.size(); index++) { - JSONObject headObj = headArr.getJSONObject(index); - if (headObj.containsKey("name") && headObj.containsKey("value")) { - responseHeadDataArr.add(headObj); + try{ + JSONArray responseHeadDataArr = new JSONArray(); + JSONArray headArr = responseJsonObj.getJSONArray("headers"); + for (int index = 0; index < headArr.size(); index++) { + JSONObject headObj = headArr.getJSONObject(index); + if (headObj.containsKey("name") && headObj.containsKey("value")) { + responseHeadDataArr.add(headObj); + } } + apiInfoDTO.setResponseHead(responseHeadDataArr.toJSONString()); + }catch (Exception e){ + } - apiInfoDTO.setResponseHead(responseHeadDataArr.toJSONString()); } // 赋值响应体 if (responseJsonObj!=null && responseJsonObj.containsKey("body")) { - JSONObject bodyObj = responseJsonObj.getJSONObject("body"); - if (bodyObj.containsKey("type")) { - String type = bodyObj.getString("type"); - if (StringUtils.equals(type, "WWW_FORM")) { - apiInfoDTO.setResponseBodyParamType("x-www-from-urlencoded"); - } else if (StringUtils.equals(type, "Form Data")) { - apiInfoDTO.setResponseBodyParamType("form-data"); - } else { - apiInfoDTO.setResponseBodyParamType(type); - } - if (StringUtils.equalsAny(type, "JSON", "XML", "Raw")) { - if (bodyObj.containsKey("raw")) { - String raw = bodyObj.getString("raw"); - apiInfoDTO.setResponseBodyStrutureData(raw); + try { + JSONObject bodyObj = responseJsonObj.getJSONObject("body"); + if (bodyObj.containsKey("type")) { + String type = bodyObj.getString("type"); + if (StringUtils.equals(type, "WWW_FORM")) { + apiInfoDTO.setResponseBodyParamType("x-www-from-urlencoded"); + } else if (StringUtils.equals(type, "Form Data")) { + apiInfoDTO.setResponseBodyParamType("form-data"); + } else { + apiInfoDTO.setResponseBodyParamType(type); } - } else if (StringUtils.equalsAny(type, "Form Data", "WWW_FORM")) { - if (bodyObj.containsKey("kvs")) { - JSONArray bodyParamArr = new JSONArray(); - JSONArray kvsArr = bodyObj.getJSONArray("kvs"); - for (int i = 0; i < kvsArr.size(); i++) { - JSONObject kv = kvsArr.getJSONObject(i); - if (kv.containsKey("name")) { - bodyParamArr.add(kv); - } + if (StringUtils.equalsAny(type, "JSON", "XML", "Raw")) { + if (bodyObj.containsKey("raw")) { + String raw = bodyObj.getString("raw"); + apiInfoDTO.setResponseBodyStrutureData(raw); } - apiInfoDTO.setResponseBodyFormData(bodyParamArr.toJSONString()); - } - } else if (StringUtils.equals(type, "BINARY")) { - if (bodyObj.containsKey("binary")) { - List> bodyParamList = new ArrayList<>(); - JSONArray kvsArr = bodyObj.getJSONArray("kvs"); - for (int i = 0; i < kvsArr.size(); i++) { - JSONObject kv = kvsArr.getJSONObject(i); - if (kv.containsKey("description") && kv.containsKey("files")) { - Map bodyMap = new HashMap<>(); - - String name = kv.getString("description"); - JSONArray fileArr = kv.getJSONArray("files"); - String value = ""; - for (int j = 0; j < fileArr.size(); j++) { - JSONObject fileObj = fileArr.getJSONObject(j); - if (fileObj.containsKey("name")) { - value += fileObj.getString("name") + " ;"; - } + } else if (StringUtils.equalsAny(type, "Form Data", "WWW_FORM")) { + if (bodyObj.containsKey("kvs")) { + JSONArray bodyParamArr = new JSONArray(); + JSONArray kvsArr = bodyObj.getJSONArray("kvs"); + for (int i = 0; i < kvsArr.size(); i++) { + JSONObject kv = kvsArr.getJSONObject(i); + if (kv.containsKey("name")) { + bodyParamArr.add(kv); } - bodyMap.put("name", name); - bodyMap.put("value", value); - bodyParamList.add(bodyMap); } + apiInfoDTO.setResponseBodyFormData(bodyParamArr.toJSONString()); + } + } else if (StringUtils.equals(type, "BINARY")) { + if (bodyObj.containsKey("binary")) { + List> bodyParamList = new ArrayList<>(); + JSONArray kvsArr = bodyObj.getJSONArray("kvs"); + for (int i = 0; i < kvsArr.size(); i++) { + JSONObject kv = kvsArr.getJSONObject(i); + if (kv.containsKey("description") && kv.containsKey("files")) { + Map bodyMap = new HashMap<>(); + + String name = kv.getString("description"); + JSONArray fileArr = kv.getJSONArray("files"); + String value = ""; + for (int j = 0; j < fileArr.size(); j++) { + JSONObject fileObj = fileArr.getJSONObject(j); + if (fileObj.containsKey("name")) { + value += fileObj.getString("name") + " ;"; + } + } + bodyMap.put("name", name); + bodyMap.put("value", value); + bodyParamList.add(bodyMap); + } + } + apiInfoDTO.setResponseBodyFormData(JSONArray.toJSONString(bodyParamList)); } - apiInfoDTO.setResponseBodyFormData(JSONArray.toJSONString(bodyParamList)); } } + }catch (Exception e){ + } + } // 赋值响应码 if (responseJsonObj!=null && responseJsonObj.containsKey("statusCode")) { - JSONArray responseStatusDataArr = new JSONArray(); - JSONArray statusArr = responseJsonObj.getJSONArray("statusCode"); - for (int index = 0; index < statusArr.size(); index++) { - JSONObject statusObj = statusArr.getJSONObject(index); - if (statusObj.containsKey("name") && statusObj.containsKey("value")) { - responseStatusDataArr.add(statusObj); + try { + JSONArray responseStatusDataArr = new JSONArray(); + JSONArray statusArr = responseJsonObj.getJSONArray("statusCode"); + for (int index = 0; index < statusArr.size(); index++) { + JSONObject statusObj = statusArr.getJSONObject(index); + if (statusObj.containsKey("name") && statusObj.containsKey("value")) { + responseStatusDataArr.add(statusObj); + } } + apiInfoDTO.setResponseCode(responseStatusDataArr.toJSONString()); + }catch (Exception e){ + } - apiInfoDTO.setResponseCode(responseStatusDataArr.toJSONString()); } } } @@ -304,6 +328,15 @@ public class ApiDocumentService { return apiInfoDTO; } + private JSONObject genJSONObject(String request) { + JSONObject returnObj = null; + try{ + returnObj = JSONObject.parseObject(request); + }catch (Exception e){ + } + return returnObj; + } + private void setPreviewData(JSONArray previewArray, String data) { try { JSONObject previewObj = JSONObject.parseObject(data); From a8b54c9d74901918fae6e0720031f354f4076122 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Thu, 25 Mar 2021 18:33:03 +0800 Subject: [PATCH 13/17] =?UTF-8?q?refactor:=20=E6=89=93=E5=BC=80=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E9=85=8D=E7=BD=AE=E6=97=B6=E9=BB=98=E8=AE=A4=E9=80=89?= =?UTF-8?q?=E4=B8=AD=E5=BD=93=E5=89=8D=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/automation/scenario/EnvSelect.vue | 8 ++++---- .../components/case/MsEnvironmentSelect.vue | 2 +- .../environment/ApiEnvironmentConfig.vue | 17 ++++++++++++++--- .../test/components/ApiEnvironmentConfig.vue | 17 ++++++++++++++--- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/EnvSelect.vue b/frontend/src/business/components/api/automation/scenario/EnvSelect.vue index c9eda69790..87c62495f0 100644 --- a/frontend/src/business/components/api/automation/scenario/EnvSelect.vue +++ b/frontend/src/business/components/api/automation/scenario/EnvSelect.vue @@ -5,12 +5,12 @@ - + {{ $t('api_test.environment.environment_config') }} @@ -42,6 +42,7 @@ v-model="threadGroup.threadNumber" @change="calculateTotalChart(threadGroup)" :min="resourcePoolResourceLength" + :max="maxThreadNumbers" size="mini"/>
@@ -219,7 +220,8 @@ export default { resourcePools: [], activeNames: ["0"], threadGroups: [], - resourcePoolResourceLength: 1 + resourcePoolResourceLength: 1, + maxThreadNumbers: 5000, } }, mounted() { @@ -336,6 +338,22 @@ export default { }); } }, + resourcePoolChange() { + let result = this.resourcePools.filter(p => p.id === this.resourcePool); + if (result.length === 1) { + let threadNumber = 0; + result[0].resources.forEach(resource => { + threadNumber += JSON.parse(resource.configuration).maxConcurrency; + }) + this.maxThreadNumbers = threadNumber; + this.threadGroups.forEach(tg => { + if (tg.threadNumber > threadNumber) { + this.$set(tg, "threadNumber", threadNumber); + } + }) + this.calculateTotalChart(); + } + }, calculateTotalChart() { let handler = this; if (handler.duration < handler.rampUpTime) { @@ -344,6 +362,11 @@ export default { if (handler.rampUpTime < handler.step) { handler.step = handler.rampUpTime; } + // 线程数不能小于资源池节点的数量 + let resourcePool = this.resourcePools.filter(v => v.id === this.resourcePool)[0]; + if (resourcePool) { + this.resourcePoolResourceLength = resourcePool.resources.length; + } let color = ['#60acfc', '#32d3eb', '#5bc49f', '#feb64d', '#ff7c7c', '#9287e7', '#ca8622', '#bda29a', '#6e7074', '#546570', '#c4ccd3']; handler.options = { color: color, @@ -649,7 +672,7 @@ export default { border-bottom: 1px solid #DCDFE6; } -/deep/ .el-collapse-item__content{ +/deep/ .el-collapse-item__content { padding-left: 10px; padding-bottom: 5px; border-left-width: 8px; From ef6c7ae83cafa33344b8c3cc60e36d8475b80230 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Thu, 25 Mar 2021 19:26:42 +0800 Subject: [PATCH 16/17] chore: sync --- frontend/src/business/components/xpack | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/business/components/xpack b/frontend/src/business/components/xpack index 07951ba17a..2115bd28a9 160000 --- a/frontend/src/business/components/xpack +++ b/frontend/src/business/components/xpack @@ -1 +1 @@ -Subproject commit 07951ba17aef6f29e50cfd68e40de3266f9a60cd +Subproject commit 2115bd28a90854d2b6276a90878934715498c584 From 767faf9dfe9032ede1ccb89d57f3696a91eb1c39 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Fri, 26 Mar 2021 09:52:03 +0800 Subject: [PATCH 17/17] =?UTF-8?q?fix:=20=E5=B0=9D=E8=AF=95=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E8=A1=A8=E6=A0=BC=E5=9B=BA=E5=AE=9A=E5=88=97=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=E9=94=99=E4=B9=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/api/automation/scenario/ApiScenarioList.vue | 2 +- .../api/definition/components/list/ApiCaseSimpleList.vue | 2 +- .../components/api/definition/components/list/ApiList.vue | 2 +- .../business/components/track/case/components/TestCaseList.vue | 2 +- .../plan/view/comonents/functional/FunctionalTestCaseList.vue | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue index d71c832f56..7334643973 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue @@ -433,7 +433,7 @@ this.result.loading = false; this.unSelection = data.listObject.map(s => s.id); if (this.$refs.scenarioTable) { - setTimeout(this.$refs.scenarioTable.doLayout,500) + setTimeout(this.$refs.scenarioTable.doLayout, 200) } }); } diff --git a/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue b/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue index 48f4e2e212..6437c94123 100644 --- a/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue +++ b/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue @@ -340,7 +340,7 @@ export default { } }) if (this.$refs.caseTable) { - setTimeout(this.$refs.caseTable.doLayout,500) + setTimeout(this.$refs.caseTable.doLayout, 200) } }); } diff --git a/frontend/src/business/components/api/definition/components/list/ApiList.vue b/frontend/src/business/components/api/definition/components/list/ApiList.vue index 46ffe54bea..7ec2982c49 100644 --- a/frontend/src/business/components/api/definition/components/list/ApiList.vue +++ b/frontend/src/business/components/api/definition/components/list/ApiList.vue @@ -464,7 +464,7 @@ } }) if (this.$refs.apiDefinitionTable) { - setTimeout(this.$refs.apiDefinitionTable.doLayout, 500) + setTimeout(this.$refs.apiDefinitionTable.doLayout, 200) } }); diff --git a/frontend/src/business/components/track/case/components/TestCaseList.vue b/frontend/src/business/components/track/case/components/TestCaseList.vue index 2b0ec84d70..8a6220194d 100644 --- a/frontend/src/business/components/track/case/components/TestCaseList.vue +++ b/frontend/src/business/components/track/case/components/TestCaseList.vue @@ -399,7 +399,7 @@ export default { item.tags = JSON.parse(item.tags); }) if (this.$refs.table) { - setTimeout(this.$refs.table.doLayout,500) + setTimeout(this.$refs.table.doLayout, 200) } }); diff --git a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue index b3682c0801..5117b039af 100644 --- a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue +++ b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue @@ -477,7 +477,7 @@ export default { } this.selectRows.clear(); if (this.$refs.table) { - setTimeout(this.$refs.table.doLayout,500) + setTimeout(this.$refs.table.doLayout, 200) } }); }