Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
601cc893
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,体验更适合开发者的 AI 搜索 >>
提交
601cc893
编写于
5月 21, 2020
作者:
C
Captain.B
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/dev' into dev
上级
a11eb7da
601e329f
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
78 addition
and
20 deletion
+78
-20
backend/src/main/java/io/metersphere/api/controller/APITestController.java
...java/io/metersphere/api/controller/APITestController.java
+3
-2
backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java
...a/io/metersphere/api/jmeter/APIBackendListenerClient.java
+2
-2
backend/src/main/java/io/metersphere/api/jmeter/TestResult.java
...d/src/main/java/io/metersphere/api/jmeter/TestResult.java
+1
-1
backend/src/main/java/io/metersphere/api/service/APIReportService.java
...ain/java/io/metersphere/api/service/APIReportService.java
+43
-8
backend/src/main/java/io/metersphere/api/service/APITestService.java
.../main/java/io/metersphere/api/service/APITestService.java
+8
-1
backend/src/main/resources/i18n/messages_en_US.properties
backend/src/main/resources/i18n/messages_en_US.properties
+1
-0
backend/src/main/resources/i18n/messages_zh_CN.properties
backend/src/main/resources/i18n/messages_zh_CN.properties
+1
-0
backend/src/main/resources/i18n/messages_zh_TW.properties
backend/src/main/resources/i18n/messages_zh_TW.properties
+1
-0
frontend/src/business/components/api/report/ApiReportView.vue
...tend/src/business/components/api/report/ApiReportView.vue
+12
-3
frontend/src/business/components/api/report/components/MetricChart.vue
...business/components/api/report/components/MetricChart.vue
+2
-2
frontend/src/business/components/api/test/ApiTestConfig.vue
frontend/src/business/components/api/test/ApiTestConfig.vue
+4
-1
未找到文件。
backend/src/main/java/io/metersphere/api/controller/APITestController.java
浏览文件 @
601cc893
...
...
@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.*;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
java.util.List
;
@RestController
...
...
@@ -64,7 +65,7 @@ public class APITestController {
}
@PostMapping
(
value
=
"/run"
)
public
void
run
(
@RequestBody
SaveAPITestRequest
request
)
{
apiTestService
.
run
(
request
);
public
String
run
(
@RequestBody
SaveAPITestRequest
request
)
{
return
apiTestService
.
run
(
request
);
}
}
backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java
浏览文件 @
601cc893
...
...
@@ -61,7 +61,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
queue
.
forEach
((
id
,
sampleResults
)
->
{
TestResult
testResult
=
new
TestResult
();
testResult
.
setId
(
id
);
testResult
.
set
Test
Id
(
id
);
testResult
.
setTotal
(
sampleResults
.
size
());
// key: 场景Id
...
...
@@ -104,7 +104,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
testResult
.
getScenarios
().
addAll
(
scenarios
.
values
());
testResult
.
getScenarios
().
sort
(
Comparator
.
comparing
(
ScenarioResult:
:
getOrder
));
apiTestService
.
changeStatus
(
id
,
APITestStatus
.
Completed
);
apiReportService
.
sav
e
(
testResult
);
apiReportService
.
complet
e
(
testResult
);
});
queue
.
clear
();
super
.
teardownTest
(
context
);
...
...
backend/src/main/java/io/metersphere/api/jmeter/TestResult.java
浏览文件 @
601cc893
...
...
@@ -8,7 +8,7 @@ import java.util.List;
@Data
public
class
TestResult
{
private
String
i
d
;
private
String
testI
d
;
private
int
success
=
0
;
...
...
backend/src/main/java/io/metersphere/api/service/APIReportService.java
浏览文件 @
601cc893
...
...
@@ -5,12 +5,15 @@ import io.metersphere.api.dto.APIReportResult;
import
io.metersphere.api.dto.DeleteAPIReportRequest
;
import
io.metersphere.api.dto.QueryAPIReportRequest
;
import
io.metersphere.api.jmeter.TestResult
;
import
io.metersphere.base.domain.ApiTest
;
import
io.metersphere.base.domain.ApiTestReport
;
import
io.metersphere.base.domain.ApiTest
WithBLOBs
;
import
io.metersphere.base.domain.ApiTest
ReportExample
;
import
io.metersphere.base.mapper.ApiTestReportMapper
;
import
io.metersphere.base.mapper.ext.ExtApiTestReportMapper
;
import
io.metersphere.commons.constants.APITestStatus
;
import
io.metersphere.commons.exception.MSException
;
import
io.metersphere.dto.DashboardTestDTO
;
import
io.metersphere.i18n.Translator
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -25,8 +28,6 @@ import javax.annotation.Resource;
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
class
APIReportService
{
@Resource
private
APITestService
apiTestService
;
@Resource
private
ApiTestReportMapper
apiTestReportMapper
;
@Resource
...
...
@@ -52,24 +53,58 @@ public class APIReportService {
apiTestReportMapper
.
deleteByPrimaryKey
(
request
.
getId
());
}
public
void
save
(
TestResult
result
)
{
ApiTestWithBLOBs
test
=
apiTestService
.
get
(
result
.
getId
());
public
void
deleteByTestId
(
String
testId
)
{
ApiTestReportExample
example
=
new
ApiTestReportExample
();
example
.
createCriteria
().
andTestIdEqualTo
(
testId
);
apiTestReportMapper
.
deleteByExample
(
example
);
}
public
void
complete
(
TestResult
result
)
{
ApiTestReport
report
=
getRunningReport
(
result
.
getTestId
());
if
(
report
==
null
)
{
MSException
.
throwException
(
Translator
.
get
(
"api_report_is_null"
));
}
report
.
setContent
(
JSONObject
.
toJSONString
(
result
));
report
.
setUpdateTime
(
System
.
currentTimeMillis
());
report
.
setStatus
(
APITestStatus
.
Completed
.
name
());
apiTestReportMapper
.
updateByPrimaryKeySelective
(
report
);
}
public
String
create
(
ApiTest
test
)
{
ApiTestReport
running
=
getRunningReport
(
test
.
getId
());
if
(
running
!=
null
)
{
return
running
.
getId
();
}
ApiTestReport
report
=
new
ApiTestReport
();
report
.
setId
(
UUID
.
randomUUID
().
toString
());
report
.
setTestId
(
resul
t
.
getId
());
report
.
setTestId
(
tes
t
.
getId
());
report
.
setName
(
test
.
getName
());
report
.
setDescription
(
test
.
getDescription
());
report
.
setContent
(
JSONObject
.
toJSONString
(
result
));
report
.
setCreateTime
(
System
.
currentTimeMillis
());
report
.
setUpdateTime
(
System
.
currentTimeMillis
());
report
.
setStatus
(
APITestStatus
.
Completed
.
name
());
report
.
setStatus
(
APITestStatus
.
Running
.
name
());
apiTestReportMapper
.
insert
(
report
);
return
report
.
getId
();
}
public
ApiTestReport
getRunningReport
(
String
testId
)
{
ApiTestReportExample
example
=
new
ApiTestReportExample
();
example
.
createCriteria
().
andTestIdEqualTo
(
testId
).
andStatusEqualTo
(
APITestStatus
.
Running
.
name
());
List
<
ApiTestReport
>
apiTestReports
=
apiTestReportMapper
.
selectByExample
(
example
);
if
(
apiTestReports
.
size
()
>
0
)
{
return
apiTestReports
.
get
(
0
);
}
else
{
return
null
;
}
}
public
List
<
DashboardTestDTO
>
dashboardTests
(
String
workspaceId
)
{
Instant
oneYearAgo
=
Instant
.
now
().
plus
(-
365
,
ChronoUnit
.
DAYS
);
long
startTimestamp
=
oneYearAgo
.
toEpochMilli
();
return
extApiTestReportMapper
.
selectDashboardTests
(
workspaceId
,
startTimestamp
);
}
}
backend/src/main/java/io/metersphere/api/service/APITestService.java
浏览文件 @
601cc893
...
...
@@ -39,6 +39,8 @@ public class APITestService {
private
FileService
fileService
;
@Resource
private
JMeterService
jMeterService
;
@Resource
private
APIReportService
apiReportService
;
public
List
<
APITestResult
>
list
(
QueryAPITestRequest
request
)
{
return
extApiTestMapper
.
list
(
request
);
...
...
@@ -71,18 +73,23 @@ public class APITestService {
public
void
delete
(
DeleteAPITestRequest
request
)
{
deleteFileByTestId
(
request
.
getId
());
apiReportService
.
deleteByTestId
(
request
.
getId
());
apiTestMapper
.
deleteByPrimaryKey
(
request
.
getId
());
}
public
void
run
(
SaveAPITestRequest
request
)
{
public
String
run
(
SaveAPITestRequest
request
)
{
ApiTestFile
file
=
getFileByTestId
(
request
.
getId
());
if
(
file
==
null
)
{
MSException
.
throwException
(
Translator
.
get
(
"file_cannot_be_null"
));
}
byte
[]
bytes
=
fileService
.
loadFileAsBytes
(
file
.
getFileId
());
InputStream
is
=
new
ByteArrayInputStream
(
bytes
);
String
reportId
=
apiReportService
.
create
(
get
(
request
.
getId
()));
changeStatus
(
request
.
getId
(),
APITestStatus
.
Running
);
jMeterService
.
run
(
is
);
return
reportId
;
}
public
void
changeStatus
(
String
id
,
APITestStatus
status
)
{
...
...
backend/src/main/resources/i18n/messages_en_US.properties
浏览文件 @
601cc893
...
...
@@ -37,6 +37,7 @@ organization_does_not_belong_to_user=The current organization does not belong to
organization_id_is_null
=
Organization ID cannot be null
#api
api_load_script_error
=
Load script error
api_report_is_null
=
"Report is null, can't update"
#test case
test_case_node_level
=
level
test_case_node_level_tip
=
The node tree maximum depth is
...
...
backend/src/main/resources/i18n/messages_zh_CN.properties
浏览文件 @
601cc893
...
...
@@ -37,6 +37,7 @@ organization_does_not_belong_to_user=当前组织不属于当前用户
organization_id_is_null
=
组织 ID 不能为空
#api
api_load_script_error
=
读取脚本失败
api_report_is_null
=
"测试报告是未生成,无法更新"
#test case
test_case_node_level
=
层
test_case_node_level_tip
=
模块树最大深度为
...
...
backend/src/main/resources/i18n/messages_zh_TW.properties
浏览文件 @
601cc893
...
...
@@ -37,6 +37,7 @@ organization_does_not_belong_to_user=當前組織不屬於當前用戶
organization_id_is_null
=
組織 ID 不能為空
#api
api_load_script_error
=
讀取腳本失敗
api_report_is_null
=
"測試報告是未生成,無法更新"
#test case
test_case_node_level
=
層
test_case_node_level_tip
=
模塊樹最大深度為
...
...
frontend/src/business/components/api/report/ApiReportView.vue
浏览文件 @
601cc893
...
...
@@ -5,9 +5,9 @@
<section
class=
"report-container"
v-if=
"this.report.testId"
>
<header
class=
"report-header"
>
<span>
{{
report
.
projectName
}}
/
</span>
<router-link
:to=
"path"
>
{{
report
.
testName
}}
</router-link>
<router-link
:to=
"path"
>
{{
report
.
testName
}}
[
{{
report
.
createTime
|
timestampFormatDate
}}
]
</router-link>
</header>
<main>
<main
v-if=
"this.isCompleted"
>
<div
class=
"scenario-chart"
>
<ms-metric-chart
:content=
"content"
></ms-metric-chart>
</div>
...
...
@@ -59,11 +59,17 @@
methods
:
{
getReport
()
{
this
.
report
=
{};
this
.
content
=
{};
if
(
this
.
reportId
)
{
let
url
=
"
/api/report/get/
"
+
this
.
reportId
;
this
.
result
=
this
.
$get
(
url
,
response
=>
{
this
.
report
=
response
.
data
||
{};
this
.
content
=
JSON
.
parse
(
this
.
report
.
content
);
if
(
this
.
isCompleted
)
{
this
.
content
=
JSON
.
parse
(
this
.
report
.
content
);
}
else
{
setTimeout
(
this
.
getReport
,
2000
)
}
});
}
}
...
...
@@ -83,6 +89,9 @@
},
path
()
{
return
"
/api/test/edit?id=
"
+
this
.
report
.
testId
;
},
isCompleted
()
{
return
"
Completed
"
===
this
.
report
.
status
;
}
}
}
...
...
frontend/src/business/components/api/report/components/MetricChart.vue
浏览文件 @
601cc893
...
...
@@ -96,8 +96,8 @@
show
:
false
},
data
:
[
{
value
:
this
.
content
.
success
,
name
:
this
.
$t
(
'
api_report.success
'
)
},
{
value
:
this
.
content
.
error
,
name
:
this
.
$t
(
'
api_report.fail
'
)
},
{
value
:
this
.
content
.
success
},
{
value
:
this
.
content
.
error
},
]
}
]
...
...
frontend/src/business/components/api/test/ApiTestConfig.vue
浏览文件 @
601cc893
...
...
@@ -120,8 +120,11 @@
})
},
runTest
:
function
()
{
this
.
result
=
this
.
$post
(
"
/api/run
"
,
{
id
:
this
.
test
.
id
},
()
=>
{
this
.
result
=
this
.
$post
(
"
/api/run
"
,
{
id
:
this
.
test
.
id
},
(
response
)
=>
{
this
.
$success
(
this
.
$t
(
'
api_test.running
'
));
this
.
$router
.
push
({
path
:
'
/api/report/view/
'
+
response
.
data
})
});
},
saveRunTest
:
function
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录