This commit is contained in:
shiziyuan9527 2020-07-21 20:48:34 +08:00
commit 1e08429b21
16 changed files with 86 additions and 31 deletions

View File

@ -80,6 +80,9 @@ public class PostmanParser extends ApiImportAbstractParser {
private Body parseBody(PostmanRequest requestDesc, Request request) {
Body body = new Body();
JSONObject postmanBody = requestDesc.getBody();
if (postmanBody == null) {
return null;
}
String bodyMode = postmanBody.getString("mode");
if (StringUtils.equals(bodyMode, PostmanRequestBodyMode.RAW.value())) {
body.setRaw(postmanBody.getString(bodyMode));

View File

@ -109,7 +109,7 @@ public class DockerTestEngine extends AbstractEngine {
restTemplateWithTimeOut.getForObject(uri, String.class);
} catch (Exception e) {
LogUtil.error("stop load test fail... " + testId, e);
MSException.throwException(Translator.get("container_delete_fail") + ", Error: " + e.getMessage());
MSException.throwException(Translator.get("container_delete_fail"));
}
});
}

View File

@ -46,7 +46,7 @@ max_thread_insufficient=并发用户数超额
related_case_del_fail_prefix=已关联到
related_case_del_fail_suffix=测试用例,请先解除关联
jmx_content_valid=JMX 内容无效,请检查
container_delete_fail=容器停止失败,请重试
container_delete_fail=容器由于网络原因停止失败,请重试
#workspace
workspace_name_is_null=工作空间名不能为空
workspace_name_already_exists=工作空间名已存在

View File

@ -46,7 +46,7 @@ max_thread_insufficient=並發用戶數超額
related_case_del_fail_prefix=已關聯到
related_case_del_fail_suffix=測試用例,請先解除關聯
jmx_content_valid=JMX 內容無效,請檢查
container_delete_fail=容器停止失敗,請重試
container_delete_fail=容器由於網絡原因停止失敗,請重試
#workspace
workspace_name_is_null=工作空間名不能為空
workspace_name_already_exists=工作空間名已存在

View File

@ -80,6 +80,16 @@
}
},
watch: {
projectId() {
this.initScenarioEnvironment();
}
},
activated() {
this.initScenarioEnvironment();
},
methods: {
createScenario: function () {
this.scenarios.push(new Scenario());
@ -119,6 +129,22 @@
this.activeName = 0;
this.select(this.scenarios[0]);
});
},
initScenarioEnvironment: function () {
if (this.projectId) {
this.result = this.$get('/api/environment/list/' + this.projectId, response => {
let environments = response.data;
let environmentMap = new Map();
environments.forEach(environment => {
environmentMap.set(environment.id, environment);
});
this.scenarios.forEach(scenario => {
if (scenario.environmentId) {
scenario.environment = environmentMap.get(scenario.environmentId);
}
});
});
}
}
},

View File

@ -82,7 +82,6 @@
for (let i in this.environments) {
if (this.environments[i].id === this.scenario.environmentId) {
this.scenario.environment = this.environments[i];
this.setRequestEnvironments();
hasEnvironment = true;
break;
}
@ -101,7 +100,6 @@
for (let i in this.environments) {
if (this.environments[i].id === value) {
this.scenario.environment = this.environments[i];
this.setRequestEnvironments();
break;
}
}
@ -121,11 +119,6 @@
},
environmentConfigClose() {
this.getEnvironments();
},
setRequestEnvironments() {
this.scenario.requests.forEach(request => {
request.environment = this.scenario.environment;
});
}
}
}

View File

