diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/engine/KubernetesTestEngine.java b/api-test/backend/src/main/java/io/metersphere/api/exec/engine/KubernetesTestEngine.java index 0a817a9d52..c686f5a1c7 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/engine/KubernetesTestEngine.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/engine/KubernetesTestEngine.java @@ -2,12 +2,14 @@ package io.metersphere.api.exec.engine; import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.client.KubernetesClient; +import io.metersphere.api.dto.MsgDTO; import io.metersphere.base.domain.TestResource; import io.metersphere.commons.constants.ApiRunMode; import io.metersphere.commons.constants.ExtendedParameter; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.JSON; import io.metersphere.commons.utils.LogUtil; +import io.metersphere.commons.utils.WebSocketUtil; import io.metersphere.dto.JmeterRunRequestDTO; import io.metersphere.utils.LoggerUtil; import io.metersphere.xpack.resourcepool.engine.provider.ClientCredential; @@ -21,6 +23,7 @@ import java.util.Set; public class KubernetesTestEngine extends AbstractEngine { private JmeterRunRequestDTO runRequest; + private final String DEBUG_ERROR = "DEBUG_ERROR"; // 初始化API调用 public KubernetesTestEngine(JmeterRunRequestDTO runRequest) { @@ -77,6 +80,14 @@ public class KubernetesTestEngine extends AbstractEngine { command.append(StringUtils.SPACE).append("http://127.0.0.1:8082/jmeter/").append(path); KubernetesApiExec.newExecWatch(client, clientCredential.getNamespace(), pod.getMetadata().getName(), command.toString()); } catch (Exception e) { + MsgDTO dto = new MsgDTO(); + dto.setExecEnd(false); + dto.setContent(DEBUG_ERROR); + dto.setReportId("send." + runRequest.getReportId()); + dto.setToReport(runRequest.getReportId()); + LoggerUtil.debug("send. " + runRequest.getReportId()); + WebSocketUtil.sendMessageSingle(dto); + WebSocketUtil.onClose(runRequest.getReportId()); LoggerUtil.error("当前报告:【" + runRequest.getReportId() + "】资源:【" + runRequest.getTestId() + "】CURL失败:", e); MSException.throwException(e); } diff --git a/api-test/frontend/src/business/automation/report/SyncApiReportDetail.vue b/api-test/frontend/src/business/automation/report/SyncApiReportDetail.vue index 0f2d9223db..744cfd51c8 100644 --- a/api-test/frontend/src/business/automation/report/SyncApiReportDetail.vue +++ b/api-test/frontend/src/business/automation/report/SyncApiReportDetail.vue @@ -503,6 +503,14 @@ export default { this.runningEvaluation(e.data); this.sort(this.fullTreeNodes); } + if (e && e.data === 'DEBUG_ERROR') { + this.$error(this.$t('api_definition.debug_pool_warning')); + this.messageWebSocket.close(); + this.cleanHeartBeat(); + this.$EventBus.$emit('hide', this.scenarioId); + this.$emit('refresh', this.debugResult); + } + if (e.data && e.data.indexOf('MS_TEST_END') !== -1) { this.getReport(); this.messageWebSocket.close(); diff --git a/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue b/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue index c9d998b734..6b0073f3fd 100644 --- a/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue +++ b/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue @@ -1233,6 +1233,11 @@ export default { if (e && e.data === 'CONN_SUCCEEDED') { this.run(); } + if (e && e.data === 'DEBUG_ERROR') { + this.$error(this.$t('api_definition.debug_pool_warning')); + this.messageWebSocket.close(); + this.errorRefresh(); + } if (e.data && e.data.startsWith('result_')) { let data = JSON.parse(e.data.substring(7)); this.reqTotal += 1; diff --git a/api-test/frontend/src/business/automation/scenario/component/LoopController.vue b/api-test/frontend/src/business/automation/scenario/component/LoopController.vue index 31329bb3be..498f699aea 100644 --- a/api-test/frontend/src/business/automation/scenario/component/LoopController.vue +++ b/api-test/frontend/src/business/automation/scenario/component/LoopController.vue @@ -292,6 +292,13 @@ export default { if (e && e.data === 'CONN_SUCCEEDED') { this.runDebug(); } + if (e && e.data === 'DEBUG_ERROR') { + this.$error(this.$t('api_definition.debug_pool_warning')); + this.loading = false; + this.node.expanded = true; + this.messageWebSocket.close(); + this.reload(); + } if (e.data && e.data.startsWith('result_')) { let data = JSON.parse(e.data.substring(7)); this.debugCode(data); diff --git a/api-test/frontend/src/business/definition/components/Run.vue b/api-test/frontend/src/business/definition/components/Run.vue index 7656c91976..3273067877 100644 --- a/api-test/frontend/src/business/definition/components/Run.vue +++ b/api-test/frontend/src/business/definition/components/Run.vue @@ -62,7 +62,11 @@ export default { if (e && e.data === 'CONN_SUCCEEDED') { this.run(); } - + if (e && e.data === 'DEBUG_ERROR') { + this.$error(this.$t('api_definition.debug_pool_warning')); + this.websocket.close(); + this.$emit('errorRefresh', ''); + } if (e.data && e.data.startsWith('result_')) { try { let data = e.data.substring(7); diff --git a/api-test/frontend/src/business/definition/components/debug/DebugDubboPage.vue b/api-test/frontend/src/business/definition/components/debug/DebugDubboPage.vue index 460e437732..7234dc5b99 100644 --- a/api-test/frontend/src/business/definition/components/debug/DebugDubboPage.vue +++ b/api-test/frontend/src/business/definition/components/debug/DebugDubboPage.vue @@ -53,6 +53,7 @@ :isStop="isStop" :run-data="runData" @runRefresh="runRefresh" + @errorRefresh="errorRefresh" ref="runTest" />