Merge remote-tracking branch 'origin/v1.8' into v1.8
# Conflicts: # frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue
This commit is contained in:
commit
64263c2cdb
|
@ -75,6 +75,8 @@ import org.apache.jorphan.collections.HashTree;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> {
|
public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> {
|
||||||
|
@ -132,12 +134,66 @@ public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> {
|
||||||
return (HashTree) field.get(scriptWrapper);
|
return (HashTree) field.get(scriptWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isProtocolDefaultPort(HTTPSamplerProxy source) {
|
||||||
|
String portAsString = source.getPropertyAsString("HTTPSampler.port");
|
||||||
|
if (portAsString != null && !portAsString.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String url(String protocol, String host, String port, String file) {
|
||||||
|
protocol = protocol.toLowerCase();
|
||||||
|
if (StringUtils.isNotEmpty(file) && !file.startsWith("/")) {
|
||||||
|
file += "/";
|
||||||
|
}
|
||||||
|
return protocol + "://" + host + ":" + port + file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl(HTTPSamplerProxy source) throws MalformedURLException {
|
||||||
|
String path = source.getPath();
|
||||||
|
if (!path.startsWith("http://") && !path.startsWith("https://")) {
|
||||||
|
String domain = source.getDomain();
|
||||||
|
String protocol = source.getProtocol();
|
||||||
|
String method = source.getMethod();
|
||||||
|
StringBuilder pathAndQuery = new StringBuilder(100);
|
||||||
|
if ("file".equalsIgnoreCase(protocol)) {
|
||||||
|
domain = null;
|
||||||
|
} else if (!path.startsWith("/")) {
|
||||||
|
pathAndQuery.append('/');
|
||||||
|
}
|
||||||
|
|
||||||
|
pathAndQuery.append(path);
|
||||||
|
if ("GET".equals(method) || "DELETE".equals(method) || "OPTIONS".equals(method)) {
|
||||||
|
String queryString = source.getQueryString(source.getContentEncoding());
|
||||||
|
if (queryString.length() > 0) {
|
||||||
|
if (path.contains("?")) {
|
||||||
|
pathAndQuery.append("&");
|
||||||
|
} else {
|
||||||
|
pathAndQuery.append("?");
|
||||||
|
}
|
||||||
|
|
||||||
|
pathAndQuery.append(queryString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String portAsString = source.getPropertyAsString("HTTPSampler.port");
|
||||||
|
return this.isProtocolDefaultPort(source) ? new URL(protocol, domain, pathAndQuery.toString()).toExternalForm() : this.url(protocol, domain, portAsString, pathAndQuery.toString());
|
||||||
|
} else {
|
||||||
|
return new URL(path).toExternalForm();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void convertHttpSampler(MsHTTPSamplerProxy samplerProxy, Object key) {
|
private void convertHttpSampler(MsHTTPSamplerProxy samplerProxy, Object key) {
|
||||||
try {
|
try {
|
||||||
HTTPSamplerProxy source = (HTTPSamplerProxy) key;
|
HTTPSamplerProxy source = (HTTPSamplerProxy) key;
|
||||||
BeanUtils.copyBean(samplerProxy, source);
|
BeanUtils.copyBean(samplerProxy, source);
|
||||||
samplerProxy.setRest(new ArrayList<KeyValue>(){{this.add(new KeyValue());}});
|
samplerProxy.setRest(new ArrayList<KeyValue>() {{
|
||||||
samplerProxy.setArguments(new ArrayList<KeyValue>(){{this.add(new KeyValue());}});
|
this.add(new KeyValue());
|
||||||
|
}});
|
||||||
|
samplerProxy.setArguments(new ArrayList<KeyValue>() {{
|
||||||
|
this.add(new KeyValue());
|
||||||
|
}});
|
||||||
if (source != null && source.getHTTPFiles().length > 0) {
|
if (source != null && source.getHTTPFiles().length > 0) {
|
||||||
samplerProxy.getBody().initBinary();
|
samplerProxy.getBody().initBinary();
|
||||||
samplerProxy.getBody().setType(Body.FORM_DATA);
|
samplerProxy.getBody().setType(Body.FORM_DATA);
|
||||||
|
@ -158,7 +214,8 @@ public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> {
|
||||||
samplerProxy.getBody().setKvs(keyValues);
|
samplerProxy.getBody().setKvs(keyValues);
|
||||||
}
|
}
|
||||||
samplerProxy.setProtocol(RequestType.HTTP);
|
samplerProxy.setProtocol(RequestType.HTTP);
|
||||||
samplerProxy.setPort(source.getPort() + "");
|
samplerProxy.setPort(source.getPropertyAsString("HTTPSampler.port"));
|
||||||
|
samplerProxy.setDomain(source.getDomain());
|
||||||
if (source.getArguments() != null) {
|
if (source.getArguments() != null) {
|
||||||
if (source.getPostBodyRaw()) {
|
if (source.getPostBodyRaw()) {
|
||||||
samplerProxy.getBody().setType(Body.RAW);
|
samplerProxy.getBody().setType(Body.RAW);
|
||||||
|
@ -178,10 +235,10 @@ public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> {
|
||||||
}
|
}
|
||||||
samplerProxy.getBody().initBinary();
|
samplerProxy.getBody().initBinary();
|
||||||
}
|
}
|
||||||
samplerProxy.setPath("");
|
// samplerProxy.setPath(source.getPath());
|
||||||
samplerProxy.setMethod(source.getMethod());
|
samplerProxy.setMethod(source.getMethod());
|
||||||
if (source.getUrl() != null) {
|
if (this.getUrl(source) != null) {
|
||||||
samplerProxy.setUrl(source.getUrl().toString());
|
samplerProxy.setUrl(this.getUrl(source));
|
||||||
}
|
}
|
||||||
samplerProxy.setId(UUID.randomUUID().toString());
|
samplerProxy.setId(UUID.randomUUID().toString());
|
||||||
samplerProxy.setType("HTTPSamplerProxy");
|
samplerProxy.setType("HTTPSamplerProxy");
|
||||||
|
|
|
@ -213,7 +213,7 @@ public abstract class MsTestElement {
|
||||||
csvDataSet.setName(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName());
|
csvDataSet.setName(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName());
|
||||||
csvDataSet.setProperty("fileEncoding", StringUtils.isEmpty(item.getEncoding()) ? "UTF-8" : item.getEncoding());
|
csvDataSet.setProperty("fileEncoding", StringUtils.isEmpty(item.getEncoding()) ? "UTF-8" : item.getEncoding());
|
||||||
if (CollectionUtils.isNotEmpty(item.getFiles())) {
|
if (CollectionUtils.isNotEmpty(item.getFiles())) {
|
||||||
if (!config.isOperating() && new File(BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName()).exists()) {
|
if (!config.isOperating() && !new File(BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName()).exists()) {
|
||||||
MSException.throwException(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName() + ":[ CSV文件不存在 ]");
|
MSException.throwException(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName() + ":[ CSV文件不存在 ]");
|
||||||
}
|
}
|
||||||
csvDataSet.setProperty("filename", BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName());
|
csvDataSet.setProperty("filename", BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName());
|
||||||
|
|
|
@ -91,6 +91,9 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
@JSONField(ordinal = 36)
|
@JSONField(ordinal = 36)
|
||||||
private MsAuthManager authManager;
|
private MsAuthManager authManager;
|
||||||
|
|
||||||
|
@JSONField(ordinal = 37)
|
||||||
|
private boolean urlOrPath;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
||||||
// 非导出操作,且不是启用状态则跳过执行
|
// 非导出操作,且不是启用状态则跳过执行
|
||||||
|
@ -140,23 +143,26 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
url = this.getUrl();
|
url = this.getUrl();
|
||||||
isUrl = true;
|
isUrl = true;
|
||||||
}
|
}
|
||||||
URL urlObject = new URL(url);
|
|
||||||
if (isUrl) {
|
if (isUrl) {
|
||||||
|
if (StringUtils.isNotEmpty(this.getPort()) && this.getPort().startsWith("${")) {
|
||||||
|
url.replaceAll(this.getPort(), "10990");
|
||||||
|
}
|
||||||
|
URL urlObject = new URL(url);
|
||||||
sampler.setDomain(URLDecoder.decode(urlObject.getHost(), "UTF-8"));
|
sampler.setDomain(URLDecoder.decode(urlObject.getHost(), "UTF-8"));
|
||||||
if (urlObject.getPort() > 0) {
|
if (urlObject.getPort() > 0 && urlObject.getPort() != 10990 && StringUtils.isNotEmpty(this.getPort()) && this.getPort().startsWith("${")) {
|
||||||
sampler.setPort(urlObject.getPort());
|
sampler.setPort(urlObject.getPort());
|
||||||
|
} else {
|
||||||
|
sampler.setProperty("HTTPSampler.port", this.getPort());
|
||||||
}
|
}
|
||||||
sampler.setProtocol(urlObject.getProtocol());
|
sampler.setProtocol(urlObject.getProtocol());
|
||||||
|
sampler.setPath(urlObject.getPath());
|
||||||
} else {
|
} else {
|
||||||
sampler.setDomain(config.getConfig().get(this.getProjectId()).getHttpConfig().getDomain());
|
sampler.setDomain(config.getConfig().get(this.getProjectId()).getHttpConfig().getDomain());
|
||||||
sampler.setPort(config.getConfig().get(this.getProjectId()).getHttpConfig().getPort());
|
sampler.setPort(config.getConfig().get(this.getProjectId()).getHttpConfig().getPort());
|
||||||
sampler.setProtocol(config.getConfig().get(this.getProjectId()).getHttpConfig().getProtocol());
|
sampler.setProtocol(config.getConfig().get(this.getProjectId()).getHttpConfig().getProtocol());
|
||||||
|
sampler.setPath(this.getPath());
|
||||||
}
|
}
|
||||||
String envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getPath();
|
String envPath = sampler.getPath();
|
||||||
if (StringUtils.isNotBlank(this.getPath()) && !isUrl) {
|
|
||||||
envPath += this.getPath();
|
|
||||||
sampler.setPath(envPath);
|
|
||||||
}
|
|
||||||
if (CollectionUtils.isNotEmpty(this.getRest()) && this.isRest()) {
|
if (CollectionUtils.isNotEmpty(this.getRest()) && this.isRest()) {
|
||||||
envPath = getRestParameters(URLDecoder.decode(envPath, "UTF-8"));
|
envPath = getRestParameters(URLDecoder.decode(envPath, "UTF-8"));
|
||||||
sampler.setPath(envPath);
|
sampler.setPath(envPath);
|
||||||
|
@ -327,10 +333,16 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isURL(String str) {
|
public boolean isURL(String str) {
|
||||||
//转换为小写
|
|
||||||
try {
|
try {
|
||||||
new URL(str);
|
String regex = "^((https|http|ftp|rtsp|mms)?://)"
|
||||||
return true;
|
+ "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?"
|
||||||
|
+ "(([0-9]{1,3}\\.){3}[0-9]{1,3}" + "|" + "([0-9a-z_!~*'()-]+\\.)*"
|
||||||
|
+ "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\\."
|
||||||
|
+ "[a-z]{2,6})"
|
||||||
|
+ "(:[0-9]{1,5})?"
|
||||||
|
+ "((/?)|"
|
||||||
|
+ "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";
|
||||||
|
return str.matches(regex) || (str.matches("^(http|https|ftp)://.*$") && str.matches(".*://\\$\\{.*$"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -339,5 +351,5 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
private boolean isRest() {
|
private boolean isRest() {
|
||||||
return this.getRest().stream().filter(KeyValue::isEnable).filter(KeyValue::isValid).toArray().length > 0;
|
return this.getRest().stream().filter(KeyValue::isEnable).filter(KeyValue::isValid).toArray().length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -274,7 +274,7 @@
|
||||||
#{value}
|
#{value}
|
||||||
</foreach>
|
</foreach>
|
||||||
</when>
|
</when>
|
||||||
<when test="key=='status'">
|
<when test="key=='reviewStatus'">
|
||||||
and test_case.review_status in
|
and test_case.review_status in
|
||||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||||
#{value}
|
#{value}
|
||||||
|
|
|
@ -443,7 +443,7 @@
|
||||||
});
|
});
|
||||||
this.result.loading = false;
|
this.result.loading = false;
|
||||||
if (this.$refs.scenarioTable) {
|
if (this.$refs.scenarioTable) {
|
||||||
setTimeout(this.$refs.scenarioTable.doLayout,500)
|
setTimeout(this.$refs.scenarioTable.doLayout, 200)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this.condition.selectAll){
|
if(!this.condition.selectAll){
|
||||||
|
@ -505,6 +505,7 @@
|
||||||
moveSave(param) {
|
moveSave(param) {
|
||||||
this.buildBatchParam(param);
|
this.buildBatchParam(param);
|
||||||
param.apiScenarioModuleId = param.nodeId;
|
param.apiScenarioModuleId = param.nodeId;
|
||||||
|
param.modulePath = param.nodePath;
|
||||||
this.$post('/api/automation/batch/edit', param, () => {
|
this.$post('/api/automation/batch/edit', param, () => {
|
||||||
this.$success(this.$t('commons.save_success'));
|
this.$success(this.$t('commons.save_success'));
|
||||||
this.$refs.testBatchMove.close();
|
this.$refs.testBatchMove.close();
|
||||||
|
|
|
@ -577,7 +577,7 @@
|
||||||
recursiveSorting(arr, scenarioProjectId) {
|
recursiveSorting(arr, scenarioProjectId) {
|
||||||
for (let i in arr) {
|
for (let i in arr) {
|
||||||
arr[i].index = Number(i) + 1;
|
arr[i].index = Number(i) + 1;
|
||||||
if (arr[i].type === ELEMENT_TYPE.LoopController && arr[i].hashTree && arr[i].hashTree.length > 1) {
|
if (arr[i].type === ELEMENT_TYPE.LoopController && arr[i].loopType === "LOOP_COUNT" && arr[i].hashTree && arr[i].hashTree.length > 1) {
|
||||||
arr[i].countController.proceed = true;
|
arr[i].countController.proceed = true;
|
||||||
}
|
}
|
||||||
if (!arr[i].projectId) {
|
if (!arr[i].projectId) {
|
||||||
|
@ -926,7 +926,7 @@
|
||||||
return bodyUploadFiles;
|
return bodyUploadFiles;
|
||||||
},
|
},
|
||||||
editScenario() {
|
editScenario() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve) => {
|
||||||
document.getElementById("inputDelay").focus(); // 保存前在input框自动失焦,以免保存失败
|
document.getElementById("inputDelay").focus(); // 保存前在input框自动失焦,以免保存失败
|
||||||
this.$refs['currentScenario'].validate((valid) => {
|
this.$refs['currentScenario'].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
<el-option v-for="(environment, index) in pe.envs" :key="index"
|
<el-option v-for="(environment, index) in pe.envs" :key="index"
|
||||||
:label="environment.name + (environment.config.httpConfig.socket ? (': ' + environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket) : '')"
|
:label="environment.name + (environment.config.httpConfig.socket ? (': ' + environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket) : '')"
|
||||||
:value="environment.id"/>
|
:value="environment.id"/>
|
||||||
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig(pe.id)">
|
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig(pe.id, pe['selectEnv'])">
|
||||||
{{ $t('api_test.environment.environment_config') }}
|
{{ $t('api_test.environment.environment_config') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<template v-slot:empty>
|
<template v-slot:empty>
|
||||||
<div class="empty-environment">
|
<div class="empty-environment">
|
||||||
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig(pe.id)">
|
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig(pe.id, pe['selectEnv'])">
|
||||||
{{ $t('api_test.environment.environment_config') }}
|
{{ $t('api_test.environment.environment_config') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -78,12 +78,12 @@ export default {
|
||||||
const project = this.projectList.find(p => p.id === id);
|
const project = this.projectList.find(p => p.id === id);
|
||||||
return project ? project.name : "";
|
return project ? project.name : "";
|
||||||
},
|
},
|
||||||
openEnvironmentConfig(projectId) {
|
openEnvironmentConfig(projectId, envId) {
|
||||||
if (!projectId) {
|
if (!projectId) {
|
||||||
this.$error(this.$t('api_test.select_project'));
|
this.$error(this.$t('api_test.select_project'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.$refs.environmentConfig.open(projectId);
|
this.$refs.environmentConfig.open(projectId, envId);
|
||||||
},
|
},
|
||||||
handleConfirm() {
|
handleConfirm() {
|
||||||
let map = new Map();
|
let map = new Map();
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
this.$emit('remove');
|
this.$emit('remove');
|
||||||
break;
|
break;
|
||||||
case "scenarioVar":
|
case "scenarioVar":
|
||||||
this.$refs.scenarioParameters.open(this.data.variables, this.data.headers, true);
|
this.$refs.scenarioParameters.open(this.data.variables, this.data.headers, this.data.referenced === 'REF');
|
||||||
break;
|
break;
|
||||||
case "openScenario":
|
case "openScenario":
|
||||||
this.getScenario();
|
this.getScenario();
|
||||||
|
|
|
@ -493,7 +493,7 @@
|
||||||
recursiveSorting(arr, scenarioProjectId) {
|
recursiveSorting(arr, scenarioProjectId) {
|
||||||
for (let i in arr) {
|
for (let i in arr) {
|
||||||
arr[i].index = Number(i) + 1;
|
arr[i].index = Number(i) + 1;
|
||||||
if (arr[i].type === ELEMENT_TYPE.LoopController && arr[i].hashTree && arr[i].hashTree.length > 1) {
|
if (arr[i].type === ELEMENT_TYPE.LoopController && arr[i].loopType === "LOOP_COUNT" && arr[i].hashTree && arr[i].hashTree.length > 1) {
|
||||||
arr[i].countController.proceed = true;
|
arr[i].countController.proceed = true;
|
||||||
}
|
}
|
||||||
if (!arr[i].projectId) {
|
if (!arr[i].projectId) {
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
this.$error(this.$t('api_test.select_project'));
|
this.$error(this.$t('api_test.select_project'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.$refs.environmentConfig.open(this.projectId);
|
this.$refs.environmentConfig.open(this.projectId, this.environmentId);
|
||||||
},
|
},
|
||||||
environmentChange(value) {
|
environmentChange(value) {
|
||||||
for (let i in this.environments) {
|
for (let i in this.environments) {
|
||||||
|
|
|
@ -46,13 +46,15 @@
|
||||||
icon: 'el-icon-delete',
|
icon: 'el-icon-delete',
|
||||||
func: this.deleteEnvironment
|
func: this.deleteEnvironment
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
selectEnvironmentId: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
open: function (projectId) {
|
open: function (projectId, envId) {
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
this.projectId = projectId;
|
this.projectId = projectId;
|
||||||
|
this.selectEnvironmentId = envId;
|
||||||
this.getEnvironments();
|
this.getEnvironments();
|
||||||
listenGoBack(this.close);
|
listenGoBack(this.close);
|
||||||
},
|
},
|
||||||
|
@ -114,7 +116,16 @@
|
||||||
this.result = this.$get('/api/environment/list/' + this.projectId, response => {
|
this.result = this.$get('/api/environment/list/' + this.projectId, response => {
|
||||||
this.environments = response.data;
|
this.environments = response.data;
|
||||||
if (this.environments.length > 0) {
|
if (this.environments.length > 0) {
|
||||||
|
if (this.selectEnvironmentId) {
|
||||||
|
const index = this.environments.findIndex(e => e.id === this.selectEnvironmentId);
|
||||||
|
if (index !== -1) {
|
||||||
|
this.$refs.environmentItems.itemSelected(index, this.environments[index]);
|
||||||
|
} else {
|
||||||
this.$refs.environmentItems.itemSelected(0, this.environments[0]);
|
this.$refs.environmentItems.itemSelected(0, this.environments[0]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.$refs.environmentItems.itemSelected(0, this.environments[0]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let item = new Environment({
|
let item = new Environment({
|
||||||
projectId: this.projectId
|
projectId: this.projectId
|
||||||
|
|
|
@ -357,7 +357,7 @@ export default {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (this.$refs.caseTable) {
|
if (this.$refs.caseTable) {
|
||||||
setTimeout(this.$refs.caseTable.doLayout, 500)
|
setTimeout(this.$refs.caseTable.doLayout, 200)
|
||||||
}
|
}
|
||||||
this.$nextTick(function(){
|
this.$nextTick(function(){
|
||||||
this.checkTableRowIsSelect();
|
this.checkTableRowIsSelect();
|
||||||
|
|
|
@ -467,7 +467,7 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (this.$refs.apiDefinitionTable) {
|
if (this.$refs.apiDefinitionTable) {
|
||||||
setTimeout(this.$refs.apiDefinitionTable.doLayout, 500)
|
setTimeout(this.$refs.apiDefinitionTable.doLayout, 200)
|
||||||
}
|
}
|
||||||
// nexttick:表格加载完成之后触发。判断是否需要勾选行
|
// nexttick:表格加载完成之后触发。判断是否需要勾选行
|
||||||
this.$nextTick(function(){
|
this.$nextTick(function(){
|
||||||
|
|
|
@ -46,13 +46,15 @@
|
||||||
icon: 'el-icon-delete',
|
icon: 'el-icon-delete',
|
||||||
func: this.deleteEnvironment
|
func: this.deleteEnvironment
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
selectEnvironmentId: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
open: function (projectId) {
|
open: function (projectId, envId) {
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
this.projectId = projectId;
|
this.projectId = projectId;
|
||||||
|
this.selectEnvironmentId = envId;
|
||||||
this.getEnvironments();
|
this.getEnvironments();
|
||||||
listenGoBack(this.close);
|
listenGoBack(this.close);
|
||||||
},
|
},
|
||||||
|
@ -114,7 +116,16 @@
|
||||||
this.result = this.$get('/api/environment/list/' + this.projectId, response => {
|
this.result = this.$get('/api/environment/list/' + this.projectId, response => {
|
||||||
this.environments = response.data;
|
this.environments = response.data;
|
||||||
if (this.environments.length > 0) {
|
if (this.environments.length > 0) {
|
||||||
|
if (this.selectEnvironmentId) {
|
||||||
|
const index = this.environments.findIndex(e => e.id === this.selectEnvironmentId);
|
||||||
|
if (index !== -1) {
|
||||||
|
this.$refs.environmentItems.itemSelected(index, this.environments[index]);
|
||||||
|
} else {
|
||||||
this.$refs.environmentItems.itemSelected(0, this.environments[0]);
|
this.$refs.environmentItems.itemSelected(0, this.environments[0]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.$refs.environmentItems.itemSelected(0, this.environments[0]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let item = new Environment({
|
let item = new Environment({
|
||||||
projectId: this.projectId
|
projectId: this.projectId
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-form :inline="true">
|
<el-form :inline="true">
|
||||||
<el-form-item :label="$t('load_test.select_resource_pool')">
|
<el-form-item :label="$t('load_test.select_resource_pool')">
|
||||||
<el-select v-model="resourcePool" :disabled="isReadOnly" size="mini">
|
<el-select v-model="resourcePool" :disabled="isReadOnly" size="mini" @change="resourcePoolChange">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in resourcePools"
|
v-for="item in resourcePools"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
|
@ -42,6 +42,7 @@
|
||||||
v-model="threadGroup.threadNumber"
|
v-model="threadGroup.threadNumber"
|
||||||
@change="calculateTotalChart(threadGroup)"
|
@change="calculateTotalChart(threadGroup)"
|
||||||
:min="resourcePoolResourceLength"
|
:min="resourcePoolResourceLength"
|
||||||
|
:max="maxThreadNumbers"
|
||||||
size="mini"/>
|
size="mini"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<br>
|
<br>
|
||||||
|
@ -219,7 +220,8 @@ export default {
|
||||||
resourcePools: [],
|
resourcePools: [],
|
||||||
activeNames: ["0"],
|
activeNames: ["0"],
|
||||||
threadGroups: [],
|
threadGroups: [],
|
||||||
resourcePoolResourceLength: 1
|
resourcePoolResourceLength: 1,
|
||||||
|
maxThreadNumbers: 5000,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -336,6 +338,22 @@ export default {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
resourcePoolChange() {
|
||||||
|
let result = this.resourcePools.filter(p => p.id === this.resourcePool);
|
||||||
|
if (result.length === 1) {
|
||||||
|
let threadNumber = 0;
|
||||||
|
result[0].resources.forEach(resource => {
|
||||||
|
threadNumber += JSON.parse(resource.configuration).maxConcurrency;
|
||||||
|
})
|
||||||
|
this.maxThreadNumbers = threadNumber;
|
||||||
|
this.threadGroups.forEach(tg => {
|
||||||
|
if (tg.threadNumber > threadNumber) {
|
||||||
|
this.$set(tg, "threadNumber", threadNumber);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.calculateTotalChart();
|
||||||
|
}
|
||||||
|
},
|
||||||
calculateTotalChart() {
|
calculateTotalChart() {
|
||||||
let handler = this;
|
let handler = this;
|
||||||
if (handler.duration < handler.rampUpTime) {
|
if (handler.duration < handler.rampUpTime) {
|
||||||
|
@ -344,6 +362,11 @@ export default {
|
||||||
if (handler.rampUpTime < handler.step) {
|
if (handler.rampUpTime < handler.step) {
|
||||||
handler.step = handler.rampUpTime;
|
handler.step = handler.rampUpTime;
|
||||||
}
|
}
|
||||||
|
// 线程数不能小于资源池节点的数量
|
||||||
|
let resourcePool = this.resourcePools.filter(v => v.id === this.resourcePool)[0];
|
||||||
|
if (resourcePool) {
|
||||||
|
this.resourcePoolResourceLength = resourcePool.resources.length;
|
||||||
|
}
|
||||||
let color = ['#60acfc', '#32d3eb', '#5bc49f', '#feb64d', '#ff7c7c', '#9287e7', '#ca8622', '#bda29a', '#6e7074', '#546570', '#c4ccd3'];
|
let color = ['#60acfc', '#32d3eb', '#5bc49f', '#feb64d', '#ff7c7c', '#9287e7', '#ca8622', '#bda29a', '#6e7074', '#546570', '#c4ccd3'];
|
||||||
handler.options = {
|
handler.options = {
|
||||||
color: color,
|
color: color,
|
||||||
|
|
|
@ -303,20 +303,12 @@ export default {
|
||||||
},
|
},
|
||||||
created: function () {
|
created: function () {
|
||||||
this.$emit('setCondition', this.condition);
|
this.$emit('setCondition', this.condition);
|
||||||
if (this.trashEnable) {
|
this.condition.filters = {reviewStatus: ["Prepare", "Pass", "UnPass"]};
|
||||||
this.condition.filters = {status: ["Trash"]};
|
|
||||||
} else {
|
|
||||||
this.condition.filters = {status: ["Prepare", "Pass", "UnPass"]};
|
|
||||||
}
|
|
||||||
this.initTableData();
|
this.initTableData();
|
||||||
getSystemLabel(this, this.type)
|
getSystemLabel(this, this.type)
|
||||||
},
|
},
|
||||||
activated() {
|
activated() {
|
||||||
if (this.trashEnable) {
|
this.condition.filters = {reviewStatus: ["Prepare", "Pass", "UnPass"]};
|
||||||
this.condition.filters = {status: ["Trash"]};
|
|
||||||
} else {
|
|
||||||
this.condition.filters = {status: ["Prepare", "Pass", "UnPass"]};
|
|
||||||
}
|
|
||||||
this.initTableData();
|
this.initTableData();
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -374,15 +366,15 @@ export default {
|
||||||
case 'coverage':
|
case 'coverage':
|
||||||
this.condition.caseCoverage = 'coverage';
|
this.condition.caseCoverage = 'coverage';
|
||||||
break;
|
break;
|
||||||
/* case 'Prepare':
|
case 'Prepare':
|
||||||
this.condition.filters.status = [this.selectDataRange];
|
this.condition.filters.reviewStatus = [this.selectDataRange];
|
||||||
break;
|
break;
|
||||||
case 'Pass':
|
case 'Pass':
|
||||||
this.condition.filters.status = [this.selectDataRange];
|
this.condition.filters.reviewStatus = [this.selectDataRange];
|
||||||
break;
|
break;
|
||||||
case 'UnPass':
|
case 'UnPass':
|
||||||
this.condition.filters.status = [this.selectDataRange];
|
this.condition.filters.reviewStatus = [this.selectDataRange];
|
||||||
break;*/
|
break;
|
||||||
}
|
}
|
||||||
if (this.projectId) {
|
if (this.projectId) {
|
||||||
this.condition.projectId = this.projectId;
|
this.condition.projectId = this.projectId;
|
||||||
|
@ -401,7 +393,7 @@ export default {
|
||||||
item.tags = JSON.parse(item.tags);
|
item.tags = JSON.parse(item.tags);
|
||||||
})
|
})
|
||||||
if (this.$refs.table) {
|
if (this.$refs.table) {
|
||||||
setTimeout(this.$refs.table.doLayout,500)
|
setTimeout(this.$refs.table.doLayout, 200)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$nextTick(function(){
|
this.$nextTick(function(){
|
||||||
|
|
|
@ -477,7 +477,7 @@ export default {
|
||||||
}
|
}
|
||||||
this.selectRows.clear();
|
this.selectRows.clear();
|
||||||
if (this.$refs.table) {
|
if (this.$refs.table) {
|
||||||
setTimeout(this.$refs.table.doLayout,500)
|
setTimeout(this.$refs.table.doLayout, 200)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 07951ba17aef6f29e50cfd68e40de3266f9a60cd
|
Subproject commit 2115bd28a90854d2b6276a90878934715498c584
|
Loading…
Reference in New Issue