fix(接口测试): 修复用例频繁执行socket连接问题

--bug=1012793 --user=赵勇 【接口测试】接口定义-接口case中query参数值是json文件-执行多次卡住 https://www.tapd.cn/55049933/s/1150087
This commit is contained in:
fit2-zhao 2022-04-27 16:57:27 +08:00 committed by 刘瑞斌
parent aca4456755
commit 321b5fe422
2 changed files with 17 additions and 14 deletions

View File

@ -511,7 +511,6 @@ export default {
isTop: false,
stepSize: 0,
message: "",
websocket: {},
messageWebSocket: {},
buttonData: [],
stepFilter: new STEP,
@ -559,9 +558,10 @@ export default {
},
],
reloadTree: "",
newCreateTime:0,
oldCreateTime:0,
oldUserName:''
newCreateTime: 0,
oldCreateTime: 0,
oldUserName: '',
debugReportId: ""
}
},
created() {
@ -816,9 +816,6 @@ export default {
if (this.messageWebSocket) {
this.messageWebSocket.close();
}
if (this.websocket) {
this.websocket.close();
}
this.clearNodeStatus(this.$refs.stepTree.root.childNodes);
this.clearDebug();
this.$success(this.$t('report.test_stop_success'));
@ -902,8 +899,11 @@ export default {
}
},
initMessageSocket() {
this.messageWebSocket = getReportMessageSocket(this.reportId);
this.debugReportId = getUUID().substring(0, 8);
this.messageWebSocket = getReportMessageSocket(this.debugReportId);
this.messageWebSocket.onmessage = this.onDebugMessage;
//
this.messageWebSocket.onopen = this.run();
},
runningEditParent(node) {
if (node.parent && node.parent.data && node.parent.data.id) {
@ -1361,6 +1361,9 @@ export default {
this.$store.state.forceRerenderIndex = getUUID();
});
},
run() {
this.reportId = this.debugReportId;
},
runDebug(runScenario) {
if (this.scenarioDefinition.length < 1) {
return;
@ -1412,9 +1415,10 @@ export default {
} else {
this.debugLoading = true;
}
this.reportId = getUUID().substring(0, 8);
this.debug = true;
this.pluginDelStep = false;
//
this.initMessageSocket();
} else {
this.clearMessage = getUUID().substring(0, 8);
}
@ -1733,8 +1737,6 @@ export default {
if (!this.debug) {
this.debugVisible = true;
this.loading = false;
} else {
this.initMessageSocket();
}
},
errorRefresh(error) {

View File

@ -34,9 +34,9 @@ export default {
},
watch: {
//
reportId() {
this.run()
//
this.socketSyncResult();
},
isStop() {
if (!this.isStop && this.websocket && this.websocket.close instanceof Function) {
@ -53,6 +53,8 @@ export default {
const uri = protocol + window.location.host + "/ws/" + this.reportId;
this.websocket = new WebSocket(uri);
this.websocket.onmessage = this.onMessages;
//
this.websocket.onopen = this.run();
},
onMessages(e) {
if (e.data && e.data.startsWith("result_")) {
@ -127,7 +129,6 @@ export default {
if (!this.debug) {
reqObj.syncResult = true;
}
this.socketSyncResult();
this.$fileUpload(url, null, bodyFiles, reqObj, response => {
this.requestResult = response.data;
this.$emit('autoCheckStatus'); //