Top 5 Errors by sampler
This commit is contained in:
parent
f11437bf19
commit
ff3ec3ff15
|
@ -9,8 +9,8 @@ import io.metersphere.commons.utils.Pager;
|
|||
import io.metersphere.controller.request.ReportRequest;
|
||||
import io.metersphere.dto.ReportDTO;
|
||||
import io.metersphere.report.base.Errors;
|
||||
import io.metersphere.report.base.RequestStatistics;
|
||||
import io.metersphere.report.base.RequestStatisticsDTO;
|
||||
import io.metersphere.report.dto.ErrorsTop5DTO;
|
||||
import io.metersphere.report.dto.RequestStatisticsDTO;
|
||||
import io.metersphere.service.ReportService;
|
||||
import io.metersphere.user.SessionUtils;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
|
@ -65,5 +65,10 @@ public class ReportController {
|
|||
return reportService.getReportErrors(reportId);
|
||||
}
|
||||
|
||||
@GetMapping("/content/errors_top5/{reportId}")
|
||||
public ErrorsTop5DTO getReportErrorsTop5(@PathVariable String reportId) {
|
||||
return reportService.getReportErrorsTOP5(reportId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,9 +4,11 @@ import com.opencsv.bean.CsvToBean;
|
|||
import com.opencsv.bean.CsvToBeanBuilder;
|
||||
import com.opencsv.bean.HeaderColumnNameMappingStrategy;
|
||||
import io.metersphere.report.base.Errors;
|
||||
import io.metersphere.report.base.ErrorsTop5;
|
||||
import io.metersphere.report.base.Metric;
|
||||
import io.metersphere.report.base.RequestStatistics;
|
||||
import io.metersphere.report.base.RequestStatisticsDTO;
|
||||
import io.metersphere.report.dto.ErrorsTop5DTO;
|
||||
import io.metersphere.report.dto.RequestStatisticsDTO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.Reader;
|
||||
|
@ -178,4 +180,52 @@ public class JtlResolver {
|
|||
return metric.getResponseCode() + "/" + metric.getResponseMessage();
|
||||
}
|
||||
|
||||
public static ErrorsTop5DTO getErrorsTop5DTO(String jtlString) {
|
||||
List<Metric> totalLines = resolver(jtlString);
|
||||
ErrorsTop5DTO top5DTO = new ErrorsTop5DTO();
|
||||
List<Metric> falseList = totalLines.stream().filter(metric -> StringUtils.equals("false", metric.getSuccess())).collect(Collectors.toList());
|
||||
Map<String, List<Metric>> collect = falseList.stream().collect(Collectors.groupingBy(JtlResolver::getResponseCodeAndFailureMessage));
|
||||
Iterator<Map.Entry<String, List<Metric>>> iterator = collect.entrySet().iterator();
|
||||
List<ErrorsTop5> errorsTop5s = new ArrayList<>();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, List<Metric>> next = iterator.next();
|
||||
String key = next.getKey();
|
||||
List<Metric> value = next.getValue();
|
||||
ErrorsTop5 errorsTop5 = new ErrorsTop5();
|
||||
List<Metric> list = totalLines.stream()
|
||||
.filter(metric -> StringUtils.equals(metric.getLabel(), value.get(0).getLabel())).collect(Collectors.toList());
|
||||
errorsTop5.setSamples(String.valueOf(list.size()));
|
||||
errorsTop5.setSample(value.get(0).getLabel());
|
||||
errorsTop5.setErrors(String.valueOf(value.size()));
|
||||
errorsTop5.setErrorsAllSize(value.size());
|
||||
errorsTop5.setError(key);
|
||||
errorsTop5s.add(errorsTop5);
|
||||
}
|
||||
|
||||
Collections.sort(errorsTop5s, (t0, t1) -> t1.getErrorsAllSize().compareTo(t0.getErrorsAllSize()));
|
||||
|
||||
if (errorsTop5s.size() >= 5) {
|
||||
errorsTop5s = errorsTop5s.subList(0, 5);
|
||||
}
|
||||
|
||||
top5DTO.setLabel("Total");
|
||||
top5DTO.setErrorsTop5List(errorsTop5s);
|
||||
top5DTO.setTotalSamples(String.valueOf(totalLines.size()));
|
||||
top5DTO.setTotalErrors(String.valueOf(falseList.size()));
|
||||
Integer size = errorsTop5s.size();
|
||||
// Total行 信息
|
||||
top5DTO.setError1(size > 0 ? errorsTop5s.get(0).getError() : null);
|
||||
top5DTO.setError1Size(size > 0 ? errorsTop5s.get(0).getErrors() : null);
|
||||
top5DTO.setError2(size > 1 ? errorsTop5s.get(1).getError() : null);
|
||||
top5DTO.setError2Size(size > 1 ? errorsTop5s.get(1).getErrors() : null);
|
||||
top5DTO.setError3(size > 2 ? errorsTop5s.get(2).getError() : null);
|
||||
top5DTO.setError3Size(size > 2 ? errorsTop5s.get(2).getErrors() : null);
|
||||
top5DTO.setError4(size > 3 ? errorsTop5s.get(3).getError() : null);
|
||||
top5DTO.setError4Size(size > 3 ? errorsTop5s.get(3).getErrors() : null);
|
||||
top5DTO.setError5(size > 4 ? errorsTop5s.get(4).getError() : null);
|
||||
top5DTO.setError5Size(size > 4 ? errorsTop5s.get(4).getErrors() : null);
|
||||
|
||||
return top5DTO;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package io.metersphere.report.base;
|
||||
|
||||
public class ErrorsTop5 {
|
||||
|
||||
private String sample;
|
||||
private String samples;
|
||||
private Integer errorsAllSize;
|
||||
private String error;
|
||||
private String errors;
|
||||
|
||||
public String getSample() {
|
||||
return sample;
|
||||
}
|
||||
|
||||
public void setSample(String sample) {
|
||||
this.sample = sample;
|
||||
}
|
||||
|
||||
public String getSamples() {
|
||||
return samples;
|
||||
}
|
||||
|
||||
public void setSamples(String samples) {
|
||||
this.samples = samples;
|
||||
}
|
||||
|
||||
public Integer getErrorsAllSize() {
|
||||
return errorsAllSize;
|
||||
}
|
||||
|
||||
public void setErrorsAllSize(Integer errorsAllSize) {
|
||||
this.errorsAllSize = errorsAllSize;
|
||||
}
|
||||
|
||||
public String getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setError(String error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
public String getErrors() {
|
||||
return errors;
|
||||
}
|
||||
|
||||
public void setErrors(String errors) {
|
||||
this.errors = errors;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
package io.metersphere.report.dto;
|
||||
|
||||
import io.metersphere.report.base.ErrorsTop5;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ErrorsTop5DTO {
|
||||
|
||||
private List<ErrorsTop5> errorsTop5List;
|
||||
private String label;
|
||||
private String totalSamples;
|
||||
private String totalErrors;
|
||||
private String error1;
|
||||
private String error1Size;
|
||||
private String error2;
|
||||
private String error2Size;
|
||||
private String error3;
|
||||
private String error3Size;
|
||||
private String error4;
|
||||
private String error4Size;
|
||||
private String error5;
|
||||
private String error5Size;
|
||||
|
||||
public List<ErrorsTop5> getErrorsTop5List() {
|
||||
return errorsTop5List;
|
||||
}
|
||||
|
||||
public void setErrorsTop5List(List<ErrorsTop5> errorsTop5List) {
|
||||
this.errorsTop5List = errorsTop5List;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getTotalSamples() {
|
||||
return totalSamples;
|
||||
}
|
||||
|
||||
public void setTotalSamples(String totalSamples) {
|
||||
this.totalSamples = totalSamples;
|
||||
}
|
||||
|
||||
public String getTotalErrors() {
|
||||
return totalErrors;
|
||||
}
|
||||
|
||||
public void setTotalErrors(String totalErrors) {
|
||||
this.totalErrors = totalErrors;
|
||||
}
|
||||
|
||||
public String getError1() {
|
||||
return error1;
|
||||
}
|
||||
|
||||
public void setError1(String error1) {
|
||||
this.error1 = error1;
|
||||
}
|
||||
|
||||
public String getError1Size() {
|
||||
return error1Size;
|
||||
}
|
||||
|
||||
public void setError1Size(String error1Size) {
|
||||
this.error1Size = error1Size;
|
||||
}
|
||||
|
||||
public String getError2() {
|
||||
return error2;
|
||||
}
|
||||
|
||||
public void setError2(String error2) {
|
||||
this.error2 = error2;
|
||||
}
|
||||
|
||||
public String getError2Size() {
|
||||
return error2Size;
|
||||
}
|
||||
|
||||
public void setError2Size(String error2Size) {
|
||||
this.error2Size = error2Size;
|
||||
}
|
||||
|
||||
public String getError3() {
|
||||
return error3;
|
||||
}
|
||||
|
||||
public void setError3(String error3) {
|
||||
this.error3 = error3;
|
||||
}
|
||||
|
||||
public String getError3Size() {
|
||||
return error3Size;
|
||||
}
|
||||
|
||||
public void setError3Size(String error3Size) {
|
||||
this.error3Size = error3Size;
|
||||
}
|
||||
|
||||
public String getError4() {
|
||||
return error4;
|
||||
}
|
||||
|
||||
public void setError4(String error4) {
|
||||
this.error4 = error4;
|
||||
}
|
||||
|
||||
public String getError4Size() {
|
||||
return error4Size;
|
||||
}
|
||||
|
||||
public void setError4Size(String error4Size) {
|
||||
this.error4Size = error4Size;
|
||||
}
|
||||
|
||||
public String getError5() {
|
||||
return error5;
|
||||
}
|
||||
|
||||
public void setError5(String error5) {
|
||||
this.error5 = error5;
|
||||
}
|
||||
|
||||
public String getError5Size() {
|
||||
return error5Size;
|
||||
}
|
||||
|
||||
public void setError5Size(String error5Size) {
|
||||
this.error5Size = error5Size;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
package io.metersphere.report.base;
|
||||
package io.metersphere.report.dto;
|
||||
|
||||
import io.metersphere.report.base.RequestStatistics;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -8,8 +8,8 @@ import io.metersphere.controller.request.ReportRequest;
|
|||
import io.metersphere.dto.ReportDTO;
|
||||
import io.metersphere.report.JtlResolver;
|
||||
import io.metersphere.report.base.Errors;
|
||||
import io.metersphere.report.base.RequestStatistics;
|
||||
import io.metersphere.report.base.RequestStatisticsDTO;
|
||||
import io.metersphere.report.dto.ErrorsTop5DTO;
|
||||
import io.metersphere.report.dto.RequestStatisticsDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -59,4 +59,11 @@ public class ReportService {
|
|||
List<Errors> errors = JtlResolver.getErrorsList(content);
|
||||
return errors;
|
||||
}
|
||||
|
||||
public ErrorsTop5DTO getReportErrorsTOP5(String id) {
|
||||
LoadTestReport loadTestReport = loadTestReportMapper.selectByPrimaryKey(id);
|
||||
String content = loadTestReport.getContent();
|
||||
ErrorsTop5DTO errors = JtlResolver.getErrorsTop5DTO(content);
|
||||
return errors;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,37 +34,39 @@
|
|||
|
||||
<span class="table-title">Top 5 Errors by sampler </span>
|
||||
<el-table
|
||||
:data="tableData"
|
||||
:data="errorTop5"
|
||||
border
|
||||
stripe
|
||||
style="width: 100%"
|
||||
show-summary
|
||||
:summary-method="getSummaries"
|
||||
>
|
||||
<el-table-column
|
||||
prop="errorType"
|
||||
prop="sample"
|
||||
label="Sample"
|
||||
width="400"
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="errorNumber"
|
||||
prop="samples"
|
||||
label="#Samples"
|
||||
width="120"
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="#Errors"
|
||||
prop="errorsAllSize"
|
||||
label="#Errors"
|
||||
width="100"
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="Error"
|
||||
prop="error"
|
||||
label="Error"
|
||||
width="400"
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="#Errors"
|
||||
prop="errors"
|
||||
label="#Errors"
|
||||
width="100"
|
||||
>
|
||||
|
@ -126,7 +128,9 @@
|
|||
name: "ErrorLog",
|
||||
data() {
|
||||
return {
|
||||
tableData: [{},{},{},{},{}]
|
||||
tableData: [{},{},{},{},{}],
|
||||
errorTotal: {},
|
||||
errorTop5: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -134,10 +138,32 @@
|
|||
this.$get("/report/content/errors/" + this.id, res => {
|
||||
this.tableData = res.data;
|
||||
})
|
||||
this.$get("/report/content/errors_top5/" + this.id, res => {
|
||||
this.errorTotal = res.data
|
||||
this.errorTop5 = res.data.errorsTop5List;
|
||||
})
|
||||
},
|
||||
getSummaries () {
|
||||
const sums = []
|
||||
sums[0] = this.errorTotal.label;
|
||||
sums[1] = this.errorTotal.totalSamples;
|
||||
sums[2] = this.errorTotal.totalErrors;
|
||||
sums[3] = this.errorTotal.error1;
|
||||
sums[4] = this.errorTotal.error1Size;
|
||||
sums[5] = this.errorTotal.error2;
|
||||
sums[6] = this.errorTotal.error2Size;
|
||||
sums[7] = this.errorTotal.error3;
|
||||
sums[8] = this.errorTotal.error3Size;
|
||||
sums[9] = this.errorTotal.error4;
|
||||
sums[10] = this.errorTotal.error4Size;
|
||||
sums[11] = this.errorTotal.error5;
|
||||
sums[12] = this.errorTotal.error5Size;
|
||||
return sums;
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.initTableData();
|
||||
this.getSummaries()
|
||||
},
|
||||
props: ['id'],
|
||||
watch: {
|
||||
|
@ -145,9 +171,13 @@
|
|||
if (to.name === "perReportView") {
|
||||
let reportId = to.path.split('/')[4];
|
||||
if(reportId){
|
||||
this.$get("/report/content/errors/" + this.id, res => {
|
||||
this.$get("/report/content/errors/" + reportId, res => {
|
||||
this.tableData = res.data;
|
||||
})
|
||||
this.$get("/report/content/errors_top5/" + reportId, res => {
|
||||
this.errorTop5 = res.data.errorsTop5List;
|
||||
this.errorTotal = res.data
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue