fix(接口自动化): 修复导出jmx校验问题
This commit is contained in:
parent
bd0a6132e6
commit
8cf3e3f9ce
|
@ -140,7 +140,7 @@ public class MsScenario extends MsTestElement {
|
||||||
if (arguments != null) {
|
if (arguments != null) {
|
||||||
tree.add(config.valueSupposeMock(arguments));
|
tree.add(config.valueSupposeMock(arguments));
|
||||||
}
|
}
|
||||||
this.addCsvDataSet(tree, variables);
|
this.addCsvDataSet(tree, variables,config);
|
||||||
this.addCounter(tree, variables);
|
this.addCounter(tree, variables);
|
||||||
this.addRandom(tree, variables);
|
this.addRandom(tree, variables);
|
||||||
if (CollectionUtils.isNotEmpty(this.headers)) {
|
if (CollectionUtils.isNotEmpty(this.headers)) {
|
||||||
|
|
|
@ -201,7 +201,7 @@ public abstract class MsTestElement {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addCsvDataSet(HashTree tree, List<ScenarioVariable> variables) {
|
protected void addCsvDataSet(HashTree tree, List<ScenarioVariable> variables,ParameterConfig config) {
|
||||||
if (CollectionUtils.isNotEmpty(variables)) {
|
if (CollectionUtils.isNotEmpty(variables)) {
|
||||||
List<ScenarioVariable> list = variables.stream().filter(ScenarioVariable::isCSVValid).collect(Collectors.toList());
|
List<ScenarioVariable> list = variables.stream().filter(ScenarioVariable::isCSVValid).collect(Collectors.toList());
|
||||||
if (CollectionUtils.isNotEmpty(list)) {
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
|
@ -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 (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());
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class MsLoopController extends MsTestElement {
|
||||||
}
|
}
|
||||||
final HashTree groupTree = controller(tree);
|
final HashTree groupTree = controller(tree);
|
||||||
if (CollectionUtils.isNotEmpty(config.getVariables())) {
|
if (CollectionUtils.isNotEmpty(config.getVariables())) {
|
||||||
this.addCsvDataSet(groupTree, config.getVariables());
|
this.addCsvDataSet(groupTree, config.getVariables(),config);
|
||||||
this.addCounter(groupTree, config.getVariables());
|
this.addCounter(groupTree, config.getVariables());
|
||||||
this.addRandom(groupTree, config.getVariables());
|
this.addRandom(groupTree, config.getVariables());
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class MsJmeterElement extends MsTestElement {
|
||||||
LogUtil.info(((ThreadGroup) scriptWrapper).getName() + "是被禁用线程组不加入执行");
|
LogUtil.info(((ThreadGroup) scriptWrapper).getName() + "是被禁用线程组不加入执行");
|
||||||
} else {
|
} else {
|
||||||
// CSV数据检查文件路径是否还存在
|
// CSV数据检查文件路径是否还存在
|
||||||
if (scriptWrapper instanceof CSVDataSet) {
|
if (!config.isOperating() && scriptWrapper instanceof CSVDataSet) {
|
||||||
String path = ((CSVDataSet) scriptWrapper).getPropertyAsString("filename");
|
String path = ((CSVDataSet) scriptWrapper).getPropertyAsString("filename");
|
||||||
if (!new File(path).exists()) {
|
if (!new File(path).exists()) {
|
||||||
MSException.throwException(StringUtils.isEmpty(((CSVDataSet) scriptWrapper).getName()) ? "CSVDataSet" : ((CSVDataSet) scriptWrapper).getName() + ":[ CSV文件不存在 ]");
|
MSException.throwException(StringUtils.isEmpty(((CSVDataSet) scriptWrapper).getName()) ? "CSVDataSet" : ((CSVDataSet) scriptWrapper).getName() + ":[ CSV文件不存在 ]");
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<el-card class="table-card" v-loading="loading">
|
<el-card class="table-card" v-loading="result.loading">
|
||||||
<template v-slot:header>
|
<template v-slot:header>
|
||||||
<ms-table-header :condition.sync="condition" @search="selectByParam" title=""
|
<ms-table-header :condition.sync="condition" @search="selectByParam" title=""
|
||||||
:show-create="false" :tip="$t('commons.search_by_id_name_tag')"/>
|
:show-create="false" :tip="$t('commons.search_by_id_name_tag')"/>
|
||||||
|
@ -246,10 +246,10 @@
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
result: {},
|
||||||
type: API_SCENARIO_LIST,
|
type: API_SCENARIO_LIST,
|
||||||
headerItems: Api_Scenario_List,
|
headerItems: Api_Scenario_List,
|
||||||
tableLabel: Api_Scenario_List,
|
tableLabel: Api_Scenario_List,
|
||||||
loading: false,
|
|
||||||
screenHeight: document.documentElement.clientHeight - 280,//屏幕高度,
|
screenHeight: document.documentElement.clientHeight - 280,//屏幕高度,
|
||||||
condition: {
|
condition: {
|
||||||
components: API_SCENARIO_CONFIGS
|
components: API_SCENARIO_CONFIGS
|
||||||
|
@ -358,7 +358,7 @@
|
||||||
this.search();
|
this.search();
|
||||||
},
|
},
|
||||||
batchReportId() {
|
batchReportId() {
|
||||||
this.loading = true;
|
this.result.loading = true;
|
||||||
this.getReport();
|
this.getReport();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -418,7 +418,7 @@
|
||||||
this.selectDataCounts = 0;
|
this.selectDataCounts = 0;
|
||||||
let url = "/api/automation/list/" + this.currentPage + "/" + this.pageSize;
|
let url = "/api/automation/list/" + this.currentPage + "/" + this.pageSize;
|
||||||
if (this.condition.projectId) {
|
if (this.condition.projectId) {
|
||||||
this.loading = true;
|
this.result.loading = true;
|
||||||
this.$post(url, this.condition, response => {
|
this.$post(url, this.condition, response => {
|
||||||
let data = response.data;
|
let data = response.data;
|
||||||
this.total = data.itemCount;
|
this.total = data.itemCount;
|
||||||
|
@ -428,7 +428,7 @@
|
||||||
item.tags = JSON.parse(item.tags);
|
item.tags = JSON.parse(item.tags);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.loading = false;
|
this.result.loading = false;
|
||||||
this.unSelection = data.listObject.map(s => s.id);
|
this.unSelection = data.listObject.map(s => s.id);
|
||||||
if (this.$refs.scenarioTable) {
|
if (this.$refs.scenarioTable) {
|
||||||
this.$refs.scenarioTable.doLayout()
|
this.$refs.scenarioTable.doLayout()
|
||||||
|
@ -550,13 +550,13 @@
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
this.loading = false;
|
this.result.loading = false;
|
||||||
this.$success("批量执行成功,请到报告页面查看详情!");
|
this.$success("批量执行成功,请到报告页面查看详情!");
|
||||||
} else {
|
} else {
|
||||||
setTimeout(this.getReport, 2000)
|
setTimeout(this.getReport, 2000)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.loading = false;
|
this.result.loading = false;
|
||||||
this.$error(this.$t('api_report.not_exist'));
|
this.$error(this.$t('api_report.not_exist'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -723,9 +723,9 @@
|
||||||
this.$warning(this.$t("api_test.automation.scenario.check_case"));
|
this.$warning(this.$t("api_test.automation.scenario.check_case"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.loading = true;
|
this.result.loading = true;
|
||||||
this.result = this.$post("/api/automation/export", param, response => {
|
this.result = this.$post("/api/automation/export", param, response => {
|
||||||
this.loading = false;
|
this.result.loading = false;
|
||||||
let obj = response.data;
|
let obj = response.data;
|
||||||
this.buildApiPath(obj.data);
|
this.buildApiPath(obj.data);
|
||||||
downloadFile("Metersphere_Scenario_" + localStorage.getItem(PROJECT_NAME) + ".json", JSON.stringify(obj));
|
downloadFile("Metersphere_Scenario_" + localStorage.getItem(PROJECT_NAME) + ".json", JSON.stringify(obj));
|
||||||
|
@ -738,9 +738,9 @@
|
||||||
this.$warning(this.$t("api_test.automation.scenario.check_case"));
|
this.$warning(this.$t("api_test.automation.scenario.check_case"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.loading = true;
|
this.result.loading = true;
|
||||||
this.result = this.$post("/api/automation/export/jmx", param, response => {
|
this.result = this.$post("/api/automation/export/jmx", param, response => {
|
||||||
this.loading = false;
|
this.result.loading = false;
|
||||||
let obj = response.data;
|
let obj = response.data;
|
||||||
if (obj && obj.length > 0) {
|
if (obj && obj.length > 0) {
|
||||||
obj.forEach(item => {
|
obj.forEach(item => {
|
||||||
|
|
|
@ -20,28 +20,29 @@
|
||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
<el-dropdown v-if="!isReadOnly" size="small" split-button type="primary" class="ms-api-button" @click="handleCommand('add-api')"
|
<el-dropdown v-if="!isReadOnly" size="small" split-button type="primary" class="ms-api-button" @click="handleCommand('add-api')"
|
||||||
v-tester
|
v-tester
|
||||||
@command="handleCommand">
|
@command="handleCommand" trigger="click">
|
||||||
<el-button icon="el-icon-folder-add" @click="addScenario"></el-button>
|
<el-button icon="el-icon-folder-add" @click="addScenario"></el-button>
|
||||||
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-menu slot="dropdown">
|
||||||
<el-dropdown-item command="add-scenario">{{ $t('api_test.automation.add_scenario') }}</el-dropdown-item>
|
<el-dropdown-item command="add-scenario">{{ $t('api_test.automation.add_scenario') }}</el-dropdown-item>
|
||||||
<el-dropdown-item command="import">{{ $t('api_test.api_import.label') }}</el-dropdown-item>
|
<el-dropdown-item command="import">{{ $t('api_test.api_import.label') }}</el-dropdown-item>
|
||||||
<el-dropdown-item command="export">{{ $t('report.export') }}MS</el-dropdown-item>
|
<el-dropdown-item command="exports">
|
||||||
<el-dropdown-item command="exportJmx">{{ $t('report.export') }}JMX</el-dropdown-item>
|
<el-dropdown placement="right-start" @command="chooseExportType">
|
||||||
|
<span>
|
||||||
|
{{ $t('report.export') }} <i class="el-icon-arrow-down el-icon--right"></i>
|
||||||
|
</span>
|
||||||
|
<el-dropdown-menu slot="dropdown">
|
||||||
|
<template>
|
||||||
|
<el-dropdown-item command="export">{{ $t('report.export_to_ms_format') }}</el-dropdown-item>
|
||||||
|
<el-dropdown-item command="exportJmx">{{ $t('report.export') }} JMETER 格式</el-dropdown-item>
|
||||||
|
</template>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</el-dropdown>
|
||||||
|
</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
</template>
|
</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
<module-trash-button v-if="!isReadOnly" :condition="condition" :exe="enableTrash"/>
|
<module-trash-button v-if="!isReadOnly" :condition="condition" :exe="enableTrash"/>
|
||||||
<!-- 是否保留这个 -->
|
|
||||||
<!--<api-scenario-module-header-->
|
|
||||||
<!--:condition="condition"-->
|
|
||||||
<!--:current-module="currentModule"-->
|
|
||||||
<!--:is-read-only="isReadOnly"-->
|
|
||||||
<!--:project-id="projectId"-->
|
|
||||||
<!--@exportAPI="exportAPI"-->
|
|
||||||
<!--@addScenario="addScenario"-->
|
|
||||||
<!--@refreshTable="$emit('refreshTable')"-->
|
|
||||||
<!--@refresh="refresh"/>-->
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
</ms-node-tree>
|
</ms-node-tree>
|
||||||
|
@ -150,6 +151,16 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
chooseExportType(e) {
|
||||||
|
switch (e) {
|
||||||
|
case "export":
|
||||||
|
this.$emit('exportAPI');
|
||||||
|
break;
|
||||||
|
case "exportJmx":
|
||||||
|
this.$emit('exportJmx');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
list(projectId) {
|
list(projectId) {
|
||||||
let url = undefined;
|
let url = undefined;
|
||||||
if (this.isPlanModel) {
|
if (this.isPlanModel) {
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<div class="header-right" @click.stop>
|
<div class="header-right" @click.stop>
|
||||||
<slot name="message"></slot>
|
<slot name="message"></slot>
|
||||||
<el-tooltip :content="$t('test_resource_pool.enable_disable')" placement="top" v-if="showBtn">
|
<el-tooltip :content="$t('test_resource_pool.enable_disable')" placement="top" v-if="showBtn">
|
||||||
<el-switch v-model="data.enable" class="enable-switch" size="mini" :disabled="data.disabled"/>
|
<el-switch v-model="data.enable" class="enable-switch" size="mini" :disabled="data.disabled && !data.root"/>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<slot name="button"></slot>
|
<slot name="button"></slot>
|
||||||
<step-extend-btns style="display: contents" :data="data" @copy="copyRow" @remove="remove" @openScenario="openScenario" v-if="showBtn && (!data.disabled || data.root)"/>
|
<step-extend-btns style="display: contents" :data="data" @copy="copyRow" @remove="remove" @openScenario="openScenario" v-if="showBtn && (!data.disabled || data.root)"/>
|
||||||
|
|
Loading…
Reference in New Issue