fix(接口用例): 接口用例创建性能测试失败、json-schema转换报错
修复接口用例创建性能测试失败、json-schema转换报错的问题
This commit is contained in:
parent
8912941bea
commit
d926da8124
|
@ -289,12 +289,26 @@ public class JSONSchemaGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Object> analyzeEnumProperty(JsonObject object) {
|
private static List<Object> analyzeEnumProperty(JsonObject object) {
|
||||||
JsonArray enumValues = object.get("enum").getAsJsonArray();
|
|
||||||
List<Object> list = new LinkedList<>();
|
List<Object> list = new LinkedList<>();
|
||||||
for (JsonElement enumValueElem : enumValues) {
|
String jsonStr = null;
|
||||||
String enumValue = enumValueElem.getAsString();
|
JsonArray enumValues = null;
|
||||||
list.add(enumValue);
|
try {
|
||||||
|
enumValues = object.get("enum").getAsJsonArray();
|
||||||
|
for (JsonElement enumValueElem : enumValues) {
|
||||||
|
String enumValue = enumValueElem.getAsString();
|
||||||
|
list.add(enumValue);
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
jsonStr = object.get("enum").getAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(jsonStr != null && list.isEmpty()){
|
||||||
|
String [] arrs = jsonStr.split("\n");
|
||||||
|
for (String str: arrs) {
|
||||||
|
list.add(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -370,6 +370,7 @@ export default {
|
||||||
this.selectedNode = node;
|
this.selectedNode = node;
|
||||||
this.$store.state.selectStep = data;
|
this.$store.state.selectStep = data;
|
||||||
this.buttonData = buttons(this);
|
this.buttonData = buttons(this);
|
||||||
|
this.reload();
|
||||||
this.initPlugins();
|
this.initPlugins();
|
||||||
},
|
},
|
||||||
suggestClick(node) {
|
suggestClick(node) {
|
||||||
|
|
|
@ -206,7 +206,7 @@ import ShowMoreBtn from "../../../../track/case/components/ShowMoreBtn";
|
||||||
import MsBatchEdit from "../basis/BatchEdit";
|
import MsBatchEdit from "../basis/BatchEdit";
|
||||||
import {API_METHOD_COLOUR, CASE_PRIORITY, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData";
|
import {API_METHOD_COLOUR, CASE_PRIORITY, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData";
|
||||||
|
|
||||||
import {getBodyUploadFiles, getCurrentProjectID, getUUID} from "@/common/js/utils";
|
import {getBodyUploadFiles, getCurrentProjectID, getUUID, strMapToObj} from "@/common/js/utils";
|
||||||
import PriorityTableItem from "../../../../track/common/tableItems/planview/PriorityTableItem";
|
import PriorityTableItem from "../../../../track/common/tableItems/planview/PriorityTableItem";
|
||||||
import MsApiCaseTableExtendBtns from "../reference/ApiCaseTableExtendBtns";
|
import MsApiCaseTableExtendBtns from "../reference/ApiCaseTableExtendBtns";
|
||||||
import MsReferenceView from "../reference/ReferenceView";
|
import MsReferenceView from "../reference/ReferenceView";
|
||||||
|
@ -230,6 +230,7 @@ import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOpe
|
||||||
import ApiCaseBatchRun from "@/business/components/api/definition/components/list/ApiCaseBatchRun";
|
import ApiCaseBatchRun from "@/business/components/api/definition/components/list/ApiCaseBatchRun";
|
||||||
import MsRequestResultTail from "../../../../api/definition/components/response/RequestResultTail";
|
import MsRequestResultTail from "../../../../api/definition/components/response/RequestResultTail";
|
||||||
import {editApiTestCaseOrder} from "@/network/api";
|
import {editApiTestCaseOrder} from "@/network/api";
|
||||||
|
import {TYPE_TO_C} from "@/business/components/api/automation/scenario/Setting";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ApiCaseSimpleList",
|
name: "ApiCaseSimpleList",
|
||||||
|
@ -960,6 +961,18 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
sortHashTree(stepArray) {
|
||||||
|
if (stepArray) {
|
||||||
|
for (let i in stepArray) {
|
||||||
|
if (!stepArray[i].clazzName) {
|
||||||
|
stepArray[i].clazzName = TYPE_TO_C.get(stepArray[i].type);
|
||||||
|
}
|
||||||
|
if (stepArray[i].hashTree && stepArray[i].hashTree.length > 0) {
|
||||||
|
this.sortHashTree(stepArray[i].hashTree);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
createPerformance(row, environment) {
|
createPerformance(row, environment) {
|
||||||
/**
|
/**
|
||||||
* 思路:调用后台创建性能测试的方法,把当前案例的hashTree在后台转化为jmx并文件创建性能测试。
|
* 思路:调用后台创建性能测试的方法,把当前案例的hashTree在后台转化为jmx并文件创建性能测试。
|
||||||
|
@ -972,6 +985,7 @@ export default {
|
||||||
this.$warning(this.$t('api_test.environment.select_environment'));
|
this.$warning(this.$t('api_test.environment.select_environment'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let projectId = getCurrentProjectID();
|
||||||
let runData = [];
|
let runData = [];
|
||||||
let singleLoading = true;
|
let singleLoading = true;
|
||||||
row.request = JSON.parse(row.request);
|
row.request = JSON.parse(row.request);
|
||||||
|
@ -983,17 +997,28 @@ export default {
|
||||||
runData.push(row.request);
|
runData.push(row.request);
|
||||||
/*触发执行操作*/
|
/*触发执行操作*/
|
||||||
let testPlan = new TestPlan();
|
let testPlan = new TestPlan();
|
||||||
|
testPlan.clazzName = TYPE_TO_C.get(testPlan.type);
|
||||||
let threadGroup = new ThreadGroup();
|
let threadGroup = new ThreadGroup();
|
||||||
|
threadGroup.clazzName = TYPE_TO_C.get(threadGroup.type);
|
||||||
threadGroup.hashTree = [];
|
threadGroup.hashTree = [];
|
||||||
testPlan.hashTree = [threadGroup];
|
testPlan.hashTree = [threadGroup];
|
||||||
runData.forEach(item => {
|
runData.forEach(item => {
|
||||||
|
item.projectId = projectId;
|
||||||
|
if (!item.clazzName) {
|
||||||
|
item.clazzName = TYPE_TO_C.get(item.type);
|
||||||
|
}
|
||||||
threadGroup.hashTree.push(item);
|
threadGroup.hashTree.push(item);
|
||||||
});
|
});
|
||||||
|
this.sortHashTree(testPlan.hashTree);
|
||||||
let reqObj = {
|
let reqObj = {
|
||||||
id: row.id,
|
id: row.id,
|
||||||
testElement: testPlan,
|
testElement: testPlan,
|
||||||
|
clazzName: this.clazzName ? this.clazzName : TYPE_TO_C.get(this.type),
|
||||||
name: row.name,
|
name: row.name,
|
||||||
projectId: this.projectId,
|
projectId: this.projectId,
|
||||||
|
environmentMap: new Map([
|
||||||
|
[projectId, environment.id]
|
||||||
|
]),
|
||||||
};
|
};
|
||||||
let bodyFiles = getBodyUploadFiles(reqObj, runData);
|
let bodyFiles = getBodyUploadFiles(reqObj, runData);
|
||||||
reqObj.reportId = "run";
|
reqObj.reportId = "run";
|
||||||
|
|
|
@ -14,9 +14,10 @@
|
||||||
<script>
|
<script>
|
||||||
import MsReferenceView from "./ReferenceView";
|
import MsReferenceView from "./ReferenceView";
|
||||||
import MsTestPlanList from "../../../automation/scenario/testplan/TestPlanList";
|
import MsTestPlanList from "../../../automation/scenario/testplan/TestPlanList";
|
||||||
import {getBodyUploadFiles, getCurrentProjectID, getUUID} from "@/common/js/utils";
|
import {getBodyUploadFiles, getCurrentProjectID, getUUID, strMapToObj} from "@/common/js/utils";
|
||||||
import TestPlan from "@/business/components/api/definition/components/jmeter/components/test-plan";
|
import TestPlan from "@/business/components/api/definition/components/jmeter/components/test-plan";
|
||||||
import ThreadGroup from "@/business/components/api/definition/components/jmeter/components/thread-group";
|
import ThreadGroup from "@/business/components/api/definition/components/jmeter/components/thread-group";
|
||||||
|
import {TYPE_TO_C} from "@/business/components/api/automation/scenario/Setting";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsApiExtendBtns",
|
name: "MsApiExtendBtns",
|
||||||
|
@ -46,6 +47,18 @@
|
||||||
this.$warning(this.$t('api_test.automation.save_case_info'))
|
this.$warning(this.$t('api_test.automation.save_case_info'))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
sortHashTree(stepArray) {
|
||||||
|
if (stepArray) {
|
||||||
|
for (let i in stepArray) {
|
||||||
|
if (!stepArray[i].clazzName) {
|
||||||
|
stepArray[i].clazzName = TYPE_TO_C.get(stepArray[i].type);
|
||||||
|
}
|
||||||
|
if (stepArray[i].hashTree && stepArray[i].hashTree.length > 0) {
|
||||||
|
this.sortHashTree(stepArray[i].hashTree);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
createPerformance(row) {
|
createPerformance(row) {
|
||||||
/**
|
/**
|
||||||
* 思路:调用后台创建性能测试的方法,把当前案例的hashTree在后台转化为jmx并文件创建性能测试。
|
* 思路:调用后台创建性能测试的方法,把当前案例的hashTree在后台转化为jmx并文件创建性能测试。
|
||||||
|
@ -58,6 +71,7 @@
|
||||||
this.$warning(this.$t('api_test.environment.select_environment'));
|
this.$warning(this.$t('api_test.environment.select_environment'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let projectId = getCurrentProjectID();
|
||||||
this.runData = [];
|
this.runData = [];
|
||||||
this.singleLoading = true;
|
this.singleLoading = true;
|
||||||
this.row.request.name = this.row.id;
|
this.row.request.name = this.row.id;
|
||||||
|
@ -65,26 +79,33 @@
|
||||||
this.runData.push(this.row.request);
|
this.runData.push(this.row.request);
|
||||||
/*触发执行操作*/
|
/*触发执行操作*/
|
||||||
let testPlan = new TestPlan();
|
let testPlan = new TestPlan();
|
||||||
|
testPlan.clazzName = TYPE_TO_C.get(testPlan.type);
|
||||||
let threadGroup = new ThreadGroup();
|
let threadGroup = new ThreadGroup();
|
||||||
|
threadGroup.clazzName = TYPE_TO_C.get(threadGroup.type);
|
||||||
threadGroup.hashTree = [];
|
threadGroup.hashTree = [];
|
||||||
testPlan.hashTree = [threadGroup];
|
testPlan.hashTree = [threadGroup];
|
||||||
this.runData.forEach(item => {
|
this.runData.forEach(item => {
|
||||||
|
item.projectId = projectId;
|
||||||
|
if (!item.clazzName) {
|
||||||
|
item.clazzName = TYPE_TO_C.get(item.type);
|
||||||
|
}
|
||||||
threadGroup.hashTree.push(item);
|
threadGroup.hashTree.push(item);
|
||||||
})
|
});
|
||||||
|
this.sortHashTree(testPlan.hashTree);
|
||||||
let reqObj = {
|
let reqObj = {
|
||||||
id: this.row.id,
|
id: row.id,
|
||||||
testElement: testPlan,
|
testElement: testPlan,
|
||||||
type: this.type,
|
type: this.type,
|
||||||
name: this.row.name,
|
name: row.name,
|
||||||
|
clazzName: this.clazzName ? this.clazzName : TYPE_TO_C.get(this.type),
|
||||||
projectId: getCurrentProjectID(),
|
projectId: getCurrentProjectID(),
|
||||||
environmentMap: new Map([
|
environmentMap: new Map([
|
||||||
[getCurrentProjectID(), this.environment.id]
|
[projectId, this.environment.id]
|
||||||
]),
|
]),
|
||||||
};
|
};
|
||||||
|
|
||||||
let bodyFiles = getBodyUploadFiles(reqObj, this.runData);
|
let bodyFiles = getBodyUploadFiles(reqObj, this.runData);
|
||||||
reqObj.reportId = "run";
|
reqObj.reportId = "run";
|
||||||
// let url = "/api/genPerformanceTest";
|
|
||||||
let url = "/api/genPerformanceTestXml";
|
let url = "/api/genPerformanceTestXml";
|
||||||
this.$fileUpload(url, null, bodyFiles, reqObj, response => {
|
this.$fileUpload(url, null, bodyFiles, reqObj, response => {
|
||||||
let jmxObj = {};
|
let jmxObj = {};
|
||||||
|
@ -105,7 +126,6 @@
|
||||||
}, erro => {
|
}, erro => {
|
||||||
this.$emit('runRefresh', {});
|
this.$emit('runRefresh', {});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,9 +85,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
jsonData(data) {
|
jsonData(data) {
|
||||||
let obj = {"root": data}
|
this.schema.root = {};
|
||||||
this.schema = obj;
|
this.$nextTick(() => {
|
||||||
this.body.jsonSchema = this.schema.root
|
this.schema.root = data;
|
||||||
|
this.body.jsonSchema = this.schema.root;
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue