Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
8001fdee
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,发现更多精彩内容 >>
提交
8001fdee
编写于
4月 23, 2020
作者:
C
Captain.B
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tmp
上级
d0ddd8d8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
45 addition
and
32 deletion
+45
-32
backend/src/main/java/io/metersphere/commons/constants/ReportKeys.java
...ain/java/io/metersphere/commons/constants/ReportKeys.java
+6
-0
backend/src/main/java/io/metersphere/service/ReportService.java
...d/src/main/java/io/metersphere/service/ReportService.java
+26
-32
backend/src/main/resources/db/migration/V2__metersphere_ddl.sql
...d/src/main/resources/db/migration/V2__metersphere_ddl.sql
+13
-0
未找到文件。
backend/src/main/java/io/metersphere/commons/constants/ReportKeys.java
0 → 100644
浏览文件 @
8001fdee
package
io.metersphere.commons.constants
;
public
enum
ReportKeys
{
LoadChart
,
ResponseTimeChart
,
Errors
,
ErrorsTop5
,
RequestStatistics
,
Overview
,
TimeInfo
}
backend/src/main/java/io/metersphere/service/ReportService.java
浏览文件 @
8001fdee
package
io.metersphere.service
;
package
io.metersphere.service
;
import
io.metersphere.base.domain.LoadTestReport
;
import
com.alibaba.fastjson.JSON
;
import
io.metersphere.base.domain.LoadTestReportExample
;
import
io.metersphere.base.domain.*
;
import
io.metersphere.base.domain.LoadTestReportWithBLOBs
;
import
io.metersphere.base.domain.LoadTestWithBLOBs
;
import
io.metersphere.base.mapper.LoadTestMapper
;
import
io.metersphere.base.mapper.LoadTestMapper
;
import
io.metersphere.base.mapper.LoadTestReportMapper
;
import
io.metersphere.base.mapper.LoadTestReportMapper
;
import
io.metersphere.base.mapper.LoadTestReportResultMapper
;
import
io.metersphere.base.mapper.ext.ExtLoadTestReportMapper
;
import
io.metersphere.base.mapper.ext.ExtLoadTestReportMapper
;
import
io.metersphere.commons.constants.PerformanceTestStatus
;
import
io.metersphere.commons.constants.PerformanceTestStatus
;
import
io.metersphere.commons.constants.ReportKeys
;
import
io.metersphere.commons.exception.MSException
;
import
io.metersphere.commons.exception.MSException
;
import
io.metersphere.commons.utils.LogUtil
;
import
io.metersphere.commons.utils.LogUtil
;
import
io.metersphere.controller.request.ReportRequest
;
import
io.metersphere.controller.request.ReportRequest
;
import
io.metersphere.dto.ReportDTO
;
import
io.metersphere.dto.ReportDTO
;
import
io.metersphere.engine.Engine
;
import
io.metersphere.engine.Engine
;
import
io.metersphere.engine.EngineFactory
;
import
io.metersphere.engine.EngineFactory
;
import
io.metersphere.report.GenerateReport
;
import
io.metersphere.report.base.*
;
import
io.metersphere.report.base.*
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -33,6 +32,8 @@ public class ReportService {
...
@@ -33,6 +32,8 @@ public class ReportService {
private
ExtLoadTestReportMapper
extLoadTestReportMapper
;
private
ExtLoadTestReportMapper
extLoadTestReportMapper
;
@Resource
@Resource
private
LoadTestMapper
loadTestMapper
;
private
LoadTestMapper
loadTestMapper
;
@Resource
private
LoadTestReportResultMapper
loadTestReportResultMapper
;
public
List
<
LoadTestReport
>
getRecentReportList
(
ReportRequest
request
)
{
public
List
<
LoadTestReport
>
getRecentReportList
(
ReportRequest
request
)
{
LoadTestReportExample
example
=
new
LoadTestReportExample
();
LoadTestReportExample
example
=
new
LoadTestReportExample
();
...
@@ -84,58 +85,51 @@ public class ReportService {
...
@@ -84,58 +85,51 @@ public class ReportService {
return
extLoadTestReportMapper
.
getReportTestAndProInfo
(
reportId
);
return
extLoadTestReportMapper
.
getReportTestAndProInfo
(
reportId
);
}
}
private
String
getContent
(
String
id
,
ReportKeys
reportKey
)
{
LoadTestReportResultExample
example
=
new
LoadTestReportResultExample
();
example
.
createCriteria
().
andReportIdEqualTo
(
id
).
andReportKeyEqualTo
(
reportKey
.
name
());
return
loadTestReportResultMapper
.
selectByExampleWithBLOBs
(
example
).
get
(
0
).
getReportValue
();
}
public
List
<
Statistics
>
getReport
(
String
id
)
{
public
List
<
Statistics
>
getReport
(
String
id
)
{
checkReportStatus
(
id
);
checkReportStatus
(
id
);
LoadTestReportWithBLOBs
loadTestReport
=
loadTestReportMapper
.
selectByPrimaryKey
(
id
);
String
reportValue
=
getContent
(
id
,
ReportKeys
.
RequestStatistics
);
String
content
=
loadTestReport
.
getContent
();
return
JSON
.
parseArray
(
reportValue
,
Statistics
.
class
);
return
GenerateReport
.
getRequestStatistics
(
content
);
}
}
public
List
<
Errors
>
getReportErrors
(
String
id
)
{
public
List
<
Errors
>
getReportErrors
(
String
id
)
{
checkReportStatus
(
id
);
checkReportStatus
(
id
);
LoadTestReportWithBLOBs
loadTestReport
=
loadTestReportMapper
.
selectByPrimaryKey
(
id
);
String
content
=
getContent
(
id
,
ReportKeys
.
Errors
);
String
content
=
loadTestReport
.
getContent
();
return
JSON
.
parseArray
(
content
,
Errors
.
class
);
List
<
Errors
>
errors
=
GenerateReport
.
getErrorsList
(
content
);
return
errors
;
}
}
public
List
<
ErrorsTop5
>
getReportErrorsTOP5
(
String
id
)
{
public
List
<
ErrorsTop5
>
getReportErrorsTOP5
(
String
id
)
{
checkReportStatus
(
id
);
checkReportStatus
(
id
);
LoadTestReportWithBLOBs
loadTestReport
=
loadTestReportMapper
.
selectByPrimaryKey
(
id
);
String
content
=
getContent
(
id
,
ReportKeys
.
ErrorsTop5
);
String
content
=
loadTestReport
.
getContent
();
return
JSON
.
parseArray
(
content
,
ErrorsTop5
.
class
);
List
<
ErrorsTop5
>
errorsTop5
=
GenerateReport
.
getErrorsTop5List
(
content
);
return
errorsTop5
;
}
}
public
TestOverview
getTestOverview
(
String
id
)
{
public
TestOverview
getTestOverview
(
String
id
)
{
checkReportStatus
(
id
);
checkReportStatus
(
id
);
LoadTestReportWithBLOBs
loadTestReport
=
loadTestReportMapper
.
selectByPrimaryKey
(
id
);
String
content
=
getContent
(
id
,
ReportKeys
.
Overview
);
String
content
=
loadTestReport
.
getContent
();
return
JSON
.
parseObject
(
content
,
TestOverview
.
class
);
TestOverview
testOverview
=
GenerateReport
.
getTestOverview
(
content
);
return
testOverview
;
}
}
public
ReportTimeInfo
getReportTimeInfo
(
String
id
)
{
public
ReportTimeInfo
getReportTimeInfo
(
String
id
)
{
LoadTestReportWithBLOBs
loadTestReport
=
loadTestReportMapper
.
selectByPrimaryKey
(
id
);
String
content
=
getContent
(
id
,
ReportKeys
.
TimeInfo
);
String
content
=
loadTestReport
.
getContent
();
return
JSON
.
parseObject
(
content
,
ReportTimeInfo
.
class
);
ReportTimeInfo
reportTimeInfo
=
GenerateReport
.
getReportTimeInfo
(
content
);
return
reportTimeInfo
;
}
}
public
List
<
ChartsData
>
getLoadChartData
(
String
id
)
{
public
List
<
ChartsData
>
getLoadChartData
(
String
id
)
{
checkReportStatus
(
id
);
checkReportStatus
(
id
);
LoadTestReportWithBLOBs
loadTestReport
=
loadTestReportMapper
.
selectByPrimaryKey
(
id
);
String
content
=
getContent
(
id
,
ReportKeys
.
LoadChart
);
String
content
=
loadTestReport
.
getContent
();
return
JSON
.
parseArray
(
content
,
ChartsData
.
class
);
List
<
ChartsData
>
chartsDataList
=
GenerateReport
.
getLoadChartData
(
content
);
return
chartsDataList
;
}
}
public
List
<
ChartsData
>
getResponseTimeChartData
(
String
id
)
{
public
List
<
ChartsData
>
getResponseTimeChartData
(
String
id
)
{
checkReportStatus
(
id
);
checkReportStatus
(
id
);
LoadTestReportWithBLOBs
loadTestReport
=
loadTestReportMapper
.
selectByPrimaryKey
(
id
);
String
content
=
getContent
(
id
,
ReportKeys
.
ResponseTimeChart
);
String
content
=
loadTestReport
.
getContent
();
return
JSON
.
parseArray
(
content
,
ChartsData
.
class
);
List
<
ChartsData
>
chartsDataList
=
GenerateReport
.
getResponseTimeChartData
(
content
);
return
chartsDataList
;
}
}
public
void
checkReportStatus
(
String
reportId
)
{
public
void
checkReportStatus
(
String
reportId
)
{
...
...
backend/src/main/resources/db/migration/V2__metersphere_ddl.sql
浏览文件 @
8001fdee
...
@@ -71,6 +71,19 @@ CREATE TABLE IF NOT EXISTS `load_test_report_detail` (
...
@@ -71,6 +71,19 @@ CREATE TABLE IF NOT EXISTS `load_test_report_detail` (
DEFAULT
CHARSET
=
utf8mb4
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_bin
;
COLLATE
=
utf8mb4_bin
;
CREATE
TABLE
IF
NOT
EXISTS
`load_test_report_result`
(
`id`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
,
`report_id`
varchar
(
50
)
NOT
NULL
,
`report_key`
varchar
(
64
)
DEFAULT
NULL
,
`report_value`
text
,
PRIMARY
KEY
(
`id`
),
KEY
`load_test_report_result_report_id_report_key_index`
(
`report_id`
,
`report_key`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_bin
;
CREATE
TABLE
IF
NOT
EXISTS
`organization`
(
CREATE
TABLE
IF
NOT
EXISTS
`organization`
(
`id`
varchar
(
50
)
NOT
NULL
COMMENT
'Organization ID'
,
`id`
varchar
(
50
)
NOT
NULL
COMMENT
'Organization ID'
,
`name`
varchar
(
64
)
NOT
NULL
COMMENT
'Organization name'
,
`name`
varchar
(
64
)
NOT
NULL
COMMENT
'Organization name'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录