@ -6,7 +6,7 @@
<div class="kv-row" v-for="(item, index) in items" :key="index">
<el-row type="flex" :gutter="20" justify="space-between" align="middle">
<el-col>
<ms-api-variable-input :is-read-only="isReadOnly" v-model="item.name" size="small" maxlength="100" @change="change"
<ms-api-variable-input :show-variable="showVariable" :is-read-only="isReadOnly" v-model="item.name" size="small" maxlength="100" @change="change"
:placeholder="$t('api_test.variable_name')" show-word-limit/>
</el-col>
<el-col>
@ -35,7 +35,11 @@
isReadOnly: {
type: Boolean,
default: false
}
},
showVariable: {
type: Boolean,
default: true
},
},
methods: {

View File

@ -1,7 +1,7 @@
<template>
<div class="variable-input">
<el-input :disabled="isReadOnly" :value="value" v-bind="$attrs" :size="size" @change="change" @input="input"/>
<div class="variable-combine" v-if="value">
<div :class="{'hidden': !showVariable}" class="variable-combine" v-if="value">
<div class="variable">{{variable}}</div>
<el-tooltip :content="$t('api_test.copied')" manual v-model="visible" placement="top" :visible-arrow="false">
<i class="el-icon-copy-document copy" @click="copy"/>
@ -20,7 +20,11 @@
isReadOnly: {
type: Boolean,
default: false
}
},
showVariable: {
type: Boolean,
default: true
},
},
data() {
@ -93,4 +97,9 @@
cursor: pointer;
color: #1E90FF;
}
.hidden {
visibility: hidden;
}
</style>

View File

@ -22,7 +22,7 @@
</el-form-item>
<span>{{$t('api_test.environment.globalVariable')}}</span>
<ms-api-scenario-variables :items="environment.variables"/>
<ms-api-scenario-variables :show-variable="false" :items="environment.variables"/>
<span>{{$t('api_test.request.headers')}}</span>
<ms-api-key-value :items="environment.headers" :suggestions="headerSuggestions"/>

View File

