refactor(接口测试): 场景插件步骤优化加载
This commit is contained in:
parent
78bf105b45
commit
bba03a8aeb
|
@ -98,15 +98,11 @@ public class GenerateHashTreeUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<JvmInfoDTO> setPoolResource(String id) {
|
public static List<JvmInfoDTO> setPoolResource(String id) {
|
||||||
if (GenerateHashTreeUtil.isResourcePool(id).isPool()) {
|
if (GenerateHashTreeUtil.isResourcePool(id).isPool() && !GenerateHashTreeUtil.isResourcePool(id).isK8s()) {
|
||||||
if (GenerateHashTreeUtil.isResourcePool(id).isK8s()) {
|
ResourcePoolCalculation resourcePoolCalculation = CommonBeanFactory.getBean(ResourcePoolCalculation.class);
|
||||||
LogUtil.info("K8S 暂时不做校验 ");
|
return resourcePoolCalculation.getPools(id);
|
||||||
} else {
|
|
||||||
ResourcePoolCalculation resourcePoolCalculation = CommonBeanFactory.getBean(ResourcePoolCalculation.class);
|
|
||||||
return resourcePoolCalculation.getPools(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return new LinkedList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setScenarioEnv(MsScenario scenario, ApiScenarioWithBLOBs apiScenarioWithBLOBs) {
|
public static void setScenarioEnv(MsScenario scenario, ApiScenarioWithBLOBs apiScenarioWithBLOBs) {
|
||||||
|
|
|
@ -1198,7 +1198,7 @@ export default {
|
||||||
}
|
}
|
||||||
this.isBtnHide = false;
|
this.isBtnHide = false;
|
||||||
this.sort();
|
this.sort();
|
||||||
this.reload();
|
this.cancelBatchProcessing();
|
||||||
},
|
},
|
||||||
setApiParameter(item, refType, referenced) {
|
setApiParameter(item, refType, referenced) {
|
||||||
let request = {};
|
let request = {};
|
||||||
|
@ -1245,7 +1245,7 @@ export default {
|
||||||
this.isBtnHide = false;
|
this.isBtnHide = false;
|
||||||
this.$refs.scenarioApiRelevance.changeButtonLoadingType();
|
this.$refs.scenarioApiRelevance.changeButtonLoadingType();
|
||||||
this.sort();
|
this.sort();
|
||||||
this.reload();
|
this.cancelBatchProcessing();
|
||||||
},
|
},
|
||||||
getMaintainerOptions() {
|
getMaintainerOptions() {
|
||||||
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
|
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
|
||||||
|
@ -1455,32 +1455,34 @@ export default {
|
||||||
}
|
}
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
document.getElementById("inputDelay").focus(); // 保存前在input框自动失焦,以免保存失败
|
document.getElementById("inputDelay").focus(); // 保存前在input框自动失焦,以免保存失败
|
||||||
this.$refs['currentScenario'].validate(async (valid) => {
|
if (this.$refs['currentScenario']) {
|
||||||
if (valid) {
|
this.$refs['currentScenario'].validate(async (valid) => {
|
||||||
await this.setParameter();
|
if (valid) {
|
||||||
if (!this.currentScenario.versionId) {
|
await this.setParameter();
|
||||||
if (this.$refs.versionHistory && this.$refs.versionHistory.currentVersion) {
|
if (!this.currentScenario.versionId) {
|
||||||
this.currentScenario.versionId = this.$refs.versionHistory.currentVersion.id;
|
if (this.$refs.versionHistory && this.$refs.versionHistory.currentVersion) {
|
||||||
|
this.currentScenario.versionId = this.$refs.versionHistory.currentVersion.id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
saveScenario(this.path, this.currentScenario, this.scenarioDefinition, this, (response) => {
|
||||||
|
this.$success(this.$t('commons.save_success'));
|
||||||
|
this.path = "/api/automation/update";
|
||||||
|
this.$store.state.pluginFiles = [];
|
||||||
|
if (response.data) {
|
||||||
|
this.currentScenario.id = response.data.id;
|
||||||
|
}
|
||||||
|
// 保存成功后刷新历史版本
|
||||||
|
this.getVersionHistory();
|
||||||
|
if (this.currentScenario.tags instanceof String) {
|
||||||
|
this.currentScenario.tags = JSON.parse(this.currentScenario.tags);
|
||||||
|
}
|
||||||
|
this.pluginDelStep = false;
|
||||||
|
this.$emit('refresh', this.currentScenario);
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
saveScenario(this.path, this.currentScenario, this.scenarioDefinition, this, (response) => {
|
})
|
||||||
this.$success(this.$t('commons.save_success'));
|
}
|
||||||
this.path = "/api/automation/update";
|
|
||||||
this.$store.state.pluginFiles = [];
|
|
||||||
if (response.data) {
|
|
||||||
this.currentScenario.id = response.data.id;
|
|
||||||
}
|
|
||||||
// 保存成功后刷新历史版本
|
|
||||||
this.getVersionHistory();
|
|
||||||
if (this.currentScenario.tags instanceof String) {
|
|
||||||
this.currentScenario.tags = JSON.parse(this.currentScenario.tags);
|
|
||||||
}
|
|
||||||
this.pluginDelStep = false;
|
|
||||||
this.$emit('refresh', this.currentScenario);
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getEnv(definition) {
|
getEnv(definition) {
|
||||||
|
@ -1560,8 +1562,6 @@ export default {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.sort();
|
|
||||||
this.cancelBatchProcessing();
|
|
||||||
// 初始化resourceId
|
// 初始化resourceId
|
||||||
if (this.scenarioDefinition) {
|
if (this.scenarioDefinition) {
|
||||||
this.resetResourceId(this.scenarioDefinition);
|
this.resetResourceId(this.scenarioDefinition);
|
||||||
|
@ -1580,7 +1580,10 @@ export default {
|
||||||
|
|
||||||
this.currentScenario.scenarioDefinitionOrg = JSON.parse(JSON.stringify(v1));
|
this.currentScenario.scenarioDefinitionOrg = JSON.parse(JSON.stringify(v1));
|
||||||
this.currentScenario.scenarioDefinition = this.scenarioDefinition;
|
this.currentScenario.scenarioDefinition = this.scenarioDefinition;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.sort();
|
||||||
|
this.cancelBatchProcessing();
|
||||||
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -161,27 +161,27 @@ export function setComponent(type, _this, plugin) {
|
||||||
_this.scenarioDefinition.push(new JSR223Processor());
|
_this.scenarioDefinition.push(new JSR223Processor());
|
||||||
break;
|
break;
|
||||||
case ELEMENT_TYPE.JSR223PreProcessor:
|
case ELEMENT_TYPE.JSR223PreProcessor:
|
||||||
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new JSR223Processor({type: "JSR223PreProcessor",label: "SCENARIO-REF-STEP"})) :
|
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new JSR223Processor({type: "JSR223PreProcessor", label: "SCENARIO-REF-STEP"})) :
|
||||||
_this.scenarioDefinition.push(new JSR223Processor({type: "JSR223PreProcessor"}));
|
_this.scenarioDefinition.push(new JSR223Processor({type: "JSR223PreProcessor"}));
|
||||||
break;
|
break;
|
||||||
case ELEMENT_TYPE.JSR223PostProcessor:
|
case ELEMENT_TYPE.JSR223PostProcessor:
|
||||||
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new JSR223Processor({type: "JSR223PostProcessor",label: "SCENARIO-REF-STEP"})) :
|
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new JSR223Processor({type: "JSR223PostProcessor", label: "SCENARIO-REF-STEP"})) :
|
||||||
_this.scenarioDefinition.push(new JSR223Processor({type: "JSR223PostProcessor"}));
|
_this.scenarioDefinition.push(new JSR223Processor({type: "JSR223PostProcessor"}));
|
||||||
break;
|
break;
|
||||||
case ELEMENT_TYPE.JDBCPreProcessor:
|
case ELEMENT_TYPE.JDBCPreProcessor:
|
||||||
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new JDBCProcessor({type: "JDBCPreProcessor",label: "SCENARIO-REF-STEP"})) :
|
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new JDBCProcessor({type: "JDBCPreProcessor", label: "SCENARIO-REF-STEP"})) :
|
||||||
_this.scenarioDefinition.push(new JDBCProcessor({type: "JDBCPreProcessor"}));
|
_this.scenarioDefinition.push(new JDBCProcessor({type: "JDBCPreProcessor"}));
|
||||||
break;
|
break;
|
||||||
case ELEMENT_TYPE.JDBCPostProcessor:
|
case ELEMENT_TYPE.JDBCPostProcessor:
|
||||||
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new JDBCProcessor({type: "JDBCPostProcessor",label: "SCENARIO-REF-STEP"})) :
|
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new JDBCProcessor({type: "JDBCPostProcessor", label: "SCENARIO-REF-STEP"})) :
|
||||||
_this.scenarioDefinition.push(new JDBCProcessor({type: "JDBCPostProcessor"}));
|
_this.scenarioDefinition.push(new JDBCProcessor({type: "JDBCPostProcessor"}));
|
||||||
break;
|
break;
|
||||||
case ELEMENT_TYPE.Assertions:
|
case ELEMENT_TYPE.Assertions:
|
||||||
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new Assertions({label: "SCENARIO-REF-STEP",id:getUUID()})) :
|
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new Assertions({label: "SCENARIO-REF-STEP", id: getUUID()})) :
|
||||||
_this.scenarioDefinition.push(new Assertions());
|
_this.scenarioDefinition.push(new Assertions());
|
||||||
break;
|
break;
|
||||||
case ELEMENT_TYPE.Extract:
|
case ELEMENT_TYPE.Extract:
|
||||||
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new Extract({label: "SCENARIO-REF-STEP",id:getUUID()})) :
|
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new Extract({label: "SCENARIO-REF-STEP", id: getUUID()})) :
|
||||||
_this.scenarioDefinition.push(new Extract());
|
_this.scenarioDefinition.push(new Extract());
|
||||||
break;
|
break;
|
||||||
case ELEMENT_TYPE.CustomizeReq:
|
case ELEMENT_TYPE.CustomizeReq:
|
||||||
|
@ -201,11 +201,14 @@ export function setComponent(type, _this, plugin) {
|
||||||
_this.$refs.scenarioRelevance.open();
|
_this.$refs.scenarioRelevance.open();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
_this.scenarioDefinition.push(new PluginController({type: plugin.jmeterClazz,stepName:plugin.name, pluginId: plugin.scriptId}));
|
_this.scenarioDefinition.push(new PluginController({type: plugin.jmeterClazz, stepName: plugin.name, pluginId: plugin.scriptId}));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (_this.selectedNode) {
|
if (_this.selectedNode) {
|
||||||
_this.selectedNode.expanded = true;
|
_this.selectedNode.expanded = true;
|
||||||
}
|
}
|
||||||
_this.sort();
|
_this.sort();
|
||||||
|
_this.$nextTick(() => {
|
||||||
|
_this.cancelBatchProcessing();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -460,78 +460,71 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getCurrentScenario() {
|
getCurrentScenario() {
|
||||||
return new Promise((resolve) => {
|
if (this.currentScenarioId) {
|
||||||
if (this.currentScenarioId) {
|
this.result = this.$get("/api/automation/getApiScenario/" + this.currentScenarioId, response => {
|
||||||
this.result = this.$get("/api/automation/getApiScenario/" + this.currentScenarioId, response => {
|
if (response.data) {
|
||||||
if (response.data) {
|
if (response.data.scenarioDefinition != null) {
|
||||||
if (response.data.scenarioDefinition != null) {
|
let obj = JSON.parse(response.data.scenarioDefinition);
|
||||||
let obj = JSON.parse(response.data.scenarioDefinition);
|
if (obj) {
|
||||||
if (obj) {
|
this.oldScenarioDefinition = obj.hashTree;
|
||||||
this.oldScenarioDefinition = obj.hashTree;
|
}
|
||||||
|
}
|
||||||
|
this.oldData = response.data;
|
||||||
|
this.$get('/api/automation/follow/' + this.currentScenarioId, response => {
|
||||||
|
this.oldData.follows = response.data;
|
||||||
|
for (let i = 0; i < response.data.length; i++) {
|
||||||
|
if (response.data[i] === this.currentUser().id) {
|
||||||
|
this.showFollow = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.oldData = response.data;
|
});
|
||||||
this.$get('/api/automation/follow/' + this.currentScenarioId, response => {
|
}
|
||||||
this.oldData.follows = response.data;
|
})
|
||||||
for (let i = 0; i < response.data.length; i++) {
|
}
|
||||||
if (response.data[i] === this.currentUser().id) {
|
|
||||||
this.showFollow = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.getDffScenario();
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
getDffScenario() {
|
getDffScenario() {
|
||||||
return new Promise((resolve) => {
|
this.$get('/api/automation/get/' + this.dffScenarioId + "/" + this.scenarioRefId, response => {
|
||||||
this.$get('/api/automation/get/' + this.dffScenarioId + "/" + this.scenarioRefId, response => {
|
this.$get("/api/automation/getApiScenario/" + response.data.id, res => {
|
||||||
this.$get("/api/automation/getApiScenario/" + response.data.id, res => {
|
if (res.data) {
|
||||||
if (res.data) {
|
if (res.data.scenarioDefinition != null) {
|
||||||
if (res.data.scenarioDefinition != null) {
|
let obj = JSON.parse(res.data.scenarioDefinition);
|
||||||
let obj = JSON.parse(res.data.scenarioDefinition);
|
if (obj) {
|
||||||
if (obj) {
|
if (obj.hashTree) {
|
||||||
if (obj.hashTree) {
|
for (let i = 0; i < obj.hashTree.length; i++) {
|
||||||
for (let i = 0; i < obj.hashTree.length; i++) {
|
if (!obj.hashTree[i].index) {
|
||||||
if (!obj.hashTree[i].index) {
|
obj.hashTree[i].index = i + 1;
|
||||||
obj.hashTree[i].index = i + 1;
|
|
||||||
}
|
|
||||||
obj.hashTree[i].disabled = true;
|
|
||||||
if (!obj.hashTree[i].requestResult) {
|
|
||||||
obj.hashTree[i].requestResult = [{responseResult: {}}];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.newEnableCookieShare = obj.enableCookieShare;
|
obj.hashTree[i].disabled = true;
|
||||||
if (obj.onSampleError === undefined) {
|
if (!obj.hashTree[i].requestResult) {
|
||||||
this.newOnSampleError = true;
|
obj.hashTree[i].requestResult = [{responseResult: {}}];
|
||||||
} else {
|
|
||||||
this.newOnSampleError = obj.onSampleError;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.newScenarioDefinition = obj.hashTree;
|
this.newEnableCookieShare = obj.enableCookieShare;
|
||||||
for (let i = 0; i < this.oldScenarioDefinition.length; i++) {
|
if (obj.onSampleError === undefined) {
|
||||||
this.oldScenarioDefinition[i].disabled = true;
|
this.newOnSampleError = true;
|
||||||
}
|
|
||||||
if (response.data.environmentJson) {
|
|
||||||
this.newProjectEnvMap = objToStrMap(JSON.parse(response.data.environmentJson));
|
|
||||||
} else {
|
} else {
|
||||||
// 兼容历史数据
|
this.newOnSampleError = obj.onSampleError;
|
||||||
this.newProjectEnvMap.set(this.projectId, obj.environmentId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.newScenarioDefinition = obj.hashTree;
|
||||||
|
for (let i = 0; i < this.oldScenarioDefinition.length; i++) {
|
||||||
|
this.oldScenarioDefinition[i].disabled = true;
|
||||||
|
}
|
||||||
|
if (response.data.environmentJson) {
|
||||||
|
this.newProjectEnvMap = objToStrMap(JSON.parse(response.data.environmentJson));
|
||||||
|
} else {
|
||||||
|
// 兼容历史数据
|
||||||
|
this.newProjectEnvMap.set(this.projectId, obj.environmentId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
res.data.userName = response.data.userName
|
|
||||||
this.dealWithTag(res.data);
|
|
||||||
this.newData = res.data;
|
|
||||||
this.closeExpansion()
|
|
||||||
resolve();
|
|
||||||
}
|
}
|
||||||
});
|
res.data.userName = response.data.userName
|
||||||
})
|
this.dealWithTag(res.data);
|
||||||
|
this.newData = res.data;
|
||||||
|
this.closeExpansion()
|
||||||
|
}
|
||||||
|
});
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
dealWithTag(newScenario) {
|
dealWithTag(newScenario) {
|
||||||
|
@ -723,6 +716,7 @@ export default {
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getCurrentScenario();
|
this.getCurrentScenario();
|
||||||
|
this.getDffScenario();
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$nextTick(function () {
|
this.$nextTick(function () {
|
||||||
|
|
Loading…
Reference in New Issue