Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
e968eeac
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,发现更多精彩内容 >>
提交
e968eeac
编写于
4月 22, 2021
作者:
F
fit2-zhao
提交者:
fit2-zhao
4月 22, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(接口自动化): 修复环境匹配取消,执行优化等 问题
上级
006e382d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
74 addition
and
30 deletion
+74
-30
backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java
...pi/dto/definition/request/sampler/MsHTTPSamplerProxy.java
+18
-3
backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java
.../io/metersphere/api/service/ApiScenarioModuleService.java
+12
-14
frontend/src/business/components/api/automation/scenario/AddBasisScenario.vue
...s/components/api/automation/scenario/AddBasisScenario.vue
+9
-8
frontend/src/business/components/api/automation/scenario/component/ApiResponseComponent.vue
...pi/automation/scenario/component/ApiResponseComponent.vue
+3
-0
frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue
...nts/api/automation/scenario/component/ComponentConfig.vue
+6
-4
frontend/src/business/components/api/definition/components/case/MsEnvironmentSelect.vue
...ts/api/definition/components/case/MsEnvironmentSelect.vue
+5
-0
frontend/src/business/components/api/definition/components/response/RequestMetric.vue
...ents/api/definition/components/response/RequestMetric.vue
+21
-1
未找到文件。
backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java
浏览文件 @
e968eeac
...
...
@@ -18,12 +18,14 @@ import io.metersphere.api.service.ApiTestCaseService;
import
io.metersphere.base.domain.ApiDefinition
;
import
io.metersphere.base.domain.ApiDefinitionWithBLOBs
;
import
io.metersphere.base.domain.ApiTestCaseWithBLOBs
;
import
io.metersphere.base.domain.TestPlanApiCase
;
import
io.metersphere.commons.constants.ConditionType
;
import
io.metersphere.commons.constants.MsTestElementConstants
;
import
io.metersphere.commons.exception.MSException
;
import
io.metersphere.commons.utils.CommonBeanFactory
;
import
io.metersphere.commons.utils.LogUtil
;
import
io.metersphere.commons.utils.ScriptEngineUtils
;
import
io.metersphere.track.service.TestPlanApiCaseService
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
org.apache.commons.collections.CollectionUtils
;
...
...
@@ -203,7 +205,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
if
(
config
.
isEffective
(
this
.
getProjectId
()))
{
HttpConfig
httpConfig
=
getHttpConfig
(
config
.
getConfig
().
get
(
this
.
getProjectId
()).
getHttpConfig
(),
tree
);
if
(
httpConfig
==
null
)
{
MSException
.
throwException
(
"
未匹配到环境,请检查环境配置"
);
MSException
.
throwException
(
this
.
getName
()
+
"
未匹配到环境,请检查环境配置"
);
}
String
url
=
httpConfig
.
getProtocol
()
+
"://"
+
httpConfig
.
getSocket
();
// 补充如果是完整URL 则用自身URL
...
...
@@ -424,6 +426,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
tree
.
add
(
headerManager
);
}
}
/**
* 按照环境规则匹配环境
*
...
...
@@ -444,12 +447,22 @@ public class MsHTTPSamplerProxy extends MsTestElement {
}
else
if
(
item
.
getType
().
equals
(
ConditionType
.
MODULE
.
name
()))
{
ApiDefinition
apiDefinition
;
ApiDefinitionService
apiDefinitionService
=
CommonBeanFactory
.
getBean
(
ApiDefinitionService
.
class
);
ApiTestCaseService
apiTestCaseService
=
CommonBeanFactory
.
getBean
(
ApiTestCaseService
.
class
);
if
(
StringUtils
.
isNotEmpty
(
this
.
getReferenced
())
&&
this
.
getReferenced
().
equals
(
"REF"
)
&&
StringUtils
.
isNotEmpty
(
this
.
getRefType
())
&&
this
.
getRefType
().
equals
(
"CASE"
))
{
ApiTestCaseService
apiTestCaseService
=
CommonBeanFactory
.
getBean
(
ApiTestCaseService
.
class
);
ApiTestCaseWithBLOBs
caseWithBLOBs
=
apiTestCaseService
.
get
(
this
.
getId
());
apiDefinition
=
apiDefinitionService
.
get
(
caseWithBLOBs
.
getApiDefinitionId
());
}
else
{
apiDefinition
=
apiDefinitionService
.
get
(
this
.
getId
());
if
(
apiDefinition
==
null
)
{
TestPlanApiCaseService
testPlanApiCaseService
=
CommonBeanFactory
.
getBean
(
TestPlanApiCaseService
.
class
);
TestPlanApiCase
testPlanApiCase
=
testPlanApiCaseService
.
getById
(
this
.
getId
());
if
(
testPlanApiCase
!=
null
)
{
ApiTestCaseWithBLOBs
caseWithBLOBs
=
apiTestCaseService
.
get
(
testPlanApiCase
.
getApiCaseId
());
if
(
caseWithBLOBs
!=
null
)
{
apiDefinition
=
apiDefinitionService
.
get
(
caseWithBLOBs
.
getApiDefinitionId
());
}
}
}
}
if
(
apiDefinition
!=
null
)
{
HttpConfig
config
=
httpConfig
.
getModuleCondition
(
apiDefinition
.
getModuleId
(),
item
);
...
...
@@ -470,7 +483,9 @@ public class MsHTTPSamplerProxy extends MsTestElement {
}
}
}
if
(
httpConfig
!=
null
&&
(
StringUtils
.
isEmpty
(
httpConfig
.
getProtocol
())
||
StringUtils
.
isEmpty
(
httpConfig
.
getSocket
())))
{
return
null
;
}
// 环境中请求头
if
(
httpConfig
!=
null
)
{
Arguments
arguments
=
arguments
(
httpConfig
.
getHeaders
());
...
...
backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java
浏览文件 @
e968eeac
...
...
@@ -189,20 +189,18 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
public
int
editNode
(
DragApiScenarioModuleRequest
request
)
{
request
.
setUpdateTime
(
System
.
currentTimeMillis
());
checkApiScenarioModuleExist
(
request
);
List
<
ApiScenarioDTO
>
apiScenarios
=
queryByModuleIds
(
request
);
apiScenarios
.
forEach
(
apiScenario
->
{
StringBuilder
path
=
new
StringBuilder
(
apiScenario
.
getModulePath
());
List
<
String
>
pathLists
=
Arrays
.
asList
(
path
.
toString
().
split
(
"/"
));
pathLists
.
set
(
request
.
getLevel
(),
request
.
getName
());
path
.
delete
(
0
,
path
.
length
());
for
(
int
i
=
1
;
i
<
pathLists
.
size
();
i
++)
{
path
.
append
(
"/"
).
append
(
pathLists
.
get
(
i
));
}
apiScenario
.
setModulePath
(
path
.
toString
());
});
batchUpdateApiScenario
(
apiScenarios
);
// List<ApiScenarioDTO> apiScenarios = queryByModuleIds(request);
// apiScenarios.forEach(apiScenario -> {
// StringBuilder path = new StringBuilder(apiScenario.getModulePath());
// List<String> pathLists = Arrays.asList(path.toString().split("/"));
// pathLists.set(request.getLevel(), request.getName());
// path.delete(0, path.length());
// for (int i = 1; i < pathLists.size(); i++) {
// path.append("/").append(pathLists.get(i));
// }
// apiScenario.setModulePath(path.toString());
// });
// batchUpdateApiScenario(apiScenarios);
return
apiScenarioModuleMapper
.
updateByPrimaryKeySelective
(
request
);
}
...
...
frontend/src/business/components/api/automation/scenario/AddBasisScenario.vue
浏览文件 @
e968eeac
...
...
@@ -95,15 +95,16 @@
if
(
valid
)
{
let
path
=
"
/api/automation/create
"
;
this
.
setParameter
();
this
.
$fileUpload
(
path
,
null
,
[],
this
.
scenarioForm
,
()
=>
{
if
(
saveAs
)
{
this
.
scenarioForm
.
request
=
JSON
.
stringify
(
this
.
scenarioForm
.
request
);
this
.
$emit
(
'
saveAsEdit
'
,
this
.
scenarioForm
);
this
.
visible
=
false
;
if
(
saveAs
)
{
this
.
scenarioForm
.
request
=
JSON
.
stringify
(
this
.
scenarioForm
.
request
);
this
.
$emit
(
'
saveAsEdit
'
,
this
.
scenarioForm
);
}
else
{
}
else
{
this
.
$fileUpload
(
path
,
null
,
[],
this
.
scenarioForm
,
()
=>
{
this
.
visible
=
false
;
this
.
$emit
(
'
refresh
'
);
}
}
);
}
);
}
}
else
{
return
false
;
}
...
...
@@ -117,7 +118,7 @@
if
(
this
.
currentModule
&&
this
.
currentModule
.
id
!=
"
root
"
)
{
this
.
scenarioForm
.
modulePath
=
this
.
currentModule
.
method
!==
undefined
?
this
.
currentModule
.
method
:
null
;
this
.
scenarioForm
.
apiScenarioModuleId
=
this
.
currentModule
.
id
;
}
else
{
}
else
{
this
.
scenarioForm
.
modulePath
=
this
.
$t
(
"
commons.module_title
"
);
this
.
scenarioForm
.
apiScenarioModuleId
=
"
default-module
"
;
}
...
...
frontend/src/business/components/api/automation/scenario/component/ApiResponseComponent.vue
浏览文件 @
e968eeac
...
...
@@ -46,6 +46,9 @@
result
()
{
this
.
response
=
this
.
result
;
this
.
isActive
=
true
;
},
apiItem
(){
this
.
getExecResult
();
}
},
methods
:
{
...
...
frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue
浏览文件 @
e968eeac
<
template
>
<div
class=
"request-form"
>
<component
:is=
"component"
:isMax=
"isMax"
:show-btn=
"showBtn"
:scenario=
"scenario"
:controller=
"scenario"
:timer=
"scenario"
:assertions=
"scenario"
:extract=
"scenario"
:jsr223-processor=
"scenario"
:request=
"scenario"
:currentScenario=
"currentScenario"
:currentEnvironmentId=
"currentEnvironmentId"
:node=
"node"
:draggable=
"draggable"
:title=
"title"
:color=
"titleColor"
:background-color=
"backgroundColor"
@
suggestClick=
"suggestClick(node)"
:response=
"response"
@
remove=
"remove"
@
copyRow=
"copyRow"
@
refReload=
"refReload"
@
openScenario=
"openScenario"
:project-list=
"projectList"
:env-map=
"envMap"
/>
<keep-alive>
<component
v-bind:is=
"component"
:isMax=
"isMax"
:show-btn=
"showBtn"
:scenario=
"scenario"
:controller=
"scenario"
:timer=
"scenario"
:assertions=
"scenario"
:extract=
"scenario"
:jsr223-processor=
"scenario"
:request=
"scenario"
:currentScenario=
"currentScenario"
:currentEnvironmentId=
"currentEnvironmentId"
:node=
"node"
:draggable=
"draggable"
:title=
"title"
:color=
"titleColor"
:background-color=
"backgroundColor"
@
suggestClick=
"suggestClick(node)"
:response=
"response"
@
remove=
"remove"
@
copyRow=
"copyRow"
@
refReload=
"refReload"
@
openScenario=
"openScenario"
:project-list=
"projectList"
:env-map=
"envMap"
/>
</keep-alive>
</div>
</
template
>
...
...
frontend/src/business/components/api/definition/components/case/MsEnvironmentSelect.vue
浏览文件 @
e968eeac
...
...
@@ -55,6 +55,7 @@
},
methods
:
{
getEnvironments
()
{
let
flag
=
false
;
if
(
this
.
projectId
)
{
this
.
$get
(
'
/api/environment/list/
'
+
this
.
projectId
,
response
=>
{
this
.
environments
=
response
.
data
;
...
...
@@ -62,12 +63,16 @@
parseEnvironment
(
environment
);
if
(
this
.
useEnvironment
&&
this
.
useEnvironment
===
environment
.
id
)
{
this
.
environmentId
=
this
.
useEnvironment
;
flag
=
true
;
}
});
});
}
else
{
this
.
environmentId
=
undefined
;
}
if
(
this
.
useEnvironment
&&
!
flag
){
this
.
$emit
(
'
setEnvironment
'
,
{});
}
},
openEnvironmentConfig
()
{
if
(
!
this
.
projectId
)
{
...
...
frontend/src/business/components/api/definition/components/response/RequestMetric.vue
浏览文件 @
e968eeac
...
...
@@ -3,7 +3,13 @@
<el-row
type=
"flex"
>
<el-col>
<div
style=
"font-size: 14px;color: #AAAAAA;float: left"
>
{{
$t
(
'
api_report.response_code
'
)
}}
:
</div>
<div
style=
"font-size: 14px;color:#61C550;margin-top:2px;margin-left:10px;float: left"
>
{{
response
.
responseResult
&&
response
.
responseResult
.
responseCode
?
response
.
responseResult
.
responseCode
:
'
0
'
}}
</div>
<el-tooltip
:content=
"response.responseResult.responseCode"
placement=
"top"
>
<div
class=
"node-title"
>
{{
response
.
responseResult
&&
response
.
responseResult
.
responseCode
?
response
.
responseResult
.
responseCode
:
'
0
'
}}
</div>
</el-tooltip>
</el-col>
<el-col>
<div
style=
"font-size: 14px;color: #AAAAAA;float: left"
>
{{
$t
(
'
api_report.response_time
'
)
}}
:
</div>
...
...
@@ -37,4 +43,18 @@
.metric-container
{
padding-bottom
:
20px
;
}
.node-title
{
width
:
150px
;
text-overflow
:
ellipsis
;
white-space
:
nowrap
;
flex
:
1
1
auto
;
padding
:
0px
5px
;
overflow
:
hidden
;
font-size
:
14px
;
color
:
#61C550
;
margin-top
:
2px
;
margin-left
:
10px
;
float
:
left
}
</
style
>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录