Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
8423f59b
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,发现更多精彩内容 >>
提交
8423f59b
编写于
4月 12, 2021
作者:
F
fit2-zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(接口自动化): 1.8版本部分缺陷修复
上级
2aca9639
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
80 addition
and
50 deletion
+80
-50
backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java
...api/dto/definition/request/controller/MsIfController.java
+6
-2
backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java
...i/dto/definition/request/controller/MsLoopController.java
+7
-2
backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java
...pi/dto/definition/request/sampler/MsHTTPSamplerProxy.java
+0
-8
backend/src/main/java/io/metersphere/api/jmeter/JMeterVars.java
...d/src/main/java/io/metersphere/api/jmeter/JMeterVars.java
+26
-21
backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java
...java/io/metersphere/api/service/ApiAutomationService.java
+1
-1
frontend/src/business/components/api/automation/report/ApiReportDetail.vue
...ness/components/api/automation/report/ApiReportDetail.vue
+37
-16
frontend/src/business/components/api/automation/report/components/RequestResult.vue
...onents/api/automation/report/components/RequestResult.vue
+3
-0
未找到文件。
backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java
浏览文件 @
8423f59b
...
...
@@ -76,8 +76,12 @@ public class MsIfController extends MsTestElement {
public
String
getCondition
()
{
String
variable
=
"\""
+
this
.
variable
+
"\""
;
String
operator
=
this
.
operator
;
String
value
=
"\""
+
this
.
value
+
"\""
;
String
value
;
if
(
StringUtils
.
equals
(
operator
,
"<"
)
||
StringUtils
.
equals
(
operator
,
">"
))
{
value
=
this
.
value
;
}
else
{
value
=
"\""
+
this
.
value
+
"\""
;
}
if
(
StringUtils
.
contains
(
operator
,
"~"
))
{
value
=
"\".*"
+
this
.
value
+
".*\""
;
}
...
...
backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java
浏览文件 @
8423f59b
...
...
@@ -56,7 +56,7 @@ public class MsLoopController extends MsTestElement {
}
final
HashTree
groupTree
=
controller
(
tree
);
if
(
CollectionUtils
.
isNotEmpty
(
config
.
getVariables
()))
{
this
.
addCsvDataSet
(
groupTree
,
config
.
getVariables
(),
config
);
this
.
addCsvDataSet
(
groupTree
,
config
.
getVariables
(),
config
);
this
.
addCounter
(
groupTree
,
config
.
getVariables
());
this
.
addRandom
(
groupTree
,
config
.
getVariables
());
}
...
...
@@ -111,7 +111,12 @@ public class MsLoopController extends MsTestElement {
private
String
getCondition
()
{
String
variable
=
"\""
+
this
.
whileController
.
getVariable
()
+
"\""
;
String
operator
=
this
.
whileController
.
getOperator
();
String
value
=
"\""
+
this
.
whileController
.
getValue
()
+
"\""
;
String
value
;
if
(
StringUtils
.
equals
(
operator
,
"<"
)
||
StringUtils
.
equals
(
operator
,
">"
))
{
value
=
this
.
whileController
.
getValue
();
}
else
{
value
=
"\""
+
this
.
whileController
.
getValue
()
+
"\""
;
}
if
(
StringUtils
.
contains
(
operator
,
"~"
))
{
value
=
"\".*"
+
this
.
whileController
.
getValue
()
+
".*\""
;
...
...
backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java
浏览文件 @
8423f59b
...
...
@@ -248,14 +248,6 @@ public class MsHTTPSamplerProxy extends MsTestElement {
LogUtil
.
error
(
e
);
MSException
.
throwException
(
e
.
getMessage
());
}
// REST参数
if
(
CollectionUtils
.
isNotEmpty
(
this
.
getRest
()))
{
sampler
.
setArguments
(
httpArguments
(
this
.
getRest
()));
}
// 请求参数
if
(
CollectionUtils
.
isNotEmpty
(
this
.
getArguments
()))
{
sampler
.
setArguments
(
httpArguments
(
this
.
getArguments
()));
}
// 请求体
if
(!
StringUtils
.
equals
(
this
.
getMethod
(),
"GET"
))
{
if
(
this
.
body
!=
null
)
{
...
...
backend/src/main/java/io/metersphere/api/jmeter/JMeterVars.java
浏览文件 @
8423f59b
...
...
@@ -2,6 +2,7 @@ package io.metersphere.api.jmeter;
import
com.alibaba.fastjson.JSON
;
import
io.github.ningyu.jmeter.plugin.dubbo.sample.DubboSample
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.jmeter.extractor.JSR223PostProcessor
;
import
org.apache.jmeter.extractor.RegexExtractor
;
import
org.apache.jmeter.extractor.XPath2Extractor
;
...
...
@@ -31,32 +32,36 @@ public class JMeterVars {
* @param vars
* @param extract
*/
public
static
void
addVars
(
Integer
testId
,
JMeterVariables
vars
,
String
extract
)
{
JMeterVariables
vs
=
new
JMeterVariables
();
public
static
void
addVars
(
Integer
testId
,
JMeterVariables
vars
,
String
extract
)
{
JMeterVariables
vs
=
variables
.
get
(
testId
);
if
(
vs
==
null
)
{
vs
=
new
JMeterVariables
();
}
if
(!
StringUtils
.
isEmpty
(
extract
)
&&
vars
!=
null
)
{
List
<
String
>
extracts
=
Arrays
.
asList
(
extract
.
split
(
";"
));
Optional
.
ofNullable
(
extracts
).
orElse
(
new
ArrayList
<>()).
forEach
(
item
->
{
String
nrKey
=
item
+
"_matchNr"
;
Object
nr
=
vars
.
get
(
nrKey
);
if
(
nr
!=
null
)
{
int
nrv
=
0
;
try
{
nrv
=
Integer
.
valueOf
(
String
.
valueOf
(
nr
));
}
catch
(
Exception
e
)
{
}
if
(
nrv
>
0
)
{
List
<
Object
>
data
=
new
ArrayList
<>();
for
(
int
i
=
1
;
i
<
nrv
+
1
;
i
++)
{
data
.
add
(
vars
.
get
(
item
+
"_"
+
i
));
if
(
CollectionUtils
.
isNotEmpty
(
extracts
))
{
for
(
String
item
:
extracts
)
{
String
nrKey
=
item
+
"_matchNr"
;
Object
nr
=
vars
.
get
(
nrKey
);
if
(
nr
!=
null
)
{
int
nrv
=
0
;
try
{
nrv
=
Integer
.
valueOf
(
String
.
valueOf
(
nr
));
}
catch
(
Exception
e
)
{
}
if
(
nrv
>
0
)
{
List
<
Object
>
data
=
new
ArrayList
<>();
for
(
int
i
=
1
;
i
<
nrv
+
1
;
i
++)
{
data
.
add
(
vars
.
get
(
item
+
"_"
+
i
));
}
String
array
=
JSON
.
toJSONString
(
data
);
vars
.
put
(
item
,
array
);
}
String
array
=
JSON
.
toJSONString
(
data
);
vars
.
put
(
item
,
array
);
}
vs
.
put
(
item
,
vars
.
get
(
item
)
==
null
?
""
:
vars
.
get
(
item
));
}
vs
.
put
(
item
,
vars
.
get
(
item
)
==
null
?
""
:
vars
.
get
(
item
));
});
vs
.
remove
(
"TESTSTART.MS"
);
// 标示变量移除
vs
.
remove
(
"TESTSTART.MS"
);
// 标示变量移除
}
}
variables
.
put
(
testId
,
vs
);
...
...
backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java
浏览文件 @
8423f59b
...
...
@@ -533,7 +533,7 @@ public class ApiAutomationService {
}
public
byte
[]
loadFileAsBytes
(
FileOperationRequest
fileOperationRequest
)
{
File
file
=
new
File
(
FileUtils
.
BODY_FILE_DIR
+
fileOperationRequest
.
getId
()
+
"_"
+
fileOperationRequest
.
getName
());
File
file
=
new
File
(
FileUtils
.
BODY_FILE_DIR
+
"/"
+
fileOperationRequest
.
getId
()
+
"_"
+
fileOperationRequest
.
getName
());
try
(
FileInputStream
fis
=
new
FileInputStream
(
file
);
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
(
1000
);)
{
byte
[]
b
=
new
byte
[
1000
];
...
...
frontend/src/business/components/api/automation/report/ApiReportDetail.vue
浏览文件 @
8423f59b
...
...
@@ -29,6 +29,7 @@
</template>
<
script
>
import
MsRequestResult
from
"
./components/RequestResult
"
;
import
MsRequestResultTail
from
"
./components/RequestResultTail
"
;
import
MsScenarioResult
from
"
./components/ScenarioResult
"
;
...
...
@@ -39,7 +40,8 @@
import
MsApiReportExport
from
"
./ApiReportExport
"
;
import
MsApiReportViewHeader
from
"
./ApiReportViewHeader
"
;
import
{
RequestFactory
}
from
"
../../definition/model/ApiTestModel
"
;
import
{
windowPrint
}
from
"
@/common/js/utils
"
;
import
{
windowPrint
,
getUUID
}
from
"
@/common/js/utils
"
;
export
default
{
name
:
"
MsApiReport
"
,
components
:
{
...
...
@@ -105,7 +107,7 @@
if
(
item
&&
item
.
requestResults
)
{
item
.
requestResults
.
forEach
(
req
=>
{
resMap
.
set
(
req
.
id
,
req
);
req
.
name
=
item
.
name
+
"
^@~@^
"
+
req
.
name
;
req
.
name
=
item
.
name
+
"
^@~@^
"
+
req
.
name
+
"
UUID=
"
+
getUUID
()
;
array
.
push
(
req
);
})
}
...
...
@@ -122,51 +124,60 @@
let
children
=
tree
;
// 循环构建子节点
for
(
let
i
in
nodeArray
)
{
if
(
!
nodeArray
[
i
])
{
continue
;
}
let
node
=
{
label
:
nodeArray
[
i
],
value
:
item
,
};
if
(
i
!=
nodeArray
.
length
)
{
if
(
i
!=
=
nodeArray
.
length
)
{
node
.
children
=
[];
}
if
(
children
.
length
==
0
)
{
if
(
children
.
length
===
0
)
{
children
.
push
(
node
);
}
let
isExist
=
false
;
for
(
let
j
in
children
)
{
if
(
children
[
j
].
label
==
node
.
label
)
{
if
(
i
!=
nodeArray
.
length
-
1
&&
!
children
[
j
].
children
)
{
if
(
children
[
j
].
label
==
=
node
.
label
)
{
if
(
i
!=
=
nodeArray
.
length
-
1
&&
!
children
[
j
].
children
)
{
children
[
j
].
children
=
[];
}
children
=
(
i
==
nodeArray
.
length
-
1
?
children
:
children
[
j
].
children
);
children
=
(
i
==
=
nodeArray
.
length
-
1
?
children
:
children
[
j
].
children
);
isExist
=
true
;
break
;
}
}
if
(
!
isExist
)
{
children
.
push
(
node
);
if
(
i
!=
nodeArray
.
length
-
1
&&
!
children
[
children
.
length
-
1
].
children
)
{
if
(
i
!=
=
nodeArray
.
length
-
1
&&
!
children
[
children
.
length
-
1
].
children
)
{
children
[
children
.
length
-
1
].
children
=
[];
}
children
=
(
i
==
nodeArray
.
length
-
1
?
children
:
children
[
children
.
length
-
1
].
children
);
children
=
(
i
==
=
nodeArray
.
length
-
1
?
children
:
children
[
children
.
length
-
1
].
children
);
}
}
})
},
recursiveSorting
(
arr
)
{
for
(
let
i
in
arr
)
{
arr
[
i
].
index
=
Number
(
i
)
+
1
;
if
(
arr
[
i
].
children
!=
undefined
&&
arr
[
i
].
children
.
length
>
0
)
{
this
.
recursiveSorting
(
arr
[
i
].
children
);
if
(
arr
[
i
])
{
arr
[
i
].
index
=
Number
(
i
)
+
1
;
if
(
arr
[
i
].
children
&&
arr
[
i
].
children
.
length
>
0
)
{
this
.
recursiveSorting
(
arr
[
i
].
children
);
}
}
}
},
sort
(
scenarioDefinition
)
{
for
(
let
i
in
scenarioDefinition
)
{
// 排序
scenarioDefinition
[
i
].
index
=
Number
(
i
)
+
1
;
if
(
scenarioDefinition
[
i
].
children
!=
undefined
&&
scenarioDefinition
[
i
].
children
.
length
>
0
)
{
this
.
recursiveSorting
(
scenarioDefinition
[
i
].
children
);
if
(
scenarioDefinition
[
i
])
{
scenarioDefinition
[
i
].
index
=
Number
(
i
)
+
1
;
if
(
scenarioDefinition
[
i
].
children
&&
scenarioDefinition
[
i
].
children
.
length
>
0
)
{
this
.
recursiveSorting
(
scenarioDefinition
[
i
].
children
);
}
}
}
},
...
...
@@ -216,7 +227,7 @@
if
(
!
request
.
success
)
{
let
failRequest
=
Object
.
assign
({},
request
);
failScenario
.
requestResults
.
push
(
failRequest
);
array
.
push
(
request
)
array
.
push
(
request
)
;
}
})
}
...
...
@@ -286,9 +297,11 @@
this
.
$router
.
go
(
0
);
}
},
created
()
{
this
.
getReport
();
},
computed
:
{
path
()
{
return
"
/api/test/edit?id=
"
+
this
.
report
.
testId
;
...
...
@@ -309,30 +322,38 @@
</
style
>
<
style
scoped
>
.report-container
{
height
:
calc
(
100vh
-
155px
);
min-height
:
600px
;
overflow-y
:
auto
;
}
.report-header
{
font-size
:
15px
;
}
.report-header
a
{
text-decoration
:
none
;
}
.report-header
.time
{
color
:
#909399
;
margin-left
:
10px
;
}
.report-container
.fail
{
color
:
#F56C6C
;
}
.report-container
.is-active
.fail
{
color
:
inherit
;
}
.export-button
{
float
:
right
;
}
.scenario-result
.icon.is-active
{
transform
:
rotate
(
90deg
);
}
...
...
frontend/src/business/components/api/automation/report/components/RequestResult.vue
浏览文件 @
8423f59b
...
...
@@ -101,6 +101,9 @@
getName
(
name
)
{
if
(
name
&&
name
.
indexOf
(
"
^@~@^
"
)
!=
-
1
)
{
let
arr
=
name
.
split
(
"
^@~@^
"
);
if
(
arr
[
arr
.
length
-
1
].
indexOf
(
"
UUID=
"
))
{
return
arr
[
arr
.
length
-
1
].
split
(
"
UUID=
"
)[
0
];
}
return
arr
[
arr
.
length
-
1
];
}
return
name
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录