Merge remote-tracking branch 'origin/master' into master

This commit is contained in:
Captain.B 2020-10-13 17:17:57 +08:00
commit 0e23dbd564
11 changed files with 99 additions and 63 deletions

View File

@ -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>

View File

@ -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 {
}
}
private String getJmeterHome() {
public String getJmeterHome() {
String home = getClass().getResource("/").getPath() + "jmeter";
try {
File file = new File(home);

View File

@ -1,6 +1,10 @@
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);
}
}
}

View File

@ -8,7 +8,7 @@
<el-input :disabled="isReadOnly" class="test-name" v-model="test.name" maxlength="60"
:placeholder="$t('api_test.input_name')"
show-word-limit>
<el-select :disabled="isReadOnly" class="test-project" v-model="test.projectId" slot="prepend"
<el-select filterable class="test-project" v-model="test.projectId" slot="prepend"
:placeholder="$t('api_test.select_project')">
<el-option v-for="project in projects" :key="project.id" :label="project.name" :value="project.id"/>
</el-select>

View File

@ -9,7 +9,7 @@
maxlength="30" show-word-limit
>
<template v-slot:prepend>
<el-select :disabled="isReadOnly" v-model="testPlan.projectId"
<el-select filterable v-model="testPlan.projectId"
:placeholder="$t('load_test.select_project')">
<el-option
v-for="item in projects"

View File

@ -101,7 +101,7 @@
<el-form :model="memberForm" ref="form" :rules="orgMemberRule" label-position="right" label-width="100px"
size="small">
<el-form-item :label="$t('commons.member')" prop="userIds">
<el-select v-model="memberForm.userIds" multiple :placeholder="$t('member.please_choose_member')"
<el-select filterable v-model="memberForm.userIds" multiple :placeholder="$t('member.please_choose_member')"
class="select-width">
<el-option
v-for="item in memberForm.userList"
@ -114,7 +114,7 @@
</el-select>
</el-form-item>
<el-form-item :label="$t('commons.role')" prop="roleIds">
<el-select v-model="memberForm.roleIds" multiple :placeholder="$t('role.please_choose_role')"
<el-select filterable v-model="memberForm.roleIds" multiple :placeholder="$t('role.please_choose_role')"
class="select-width">
<el-option
v-for="item in memberForm.roles"
@ -151,7 +151,7 @@
</el-form-item>
<el-form-item :label="$t('commons.role')" prop="roleIds"
:rules="{required: true, message: $t('role.please_choose_role'), trigger: 'change'}">
<el-select v-model="memberForm.roleIds" multiple :placeholder="$t('role.please_choose_role')"
<el-select filterable v-model="memberForm.roleIds" multiple :placeholder="$t('role.please_choose_role')"
class="select-width">
<el-option
v-for="item in memberForm.allroles"

View File

@ -37,7 +37,7 @@
<el-input type="textarea" v-model="form.description"></el-input>
</el-form-item>
<el-form-item :label="$t('workspace.organization_name')" prop="organizationId">
<el-select v-model="form.organizationId" :placeholder="$t('organization.select_organization')"
<el-select filterable v-model="form.organizationId" :placeholder="$t('organization.select_organization')"
class="select-width">
<el-option
v-for="item in form.orgList"
@ -65,7 +65,7 @@
<el-input type="textarea" v-model="form.description"></el-input>
</el-form-item>
<el-form-item :label="$t('workspace.organization_name')" prop="organizationId">
<el-select v-model="form.organizationId" :placeholder="$t('organization.select_organization')"
<el-select filterable v-model="form.organizationId" :placeholder="$t('organization.select_organization')"
class="select-width">
<el-option
v-for="item in form.orgList1"
@ -117,7 +117,7 @@
<el-form :model="memberForm" ref="form" :rules="wsMemberRule" label-position="right" label-width="100px"
size="small">
<el-form-item :label="$t('commons.member')" prop="userIds">
<el-select v-model="memberForm.userIds" multiple :placeholder="$t('member.please_choose_member')"
<el-select filterable v-model="memberForm.userIds" multiple :placeholder="$t('member.please_choose_member')"
class="select-width">
<el-option
v-for="item in memberForm.userList"
@ -130,7 +130,7 @@
</el-select>
</el-form-item>
<el-form-item :label="$t('commons.role')" prop="roleIds">
<el-select v-model="memberForm.roleIds" multiple :placeholder="$t('role.please_choose_role')"
<el-select filterable v-model="memberForm.roleIds" multiple :placeholder="$t('role.please_choose_role')"
class="select-width">
<el-option
v-for="item in memberForm.roles"
@ -166,7 +166,7 @@
<el-input v-model="memberForm.phone" autocomplete="off" :disabled="true"/>
</el-form-item>
<el-form-item :label="$t('commons.role')" prop="roleIds" :rules="{required: true, message: $t('role.please_choose_role'), trigger: 'change'}">
<el-select v-model="memberForm.roleIds" multiple :placeholder="$t('role.please_choose_role')"
<el-select filterable v-model="memberForm.roleIds" multiple :placeholder="$t('role.please_choose_role')"
class="select-width">
<el-option
v-for="item in memberForm.allroles"

View File

