From 8bb93694bca5288e20ebf73f3e1fdf3451787945 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 17 Jun 2021 14:15:25 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E5=AE=8C=E5=96=84K8s=E6=89=A7=E8=A1=8C=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/api/jmeter/JMeterService.java | 14 +++++++++----- .../api/service/ApiScenarioReportService.java | 2 +- .../performance/engine/EngineFactory.java | 3 ++- backend/src/main/java/io/metersphere/xpack | 2 +- .../src/business/components/task/TaskCenter.vue | 6 +++--- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java b/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java index 32e4e11f84..2bd7fd240d 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java @@ -323,9 +323,7 @@ public class JMeterService { BaseSystemConfigDTO baseInfo = CommonBeanFactory.getBean(SystemParameterService.class).getBaseInfo(); RunRequest runRequest = new RunRequest(); runRequest.setTestId(testId); - if (ApiRunMode.API_PLAN.name().equals(runMode)) { - runRequest.setReportId(reportId); - } + runRequest.setReportId(reportId); runRequest.setPoolId(resourcePoolId); // 占位符 String platformUrl = "http://localhost:8081"; @@ -341,8 +339,14 @@ public class JMeterService { // 如果是K8S调用 TestResourcePool pool = testResourcePoolMapper.selectByPrimaryKey(resourcePoolId); if (pool != null && pool.getApi() && pool.getType().equals(ResourcePoolTypeEnum.K8S.name())) { - final Engine engine = EngineFactory.createApiEngine(runRequest); - engine.start(); + try { + final Engine engine = EngineFactory.createApiEngine(runRequest); + engine.start(); + } catch (Exception e) { + ApiScenarioReportService apiScenarioReportService = CommonBeanFactory.getBean(ApiScenarioReportService.class); + apiScenarioReportService.delete(reportId); + MSException.throwException(e.getMessage()); + } } else { TestResource testResource = resourcePoolCalculation.getPool(resourcePoolId); String configuration = testResource.getConfiguration(); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java index 5739f81baf..02c3ddc435 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -327,7 +327,7 @@ public class ApiScenarioReportService { * * @param reportId */ - private void updateScenarioStatus(String reportId) { + public void updateScenarioStatus(String reportId) { if (StringUtils.isNotEmpty(reportId)) { List list = new LinkedList<>(); try { diff --git a/backend/src/main/java/io/metersphere/performance/engine/EngineFactory.java b/backend/src/main/java/io/metersphere/performance/engine/EngineFactory.java index 1c0e0e7c8f..966f9dbbf9 100644 --- a/backend/src/main/java/io/metersphere/performance/engine/EngineFactory.java +++ b/backend/src/main/java/io/metersphere/performance/engine/EngineFactory.java @@ -94,8 +94,9 @@ public class EngineFactory { return (Engine) ConstructorUtils.invokeConstructor(kubernetesTestEngineClass, runRequest); } catch (Exception e) { LogUtil.error(e); - return null; + MSException.throwException(e.getMessage()); } + return null; } public static EngineContext createContext(LoadTestWithBLOBs loadTest, double[] ratios, String reportId, int resourceIndex) { diff --git a/backend/src/main/java/io/metersphere/xpack b/backend/src/main/java/io/metersphere/xpack index da4c475507..acbb458b5e 160000 --- a/backend/src/main/java/io/metersphere/xpack +++ b/backend/src/main/java/io/metersphere/xpack @@ -1 +1 @@ -Subproject commit da4c4755072cb1e4f764981f00101e1ea8de62bc +Subproject commit acbb458b5ec921754773cfdfc7a5b7f3ffebfaae diff --git a/frontend/src/business/components/task/TaskCenter.vue b/frontend/src/business/components/task/TaskCenter.vue index 0fc5ab2ab8..536eb3e84c 100644 --- a/frontend/src/business/components/task/TaskCenter.vue +++ b/frontend/src/business/components/task/TaskCenter.vue @@ -6,8 +6,8 @@ text-color="#fff" active-text-color="#fff"> - - + + @@ -107,7 +107,7 @@ export default { close() { this.visible = false; }, - open(){ + open() { this.showTaskCenter(); }, getPercentage(status) {