From 57e971a3576d2a2a837a06cd5cef9b627ccb356d Mon Sep 17 00:00:00 2001 From: "song.tianyang" Date: Wed, 20 Jan 2021 16:43:32 +0800 Subject: [PATCH 1/5] fix: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复场景步骤标题未显示的问题、修复测试计划的性能测试任务结束回调时资源占用的问题 --- .../base/mapper/ext/ExtTestPlanMapper.xml | 1 + .../commons/constants/ReportTriggerMode.java | 3 +- .../job/sechedule/TestPlanTestJob.java | 2 +- .../track/dto/TestPlanLoadCaseEventDTO.java | 17 ++++++ .../track/service/TestPlanLoadCaseEvent.java | 12 ++-- .../track/service/TestPlanReportService.java | 55 +++---------------- .../automation/scenario/EditApiScenario.vue | 2 +- .../tableItem/ReportTriggerModeItem.vue | 1 + 8 files changed, 39 insertions(+), 54 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/track/dto/TestPlanLoadCaseEventDTO.java diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml index f8ef55cc26..53d54f2994 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml @@ -238,6 +238,7 @@ \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/commons/constants/ReportTriggerMode.java b/backend/src/main/java/io/metersphere/commons/constants/ReportTriggerMode.java index af66fc3761..a202ba4ec4 100644 --- a/backend/src/main/java/io/metersphere/commons/constants/ReportTriggerMode.java +++ b/backend/src/main/java/io/metersphere/commons/constants/ReportTriggerMode.java @@ -7,5 +7,6 @@ public enum ReportTriggerMode { /** * 性能测试用例执行触发报告 */ - CASE + CASE, + TEST_PLAN_SCHEDULE } diff --git a/backend/src/main/java/io/metersphere/job/sechedule/TestPlanTestJob.java b/backend/src/main/java/io/metersphere/job/sechedule/TestPlanTestJob.java index b7aa8bd4c7..a2f87e9011 100644 --- a/backend/src/main/java/io/metersphere/job/sechedule/TestPlanTestJob.java +++ b/backend/src/main/java/io/metersphere/job/sechedule/TestPlanTestJob.java @@ -141,7 +141,7 @@ public class TestPlanTestJob extends MsScheduleJob { RunTestPlanRequest performanceRequest = new RunTestPlanRequest(); performanceRequest.setId(caseID); performanceRequest.setTestPlanLoadId(caseID); - performanceRequest.setTriggerMode(ReportTriggerMode.SCHEDULE.name()); + performanceRequest.setTriggerMode(ReportTriggerMode.TEST_PLAN_SCHEDULE.name()); String reportId = null; try { diff --git a/backend/src/main/java/io/metersphere/track/dto/TestPlanLoadCaseEventDTO.java b/backend/src/main/java/io/metersphere/track/dto/TestPlanLoadCaseEventDTO.java new file mode 100644 index 0000000000..a18ba21dfe --- /dev/null +++ b/backend/src/main/java/io/metersphere/track/dto/TestPlanLoadCaseEventDTO.java @@ -0,0 +1,17 @@ +package io.metersphere.track.dto; + +import lombok.Getter; +import lombok.Setter; + +/** + * @author song.tianyang + * @Date 2021/1/20 4:07 下午 + * @Description 测试计划性能测试执行完毕后的回调参数 + */ +@Getter +@Setter +public class TestPlanLoadCaseEventDTO { + private String reportId; + private String triggerMode; + private String status; +} diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseEvent.java b/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseEvent.java index 0a9cb14d7a..5541556205 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseEvent.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseEvent.java @@ -7,6 +7,7 @@ import io.metersphere.commons.constants.PerformanceTestStatus; import io.metersphere.commons.constants.ReportTriggerMode; import io.metersphere.commons.consumer.LoadTestFinishEvent; import io.metersphere.commons.utils.LogUtil; +import io.metersphere.track.dto.TestPlanLoadCaseEventDTO; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -25,11 +26,12 @@ public class TestPlanLoadCaseEvent implements LoadTestFinishEvent { @Override public void execute(LoadTestReport loadTestReport) { LogUtil.info("PerformanceNoticeEvent OVER:" + loadTestReport.getTriggerMode()+";"+loadTestReport.getStatus()); - if (StringUtils.equals(NoticeConstants.Mode.SCHEDULE, loadTestReport.getTriggerMode()) ) { - if (StringUtils.equalsAny(loadTestReport.getStatus(), - PerformanceTestStatus.Completed.name(), PerformanceTestStatus.Error.name())) { - testPlanReportService.updatePerformanceTestStatus(loadTestReport.getId(), ReportTriggerMode.SCHEDULE.name()); - } + if (StringUtils.equals(ReportTriggerMode.TEST_PLAN_SCHEDULE.name(), loadTestReport.getTriggerMode()) ) { + TestPlanLoadCaseEventDTO eventDTO = new TestPlanLoadCaseEventDTO(); + eventDTO.setReportId(loadTestReport.getId()); + eventDTO.setTriggerMode(ReportTriggerMode.SCHEDULE.name()); + eventDTO.setStatus(loadTestReport.getStatus()); + testPlanReportService.updatePerformanceTestStatus(eventDTO); } } } 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 538cf14dc2..4ff490f8fe 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -199,6 +199,7 @@ public class TestPlanReportService { QueryTestPlanRequest queryTestPlanRequest = new QueryTestPlanRequest(); queryTestPlanRequest.setId(testPlanReport.getTestPlanId()); TestPlanDTO testPlan = extTestPlanMapper.list(queryTestPlanRequest).get(0); + String issuesInfo = null; //因为接口案例的定时任务是单个案例开线程运行, 所以要检查是否都执行完成。全部执行完成时才会进行统一整理 if (StringUtils.equals(ReportTriggerMode.SCHEDULE.name(),triggerMode) @@ -209,6 +210,8 @@ public class TestPlanReportService { return; } } + }else if(StringUtils.equals(ReportTriggerMode.TEST_PLAN_SCHEDULE.name(),triggerMode)){ + issuesInfo = ReportTriggerMode.TEST_PLAN_SCHEDULE.name(); } testPlanReport.setEndTime(System.currentTimeMillis()); @@ -251,6 +254,9 @@ public class TestPlanReportService { testPlanReportData.setExecuteResult(JSONObject.toJSONString(testCaseReportMetricDTO.getExecuteResult())); testPlanReportData.setFailurTestCases(JSONObject.toJSONString(testCaseReportMetricDTO.getFailureTestCases())); testPlanReportData.setModuleExecuteResult(JSONArray.toJSONString(testCaseReportMetricDTO.getModuleExecuteResult())); + if(issuesInfo!=null){ + testPlanReportData.setIssuesInfo(issuesInfo); + } testPlanReportDataMapper.updateByPrimaryKeyWithBLOBs(testPlanReportData); } @@ -336,54 +342,11 @@ public class TestPlanReportService { models.setPerformanceInfo(JSONArray.toJSONString(performaneReportIDList)); testPlanReportDataMapper.updateByPrimaryKeyWithBLOBs(models); } - - /** - * 虽然kafka已经设置了topic推送,但是在1.18日测试时发现无法收到消息。 - * 由于Tapd为完成任务较多,无法抽时间查看问题,暂时先保留以下逻辑,解决完Tpad任务之后查看原因,再删除以下代码 - */ - executorService.submit(() -> { - //错误数据检查集合。 如果错误数据出现超过20次,则取消该条数据的检查 - Map errorDataCheckMap = new HashMap<>(); - while (performaneReportIDList.size()>0) { - List selectList = new ArrayList<>(performaneReportIDList); - for (String loadTestReportId:selectList) { - LoadTestReportWithBLOBs loadTestReportFromDatabase = loadTestReportMapper.selectByPrimaryKey(loadTestReportId); - if(loadTestReportFromDatabase == null){ - //检查错误数据 - if(errorDataCheckMap.containsKey(loadTestReportId)){ - if(errorDataCheckMap.get(loadTestReportId)>20){ - performaneReportIDList.remove(loadTestReportId); - }else { - errorDataCheckMap.put(loadTestReportId,errorDataCheckMap.get(loadTestReportId)+1); - } - }else { - errorDataCheckMap.put(loadTestReportId,1); - } - }else if (StringUtils.equalsAny(loadTestReportFromDatabase.getStatus(), - PerformanceTestStatus.Completed.name(), PerformanceTestStatus.Error.name())) { - performaneReportIDList.remove(loadTestReportId); - System.out.println("over"); - } - } - if(performaneReportIDList.isEmpty()){ - List testPlanReportList = new ArrayList<>(); - testPlanReportList.add(testPlanReport.getId()); - this.updateReport(testPlanReportList, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name(),triggerMode); - }else { - try { - //查询定时任务是否关闭 - Thread.sleep(1000 * 10);// 检查 loadtest 的状态 - } catch (InterruptedException e) { - } - } - } - return true; - }); } - public void updatePerformanceTestStatus(String reportId,String triggerMode) { - List testPlanReportId = extTestPlanMapper.findIdByPerformanceReportId(reportId); - this.updateReport(testPlanReportId, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name(),triggerMode); + public void updatePerformanceTestStatus(TestPlanLoadCaseEventDTO eventDTO) { + List testPlanReportId = extTestPlanMapper.findIdByPerformanceReportId(eventDTO.getReportId()); + this.updateReport(testPlanReportId, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name(),eventDTO.getTriggerMode()); } public void delete(List testPlanReportIdList) { diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 22e5fee3b1..f0843743bf 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -92,7 +92,7 @@
-

{{$t('api_test.automation.scenario_stepscenario_step')}}

+

{{$t('api_test.automation.scenario_step')}}

diff --git a/frontend/src/business/components/common/tableItem/ReportTriggerModeItem.vue b/frontend/src/business/components/common/tableItem/ReportTriggerModeItem.vue index 5b19b9d4ab..91ff1f1c4e 100644 --- a/frontend/src/business/components/common/tableItem/ReportTriggerModeItem.vue +++ b/frontend/src/business/components/common/tableItem/ReportTriggerModeItem.vue @@ -2,6 +2,7 @@ {{$t('commons.trigger_mode.manual')}} {{$t('commons.trigger_mode.schedule')}} + {{$t('commons.trigger_mode.schedule')}} {{$t('commons.trigger_mode.api')}} 用例触发 From 9dea1d11ea69b228ff6f4d5120c9fea8eb1a6bd7 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 20 Jan 2021 16:49:54 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89):?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E5=86=99=E8=BD=AC=E6=8D=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/definition/components/complete/EditCompleteHTTPApi.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/business/components/api/definition/components/complete/EditCompleteHTTPApi.vue b/frontend/src/business/components/api/definition/components/complete/EditCompleteHTTPApi.vue index b07e98b3b5..4530217333 100644 --- a/frontend/src/business/components/api/definition/components/complete/EditCompleteHTTPApi.vue +++ b/frontend/src/business/components/api/definition/components/complete/EditCompleteHTTPApi.vue @@ -202,7 +202,7 @@ export default { if (!this.httpForm.path || this.httpForm.path.indexOf('?') === -1) return; let url = this.getURL(this.addProtocol(this.httpForm.path)); if (url) { - this.httpForm.path = decodeURIComponent("/" + url.hostname + url.pathname); + this.httpForm.path = decodeURIComponent(this.httpForm.path.substr(0,this.httpForm.path.indexOf("?"))); } }, addProtocol(url) { From 9d49124fc7d4a59b3d496c57257e7966296e1e8a Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Wed, 20 Jan 2021 16:53:27 +0800 Subject: [PATCH 3/5] =?UTF-8?q?feat:=20=E5=88=97=E8=A1=A8=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E6=A0=B9=E6=8D=AEtag=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml | 3 ++- .../io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml | 2 +- .../io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml index 312a471fe4..6751e067fd 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml @@ -218,7 +218,8 @@ - and api_definition.name like CONCAT('%', #{request.name},'%') + and (api_definition.name like CONCAT('%', #{request.name},'%') + or api_definition.tags like CONCAT('%', #{request.name},'%')) AND api_definition.protocol = #{request.protocol} diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml index 0de6fad92b..aad982b1f3 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml @@ -114,7 +114,7 @@ - and api_scenario.name like CONCAT('%', #{request.name},'%') + and (api_scenario.name like CONCAT('%', #{request.name},'%') or api_scenario.tags like CONCAT('%', #{request.name},'%')) AND project.workspace_id = #{request.workspaceId} diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml index 21a2253880..2e56a4b202 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml @@ -278,8 +278,9 @@ - and (test_case.name like CONCAT('%', #{request.name},'%') or test_case.num like CONCAT('%', - #{request.name},'%')) + and (test_case.name like CONCAT('%', #{request.name},'%') + or test_case.num like CONCAT('%', #{request.name},'%') + or test_case.tags like CONCAT('%', #{request.name},'%')) and test_case.node_id in From 45c65497ce11ff5ef640b9a175f880320495f83f Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Wed, 20 Jan 2021 17:15:41 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20=E7=94=A8=E6=88=B7=E4=B8=8D=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E6=97=B6=E5=80=99=E6=8F=90=E7=A4=BA=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #1091 --- .../main/java/io/metersphere/security/realm/ShiroDBRealm.java | 4 ++-- backend/src/main/resources/i18n/messages_en_US.properties | 2 +- backend/src/main/resources/i18n/messages_zh_CN.properties | 2 +- backend/src/main/resources/i18n/messages_zh_TW.properties | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/io/metersphere/security/realm/ShiroDBRealm.java b/backend/src/main/java/io/metersphere/security/realm/ShiroDBRealm.java index 3d4a5ed12d..6fc4f95698 100644 --- a/backend/src/main/java/io/metersphere/security/realm/ShiroDBRealm.java +++ b/backend/src/main/java/io/metersphere/security/realm/ShiroDBRealm.java @@ -105,7 +105,7 @@ public class ShiroDBRealm extends AuthorizingRealm { if (user == null) { msg = "The user does not exist: " + userId; logger.warn(msg); - throw new UnknownAccountException(Translator.get("user_not_exist") + userId); + throw new UnknownAccountException(Translator.get("password_is_incorrect") + userId); } } return user; @@ -119,7 +119,7 @@ public class ShiroDBRealm extends AuthorizingRealm { if (user == null) { msg = "The user does not exist: " + userId; logger.warn(msg); - throw new UnknownAccountException(Translator.get("user_not_exist") + userId); + throw new UnknownAccountException(Translator.get("password_is_incorrect") + userId); } userId = user.getId(); } diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 8ccf687304..1a5222966c 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -20,7 +20,7 @@ password_modification_failed=The old password is wrong. Please re-enter it cannot_delete_current_user=Cannot delete the user currently logged in user_already_exists=The user already exists in the current member list cannot_remove_current=Unable to remove the currently logged in user -password_is_incorrect=Incorrect password +password_is_incorrect=Incorrect password or username user_not_exist=user does not exist: user_has_been_disabled=the user has been disabled. excessive_attempts=Excessive attempts diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 30d7aa1353..2d077f1e49 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -21,7 +21,7 @@ connection_failed=连接失败 user_already_exists=该用户已存在于当前成员列表中 cannot_remove_current=无法移除当前登录用户 login_fail=登录失败 -password_is_incorrect=密码不正确 +password_is_incorrect=用户名或密码不正确 user_not_exist=用户不存在: user_has_been_disabled=用户已被禁用 excessive_attempts=操作频繁 diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 5d5eff1963..7314bdecaa 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -20,7 +20,7 @@ password_modification_failed=舊密碼輸入錯誤,請重新輸入 cannot_delete_current_user=無法刪除當前登錄用戶 user_already_exists=該用戶已存在於當前成員列表中 cannot_remove_current=無法移除當前登錄用戶 -password_is_incorrect=密碼不正確 +password_is_incorrect=用戶名或密碼不正確 user_not_exist=用戶不存在: user_has_been_disabled=用戶已被禁用 excessive_attempts=操作頻繁 From bf0bff3b0a1ec8c163b8687adad837de29f0a239 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Wed, 20 Jan 2021 17:34:45 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E7=9A=84=E6=97=B6=E5=80=99=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=8F=8A=E6=97=B6=E5=88=B7=E6=96=B0=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/components/track/case/components/TestCaseEdit.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/business/components/track/case/components/TestCaseEdit.vue b/frontend/src/business/components/track/case/components/TestCaseEdit.vue index ff9667f901..97c21c59da 100644 --- a/frontend/src/business/components/track/case/components/TestCaseEdit.vue +++ b/frontend/src/business/components/track/case/components/TestCaseEdit.vue @@ -3,7 +3,7 @@ + :visible.sync="dialogFormVisible" width="85%" v-if="dialogFormVisible">