diff --git a/backend/src/main/java/io/metersphere/controller/ShareController.java b/backend/src/main/java/io/metersphere/controller/ShareController.java index 5fd2637ed8..14b7ee527f 100644 --- a/backend/src/main/java/io/metersphere/controller/ShareController.java +++ b/backend/src/main/java/io/metersphere/controller/ShareController.java @@ -163,7 +163,7 @@ public class ShareController { @GetMapping("/performance/report/get-jmx-content/{shareId}/{reportId}") public LoadTestExportJmx getJmxContent(@PathVariable String shareId, @PathVariable String reportId) { - return performanceReportService.getJmxContent(reportId); + return performanceReportService.getJmxContent(reportId).get(0); } @GetMapping("/performance/get-jmx-content/{shareId}/{testId}") diff --git a/backend/src/main/java/io/metersphere/performance/controller/PerformanceReportController.java b/backend/src/main/java/io/metersphere/performance/controller/PerformanceReportController.java index f740a13ec0..1c8f2e82a2 100644 --- a/backend/src/main/java/io/metersphere/performance/controller/PerformanceReportController.java +++ b/backend/src/main/java/io/metersphere/performance/controller/PerformanceReportController.java @@ -149,10 +149,20 @@ public class PerformanceReportController { } @GetMapping("get-jmx-content/{reportId}") - public LoadTestExportJmx getJmxContent(@PathVariable String reportId) { + public List getJmxContent(@PathVariable String reportId) { return performanceReportService.getJmxContent(reportId); } + @GetMapping("/get-load-config/{reportId}") + public String getLoadConfiguration(@PathVariable String reportId) { + return performanceReportService.getLoadConfiguration(reportId); + } + + @GetMapping("/get-advanced-config/{reportId}") + public String getAdvancedConfiguration(@PathVariable String reportId) { + return performanceReportService.getAdvancedConfiguration(reportId); + } + @PostMapping("rename") @MsAuditLog(module = "performance_test_report", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = PerformanceReportService.class) public void renameReport(@RequestBody RenameReportRequest request) { diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java index 244f96f64b..1c48c45e91 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java @@ -43,9 +43,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.InputStream; import java.io.OutputStream; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; @Service @@ -377,12 +375,13 @@ public class PerformanceReportService { return ""; } - public LoadTestExportJmx getJmxContent(String reportId) { + public List getJmxContent(String reportId) { LoadTestReportWithBLOBs loadTestReportWithBLOBs = loadTestReportMapper.selectByPrimaryKey(reportId); if (loadTestReportWithBLOBs == null) { - return null; + return new ArrayList<>(); } - return new LoadTestExportJmx(loadTestReportWithBLOBs.getTestName(), loadTestReportWithBLOBs.getJmxContent()); + LoadTestExportJmx loadTestExportJmx = new LoadTestExportJmx(loadTestReportWithBLOBs.getTestName(), loadTestReportWithBLOBs.getJmxContent()); + return Collections.singletonList(loadTestExportJmx); } public void renameReport(RenameReportRequest request) { @@ -432,4 +431,20 @@ public class PerformanceReportService { return new ArrayList<>(); } } + + public String getLoadConfiguration(String reportId) { + LoadTestReportWithBLOBs loadTestReportWithBLOBs = loadTestReportMapper.selectByPrimaryKey(reportId); + if (loadTestReportWithBLOBs == null) { + return null; + } + return loadTestReportWithBLOBs.getLoadConfiguration(); + } + + public String getAdvancedConfiguration(String reportId) { + LoadTestReportWithBLOBs loadTestReportWithBLOBs = loadTestReportMapper.selectByPrimaryKey(reportId); + if (loadTestReportWithBLOBs == null) { + return null; + } + return loadTestReportWithBLOBs.getAdvancedConfiguration(); + } } 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 5bbab9d40f..24b6044af7 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -1632,9 +1632,9 @@ public class TestPlanService { String loadConfiguration = performanceTestService.getLoadConfiguration(item.getId()); response.setFixLoadConfiguration(loadConfiguration); } - LoadTestExportJmx jmxContent = performanceReportService.getJmxContent(reportId); - if (jmxContent != null) { - response.setJmxContent(JSONObject.toJSONString(jmxContent)); + List jmxContent = performanceReportService.getJmxContent(reportId); + if (!CollectionUtils.isEmpty(jmxContent)) { + response.setJmxContent(JSONObject.toJSONString(jmxContent.get(0))); } List fixJmxContent = performanceTestService.getJmxContent(item.getId()); response.setFixJmxContent(fixJmxContent); diff --git a/frontend/src/business/components/performance/report/PerformanceReportView.vue b/frontend/src/business/components/performance/report/PerformanceReportView.vue index 585cbaa5a3..ab58776e8b 100644 --- a/frontend/src/business/components/performance/report/PerformanceReportView.vue +++ b/frontend/src/business/components/performance/report/PerformanceReportView.vue @@ -101,7 +101,7 @@ - + diff --git a/frontend/src/business/components/performance/report/components/TestConfiguration.vue b/frontend/src/business/components/performance/report/components/TestConfiguration.vue index 31bdf7a160..bbee8963e3 100644 --- a/frontend/src/business/components/performance/report/components/TestConfiguration.vue +++ b/frontend/src/business/components/performance/report/components/TestConfiguration.vue @@ -1,10 +1,10 @@ @@ -18,9 +18,9 @@ export default { name: "TestConfiguration", components: {PerformanceBasicConfig, PerformancePressureConfig, PerformanceAdvancedConfig}, props: { - report: Object, test: Object, testId: String, + reportId: String, } }; diff --git a/frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue b/frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue index 3f928f89d8..772865a1af 100644 --- a/frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue +++ b/frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue @@ -422,6 +422,9 @@ export default { }, props: { testId: String, + reportId: { + type: String + }, isReadOnly: { type: Boolean, default() { @@ -432,6 +435,8 @@ export default { mounted() { if (this.testId) { this.getAdvancedConfig(); + } else if (this.reportId) { + this.getAdvancedConfig('report'); } }, watch: { @@ -450,8 +455,12 @@ export default { } }, methods: { - getAdvancedConfig() { - this.$get('/performance/get-advanced-config/' + this.testId, (response) => { + getAdvancedConfig(type) { + let url = '/performance/get-advanced-config/' + this.testId; + if (type) { + url = '/performance/report/get-advanced-config/' + this.reportId; + } + this.$get(url, (response) => { if (response.data) { let data = JSON.parse(response.data); this.timeout = data.timeout; diff --git a/frontend/src/business/components/performance/test/components/PerformancePressureConfig.vue b/frontend/src/business/components/performance/test/components/PerformancePressureConfig.vue index b2ca64e830..513e1d1871 100644 --- a/frontend/src/business/components/performance/test/components/PerformancePressureConfig.vue +++ b/frontend/src/business/components/performance/test/components/PerformancePressureConfig.vue @@ -6,11 +6,11 @@ + v-for="item in resourcePools" + :key="item.id" + :label="item.name" + :disabled="!item.performance" + :value="item.id"> @@ -80,10 +80,10 @@ + v-for="item in onSampleErrors" + :key="item.value" + :label="item.label" + :value="item.value"> @@ -221,10 +221,10 @@ + v-for="(node, index) in resourceNodes" + :key="node.ip" + :label="node.ip" + :value="index"> @@ -289,7 +289,7 @@ const RATIOS = "ratios"; const hexToRgb = function (hex) { return 'rgb(' + parseInt('0x' + hex.slice(1, 3)) + ',' + parseInt('0x' + hex.slice(3, 5)) - + ',' + parseInt('0x' + hex.slice(5, 7)) + ')'; + + ',' + parseInt('0x' + hex.slice(5, 7)) + ')'; }; export default { @@ -302,6 +302,9 @@ export default { testId: { type: String }, + reportId: { + type: String + }, isReadOnly: { type: Boolean, default() { @@ -346,6 +349,8 @@ export default { mounted() { if (this.testId) { this.getJmxContent(); + } else if (this.reportId) { + this.getJmxContent(); } else { this.calculateTotalChart(); } @@ -369,6 +374,14 @@ export default { } this.getResourcePools(); }, + reportId() { + if (this.reportId) { + this.getJmxContent(); + } else { + this.calculateTotalChart(); + } + this.getResourcePools(); + }, }, methods: { getResourcePools() { @@ -383,7 +396,17 @@ export default { }); }, getLoadConfig() { - this.$get('/performance/get-load-config/' + this.testId, (response) => { + let url = ''; + if (this.testId) { + url = '/performance/get-load-config/' + this.testId; + } + if (this.reportId) { + url = '/performance/report/get-load-config/' + this.reportId; + } + if (!url) { + return; + } + this.$get(url, (response) => { if (response.data) { let data = JSON.parse(response.data); for (let i = 0; i < this.threadGroups.length; i++) { @@ -396,6 +419,10 @@ export default { break; } } + // 这里是报告查询 + if (this.reportId) { + j = i; + } data[j].forEach(item => { switch (item.key) { @@ -496,20 +523,28 @@ export default { }); }, getJmxContent() { + let url = ''; if (this.testId) { - let threadGroups = []; - this.$get('/performance/get-jmx-content/' + this.testId, (response) => { - response.data.forEach(d => { - threadGroups = threadGroups.concat(findThreadGroup(d.jmx, d.name)); - threadGroups.forEach(tg => { - tg.options = {}; - }); - }); - this.threadGroups = threadGroups; - this.$emit('fileChange', threadGroups); - this.getLoadConfig(); - }); + url = '/performance/get-jmx-content/' + this.testId; } + if (this.reportId) { + url = '/performance/report/get-jmx-content/' + this.reportId; + } + if (!url) { + return; + } + let threadGroups = []; + this.$get(url, (response) => { + response.data.forEach(d => { + threadGroups = threadGroups.concat(findThreadGroup(d.jmx, d.name)); + threadGroups.forEach(tg => { + tg.options = {}; + }); + }); + this.threadGroups = threadGroups; + this.$emit('fileChange', threadGroups); + this.getLoadConfig(); + }); }, resourcePoolChange() { let result = this.resourcePools.filter(p => p.id === this.resourcePool); @@ -588,8 +623,8 @@ export default { let tg = handler.threadGroups[i]; if (tg.enabled === 'false' || - tg.deleted === 'true' || - tg.threadType === 'ITERATION') { + tg.deleted === 'true' || + tg.threadType === 'ITERATION') { continue; } if (this.getDuration(tg) < tg.rampUpTime) { @@ -704,7 +739,7 @@ export default { } if (!tg.threadNumber || !tg.duration - || !tg.rampUpTime || !tg.step || !tg.iterateNum) { + || !tg.rampUpTime || !tg.step || !tg.iterateNum) { this.$warning(this.$t('load_test.pressure_config_params_is_empty')); this.$emit('changeActive', '1'); return false; diff --git a/frontend/src/business/components/track/plan/view/comonents/load/LoadCaseReportView.vue b/frontend/src/business/components/track/plan/view/comonents/load/LoadCaseReportView.vue index b002561c0a..3c318f0e35 100644 --- a/frontend/src/business/components/track/plan/view/comonents/load/LoadCaseReportView.vue +++ b/frontend/src/business/components/track/plan/view/comonents/load/LoadCaseReportView.vue @@ -74,7 +74,7 @@ :share-id="shareId"/> - +