diff --git a/backend/src/main/java/io/metersphere/api/controller/APITestController.java b/backend/src/main/java/io/metersphere/api/controller/APITestController.java index c45fdb9f25..78b90cec9f 100644 --- a/backend/src/main/java/io/metersphere/api/controller/APITestController.java +++ b/backend/src/main/java/io/metersphere/api/controller/APITestController.java @@ -393,14 +393,28 @@ public class APITestController { String jmxString = runRequest.getTestElement().getJmx(hashTree); String testName = runRequest.getName(); - //将ThreadGroup的testname改为接口名称 - Document doc = DocumentHelper.parseText(jmxString);// 获取可续保保单列表报文模板 - Element root = doc.getRootElement(); - Element rootHashTreeElement = root.element("hashTree"); - Element innerHashTreeElement = rootHashTreeElement.elements("hashTree").get(0); - Element theadGroupElement = innerHashTreeElement.elements("ThreadGroup").get(0); - theadGroupElement.attribute("testname").setText(testName); - jmxString = root.asXML(); + + try{ + //将ThreadGroup的testname改为接口名称 + Document doc = DocumentHelper.parseText(jmxString);// 获取可续保保单列表报文模板 + Element root = doc.getRootElement(); + Element rootHashTreeElement = root.element("hashTree"); + Element innerHashTreeElement = rootHashTreeElement.elements("hashTree").get(0); + Element theadGroupElement = innerHashTreeElement.elements("ThreadGroup").get(0); + theadGroupElement.attribute("testname").setText(testName); + + List thirdHashTreeElementList =innerHashTreeElement.elements("hashTree"); + for (Element element:thirdHashTreeElementList) { + List sampleProxyElementList = element.elements("HTTPSamplerProxy"); + for (Element itemElement: sampleProxyElementList) { + itemElement.attribute("testname").setText(testName); + } + } + + jmxString = root.asXML(); + }catch (Exception e){ + e.printStackTrace(); + } JmxInfoDTO dto = new JmxInfoDTO(); dto.setName(runRequest.getName()+".jmx"); 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 238cdd6402..2064106194 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -421,6 +421,53 @@ public class TestPlanReportService { models.setPerformanceInfo(JSONArray.toJSONString(performaneReportIDList)); testPlanReportDataMapper.updateByPrimaryKeyWithBLOBs(models); } + + /** + * 虽然kafka已经设置了topic推送,但是当执行机器性能不够时会影响到报告状态当修改 + * 同时如果执行过程中报告删除,那么此时也应当记为失败。 + */ + List updatePerformaneReportIDList = new ArrayList<>(performaneReportIDList); + 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); + } + } + if(performaneReportIDList.isEmpty()){ + for (String string: updatePerformaneReportIDList) { + TestPlanLoadCaseEventDTO eventDTO = new TestPlanLoadCaseEventDTO(); + eventDTO.setReportId(string); + eventDTO.setTriggerMode(ReportTriggerMode.SCHEDULE.name()); + eventDTO.setStatus(PerformanceTestStatus.Completed.name()); + this.updatePerformanceTestStatus(eventDTO); + } + }else { + try { + //查询定时任务是否关闭 + Thread.sleep(1000 * 10);// 检查 loadtest 的状态 + } catch (InterruptedException e) { + } + } + } + return true; + }); } public void updatePerformanceTestStatus(TestPlanLoadCaseEventDTO eventDTO) { diff --git a/frontend/src/business/components/api/automation/scenario/MsInputTag.vue b/frontend/src/business/components/api/automation/scenario/MsInputTag.vue index c53111a410..ee43a990c8 100644 --- a/frontend/src/business/components/api/automation/scenario/MsInputTag.vue +++ b/frontend/src/business/components/api/automation/scenario/MsInputTag.vue @@ -21,7 +21,7 @@ v-if="!readOnly" class="tag-input el-input" v-model="newTag" - placeholder="$t('commons.tag_tip)" + :placeholder="$t('commons.tag_tip')" @keydown.delete.stop="removeLastTag" @keydown="addNew" @blur="addNew"/>