@ -74,7 +74,7 @@
:prop="'roles.' + index + '.id'"
:rules="{required: true, message: $t('role.please_choose_role'), trigger: 'change'}"
>
<el-select v-model="role.id" :placeholder="$t('role.please_choose_role')">
<el-select filterable v-model="role.id" :placeholder="$t('role.please_choose_role')">
<el-option
v-for="item in activeRole(role)"
:key="item.id"
@ -93,7 +93,7 @@
:prop="'roles.' + index + '.ids'"
:rules="{required: true, message: $t('organization.select_organization'), trigger: 'change'}"
>
<el-select v-model="role.ids" :placeholder="$t('organization.select_organization')" multiple>
<el-select filterable v-model="role.ids" :placeholder="$t('organization.select_organization')" multiple>
<el-option
v-for="item in form.orgList"
:key="item.id"
@ -108,7 +108,7 @@
:prop="'roles.' + index + '.ids'"
:rules="{required: true, message: $t('workspace.select'), trigger: 'change'}"
>
<el-select v-model="role.ids" :placeholder="$t('workspace.select')" multiple>
<el-select filterable v-model="role.ids" :placeholder="$t('workspace.select')" multiple>
<el-option
v-for="item in form.wsList"
:key="item.id"
@ -123,7 +123,7 @@
:prop="'roles.' + index + '.ids'"
:rules="{required: true, message: $t('workspace.select'), trigger: 'change'}"
>
<el-select v-model="role.ids" :placeholder="$t('workspace.select')" multiple>
<el-select filterable v-model="role.ids" :placeholder="$t('workspace.select')" multiple>
<el-option
v-for="item in form.wsList"
:key="item.id"
@ -138,7 +138,7 @@
:prop="'roles.' + index + '.ids'"
:rules="{required: true, message: $t('workspace.select'), trigger: 'change'}"
>
<el-select v-model="role.ids" :placeholder="$t('workspace.select')" multiple>
<el-select filterable v-model="role.ids" :placeholder="$t('workspace.select')" multiple>
<el-option
v-for="item in form.wsList"
:key="item.id"
@ -187,7 +187,7 @@
:prop="'roles.' + index + '.id'"
:rules="{required: true, message: $t('role.please_choose_role'), trigger: 'change'}"
>
<el-select v-model="role.id" :placeholder="$t('role.please_choose_role')" :disabled="!!role.id">
<el-select filterable v-model="role.id" :placeholder="$t('role.please_choose_role')" :disabled="!!role.id">
<el-option
v-for="item in activeRole(role)"
:key="item.id"
@ -204,7 +204,7 @@
:prop="'roles.' + index + '.ids'"
:rules="{required: true, message: $t('organization.select_organization'), trigger: 'change'}"
>
<el-select v-model="role.ids" :placeholder="$t('organization.select_organization')" multiple>
<el-select filterable v-model="role.ids" :placeholder="$t('organization.select_organization')" multiple>
<el-option
v-for="item in form.orgList"
:key="item.id"
@ -219,7 +219,7 @@
:prop="'roles.' + index + '.ids'"
:rules="{required: true, message: $t('workspace.select'), trigger: 'change'}"
>
<el-select v-model="role.ids" :placeholder="$t('workspace.select')" multiple>
<el-select filterable v-model="role.ids" :placeholder="$t('workspace.select')" multiple>
<el-option
v-for="item in form.wsList"
:key="item.id"
@ -234,7 +234,7 @@
:prop="'roles.' + index + '.ids'"
:rules="{required: true, message: $t('workspace.select'), trigger: 'change'}"
>
<el-select v-model="role.ids" :placeholder="$t('workspace.select')" multiple>
<el-select filterable v-model="role.ids" :placeholder="$t('workspace.select')" multiple>
<el-option
v-for="item in form.wsList"
:key="item.id"
@ -249,7 +249,7 @@
:prop="'roles.' + index + '.ids'"
:rules="{required: true, message: $t('workspace.select'), trigger: 'change'}"
>
<el-select v-model="role.ids" :placeholder="$t('workspace.select')" multiple>
<el-select filterable v-model="role.ids" :placeholder="$t('workspace.select')" multiple>
<el-option
v-for="item in form.wsList"
:key="item.id"

View File

@ -1,25 +1,11 @@
<template>
<el-menu :unique-opened="true" mode="horizontal" active-text-color="write"
class="project_menu">
<el-submenu index="1" popper-class="submenu">
<template v-slot:title>
<div>
<span class="menu-title">{{'[' + title + ']'}}</span>
<span> {{currentData == null ? '' : currentData.name}} </span>
</template>
<template v-slot:default>
<div style="height:400px;">
<el-scrollbar style="height:100%">
<label v-for="(item,index) in data" :key="index">
<el-menu-item @click="changeData(item)">
{{item.name}}
<i class="el-icon-check" v-if="currentData && item.id === currentData.id"></i>
</el-menu-item>
</label>
</el-scrollbar>
<el-select filterable slot="prepend" v-model="value" @change="changeData" class="project_menu"
size="small">
<el-option v-for="(item,index) in data" :key="index" :label="item.name" :value="index"/>
</el-select>
</div>
</template>
</el-submenu>
</el-menu>
</template>
<script>
@ -36,18 +22,35 @@
type: String
}
},
data() {
return {
value: ''
}
},
watch: {
currentData(data) {
if (data != undefined && data != null) {
this.value = data.name;
}
}
},
methods: {
changeData(data) {
this.$emit("dataChange", data);
changeData(index) {
this.$emit("dataChange", this.data[index]);
}
}
}
</script>
<style scoped>
.project_menu {
width: 214px;
}
.menu-title {
color: darkgrey;
margin-left: 10px;
margin-right: 10px;
}
</style>

View File

@ -180,6 +180,7 @@
:disabled="isReadOnly"
v-model="scope.row.executeResult"
@change="stepResultChange()"
filterable
size="mini">
<el-option :label="$t('test_track.plan_view.pass')" value="Pass"
style="color: #7ebf50;"></el-option>
@ -227,6 +228,7 @@
{{ $t('test_track.issue.please_choose_current_owner') }}
<el-select v-model="testCase.tapdUsers"
multiple
filterable
style="width: 20%"
:placeholder="$t('test_track.issue.please_choose_current_owner')"
collapse-tags>

View File

@ -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});