diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosNamingServiceCheck.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosNamingServiceCheck.java index 5a2fd922..0313cee9 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosNamingServiceCheck.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosNamingServiceCheck.java @@ -63,6 +63,8 @@ public void doCheck(HealthCheckCallback callback) { } } catch (NacosException e) { callback.onFail(e); + } finally { + destroy(); } }); } diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutorTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutorTest.java index 87381169..41dc781a 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutorTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutorTest.java @@ -147,6 +147,7 @@ public void testStartExecute() throws InterruptedException { healthExecutor.execute(failHealthCheckService); //to test startExecute(), we need to call endExecute() first healthExecutor.endExecute(); + Thread.sleep(500); healthExecutor.startExecute(); HealthCheckResultEntity query = new HealthCheckResultEntity(); query.setClusterId(1L); diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheckTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheckTest.java index 87824d90..235e385a 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheckTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheckTest.java @@ -21,6 +21,7 @@ import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -40,7 +41,8 @@ public void init() { .healthCheckResourceType("meta") .healthCheckResourceSubType("nacos") .clusterId(1L) - .connectUrl("127.0.0.1:8848") + .connectUrl("175.27.155.139:8848") + .requestTimeoutMillis(1000L) .build(); nacosCheck = new NacosConfigCheck(config); } @@ -48,6 +50,7 @@ public void init() { @Test public void testDoCheck() throws InterruptedException { CountDownLatch latch = new CountDownLatch(1); + Thread.sleep(100); nacosCheck.doCheck(new HealthCheckCallback() { @Override public void onSuccess() { @@ -61,7 +64,7 @@ public void onFail(Exception e) { log.error("{}, failed for reason {}", this.getClass().getSimpleName(), e); } }); - latch.await(); + latch.await(2, TimeUnit.SECONDS); } @AfterEach diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosNamingServiceCheckTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosNamingServiceCheckTest.java index 2ed588d4..98f37626 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosNamingServiceCheckTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosNamingServiceCheckTest.java @@ -21,6 +21,7 @@ import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -41,6 +42,7 @@ public void init() { .healthCheckResourceSubType("nacos") .clusterId(1L) .connectUrl("175.27.155.139:8848") + .requestTimeoutMillis(1000L) .build(); nacosRegisterCheck = new NacosNamingServiceCheck(config); } @@ -48,6 +50,7 @@ public void init() { @Test public void testDoCheck() throws InterruptedException { CountDownLatch latch = new CountDownLatch(1); + Thread.sleep(100); nacosRegisterCheck.doCheck(new HealthCheckCallback() { @Override public void onSuccess() { @@ -61,7 +64,7 @@ public void onFail(Exception e) { log.error("{}, failed for reason {}", this.getClass().getSimpleName(), e.getMessage()); } }); - latch.await(); + latch.await(2, TimeUnit.SECONDS); } @AfterEach