Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
57120bb1
M
metersphere
项目概览
MeterSphere
/
metersphere
上一次同步 大约 3 年
通知
25
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
metersphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
57120bb1
编写于
4月 22, 2020
作者:
C
Captain.B
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/dev' into dev
上级
59468b49
192f7922
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
125 addition
and
163 deletion
+125
-163
backend/src/main/java/io/metersphere/controller/PerformanceReportController.java
...o/metersphere/controller/PerformanceReportController.java
+1
-1
backend/src/main/java/io/metersphere/report/GenerateReport.java
...d/src/main/java/io/metersphere/report/GenerateReport.java
+9
-86
backend/src/main/java/io/metersphere/report/base/ErrorsTop5.java
.../src/main/java/io/metersphere/report/base/ErrorsTop5.java
+85
-13
backend/src/main/java/io/metersphere/report/parse/ResultDataParse.java
...ain/java/io/metersphere/report/parse/ResultDataParse.java
+12
-13
backend/src/main/java/io/metersphere/service/ReportService.java
...d/src/main/java/io/metersphere/service/ReportService.java
+3
-3
frontend/src/business/components/performance/report/components/ErrorLog.vue
...ess/components/performance/report/components/ErrorLog.vue
+15
-47
未找到文件。
backend/src/main/java/io/metersphere/controller/PerformanceReportController.java
浏览文件 @
57120bb1
...
...
@@ -65,7 +65,7 @@ public class PerformanceReportController {
}
@GetMapping
(
"/content/errors_top5/{reportId}"
)
public
ErrorsTop5DTO
getReportErrorsTop5
(
@PathVariable
String
reportId
)
{
public
List
<
ErrorsTop5
>
getReportErrorsTop5
(
@PathVariable
String
reportId
)
{
return
reportService
.
getReportErrorsTOP5
(
reportId
);
}
...
...
backend/src/main/java/io/metersphere/report/GenerateReport.java
浏览文件 @
57120bb1
...
...
@@ -7,7 +7,9 @@ import io.metersphere.report.base.*;
import
io.metersphere.report.dto.ErrorsTop5DTO
;
import
io.metersphere.report.parse.ResultDataParse
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.jmeter.report.processor.ErrorsSummaryConsumer
;
import
org.apache.jmeter.report.processor.StatisticsSummaryConsumer
;
import
org.apache.jmeter.report.processor.Top5ErrorsBySamplerConsumer
;
import
org.apache.jmeter.report.processor.graph.impl.ActiveThreadsGraphConsumer
;
import
org.apache.jmeter.report.processor.graph.impl.HitsPerSecondGraphConsumer
;
import
org.apache.jmeter.report.processor.graph.impl.ResponseTimeOverTimeGraphConsumer
;
...
...
@@ -47,104 +49,25 @@ public class GenerateReport {
return
null
;
}
public
static
List
<
Errors
>
getErrorsList
(
String
jtlString
)
{
List
<
Metric
>
totalMetricList
=
resolver
(
jtlString
);
List
<
Errors
>
errorsList
=
new
ArrayList
<>();
DecimalFormat
decimalFormat
=
new
DecimalFormat
(
"0.00"
);
List
<
Metric
>
falseList
=
new
ArrayList
<>();
for
(
Metric
metric
:
totalMetricList
)
{
if
(
StringUtils
.
equals
(
"false"
,
metric
.
getSuccess
()))
{
falseList
.
add
(
metric
);
}
}
Map
<
String
,
List
<
Metric
>>
jtlMap
=
falseList
.
stream
().
collect
(
Collectors
.
groupingBy
(
GenerateReport:
:
getResponseCodeAndFailureMessage
));
for
(
Map
.
Entry
<
String
,
List
<
Metric
>>
next
:
jtlMap
.
entrySet
())
{
String
key
=
next
.
getKey
();
List
<
Metric
>
metricList
=
next
.
getValue
();
Errors
errors
=
new
Errors
();
errors
.
setErrorType
(
key
);
errors
.
setErrorNumber
(
String
.
valueOf
(
metricList
.
size
()));
int
errorSize
=
metricList
.
size
();
int
errorAllSize
=
falseList
.
size
();
int
allSamples
=
totalMetricList
.
size
();
errors
.
setPrecentOfErrors
(
decimalFormat
.
format
((
double
)
errorSize
/
errorAllSize
*
100
)
+
"%"
);
errors
.
setPrecentOfAllSamples
(
decimalFormat
.
format
((
double
)
errorSize
/
allSamples
*
100
)
+
"%"
);
errorsList
.
add
(
errors
);
}
Map
<
String
,
Object
>
statisticsDataMap
=
ResultDataParse
.
getSummryDataMap
(
jtlString
,
new
ErrorsSummaryConsumer
());
return
ResultDataParse
.
summaryMapParsing
(
statisticsDataMap
,
Errors
.
class
);
}
return
errorsList
;
public
static
List
<
ErrorsTop5
>
getErrorsTop5List
(
String
jtlString
)
{
Map
<
String
,
Object
>
statisticsDataMap
=
ResultDataParse
.
getSummryDataMap
(
jtlString
,
new
Top5ErrorsBySamplerConsumer
());
return
ResultDataParse
.
summaryMapParsing
(
statisticsDataMap
,
ErrorsTop5
.
class
);
}
public
static
List
<
Statistics
>
getRequestStatistics
(
String
jtlString
)
{
Map
<
String
,
Object
>
statisticsDataMap
=
ResultDataParse
.
getSummryDataMap
(
jtlString
,
new
StatisticsSummaryConsumer
());
return
ResultDataParse
.
summaryMapParsing
(
statisticsDataMap
);
return
ResultDataParse
.
summaryMapParsing
(
statisticsDataMap
,
Statistics
.
class
);
}
private
static
String
getResponseCodeAndFailureMessage
(
Metric
metric
)
{
return
metric
.
getResponseCode
()
+
"/"
+
metric
.
getResponseMessage
();
}
public
static
ErrorsTop5DTO
getErrorsTop5DTO
(
String
jtlString
)
{
List
<
Metric
>
totalMetricList
=
resolver
(
jtlString
);
ErrorsTop5DTO
top5DTO
=
new
ErrorsTop5DTO
();
List
<
ErrorsTop5
>
errorsTop5s
=
new
ArrayList
<>();
List
<
Metric
>
falseList
=
Objects
.
requireNonNull
(
totalMetricList
).
stream
()
.
filter
(
metric
->
StringUtils
.
equals
(
"false"
,
metric
.
getSuccess
()))
.
collect
(
Collectors
.
toList
());
Map
<
String
,
List
<
Metric
>>
collect
=
falseList
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
GenerateReport:
:
getResponseCodeAndFailureMessage
));
for
(
Map
.
Entry
<
String
,
List
<
Metric
>>
next
:
collect
.
entrySet
())
{
String
key
=
next
.
getKey
();
List
<
Metric
>
metricList
=
next
.
getValue
();
List
<
Metric
>
list
=
new
ArrayList
<>();
for
(
Metric
metric
:
totalMetricList
)
{
if
(
StringUtils
.
equals
(
metric
.
getLabel
(),
metricList
.
get
(
0
).
getLabel
()))
{
list
.
add
(
metric
);
}
}
ErrorsTop5
errorsTop5
=
new
ErrorsTop5
();
errorsTop5
.
setSamples
(
String
.
valueOf
(
list
.
size
()));
errorsTop5
.
setSample
(
metricList
.
get
(
0
).
getLabel
());
errorsTop5
.
setErrors
(
String
.
valueOf
(
metricList
.
size
()));
errorsTop5
.
setErrorsAllSize
(
metricList
.
size
());
errorsTop5
.
setError
(
key
);
errorsTop5s
.
add
(
errorsTop5
);
}
errorsTop5s
.
sort
((
t0
,
t1
)
->
t1
.
getErrorsAllSize
().
compareTo
(
t0
.
getErrorsAllSize
()));
if
(
errorsTop5s
.
size
()
>=
ERRORS_TOP_SIZE
)
{
errorsTop5s
=
errorsTop5s
.
subList
(
0
,
ERRORS_TOP_SIZE
);
}
top5DTO
.
setLabel
(
"Total"
);
top5DTO
.
setErrorsTop5List
(
errorsTop5s
);
top5DTO
.
setTotalSamples
(
String
.
valueOf
(
totalMetricList
.
size
()));
top5DTO
.
setTotalErrors
(
String
.
valueOf
(
falseList
.
size
()));
int
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
;
}
public
static
TestOverview
getTestOverview
(
String
jtlString
)
{
TestOverview
testOverview
=
new
TestOverview
();
DecimalFormat
decimalFormat
=
new
DecimalFormat
(
"0.00"
);
...
...
backend/src/main/java/io/metersphere/report/base/ErrorsTop5.java
浏览文件 @
57120bb1
...
...
@@ -4,9 +4,17 @@ public class ErrorsTop5 {
private
String
sample
;
private
String
samples
;
private
Integer
errorsAllSize
;
private
String
error
;
private
String
errors
;
private
String
errorsAllSize
;
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
String
getSample
()
{
return
sample
;
...
...
@@ -24,27 +32,91 @@ public class ErrorsTop5 {
this
.
samples
=
samples
;
}
public
Integer
getErrorsAllSize
()
{
public
String
getErrorsAllSize
()
{
return
errorsAllSize
;
}
public
void
setErrorsAllSize
(
Integer
errorsAllSize
)
{
public
void
setErrorsAllSize
(
String
errorsAllSize
)
{
this
.
errorsAllSize
=
errorsAllSize
;
}
public
String
getError
()
{
return
error
;
public
String
getError
1
()
{
return
error
1
;
}
public
void
setError
(
String
error
)
{
this
.
error
=
error
;
public
void
setError
1
(
String
error1
)
{
this
.
error
1
=
error1
;
}
public
String
getError
s
()
{
return
error
s
;
public
String
getError
1Size
()
{
return
error
1Size
;
}
public
void
setErrors
(
String
errors
)
{
this
.
errors
=
errors
;
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
;
}
}
backend/src/main/java/io/metersphere/report/parse/ResultDataParse.java
浏览文件 @
57120bb1
package
io.metersphere.report.parse
;
import
io.metersphere.commons.utils.BeanUtils
;
import
io.metersphere.commons.utils.MsJMeterUtils
;
import
io.metersphere.report.base.ChartsData
;
import
io.metersphere.report.base.Statistics
;
import
io.metersphere.report.base.SummaryData
;
import
org.apache.jmeter.report.core.Sample
;
import
org.apache.jmeter.report.core.SampleMetadata
;
import
org.apache.jmeter.report.dashboard.JsonizerVisitor
;
import
org.apache.jmeter.report.processor.*
;
import
org.apache.jmeter.report.processor.graph.AbstractOverTimeGraphConsumer
;
import
java.lang.reflect.Field
;
import
java.math.BigDecimal
;
import
java.text.ParseException
;
...
...
@@ -26,8 +22,8 @@ public class ResultDataParse {
private
static
final
String
DATE_TIME_PATTERN
=
"yyyy/MM/dd HH:mm:ss"
;
private
static
final
String
TIME_PATTERN
=
"HH:mm:ss"
;
public
static
List
<
Statistics
>
summaryMapParsing
(
Map
<
String
,
Object
>
map
)
{
List
<
Statistics
>
statisticsL
ist
=
new
ArrayList
<>();
public
static
<
T
>
List
<
T
>
summaryMapParsing
(
Map
<
String
,
Object
>
map
,
Class
<
T
>
clazz
)
{
List
<
T
>
l
ist
=
new
ArrayList
<>();
for
(
String
key
:
map
.
keySet
())
{
MapResultData
mapResultData
=
(
MapResultData
)
map
.
get
(
key
);
ListResultData
items
=
(
ListResultData
)
mapResultData
.
getResult
(
"items"
);
...
...
@@ -39,21 +35,24 @@ public class ResultDataParse {
String
[]
strArray
=
new
String
[
size
];
for
(
int
j
=
0
;
j
<
size
;
j
++)
{
ValueResultData
valueResultData
=
(
ValueResultData
)
data
.
get
(
j
);
String
accept
=
valueResultData
.
accept
(
new
JsonizerVisitor
());
strArray
[
j
]
=
accept
.
replace
(
"\\"
,
""
);
if
(
valueResultData
.
getValue
()
==
null
)
{
strArray
[
j
]
=
""
;
}
else
{
String
accept
=
valueResultData
.
accept
(
new
JsonizerVisitor
());
strArray
[
j
]
=
accept
.
replace
(
"\\"
,
""
);
}
}
Statistics
statistics
=
null
;
T
t
=
null
;
try
{
statistics
=
setParam
(
Statistics
.
class
,
strArray
);
t
=
setParam
(
clazz
,
strArray
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
statisticsList
.
add
(
statistics
);
list
.
add
(
t
);
}
}
}
return
statisticsL
ist
;
return
l
ist
;
}
public
static
List
<
ChartsData
>
graphMapParsing
(
Map
<
String
,
Object
>
map
,
String
seriesName
)
{
...
...
backend/src/main/java/io/metersphere/service/ReportService.java
浏览文件 @
57120bb1
...
...
@@ -96,12 +96,12 @@ public class ReportService {
return
errors
;
}
public
ErrorsTop5DTO
getReportErrorsTOP5
(
String
id
)
{
public
List
<
ErrorsTop5
>
getReportErrorsTOP5
(
String
id
)
{
checkReportStatus
(
id
);
LoadTestReportWithBLOBs
loadTestReport
=
loadTestReportMapper
.
selectByPrimaryKey
(
id
);
String
content
=
loadTestReport
.
getContent
();
ErrorsTop5DTO
errors
=
GenerateReport
.
getErrorsTop5DTO
(
content
);
return
errors
;
List
<
ErrorsTop5
>
errorsTop5
=
GenerateReport
.
getErrorsTop5List
(
content
);
return
errors
Top5
;
}
public
TestOverview
getTestOverview
(
String
id
)
{
...
...
frontend/src/business/components/performance/report/components/ErrorLog.vue
浏览文件 @
57120bb1
...
...
@@ -39,7 +39,6 @@
stripe
style=
"width: 100%"
show-summary
:summary-method=
"getSummaries"
>
<el-table-column
prop=
"sample"
...
...
@@ -59,62 +58,65 @@
width=
"100"
>
</el-table-column>
<el-table-column
prop=
"error"
prop=
"error
1
"
label=
"Error"
width=
"400"
>
</el-table-column>
<el-table-column
prop=
"error
s
"
prop=
"error
1Size
"
label=
"#Errors"
width=
"100"
>
</el-table-column>
<el-table-column
prop=
"
Error
"
prop=
"
error2
"
label=
"Error"
width=
"400"
>
</el-table-column>
<el-table-column
prop=
"
#Errors
"
prop=
"
error2Size
"
label=
"#Errors"
width=
"100"
>
</el-table-column>
<el-table-column
prop=
"
Error
"
prop=
"
error3
"
label=
"Error"
width=
"400"
>
</el-table-column>
<el-table-column
prop=
"
#Errors
"
prop=
"
error3Size
"
label=
"#Errors"
width=
"100"
>
</el-table-column>
<el-table-column
prop=
"
Error
"
prop=
"
error4
"
label=
"Error"
width=
"400"
>
</el-table-column>
<el-table-column
prop=
"
#Errors
"
prop=
"
error4Size
"
label=
"#Errors"
width=
"100"
>
</el-table-column>
<el-table-column
prop=
"
Error
"
prop=
"
error5
"
label=
"Error"
width=
"400"
>
</el-table-column>
<el-table-column
prop=
"
#Errors
"
prop=
"
error5Size
"
label=
"#Errors"
width=
"100"
>
...
...
@@ -128,22 +130,7 @@
name
:
"
ErrorLog
"
,
data
()
{
return
{
tableData
:
[{},{},{},{},{}],
errorTotal
:
{
label
:
''
,
totalSamples
:
''
,
totalErrors
:
''
,
error1
:
''
,
error1Size
:
''
,
error2
:
''
,
error2Size
:
''
,
error3
:
''
,
error3Size
:
''
,
error4
:
''
,
error4Size
:
''
,
error5
:
''
,
error5Size
:
''
},
tableData
:
[],
errorTop5
:
[]
}
},
...
...
@@ -153,33 +140,14 @@
this
.
tableData
=
res
.
data
;
})
this
.
$get
(
"
/performance/report/content/errors_top5/
"
+
this
.
id
,
res
=>
{
this
.
errorTotal
=
res
.
data
this
.
errorTop5
=
res
.
data
.
errorsTop5List
;
this
.
errorTop5
=
res
.
data
;
})
},
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
;
}
},
watch
:
{
status
()
{
if
(
"
Completed
"
===
this
.
status
)
{
this
.
initTableData
()
this
.
getSummaries
()
}
}
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录