fix(接口自动化): 冲突合并
This commit is contained in:
commit
a023b85f99
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.api.dto.definition.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
|
@ -22,8 +23,11 @@ import io.metersphere.api.dto.definition.request.sampler.MsJDBCSampler;
|
|||
import io.metersphere.api.dto.definition.request.sampler.MsTCPSampler;
|
||||
import io.metersphere.api.dto.definition.request.timer.MsConstantTimer;
|
||||
import io.metersphere.api.dto.scenario.KeyValue;
|
||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||
import io.metersphere.api.service.ApiDefinitionService;
|
||||
import io.metersphere.api.service.ApiTestEnvironmentService;
|
||||
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
||||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import lombok.Data;
|
||||
|
@ -153,6 +157,15 @@ public abstract class MsTestElement {
|
|||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
protected EnvironmentConfig getEnvironmentConfig(String environmentId) {
|
||||
ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class);
|
||||
ApiTestEnvironmentWithBLOBs environment = environmentService.get(environmentId);
|
||||
if (environment != null && environment.getConfig() != null) {
|
||||
return JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package io.metersphere.api.dto.definition.request.sampler;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
|
@ -8,10 +7,6 @@ import io.metersphere.api.dto.definition.request.ParameterConfig;
|
|||
import io.metersphere.api.dto.definition.request.dns.MsDNSCacheManager;
|
||||
import io.metersphere.api.dto.scenario.Body;
|
||||
import io.metersphere.api.dto.scenario.KeyValue;
|
||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||
import io.metersphere.api.service.ApiTestEnvironmentService;
|
||||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.commons.utils.ScriptEngineUtils;
|
||||
import lombok.Data;
|
||||
|
@ -35,6 +30,8 @@ import java.util.Map;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@JSONType(typeName = "HTTPSamplerProxy")
|
||||
|
@ -112,13 +109,9 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
sampler.setFollowRedirects(this.isFollowRedirects());
|
||||
sampler.setUseKeepAlive(true);
|
||||
sampler.setDoMultipart(this.isDoMultipartPost());
|
||||
if (useEnvironment != null) {
|
||||
ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class);
|
||||
ApiTestEnvironmentWithBLOBs environment = environmentService.get(useEnvironment);
|
||||
if (environment != null && environment.getConfig() != null) {
|
||||
config.setConfig(JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class));
|
||||
}
|
||||
}
|
||||
|
||||
config.setConfig(getEnvironmentConfig(useEnvironment));
|
||||
|
||||
// 添加环境中的公共变量
|
||||
Arguments arguments = this.addArguments(config);
|
||||
if (arguments != null) {
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
package io.metersphere.api.dto.definition.request.sampler;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
import io.metersphere.api.dto.definition.request.ParameterConfig;
|
||||
import io.metersphere.api.dto.scenario.KeyValue;
|
||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||
import io.metersphere.api.service.ApiTestEnvironmentService;
|
||||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
@ -16,6 +22,7 @@ import org.apache.jorphan.collections.HashTree;
|
|||
import org.apache.jorphan.collections.ListedHashTree;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
@ -51,6 +58,10 @@ public class MsTCPSampler extends MsTestElement {
|
|||
private String request;
|
||||
@JSONField(ordinal = 34)
|
||||
private Object requestResult;
|
||||
@JSONField(ordinal = 35)
|
||||
private List<KeyValue> parameters;
|
||||
@JSONField(ordinal = 36)
|
||||
private String useEnvironment;
|
||||
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
||||
if (!this.isEnable()) {
|
||||
|
@ -59,6 +70,9 @@ public class MsTCPSampler extends MsTestElement {
|
|||
if (this.getReferenced() != null && this.getReferenced().equals("REF")) {
|
||||
this.getRefElement(this);
|
||||
}
|
||||
parseParameters();
|
||||
config.setConfig(getEnvironmentConfig(useEnvironment));
|
||||
parseEnvironment(config.getConfig());
|
||||
final HashTree samplerHashTree = new ListedHashTree();
|
||||
samplerHashTree.add(tcpConfig(config));
|
||||
tree.set(tcpSampler(), samplerHashTree);
|
||||
|
@ -69,6 +83,13 @@ public class MsTCPSampler extends MsTestElement {
|
|||
}
|
||||
}
|
||||
|
||||
private void parseEnvironment(EnvironmentConfig config) {
|
||||
if (config != null && config.getTcpConfig() != null) {
|
||||
this.server = config.getTcpConfig().getServer();
|
||||
this.port = config.getTcpConfig().getPort();
|
||||
}
|
||||
}
|
||||
|
||||
private TCPSampler tcpSampler() {
|
||||
TCPSampler tcpSampler = new TCPSampler();
|
||||
tcpSampler.setName(this.getName());
|
||||
|
@ -90,14 +111,20 @@ public class MsTCPSampler extends MsTestElement {
|
|||
return tcpSampler;
|
||||
}
|
||||
|
||||
private ConfigTestElement tcpConfig(ParameterConfig config) {
|
||||
private void parseParameters() {
|
||||
if (CollectionUtils.isNotEmpty(parameters)) {
|
||||
parameters.forEach(item -> {
|
||||
if (item.isEnable() && StringUtils.isNotBlank(item.getValue())) {
|
||||
request = request.replaceAll("\\$\\{" + item.getName() + "\\}", Matcher.quoteReplacement(item.getValue()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private ConfigTestElement tcpConfig() {
|
||||
ConfigTestElement configTestElement = new ConfigTestElement();
|
||||
configTestElement.setEnabled(true);
|
||||
configTestElement.setName(this.getName());
|
||||
if (config != null && StringUtils.isNotEmpty(config.getStep())) {
|
||||
configTestElement.setName(this.getName() + "<->" + config.getStep());
|
||||
}
|
||||
|
||||
configTestElement.setProperty(TestElement.TEST_CLASS, ConfigTestElement.class.getName());
|
||||
configTestElement.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TCPConfigGui"));
|
||||
configTestElement.setProperty(TCPSampler.CLASSNAME, this.getClassname());
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
|
||||
<script>
|
||||
import MsSqlBasisParameters from "../../definition/components/request/database/BasisParameters";
|
||||
import MsTcpBasisParameters from "../../definition/components/request/tcp/BasisParameters";
|
||||
import MsTcpBasisParameters from "../../definition/components/request/tcp/TcpBasisParameters";
|
||||
import MsDubboBasisParameters from "../../definition/components/request/dubbo/BasisParameters";
|
||||
import MsApiRequestForm from "../../definition/components/request/http/ApiRequestForm";
|
||||
import {REQ_METHOD} from "../../definition/model/JsonData";
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
<script>
|
||||
import MsSqlBasisParameters from "../../definition/components/request/database/BasisParameters";
|
||||
import MsTcpBasisParameters from "../../definition/components/request/tcp/BasisParameters";
|
||||
import MsTcpBasisParameters from "../../definition/components/request/tcp/TcpBasisParameters";
|
||||
import MsDubboBasisParameters from "../../definition/components/request/dubbo/BasisParameters";
|
||||
import MsApiRequestForm from "../../definition/components/request/http/ApiRequestForm";
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ import MsApiRequestForm from "../request/http/ApiRequestForm";
|
|||
import ApiEnvironmentConfig from "../environment/ApiEnvironmentConfig";
|
||||
import MsApiAssertions from "../assertion/ApiAssertions";
|
||||
import MsSqlBasisParameters from "../request/database/BasisParameters";
|
||||
import MsTcpBasisParameters from "../request/tcp/BasisParameters";
|
||||
import MsTcpBasisParameters from "../request/tcp/TcpBasisParameters";
|
||||
import MsDubboBasisParameters from "../request/dubbo/BasisParameters";
|
||||
import MsApiExtendBtns from "../reference/ApiExtendBtns";
|
||||
import MsInputTag from "@/business/components/api/automation/scenario/MsInputTag";
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
<script>
|
||||
import MsBasisApi from "./BasisApi";
|
||||
import MsBasisParameters from "../request/tcp/BasisParameters";
|
||||
import MsBasisParameters from "../request/tcp/TcpBasisParameters";
|
||||
|
||||
export default {
|
||||
name: "MsAddCompleteTcpApi",
|
||||
|
@ -72,6 +72,9 @@ export default {
|
|||
this.validateApi();
|
||||
if (this.validated) {
|
||||
this.basisData.request = this.request;
|
||||
if (this.basisData.tags instanceof Array) {
|
||||
this.basisData.tags = JSON.stringify(this.basisData.tags);
|
||||
}
|
||||
this.$emit('runTest', this.basisData);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -2,18 +2,28 @@
|
|||
|
||||
<div class="card-container" v-loading="loading">
|
||||
<el-card class="card-content">
|
||||
<el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand"
|
||||
@command="handleCommand" size="small" style="float: right;margin-right: 20px">
|
||||
{{$t('commons.test')}}
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as')}}</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
<el-form :model="debugForm" :rules="rules" ref="debugForm" :inline="true" label-position="right">
|
||||
<p class="tip">{{$t('test_track.plan_view.base_info')}} </p>
|
||||
<el-form-item :label="$t('api_test.request.tcp.server')" prop="server">
|
||||
<el-input v-model="request.server" maxlength="300" show-word-limit size="small"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('api_test.request.tcp.port')" prop="port" label-width="60px">
|
||||
<el-input-number v-model="request.port" controls-position="right" :min="0" :max="65535" size="small"/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand"
|
||||
@command="handleCommand" size="small" style="float: right;margin-right: 20px">
|
||||
{{$t('commons.test')}}
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as')}}</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
||||
<!-- TCP 请求参数 -->
|
||||
<ms-basis-parameters :request="request" @callback="runDebug" ref="requestForm"/>
|
||||
|
||||
<tcp-basis-parameters :request="request" @callback="runDebug" ref="requestForm"/>
|
||||
|
||||
<!-- TCP 请求返回数据 -->
|
||||
<p class="tip">{{$t('api_test.definition.request.res_param')}} </p>
|
||||
|
@ -39,11 +49,13 @@
|
|||
import {createComponent} from "../jmeter/components";
|
||||
import {REQ_METHOD} from "../../model/JsonData";
|
||||
import MsRequestResultTail from "../response/RequestResultTail";
|
||||
import MsBasisParameters from "../request/tcp/BasisParameters";
|
||||
import TcpBasisParameters from "../request/tcp/TcpBasisParameters";
|
||||
|
||||
export default {
|
||||
name: "ApiConfig",
|
||||
components: {MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters},
|
||||
components: {
|
||||
TcpBasisParameters,
|
||||
MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun},
|
||||
props: {
|
||||
currentProtocol: String,
|
||||
scenario: Boolean,
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
<template>
|
||||
<span>
|
||||
<el-select v-model="currentData.environmentId" size="small" class="ms-htt-width"
|
||||
:placeholder="$t('api_test.definition.request.run_env')"
|
||||
@change="environmentChange" clearable>
|
||||
<el-option v-for="(environment, index) in environments" :key="index"
|
||||
:label="getLabel(environment)"
|
||||
:value="environment.id"/>
|
||||
<el-button class="environment-button" size="mini" type="primary" @click="openEnvironmentConfig">
|
||||
{{ $t('api_test.environment.environment_config') }}
|
||||
</el-button>
|
||||
<template v-slot:empty>
|
||||
<div class="empty-environment">
|
||||
<el-button class="environment-button" size="mini" type="primary" @click="openEnvironmentConfig">
|
||||
{{ $t('api_test.environment.environment_config') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-select>
|
||||
|
||||
<!-- 环境 -->
|
||||
<api-environment-config ref="environmentConfig" @close="environmentConfigClose"/>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {parseEnvironment} from "../../model/EnvironmentModel";
|
||||
import ApiEnvironmentConfig from "../../../test/components/ApiEnvironmentConfig";
|
||||
|
||||
export default {
|
||||
name: "EnvironmentSelect",
|
||||
components: {ApiEnvironmentConfig},
|
||||
data() {
|
||||
return {
|
||||
environments: []
|
||||
}
|
||||
},
|
||||
props: {
|
||||
projectId: String,
|
||||
currentData: {},
|
||||
type: String
|
||||
},
|
||||
created() {
|
||||
this.getEnvironments();
|
||||
},
|
||||
methods: {
|
||||
getEnvironments() {
|
||||
if (this.projectId) {
|
||||
this.$get('/api/environment/list/' + this.projectId, response => {
|
||||
this.environments = response.data;
|
||||
this.environments.forEach(environment => {
|
||||
parseEnvironment(environment);
|
||||
});
|
||||
let hasEnvironment = false;
|
||||
for (let i in this.environments) {
|
||||
if (this.environments[i].id === this.currentData.environmentId) {
|
||||
this.currentData.environmentId = this.environments[i].id;
|
||||
hasEnvironment = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasEnvironment) {
|
||||
this.currentData.environmentId = '';
|
||||
this.currentData.environment = undefined;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.currentData.environmentId = '';
|
||||
this.currentData.environment = undefined;
|
||||
}
|
||||
},
|
||||
getLabel(environment) {
|
||||
if (environment) {
|
||||
if (this.type === 'TCP') {
|
||||
if (environment.config.tcpConfig && environment.config.tcpConfig.server) {
|
||||
return environment.name + ": " + environment.config.tcpConfig.server + ":" +
|
||||
(environment.config.tcpConfig.port ? environment.config.tcpConfig.port : "");
|
||||
} else {
|
||||
return environment.name;
|
||||
}
|
||||
}
|
||||
return environment.name + (environment.config.httpConfig.socket ?
|
||||
(': ' + environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket) : '');
|
||||
}
|
||||
return "";
|
||||
},
|
||||
environmentConfigClose() {
|
||||
this.getEnvironments();
|
||||
},
|
||||
environmentChange(value) {
|
||||
for (let i in this.environments) {
|
||||
if (this.environments[i].id === value) {
|
||||
this.currentData.environmentId = value;
|
||||
if (this.currentData.request) {
|
||||
this.currentData.request.useEnvironment = value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
openEnvironmentConfig() {
|
||||
if (!this.projectId) {
|
||||
this.$error(this.$t('api_test.select_project'));
|
||||
return;
|
||||
}
|
||||
this.$refs.environmentConfig.open(this.projectId);
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.environment-button {
|
||||
margin-left: 20px;
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
</style>
|
|
@ -31,6 +31,8 @@ export default class TCPSampler extends Sampler {
|
|||
|
||||
this.username = options.username;
|
||||
this.password = options.password;
|
||||
|
||||
this.parameters = [];
|
||||
this.hashTree = [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,89 +4,93 @@
|
|||
<el-col :span="21" style="padding-bottom: 20px">
|
||||
<div style="border:1px #DCDFE6 solid; height: 100%;border-radius: 4px ;width: 100% ;margin: 10px">
|
||||
<el-form class="tcp" :model="request" :rules="rules" ref="request" label-width="auto" :disabled="isReadOnly" style="margin: 20px">
|
||||
<el-row :gutter="10">
|
||||
<el-col :span="9">
|
||||
<el-form-item label="TCPClient" prop="classname">
|
||||
<el-select v-model="request.classname" style="width: 100%" size="small">
|
||||
<el-option v-for="c in classes" :key="c" :label="c" :value="c"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="9">
|
||||
<el-form-item :label="$t('api_test.request.tcp.server')" prop="server">
|
||||
<el-input v-model="request.server" maxlength="300" show-word-limit size="small"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item :label="$t('api_test.request.tcp.port')" prop="port" label-width="60px">
|
||||
<el-input-number v-model="request.port" controls-position="right" :min="0" :max="65535" size="small"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row :gutter="10">
|
||||
<el-col :span="9">
|
||||
<el-form-item :label="$t('api_test.request.tcp.connect')" prop="ctimeout">
|
||||
<el-input-number v-model="request.ctimeout" controls-position="right" :min="0" size="small"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="9">
|
||||
<el-form-item :label="$t('api_test.request.tcp.response')" prop="timeout">
|
||||
<el-input-number v-model="request.timeout" controls-position="right" :min="0" size="small"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item :label="$t('api_test.request.tcp.so_linger')" prop="soLinger">
|
||||
<el-input v-model="request.soLinger" size="small"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-tabs v-model="activeName" class="request-tabs">
|
||||
|
||||
<el-row :gutter="10">
|
||||
<el-col :span="9">
|
||||
<el-form-item :label="$t('api_test.request.tcp.username')" prop="username">
|
||||
<el-input v-model="request.username" maxlength="100" show-word-limit size="small"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="9">
|
||||
<el-form-item :label="$t('api_test.request.tcp.password')" prop="password">
|
||||
<el-input v-model="request.password" maxlength="30" show-word-limit show-password
|
||||
autocomplete="new-password" size="small"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!--query 参数-->
|
||||
<el-tab-pane name="parameters">
|
||||
<template v-slot:label>
|
||||
{{$t('api_test.definition.request.req_param')}}
|
||||
<ms-instructions-icon :content="$t('api_test.definition.request.tcp_parameter_tip')"/>
|
||||
</template>
|
||||
<ms-api-variable :is-read-only="isReadOnly" :parameters="request.parameters"/>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-col :span="6">
|
||||
<el-form-item :label="$t('api_test.request.tcp.eol_byte')" prop="eolByte">
|
||||
<el-input v-model="request.eolByte" size="small"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-tab-pane :label="$t('api_test.definition.request.message_template')" name="request">
|
||||
<div class="send-request">
|
||||
<ms-code-edit mode="text" :read-only="isReadOnly" :data.sync="request.request"
|
||||
:modes="['text', 'json', 'xml', 'html']" theme="eclipse"/>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
|
||||
</el-row>
|
||||
<el-tab-pane :label="$t('api_test.definition.request.other_config')" name="other" class="other-config">
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="TCPClient" prop="classname">
|
||||
<el-select v-model="request.classname" style="width: 100%" size="small">
|
||||
<el-option v-for="c in classes" :key="c" :label="c" :value="c"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item :label="$t('api_test.request.tcp.connect')" prop="ctimeout">
|
||||
<el-input-number v-model="request.ctimeout" controls-position="right" :min="0" size="small"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item :label="$t('api_test.request.tcp.response')" prop="timeout">
|
||||
<el-input-number v-model="request.timeout" controls-position="right" :min="0" size="small"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="10">
|
||||
<el-col :span="6">
|
||||
<el-form-item :label="$t('api_test.request.tcp.so_linger')" prop="soLinger">
|
||||
<el-input v-model="request.soLinger" size="small"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-row :gutter="10" style="margin-left: 30px">
|
||||
<el-col :span="9">
|
||||
<el-form-item :label="$t('api_test.request.tcp.re_use_connection')">
|
||||
<el-checkbox v-model="request.reUseConnection"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="9">
|
||||
<el-form-item :label="$t('api_test.request.tcp.close_connection')">
|
||||
<el-checkbox v-model="request.closeConnection"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item :label="$t('api_test.request.tcp.no_delay')">
|
||||
<el-checkbox v-model="request.nodelay"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-col :span="6">
|
||||
<el-form-item :label="$t('api_test.request.tcp.eol_byte')" prop="eolByte">
|
||||
<el-input v-model="request.eolByte" size="small"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="6">
|
||||
<el-form-item :label="$t('api_test.request.tcp.username')" prop="username">
|
||||
<el-input v-model="request.username" maxlength="100" show-word-limit size="small"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item :label="$t('api_test.request.tcp.password')" prop="password">
|
||||
<el-input v-model="request.password" maxlength="30" show-word-limit show-password
|
||||
autocomplete="new-password" size="small"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
|
||||
<el-row :gutter="10" style="margin-left: 30px">
|
||||
<el-col :span="9">
|
||||
<el-form-item :label="$t('api_test.request.tcp.re_use_connection')">
|
||||
<el-checkbox v-model="request.reUseConnection"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="9">
|
||||
<el-form-item :label="$t('api_test.request.tcp.close_connection')">
|
||||
<el-checkbox v-model="request.closeConnection"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item :label="$t('api_test.request.tcp.no_delay')">
|
||||
<el-checkbox v-model="request.nodelay"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-tab-pane>
|
||||
|
||||
</el-tabs>
|
||||
|
||||
<el-form-item :label="$t('api_test.request.tcp.request')" prop="request">
|
||||
<div class="send-request">
|
||||
<ms-code-edit mode="text" :read-only="isReadOnly" :data.sync="request.request"
|
||||
:modes="['text', 'json', 'xml', 'html']" theme="eclipse"/>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
</div>
|
||||
|
@ -133,10 +137,15 @@
|
|||
import {API_STATUS} from "../../../model/JsonData";
|
||||
import TCPSampler from "../../jmeter/components/sampler/tcp-sampler";
|
||||
import {getCurrentProjectID, getUUID} from "@/common/js/utils";
|
||||
import MsApiVariable from "../../ApiVariable";
|
||||
import MsInstructionsIcon from "../../../../../common/components/MsInstructionsIcon";
|
||||
|
||||
|
||||
export default {
|
||||
name: "MsDatabaseConfig",
|
||||
name: "TcpBasisParameters",
|
||||
components: {
|
||||
MsInstructionsIcon,
|
||||
MsApiVariable,
|
||||
MsApiScenarioVariables,
|
||||
MsCodeEdit,
|
||||
MsJsr233Processor, ApiRequestMethodSelect, MsApiExtract, MsApiAssertions, MsApiKeyValue, ApiEnvironmentConfig
|
||||
|
@ -152,7 +161,7 @@
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
activeName: "assertions",
|
||||
activeName: "parameters",
|
||||
classes: TCPSampler.CLASSES,
|
||||
isReloadData: false,
|
||||
options: API_STATUS,
|
||||
|
@ -166,6 +175,10 @@
|
|||
},
|
||||
created() {
|
||||
this.currentProjectId = getCurrentProjectID();
|
||||
if (!this.request.parameters) {
|
||||
this.$set(this.request, 'parameters', []);
|
||||
this.request.parameters = [];
|
||||
}
|
||||
this.getEnvironments();
|
||||
},
|
||||
methods: {
|
||||
|
@ -275,7 +288,7 @@
|
|||
},
|
||||
environmentConfigClose() {
|
||||
this.getEnvironments();
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -317,4 +330,18 @@
|
|||
/deep/ .el-form-item {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
/deep/ .instructions-icon {
|
||||
font-size: 14px !important;
|
||||
}
|
||||
|
||||
.request-tabs {
|
||||
margin: 20px;
|
||||
min-height: 200px;
|
||||
}
|
||||
|
||||
.other-config {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
</style>
|
|
@ -15,23 +15,7 @@
|
|||
|
||||
<!-- 执行环境 -->
|
||||
<el-form-item prop="environmentId">
|
||||
<el-select v-model="api.environmentId" size="small" class="ms-htt-width"
|
||||
:placeholder="$t('api_test.definition.request.run_env')"
|
||||
@change="environmentChange" clearable>
|
||||
<el-option v-for="(environment, index) in environments" :key="index"
|
||||
:label="environment.name + (environment.config.httpConfig.socket ? (': ' + environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket) : '')"
|
||||
:value="environment.id"/>
|
||||
<el-button class="environment-button" size="mini" type="primary" @click="openEnvironmentConfig">
|
||||
{{ $t('api_test.environment.environment_config') }}
|
||||
</el-button>
|
||||
<template v-slot:empty>
|
||||
<div class="empty-environment">
|
||||
<el-button class="environment-button" size="mini" type="primary" @click="openEnvironmentConfig">
|
||||
{{ $t('api_test.environment.environment_config') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-select>
|
||||
<environment-select :current-data="api" :project-id="projectId"/>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 请求地址 -->
|
||||
|
@ -77,8 +61,6 @@
|
|||
:currentApi="api"
|
||||
ref="caseList"/>
|
||||
|
||||
<!-- 环境 -->
|
||||
<api-environment-config ref="environmentConfig" @close="environmentConfigClose"/>
|
||||
<!-- 执行组件 -->
|
||||
<ms-run :debug="false" :environment="api.environment" :reportId="reportId" :run-data="runData"
|
||||
@runRefresh="runRefresh" ref="runTest"/>
|
||||
|
@ -91,20 +73,19 @@
|
|||
import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils";
|
||||
import MsApiCaseList from "../case/ApiCaseList";
|
||||
import MsContainer from "../../../../common/components/MsContainer";
|
||||
import {parseEnvironment} from "../../model/EnvironmentModel";
|
||||
import ApiEnvironmentConfig from "../environment/ApiEnvironmentConfig";
|
||||
import MsRequestResultTail from "../response/RequestResultTail";
|
||||
import MsRun from "../Run";
|
||||
import {REQ_METHOD} from "../../model/JsonData";
|
||||
import EnvironmentSelect from "../environment/EnvironmentSelect";
|
||||
|
||||
export default {
|
||||
name: "RunTestHTTPPage",
|
||||
components: {
|
||||
EnvironmentSelect,
|
||||
MsApiRequestForm,
|
||||
MsApiCaseList,
|
||||
MsContainer,
|
||||
MsRequestResultTail,
|
||||
ApiEnvironmentConfig,
|
||||
MsRun
|
||||
},
|
||||
data() {
|
||||
|
@ -118,7 +99,6 @@
|
|||
refreshSign: "",
|
||||
responseData: {type: 'HTTP', responseResult: {}, subRequestResults: []},
|
||||
reqOptions: REQ_METHOD,
|
||||
environments: [],
|
||||
rules: {
|
||||
method: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
|
||||
path: [{required: true, message: this.$t('api_test.definition.request.path_info'), trigger: 'blur'}],
|
||||
|
@ -230,50 +210,7 @@
|
|||
this.api.request = this.currentRequest;
|
||||
}
|
||||
},
|
||||
getEnvironments() {
|
||||
if (this.projectId) {
|
||||
this.$get('/api/environment/list/' + this.projectId, response => {
|
||||
this.environments = response.data;
|
||||
this.environments.forEach(environment => {
|
||||
parseEnvironment(environment);
|
||||
});
|
||||
let hasEnvironment = false;
|
||||
for (let i in this.environments) {
|
||||
if (this.environments[i].id === this.api.environmentId) {
|
||||
this.api.environmentId = this.environments[i].id;
|
||||
hasEnvironment = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasEnvironment) {
|
||||
this.api.environmentId = '';
|
||||
this.api.environment = undefined;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.api.environmentId = '';
|
||||
this.api.environment = undefined;
|
||||
}
|
||||
},
|
||||
openEnvironmentConfig() {
|
||||
if (!this.projectId) {
|
||||
this.$error(this.$t('api_test.select_project'));
|
||||
return;
|
||||
}
|
||||
this.$refs.environmentConfig.open(this.projectId);
|
||||
},
|
||||
environmentChange(value) {
|
||||
for (let i in this.environments) {
|
||||
if (this.environments[i].id === value) {
|
||||
this.api.environmentId = value;
|
||||
this.api.request.useEnvironment = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
environmentConfigClose() {
|
||||
this.getEnvironments();
|
||||
},
|
||||
|
||||
refresh() {
|
||||
this.$emit('refresh');
|
||||
},
|
||||
|
@ -292,7 +229,6 @@
|
|||
this.api = this.apiData;
|
||||
this.api.protocol = this.currentProtocol;
|
||||
this.currentRequest = this.api.request;
|
||||
this.getEnvironments();
|
||||
this.getResult();
|
||||
}
|
||||
}
|
||||
|
@ -303,11 +239,6 @@
|
|||
width: 350px;
|
||||
}
|
||||
|
||||
.environment-button {
|
||||
margin-left: 20px;
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
.tip {
|
||||
padding: 3px 5px;
|
||||
font-size: 16px;
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
|
||||
<p class="tip">{{$t('test_track.plan_view.base_info')}} </p>
|
||||
<!-- 执行环境 -->
|
||||
{{$t('api_test.definition.request.run_env')}}:
|
||||
<environment-select :type="'TCP'" :current-data="api" :project-id="projectId"/>
|
||||
|
||||
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
||||
<!-- TCP 请求参数 -->
|
||||
|
@ -32,8 +36,7 @@
|
|||
<ms-api-case-list @apiCaseClose="apiCaseClose" @refresh="refresh" @selectTestCase="selectTestCase" :currentApi="api" :refreshSign="refreshSign"
|
||||
:loaded="loaded" :createCase="createCase"
|
||||
ref="caseList"/>
|
||||
<!-- 环境 -->
|
||||
<api-environment-config ref="environmentConfig" @close="environmentConfigClose"/>
|
||||
|
||||
<!-- 执行组件 -->
|
||||
<ms-run :debug="false" :environment="api.environment" :reportId="reportId" :run-data="runData"
|
||||
@runRefresh="runRefresh" ref="runTest"/>
|
||||
|
@ -47,22 +50,21 @@
|
|||
import MsApiCaseList from "../case/ApiCaseList";
|
||||
import MsContainer from "../../../../common/components/MsContainer";
|
||||
import MsBottomContainer from "../BottomContainer";
|
||||
import {parseEnvironment} from "../../model/EnvironmentModel";
|
||||
import ApiEnvironmentConfig from "../environment/ApiEnvironmentConfig";
|
||||
import MsRequestResultTail from "../response/RequestResultTail";
|
||||
import MsRun from "../Run";
|
||||
import MsBasisParameters from "../request/tcp/BasisParameters";
|
||||
import MsBasisParameters from "../request/tcp/TcpBasisParameters";
|
||||
import {REQ_METHOD} from "../../model/JsonData";
|
||||
import EnvironmentSelect from "../environment/EnvironmentSelect";
|
||||
|
||||
export default {
|
||||
name: "RunTestTCPPage",
|
||||
components: {
|
||||
EnvironmentSelect,
|
||||
MsApiRequestForm,
|
||||
MsApiCaseList,
|
||||
MsContainer,
|
||||
MsBottomContainer,
|
||||
MsRequestResultTail,
|
||||
ApiEnvironmentConfig,
|
||||
MsRun,
|
||||
MsBasisParameters
|
||||
},
|
||||
|
@ -85,6 +87,7 @@
|
|||
},
|
||||
runData: [],
|
||||
reportId: "",
|
||||
projectId: ""
|
||||
}
|
||||
},
|
||||
props: {apiData: {}, currentProtocol: String,},
|
||||
|
@ -180,40 +183,6 @@
|
|||
this.api.request = this.currentRequest;
|
||||
}
|
||||
},
|
||||
getEnvironments() {
|
||||
this.$get('/api/environment/list/' + getCurrentProjectID(), response => {
|
||||
this.environments = response.data;
|
||||
this.environments.forEach(environment => {
|
||||
parseEnvironment(environment);
|
||||
});
|
||||
let hasEnvironment = false;
|
||||
for (let i in this.environments) {
|
||||
if (this.environments[i].id === this.api.environmentId) {
|
||||
this.api.environment = this.environments[i];
|
||||
hasEnvironment = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasEnvironment) {
|
||||
this.api.environmentId = '';
|
||||
this.api.environment = undefined;
|
||||
}
|
||||
});
|
||||
},
|
||||
openEnvironmentConfig() {
|
||||
this.$refs.environmentConfig.open(getCurrentProjectID());
|
||||
},
|
||||
environmentChange(value) {
|
||||
for (let i in this.environments) {
|
||||
if (this.environments[i].id === value) {
|
||||
this.api.request.useEnvironment = this.environments[i].id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
environmentConfigClose() {
|
||||
this.getEnvironments();
|
||||
},
|
||||
getResult() {
|
||||
let url = "/api/definition/report/getReport/" + this.api.id;
|
||||
this.$get(url, response => {
|
||||
|
@ -228,7 +197,7 @@
|
|||
this.api = this.apiData;
|
||||
this.api.protocol = this.currentProtocol;
|
||||
this.currentRequest = this.api.request;
|
||||
this.getEnvironments();
|
||||
this.projectId = getCurrentProjectID();
|
||||
this.getResult();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -596,9 +596,11 @@ export class TCPRequest extends Request {
|
|||
super(RequestFactory.TYPES.TCP, options);
|
||||
this.useEnvironment = options.useEnvironment;
|
||||
this.debugReport = undefined;
|
||||
this.parameters = [];
|
||||
|
||||
//设置TCPConfig的属性
|
||||
this.set(new TCPConfig(options));
|
||||
this.sets({parameters: KeyValue}, options);
|
||||
|
||||
this.request = options.request;
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7d43154a7c19732407a8e9ace8a7d1ea13c91f36
|
||||
Subproject commit 010ad7a5f072a5e9d368c756a2473bbd20781433
|
|
@ -570,6 +570,9 @@ export default {
|
|||
update_info: 'Update',
|
||||
batch_edit: "Batch edit",
|
||||
path_valid_info: "The request path is invalid",
|
||||
other_config: "Other Config",
|
||||
message_template: "Message Template",
|
||||
tcp_parameter_tip: "The request parameters can be referenced in the request template ${XXX}",
|
||||
}
|
||||
},
|
||||
automation: {
|
||||
|
|
|
@ -569,6 +569,9 @@ export default {
|
|||
update_info: '更新',
|
||||
batch_edit: "批量编辑",
|
||||
path_valid_info: "请求路径无效",
|
||||
other_config: "其他设置",
|
||||
message_template: "报文模版",
|
||||
tcp_parameter_tip: "请求参数可以在请求模版通过${xxx}引用",
|
||||
}
|
||||
},
|
||||
automation: {
|
||||
|
|
|
@ -569,6 +569,9 @@ export default {
|
|||
update_info: '更新',
|
||||
batch_edit: "批量編輯",
|
||||
path_valid_info: "請求路徑無效",
|
||||
other_config: "其他設置",
|
||||
message_template: "報文模版",
|
||||
tcp_parameter_tip: "請求參數可以在請求模版通過${xxx}引用",
|
||||
}
|
||||
},
|
||||
automation: {
|
||||
|
@ -1450,7 +1453,7 @@ export default {
|
|||
},
|
||||
variables: {
|
||||
cvs_info: "只能上傳CSV文件",
|
||||
end: "结束",
|
||||
end: "結束",
|
||||
start: "開始",
|
||||
increment: "增量",
|
||||
counter_info: "000產生至少3位數字。user_000輸出形式為user_nnn",
|
||||
|
|
Loading…
Reference in New Issue