fix(性能测试): 修复报告中的压力配置和高级配置显示错误的问题

This commit is contained in:
CaptainB 2021-11-23 19:23:37 +08:00 committed by 刘瑞斌
parent e16ea43d2b
commit eaf9b6ff30
9 changed files with 117 additions and 48 deletions

View File

@ -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}")

View File

@ -149,10 +149,20 @@ public class PerformanceReportController {
}
@GetMapping("get-jmx-content/{reportId}")
public LoadTestExportJmx getJmxContent(@PathVariable String reportId) {
public List<LoadTestExportJmx> 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) {

View File

@ -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<LoadTestExportJmx> 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();
}
}

View File

@ -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<LoadTestExportJmx> jmxContent = performanceReportService.getJmxContent(reportId);
if (!CollectionUtils.isEmpty(jmxContent)) {
response.setJmxContent(JSONObject.toJSONString(jmxContent.get(0)));
}
List<LoadTestExportJmx> fixJmxContent = performanceTestService.getJmxContent(item.getId());
response.setFixJmxContent(fixJmxContent);

View File

@ -101,7 +101,7 @@
<monitor-card :report="report"/>
</el-tab-pane>
<el-tab-pane :label="$t('测试配置')">
<ms-test-configuration :report="report" :test="test" :test-id="testId"/>
<ms-test-configuration :test="test" :report-id="reportId"/>
</el-tab-pane>
</el-tabs>
</div>

View File

@ -1,10 +1,10 @@
<template>
<el-tabs>
<el-tab-pane :label="$t('load_test.pressure_config')">
<performance-pressure-config :is-read-only="true" :test="test" :test-id="testId"/>
<performance-pressure-config :is-read-only="true" :test="test" :report-id="reportId"/>
</el-tab-pane>
<el-tab-pane :label="$t('load_test.advanced_config')">
<performance-advanced-config :is-read-only="true" :test-id="testId"/>
<performance-advanced-config :is-read-only="true" :report-id="reportId"/>
</el-tab-pane>
</el-tabs>
</template>
@ -18,9 +18,9 @@ export default {
name: "TestConfiguration",
components: {PerformanceBasicConfig, PerformancePressureConfig, PerformanceAdvancedConfig},
props: {
report: Object,
test: Object,
testId: String,
reportId: String,
}
};
</script>

View File

@ -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;

View File

@ -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,9 +523,18 @@ export default {
});
},
getJmxContent() {
let url = '';
if (this.testId) {
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('/performance/get-jmx-content/' + this.testId, (response) => {
this.$get(url, (response) => {
response.data.forEach(d => {
threadGroups = threadGroups.concat(findThreadGroup(d.jmx, d.name));
threadGroups.forEach(tg => {
@ -509,7 +545,6 @@ export default {
this.$emit('fileChange', threadGroups);
this.getLoadConfig();
});
}
},
resourcePoolChange() {
let result = this.resourcePools.filter(p => p.id === this.resourcePool);

View File

@ -74,7 +74,7 @@
:share-id="shareId"/>
</el-tab-pane>
<el-tab-pane :label="$t('测试配置')">
<ms-test-configuration :report="report" :test="test" :test-id="testId"/>
<ms-test-configuration :report-id="reportId"/>
</el-tab-pane>
</el-tabs>
</div>