Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
f6af7c9d
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,发现更多精彩内容 >>
提交
f6af7c9d
编写于
10月 13, 2020
作者:
F
fit2-zhao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/metersphere/metersphere
上级
bb871102
1abf0de6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
38 addition
and
7 deletion
+38
-7
backend/pom.xml
backend/pom.xml
+9
-0
backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java
...rc/main/java/io/metersphere/api/jmeter/JMeterService.java
+2
-6
backend/src/main/java/io/metersphere/listener/AppStartListener.java
...c/main/java/io/metersphere/listener/AppStartListener.java
+26
-0
frontend/src/common/js/ajax.js
frontend/src/common/js/ajax.js
+1
-1
未找到文件。
backend/pom.xml
浏览文件 @
f6af7c9d
...
...
@@ -497,6 +497,15 @@
<outputDirectory>
src/main/resources/jmeter/lib/ext
</outputDirectory>
<destFileName>
ApacheJMeter_functions.jar
</destFileName>
</artifactItem>
<artifactItem>
<groupId>
org.python
</groupId>
<artifactId>
jython-standalone
</artifactId>
<version>
2.7.0
</version>
<type>
jar
</type>
<overWrite>
true
</overWrite>
<outputDirectory>
src/main/resources/jmeter/lib/ext
</outputDirectory>
<destFileName>
jython-standalone.jar
</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>
${project.build.directory}/wars
</outputDirectory>
<overWriteReleases>
false
</overWriteReleases>
...
...
backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java
浏览文件 @
f6af7c9d
...
...
@@ -11,7 +11,7 @@ import org.apache.jmeter.save.SaveService;
import
org.apache.jmeter.util.JMeterUtils
;
import
org.apache.jmeter.visualizers.backend.BackendListener
;
import
org.apache.jorphan.collections.HashTree
;
import
org.python.core.Options
;
import
org.springframework.context.i18n.LocaleContextHolder
;
import
org.springframework.stereotype.Service
;
...
...
@@ -34,10 +34,6 @@ public class JMeterService {
JMeterUtils
.
setJMeterHome
(
JMETER_HOME
);
JMeterUtils
.
setLocale
(
LocaleContextHolder
.
getLocale
());
//解决无法加载 PyScriptEngineFactory
Options
.
importSite
=
false
;
try
{
Object
scriptWrapper
=
SaveService
.
loadElement
(
is
);
HashTree
testPlan
=
getHashTree
(
scriptWrapper
);
...
...
@@ -51,7 +47,7 @@ public class JMeterService {
}
}
p
rivate
String
getJmeterHome
()
{
p
ublic
String
getJmeterHome
()
{
String
home
=
getClass
().
getResource
(
"/"
).
getPath
()
+
"jmeter"
;
try
{
File
file
=
new
File
(
home
);
...
...
backend/src/main/java/io/metersphere/listener/AppStartListener.java
浏览文件 @
f6af7c9d
package
io.metersphere.listener
;
import
io.metersphere.api.jmeter.JMeterService
;
import
io.metersphere.commons.utils.LogUtil
;
import
io.metersphere.service.ScheduleService
;
import
org.python.core.Options
;
import
org.python.util.PythonInterpreter
;
import
org.springframework.boot.context.event.ApplicationReadyEvent
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.stereotype.Component
;
...
...
@@ -12,12 +16,16 @@ public class AppStartListener implements ApplicationListener<ApplicationReadyEve
@Resource
private
ScheduleService
scheduleService
;
@Resource
private
JMeterService
jMeterService
;
@Override
public
void
onApplicationEvent
(
ApplicationReadyEvent
applicationReadyEvent
)
{
System
.
out
.
println
(
"================= 应用启动 ================="
);
initPythonEnv
();
try
{
Thread
.
sleep
(
3
*
60
*
1000
);
}
catch
(
InterruptedException
e
)
{
...
...
@@ -25,6 +33,24 @@ public class AppStartListener implements ApplicationListener<ApplicationReadyEve
}
scheduleService
.
startEnableSchedules
();
}
/**
* 解决接口测试-无法导入内置python包
*/
private
void
initPythonEnv
()
{
//解决无法加载 PyScriptEngineFactory
Options
.
importSite
=
false
;
try
{
PythonInterpreter
interp
=
new
PythonInterpreter
();
String
path
=
jMeterService
.
getJmeterHome
();
System
.
out
.
println
(
"sys.path: "
+
path
);
path
+=
"/lib/ext/jython-standalone.jar/Lib"
;
interp
.
exec
(
"import sys"
);
interp
.
exec
(
"sys.path.append(\""
+
path
+
"\")"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
LogUtil
.
error
(
e
.
getMessage
(),
e
);
}
}
}
frontend/src/common/js/ajax.js
浏览文件 @
f6af7c9d
...
...
@@ -61,7 +61,7 @@ export default {
window
.
console
.
error
(
error
.
response
||
error
.
message
);
if
(
error
.
response
&&
error
.
response
.
data
)
{
if
(
error
.
response
.
headers
[
"
authentication-status
"
]
!==
"
invalid
"
)
{
Message
.
error
({
message
:
error
.
response
.
data
.
message
,
showClose
:
true
});
Message
.
error
({
message
:
error
.
response
.
data
.
message
||
error
.
response
.
data
,
showClose
:
true
});
}
}
else
{
Message
.
error
({
message
:
error
.
message
,
showClose
:
true
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录