@ -226,8 +226,8 @@ export class HTTPSamplerProxy extends DefaultTestElement {
this.request = request || {};
if (request.useEnvironment) {
this.stringProp("HTTPSampler.domain", this.request.environment.domain);
this.stringProp("HTTPSampler.protocol", this.request.environment.protocol);
this.stringProp("HTTPSampler.domain", request.domain);
this.stringProp("HTTPSampler.protocol", request.protocol);
this.stringProp("HTTPSampler.path", this.request.path);
} else {
this.stringProp("HTTPSampler.domain", this.request.hostname);

View File

@ -160,6 +160,7 @@ export class Scenario extends BaseConfig {
this.headers = [];
this.requests = [];
this.environmentId = undefined;
this.environment = undefined;
this.set(options);
this.sets({variables: KeyValue, headers: KeyValue, requests: Request}, options);
@ -177,7 +178,7 @@ export class Scenario extends BaseConfig {
isValid() {
for (let i = 0; i < this.requests.length; i++) {
let validator = this.requests[i].isValid();
let validator = this.requests[i].isValid(this.environmentId);
if (!validator.isValid) {
return validator;
}
@ -214,9 +215,9 @@ export class Request extends BaseConfig {
return options;
}
isValid() {
isValid(environmentId) {
if (this.useEnvironment){
if (!this.environment) {
if (!environmentId) {
return {
isValid: false,
info: 'api_test.request.please_configure_environment_in_scenario'
@ -423,7 +424,7 @@ const JMX_ASSERTION_CONDITION = {
}
class JMXRequest {
constructor(request) {
constructor(request, environment) {
if (request && request instanceof Request && (request.url || request.path)) {
this.useEnvironment = request.useEnvironment;
this.method = request.method;
@ -435,10 +436,12 @@ class JMXRequest {
this.protocol = url.protocol.split(":")[0];
this.pathname = this.getPostQueryParameters(request, this.pathname);
} else {
this.environment = request.environment;
this.port = request.environment.port;
this.path = decodeURIComponent(request.path);
this.path = this.getPostQueryParameters(request, this.path);
if (environment) {
this.port = environment.port;
this.protocol = environment.protocol;
this.domain = environment.domain;
}
this.path = this.getPostQueryParameters(request, decodeURIComponent(request.path));
}
}
}
@ -497,7 +500,7 @@ class JMXGenerator {
scenario.requests.forEach(request => {
if (!request.isValid()) return;
let httpSamplerProxy = new HTTPSamplerProxy(request.name || "", new JMXRequest(request));
let httpSamplerProxy = new HTTPSamplerProxy(request.name || "", new JMXRequest(request, scenario.environment));
this.addRequestHeader(httpSamplerProxy, request);

View File

@ -259,7 +259,7 @@
maintainer: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
priority: [{required: true, message: this.$t('test_track.case.input_priority'), trigger: 'change'}],
type: [{required: true, message: this.$t('test_track.case.input_type'), trigger: 'change'}],
testId: [{required: true, message: '请选择测试', trigger: 'change'}],
testId: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}],
method: [{required: true, message: this.$t('test_track.case.input_method'), trigger: 'change'}],
prerequisite: [{max: 300, message: this.$t('test_track.length_less_than') + '300', trigger: 'blur'}],
remark: [{max: 300, message: this.$t('test_track.length_less_than') + '300', trigger: 'blur'}]

View File

@ -19,12 +19,12 @@
<el-col :span="12">
<span>{{$t('report.test_start_time')}}</span>
<span v-if="!isReport">{{reportInfo.startTime}}</span>
<el-date-picker v-if="isReport" size="mini" type="date" :placeholder="$t('commons.select_date')" v-model="reportInfo.startTime"/>
<el-date-picker @change="startTimeChange" v-if="isReport" size="mini" type="date" :placeholder="$t('commons.select_date')" v-model="reportInfo.startTime"/>
</el-col>
<el-col :span="12">
<span>{{$t('report.test_end_time')}}</span>
<span v-if="!isReport">{{reportInfo.endTime}}</span>
<el-date-picker v-if="isReport" size="mini" type="date" :placeholder="$t('commons.select_date')" v-model="reportInfo.endTime"/>
<el-date-picker @change="endTimeChange" v-if="isReport" size="mini" type="date" :placeholder="$t('commons.select_date')" v-model="reportInfo.endTime"/>
</el-col>
</el-row>
@ -55,7 +55,7 @@
principal: 'Michael',
executors: ['Michael','Tom','Jiessie'],
startTime: '2020-6-18',
endTime: '2020-6-18'
endTime: '2020-6-19'
}
}
},
@ -63,6 +63,20 @@
type: Boolean,
default: true
}
},
methods: {
startTimeChange(value) {
if (!!this.reportInfo.endTime && this.reportInfo.endTime - this.reportInfo.startTime < 0) {
this.reportInfo.startTime = undefined;
this.$warning(this.$t('commons.date.data_time_error'));
}
},
endTimeChange(value) {
if (!!this.reportInfo.startTime && this.reportInfo.endTime - this.reportInfo.startTime < 0) {
this.reportInfo.endTime = undefined;
this.$warning(this.$t('commons.date.data_time_error'));
}
}
}
}
</script>

View File

@ -114,6 +114,7 @@ export default {
start_date_time: 'Start date and time',
end_date_time: 'End date time',
range_separator: "To",
data_time_error: "Start date cannot be later than the end date",
},
trigger_mode: {
name: "Trigger Mode",

View File

@ -114,6 +114,7 @@ export default {
start_date_time: '开始日期时间',
end_date_time: '结束日期时间',
range_separator: "至",
data_time_error: "开始日期不能大于结束日期",
},
trigger_mode: {
name: "触发方式",

View File

@ -112,6 +112,7 @@ export default {
start_date_time: '開始日期時間',
end_date_time: '結束日期時間',
range_separator: "至",
data_time_error: "開始日期不能大於結束日期",
},
trigger_mode: {
name: "觸發方式",