refactor(接口测试): 场景插件步骤优化加载
This commit is contained in:
parent
78bf105b45
commit
bba03a8aeb
|
@ -98,15 +98,11 @@ public class GenerateHashTreeUtil {
|
|||
}
|
||||
|
||||
public static List<JvmInfoDTO> setPoolResource(String id) {
|
||||
if (GenerateHashTreeUtil.isResourcePool(id).isPool()) {
|
||||
if (GenerateHashTreeUtil.isResourcePool(id).isK8s()) {
|
||||
LogUtil.info("K8S 暂时不做校验 ");
|
||||
} else {
|
||||
ResourcePoolCalculation resourcePoolCalculation = CommonBeanFactory.getBean(ResourcePoolCalculation.class);
|
||||
return resourcePoolCalculation.getPools(id);
|
||||
}
|
||||
if (GenerateHashTreeUtil.isResourcePool(id).isPool() && !GenerateHashTreeUtil.isResourcePool(id).isK8s()) {
|
||||
ResourcePoolCalculation resourcePoolCalculation = CommonBeanFactory.getBean(ResourcePoolCalculation.class);
|
||||
return resourcePoolCalculation.getPools(id);
|
||||
}
|
||||
return null;
|
||||
return new LinkedList<>();
|
||||
}
|
||||
|
||||
public static void setScenarioEnv(MsScenario scenario, ApiScenarioWithBLOBs apiScenarioWithBLOBs) {
|
||||
|
|
|
@ -1198,7 +1198,7 @@ export default {
|
|||
}
|
||||
this.isBtnHide = false;
|
||||
this.sort();
|
||||
this.reload();
|
||||
this.cancelBatchProcessing();
|
||||
},
|
||||
setApiParameter(item, refType, referenced) {
|
||||
let request = {};
|
||||
|
@ -1245,7 +1245,7 @@ export default {
|
|||
this.isBtnHide = false;
|
||||
this.$refs.scenarioApiRelevance.changeButtonLoadingType();
|
||||
this.sort();
|
||||
this.reload();
|
||||
this.cancelBatchProcessing();
|
||||
},
|
||||
getMaintainerOptions() {
|
||||
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
|
||||
|
@ -1455,32 +1455,34 @@ export default {
|
|||
}
|
||||
return new Promise((resolve) => {
|
||||
document.getElementById("inputDelay").focus(); // 保存前在input框自动失焦,以免保存失败
|
||||
this.$refs['currentScenario'].validate(async (valid) => {
|
||||
if (valid) {
|
||||
await this.setParameter();
|
||||
if (!this.currentScenario.versionId) {
|
||||
if (this.$refs.versionHistory && this.$refs.versionHistory.currentVersion) {
|
||||
this.currentScenario.versionId = this.$refs.versionHistory.currentVersion.id;
|
||||
if (this.$refs['currentScenario']) {
|
||||
this.$refs['currentScenario'].validate(async (valid) => {
|
||||
if (valid) {
|
||||
await this.setParameter();
|
||||
if (!this.currentScenario.versionId) {
|
||||
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) {
|
||||
|
@ -1560,8 +1562,6 @@ export default {
|
|||
});
|
||||
}
|
||||
this.loading = false;
|
||||
this.sort();
|
||||
this.cancelBatchProcessing();
|
||||
// 初始化resourceId
|
||||
if (this.scenarioDefinition) {
|
||||
this.resetResourceId(this.scenarioDefinition);
|
||||
|
@ -1580,7 +1580,10 @@ export default {
|
|||
|
||||
this.currentScenario.scenarioDefinitionOrg = JSON.parse(JSON.stringify(v1));
|
||||
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());
|
||||
break;
|
||||
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"}));
|
||||
break;
|
||||
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"}));
|
||||
break;
|
||||
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"}));
|
||||
break;
|
||||
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"}));
|
||||
break;
|
||||
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());
|
||||
break;
|
||||
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());
|
||||
break;
|
||||
case ELEMENT_TYPE.CustomizeReq:
|
||||
|
@ -201,11 +201,14 @@ export function setComponent(type, _this, plugin) {
|
|||
_this.$refs.scenarioRelevance.open();
|
||||
break;
|
||||
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;
|
||||
}
|
||||
if (_this.selectedNode) {
|
||||
_this.selectedNode.expanded = true;
|
||||
}
|
||||
_this.sort();
|
||||
_this.$nextTick(() => {
|
||||
_this.cancelBatchProcessing();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -460,78 +460,71 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
getCurrentScenario() {
|
||||
return new Promise((resolve) => {
|
||||
if (this.currentScenarioId) {
|
||||
this.result = this.$get("/api/automation/getApiScenario/" + this.currentScenarioId, response => {
|
||||
if (response.data) {
|
||||
if (response.data.scenarioDefinition != null) {
|
||||
let obj = JSON.parse(response.data.scenarioDefinition);
|
||||
if (obj) {
|
||||
this.oldScenarioDefinition = obj.hashTree;
|
||||
if (this.currentScenarioId) {
|
||||
this.result = this.$get("/api/automation/getApiScenario/" + this.currentScenarioId, response => {
|
||||
if (response.data) {
|
||||
if (response.data.scenarioDefinition != null) {
|
||||
let obj = JSON.parse(response.data.scenarioDefinition);
|
||||
if (obj) {
|
||||
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() {
|
||||
return new Promise((resolve) => {
|
||||
this.$get('/api/automation/get/' + this.dffScenarioId + "/" + this.scenarioRefId, response => {
|
||||
this.$get("/api/automation/getApiScenario/" + response.data.id, res => {
|
||||
if (res.data) {
|
||||
if (res.data.scenarioDefinition != null) {
|
||||
let obj = JSON.parse(res.data.scenarioDefinition);
|
||||
if (obj) {
|
||||
if (obj.hashTree) {
|
||||
for (let i = 0; i < obj.hashTree.length; i++) {
|
||||
if (!obj.hashTree[i].index) {
|
||||
obj.hashTree[i].index = i + 1;
|
||||
}
|
||||
obj.hashTree[i].disabled = true;
|
||||
if (!obj.hashTree[i].requestResult) {
|
||||
obj.hashTree[i].requestResult = [{responseResult: {}}];
|
||||
}
|
||||
this.$get('/api/automation/get/' + this.dffScenarioId + "/" + this.scenarioRefId, response => {
|
||||
this.$get("/api/automation/getApiScenario/" + response.data.id, res => {
|
||||
if (res.data) {
|
||||
if (res.data.scenarioDefinition != null) {
|
||||
let obj = JSON.parse(res.data.scenarioDefinition);
|
||||
if (obj) {
|
||||
if (obj.hashTree) {
|
||||
for (let i = 0; i < obj.hashTree.length; i++) {
|
||||
if (!obj.hashTree[i].index) {
|
||||
obj.hashTree[i].index = i + 1;
|
||||
}
|
||||
this.newEnableCookieShare = obj.enableCookieShare;
|
||||
if (obj.onSampleError === undefined) {
|
||||
this.newOnSampleError = true;
|
||||
} else {
|
||||
this.newOnSampleError = obj.onSampleError;
|
||||
obj.hashTree[i].disabled = true;
|
||||
if (!obj.hashTree[i].requestResult) {
|
||||
obj.hashTree[i].requestResult = [{responseResult: {}}];
|
||||
}
|
||||
}
|
||||
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));
|
||||
this.newEnableCookieShare = obj.enableCookieShare;
|
||||
if (obj.onSampleError === undefined) {
|
||||
this.newOnSampleError = true;
|
||||
} else {
|
||||
// 兼容历史数据
|
||||
this.newProjectEnvMap.set(this.projectId, obj.environmentId);
|
||||
this.newOnSampleError = obj.onSampleError;
|
||||
}
|
||||
}
|
||||
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) {
|
||||
|
@ -723,6 +716,7 @@ export default {
|
|||
},
|
||||
created() {
|
||||
this.getCurrentScenario();
|
||||
this.getDffScenario();
|
||||
},
|
||||
mounted() {
|
||||
this.$nextTick(function () {
|
||||
|
|
Loading…
Reference in New Issue