feat(接口自动化): 完善jmx导入功能,增加jmeter相关Sampler依赖jar包

This commit is contained in:
fit2-zhao 2021-02-20 11:20:58 +08:00
parent 1c04e19880
commit 63b8801aa9
6 changed files with 71 additions and 12 deletions

View File

@ -380,7 +380,48 @@
<artifactId>json-schema-validator</artifactId>
<version>2.2.6</version>
</dependency>
<!-- 添加jmeter包支持导入的jmx能正常执行 -->
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_bolt</artifactId>
<version>${jmeter.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_jms</artifactId>
<version>${jmeter.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_ftp</artifactId>
<version>${jmeter.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_junit</artifactId>
<version>${jmeter.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_ldap</artifactId>
<version>${jmeter.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_mail</artifactId>
<version>${jmeter.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_components</artifactId>
<version>${jmeter.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_native</artifactId>
<version>${jmeter.version}</version>
</dependency>
<!-- 添加jmeter包支持导入的jmx能正常执行 -->
</dependencies>
<build>

View File

@ -43,6 +43,7 @@ import io.metersphere.base.domain.ApiScenarioWithBLOBs;
import io.metersphere.base.domain.ApiTestEnvironmentExample;
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
import io.metersphere.commons.constants.LoopConstants;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.BeanUtils;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil;
@ -96,6 +97,7 @@ public class MsJmeterParser extends ScenarioImportAbstractParser {
return scenarioImport;
} catch (Exception e) {
e.printStackTrace();
MSException.throwException("当前JMX版本不兼容");
}
return null;
}
@ -195,6 +197,7 @@ public class MsJmeterParser extends ScenarioImportAbstractParser {
}
private void convertDubboSample(MsDubboSampler elementNode, DubboSample sampler) {
elementNode.setName(sampler.getName());
elementNode.setType("DubboSampler");
elementNode.setProtocol("dubbo://");
elementNode.set_interface(sampler.getPropertyAsString("FIELD_DUBBO_INTERFACE"));

View File

@ -93,14 +93,16 @@ public class MsDubboSampler extends MsTestElement {
Constants.setInterfaceName(this.get_interface(), sampler);
Constants.setMethod(this.getMethod(), sampler);
if (CollectionUtils.isNotEmpty(this.getArgs())) {
List<MethodArgument> methodArgs = this.getArgs().stream().filter(KeyValue::isValid).filter(KeyValue::isEnable)
.map(keyValue -> new MethodArgument(keyValue.getName(), keyValue.getValue())).collect(Collectors.toList());
Constants.setMethodArgs(methodArgs, sampler);
}
if (CollectionUtils.isNotEmpty(this.getAttachmentArgs())) {
List<MethodArgument> attachmentArgs = this.getAttachmentArgs().stream().filter(KeyValue::isValid).filter(KeyValue::isEnable)
.map(keyValue -> new MethodArgument(keyValue.getName(), keyValue.getValue())).collect(Collectors.toList());
Constants.setAttachmentArgs(attachmentArgs, sampler);
}
return sampler;
}

View File

@ -9,6 +9,7 @@
@setNodeTree="setNodeTree"
@enableTrash="enableTrash"
@exportAPI="exportAPI"
@refreshAll="refreshAll"
:type="'edit'"
ref="nodeTree"/>
</ms-aside-container>
@ -264,6 +265,10 @@
this.setTabTitle(data);
this.$refs.apiScenarioList.search(data);
},
refreshAll() {
this.$refs.nodeTree.list();
this.$refs.apiScenarioList.search();
},
setTabTitle(data) {
for (let index in this.tabs) {
let tab = this.tabs[index];

View File

@ -40,7 +40,7 @@
@refresh="refresh"
ref="basisScenario"/>
<api-import ref="apiImport" :moduleOptions="moduleOptions" @refresh="$emit('refresh')"/>
<api-import ref="apiImport" :moduleOptions="moduleOptions" @refreshAll="$emit('refreshAll')"/>
</div>
</template>

View File

@ -192,6 +192,15 @@
return true;
},
save() {
if (!this.formData.file) {
this.$warning("请添加一个文件");
return;
}
let suffix = this.formData.file.name.substring(this.formData.file.name.lastIndexOf('.') + 1);
if (this.selectedPlatform.suffixes && !this.selectedPlatform.suffixes.has(suffix)) {
this.$warning(this.$t('api_test.api_import.suffixFormatErr'));
return false;
}
this.$refs.form.validate(valid => {
if (valid) {
let param = this.buildParam();
@ -199,7 +208,7 @@
let res = response.data;
this.$success(this.$t('test_track.case.import.success'));
this.visible = false;
this.$emit('refresh', res);
this.$emit('refreshAll', res);
});
} else {
return false;
@ -211,7 +220,6 @@
Object.assign(param, this.formData);
param.platform = this.selectedPlatformValue;
param.saved = this.saved;
console.log(this.formData.moduleId)
if (this.currentModule) {
param.moduleId = this.formData.moduleId
this.moduleOptions.filter(item => {