diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcConsumerSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcConsumerSDKOperationTest.java index ff58b0a5..198fe023 100644 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcConsumerSDKOperationTest.java +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcConsumerSDKOperationTest.java @@ -25,21 +25,31 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import lombok.extern.slf4j.Slf4j; + +@Slf4j public class RuntimeGrpcConsumerSDKOperationTest { private final RuntimeGrpcConsumerSDKOperation grpcConsumerSDKOperation = new RuntimeGrpcConsumerSDKOperation(); @Test void testCreateClient() { - final CreateRuntimeConfig runtimeConfig = CreateRuntimeConfig.builder() - .runtimeServerAddress("127.0.0.1:10205") - .consumerGroup("EventMeshTest-consumerGroup") - .env("test") - .idc("idc") - .sys("1234") - .build(); - final SimpleEntry grpcConsumerSimpleEntry = - grpcConsumerSDKOperation.createClient(runtimeConfig); - Assertions.assertEquals("127.0.0.1:10205", grpcConsumerSimpleEntry.getKey()); + SimpleEntry grpcConsumerSimpleEntry = null; + try { + final CreateRuntimeConfig runtimeConfig = CreateRuntimeConfig.builder() + .runtimeServerAddress("127.0.0.1:10205") + .consumerGroup("EventMeshTest-consumerGroup") + .env("test") + .idc("idc") + .sys("1234") + .build(); + grpcConsumerSimpleEntry = grpcConsumerSDKOperation.createClient(runtimeConfig); + Assertions.assertEquals("127.0.0.1:10205", grpcConsumerSimpleEntry.getKey()); + } catch (Exception e) { + log.error("create runtime GRPC consumer client failed", e); + if (grpcConsumerSimpleEntry != null) { + grpcConsumerSimpleEntry.getValue().close(); + } + } } } diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcProducerSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcProducerSDKOperationTest.java index 0d3db925..33ba467a 100644 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcProducerSDKOperationTest.java +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcProducerSDKOperationTest.java @@ -25,21 +25,31 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import lombok.extern.slf4j.Slf4j; + +@Slf4j public class RuntimeGrpcProducerSDKOperationTest { private final RuntimeGrpcProducerSDKOperation grpcProducerSDKOperation = new RuntimeGrpcProducerSDKOperation(); @Test void testCreateClient() { - final CreateRuntimeConfig runtimeConfig = CreateRuntimeConfig.builder() - .runtimeServerAddress("127.0.0.1:10205") - .producerGroup("EventMeshTest-producerGroup") - .env("test") - .idc("idc") - .sys("1234") - .build(); - final SimpleEntry grpcProducerSimpleEntry = - grpcProducerSDKOperation.createClient(runtimeConfig); - Assertions.assertEquals("127.0.0.1:10205", grpcProducerSimpleEntry.getKey()); + SimpleEntry grpcProducerSimpleEntry = null; + try { + final CreateRuntimeConfig runtimeConfig = CreateRuntimeConfig.builder() + .runtimeServerAddress("127.0.0.1:10205") + .producerGroup("EventMeshTest-producerGroup") + .env("test") + .idc("idc") + .sys("1234") + .build(); + grpcProducerSimpleEntry = grpcProducerSDKOperation.createClient(runtimeConfig); + Assertions.assertEquals("127.0.0.1:10205", grpcProducerSimpleEntry.getKey()); + } catch (Exception e) { + log.error("create runtime GRPC producer client failed", e); + if (grpcProducerSimpleEntry != null) { + grpcProducerSimpleEntry.getValue().close(); + } + } } } diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpConsumerSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpConsumerSDKOperationTest.java index 17f2ddde..a721deb0 100644 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpConsumerSDKOperationTest.java +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpConsumerSDKOperationTest.java @@ -27,25 +27,35 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import lombok.extern.slf4j.Slf4j; + +@Slf4j public class RuntimeHttpConsumerSDKOperationTest { private final RuntimeHttpConsumerSDKOperation httpConsumerSDKOperation = new RuntimeHttpConsumerSDKOperation(); @Test void testCreateClient() { - final CreateRuntimeConfig runtimeConfig = CreateRuntimeConfig.builder() - .runtimeServerAddress("127.0.0.1:10105") - .consumerGroup("EventMeshTest-consumerGroup") - .env("test") - .idc("idc") - .ip(IPUtils.getLocalAddress()) - .sys("1234") - .pid(String.valueOf(ThreadUtils.getPID())) - .username("eventmesh") - .password("123456") - .build(); - final SimpleEntry httpConsumerSimpleEntry = - httpConsumerSDKOperation.createClient(runtimeConfig); - Assertions.assertEquals("127.0.0.1:10105", httpConsumerSimpleEntry.getKey()); + SimpleEntry httpConsumerSimpleEntry = null; + try { + final CreateRuntimeConfig runtimeConfig = CreateRuntimeConfig.builder() + .runtimeServerAddress("127.0.0.1:10105") + .consumerGroup("EventMeshTest-consumerGroup") + .env("test") + .idc("idc") + .ip(IPUtils.getLocalAddress()) + .sys("1234") + .pid(String.valueOf(ThreadUtils.getPID())) + .username("eventmesh") + .password("123456") + .build(); + httpConsumerSimpleEntry = httpConsumerSDKOperation.createClient(runtimeConfig); + Assertions.assertEquals("127.0.0.1:10105", httpConsumerSimpleEntry.getKey()); + } catch (Exception e) { + log.error("create runtime GRPC consumer client failed", e); + if (httpConsumerSimpleEntry != null) { + httpConsumerSimpleEntry.getValue().close(); + } + } } } diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpProducerSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpProducerSDKOperationTest.java index 07d16408..217f1f28 100644 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpProducerSDKOperationTest.java +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpProducerSDKOperationTest.java @@ -27,25 +27,35 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import lombok.extern.slf4j.Slf4j; + +@Slf4j public class RuntimeHttpProducerSDKOperationTest { private final RuntimeHttpProducerSDKOperation httpProducerSDKOperation = new RuntimeHttpProducerSDKOperation(); @Test void testCreateClient() { - final CreateRuntimeConfig runtimeConfig = CreateRuntimeConfig.builder() - .runtimeServerAddress("127.0.0.1:10105") - .producerGroup("EventMeshTest-producerGroup") - .env("test") - .idc("idc") - .ip(IPUtils.getLocalAddress()) - .sys("1234") - .pid(String.valueOf(ThreadUtils.getPID())) - .username("eventmesh") - .password("123456") - .build(); - final SimpleEntry httpProducerSimpleEntry = - httpProducerSDKOperation.createClient(runtimeConfig); - Assertions.assertEquals("127.0.0.1:10105", httpProducerSimpleEntry.getKey()); + SimpleEntry httpProducerSimpleEntry = null; + try { + final CreateRuntimeConfig runtimeConfig = CreateRuntimeConfig.builder() + .runtimeServerAddress("127.0.0.1:10105") + .producerGroup("EventMeshTest-producerGroup") + .env("test") + .idc("idc") + .ip(IPUtils.getLocalAddress()) + .sys("1234") + .pid(String.valueOf(ThreadUtils.getPID())) + .username("eventmesh") + .password("123456") + .build(); + httpProducerSimpleEntry = httpProducerSDKOperation.createClient(runtimeConfig); + Assertions.assertEquals("127.0.0.1:10105", httpProducerSimpleEntry.getKey()); + } catch (Exception e) { + log.error("create runtime EventMesh HTTP producer client failed", e); + if (httpProducerSimpleEntry != null) { + httpProducerSimpleEntry.getValue().close(); + } + } } } diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeSDKOperationTest.java index f496382b..b24fd054 100644 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeSDKOperationTest.java +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeSDKOperationTest.java @@ -28,35 +28,45 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import lombok.extern.slf4j.Slf4j; + +@Slf4j class RuntimeSDKOperationTest { private final RuntimeSDKOperation runtimeSDKOperation = new RuntimeSDKOperation(); @Test void testCreateClient() { - final UserAgent userAgent = UserAgent.builder() - .env("test") - .host("localhost") - .password("123456") - .username("eventmesh") - .group("EventmeshTestGroup") - .path("/") - .port(8366) - .subsystem("502") - .pid(32894) - .version("2.1") - .idc("A") - .purpose(EventMeshCommon.USER_AGENT_PURPOSE_PUB) - .build(); - final CreateRuntimeConfig runtimeConfig = CreateRuntimeConfig.builder() - .runtimeServerAddress("127.0.0.1:10000") - .protocol("TCP") - .protocolName(Constants.EM_MESSAGE_PROTOCOL_NAME) - .userAgent(userAgent) - .build(); - final SimpleEntry sdkWrapperSimpleEntry = - runtimeSDKOperation.createClient(runtimeConfig); - Assertions.assertEquals("127.0.0.1:10000", sdkWrapperSimpleEntry.getKey()); - Assertions.assertNotNull(sdkWrapperSimpleEntry.getValue().getTcpEventMeshClient()); + SimpleEntry sdkWrapperSimpleEntry = null; + try { + final UserAgent userAgent = UserAgent.builder() + .env("test") + .host("localhost") + .password("123456") + .username("eventmesh") + .group("EventmeshTestGroup") + .path("/") + .port(8366) + .subsystem("502") + .pid(32894) + .version("2.1") + .idc("A") + .purpose(EventMeshCommon.USER_AGENT_PURPOSE_PUB) + .build(); + final CreateRuntimeConfig runtimeConfig = CreateRuntimeConfig.builder() + .runtimeServerAddress("127.0.0.1:10000") + .protocol("TCP") + .protocolName(Constants.EM_MESSAGE_PROTOCOL_NAME) + .userAgent(userAgent) + .build(); + sdkWrapperSimpleEntry = runtimeSDKOperation.createClient(runtimeConfig); + Assertions.assertEquals("127.0.0.1:10000", sdkWrapperSimpleEntry.getKey()); + Assertions.assertNotNull(sdkWrapperSimpleEntry.getValue().getTcpEventMeshClient()); + } catch (Exception e) { + log.error("create runtime client failed", e); + if (sdkWrapperSimpleEntry != null) { + sdkWrapperSimpleEntry.getValue().close(); + } + } } } \ No newline at end of file diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpCloudEventSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpCloudEventSDKOperationTest.java index 26ed222e..534e2ce7 100644 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpCloudEventSDKOperationTest.java +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpCloudEventSDKOperationTest.java @@ -36,29 +36,35 @@ public class RuntimeTcpCloudEventSDKOperationTest { @Test void testCreateClient() { - final UserAgent userAgent = UserAgent.builder() - .env("test") - .host("localhost") - .password("123456") - .username("eventmesh") - .group("EventmeshTestGroup") - .path("/") - .port(8366) - .subsystem("502") - .pid(32894) - .version("2.1") - .idc("A") - .purpose(EventMeshCommon.USER_AGENT_PURPOSE_PUB) - .build(); - log.info("{}", userAgent); - final CreateRuntimeConfig runtimeConfig = CreateRuntimeConfig.builder() - .runtimeServerAddress("127.0.0.1:10000") - .userAgent(userAgent) - .build(); - log.info("{}", runtimeConfig); - final SimpleEntry simpleEntry = - runtimeTCPPushSDKOperation.createClient(runtimeConfig); - Assertions.assertEquals("127.0.0.1:10000", simpleEntry.getKey()); + SimpleEntry simpleEntry = null; + try { + final UserAgent userAgent = UserAgent.builder() + .env("test") + .host("localhost") + .password("123456") + .username("eventmesh") + .group("EventmeshTestGroup") + .path("/") + .port(8366) + .subsystem("502") + .pid(32894) + .version("2.1") + .idc("A") + .purpose(EventMeshCommon.USER_AGENT_PURPOSE_PUB) + .build(); + log.info("{}", userAgent); + final CreateRuntimeConfig runtimeConfig = CreateRuntimeConfig.builder() + .runtimeServerAddress("127.0.0.1:10000") + .userAgent(userAgent) + .build(); + log.info("{}", runtimeConfig); + simpleEntry = runtimeTCPPushSDKOperation.createClient(runtimeConfig); + Assertions.assertEquals("127.0.0.1:10000", simpleEntry.getKey()); + } catch (Exception e) { + log.error("create runtime tcp CloudEvent client failed", e); + if (simpleEntry != null) { + simpleEntry.getValue().close(); + } + } } - } diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpEventMeshSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpEventMeshSDKOperationTest.java index ba6c3ea9..1e977928 100644 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpEventMeshSDKOperationTest.java +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpEventMeshSDKOperationTest.java @@ -36,28 +36,35 @@ public class RuntimeTcpEventMeshSDKOperationTest { @Test void testCreateClient() { - final UserAgent userAgent = UserAgent.builder() - .env("test") - .host("localhost") - .password("123456") - .username("eventmesh") - .group("EventmeshTestGroup") - .path("/") - .port(8365) - .subsystem("501") - .pid(32893) - .version("2.1") - .idc("A") - .purpose(EventMeshCommon.USER_AGENT_PURPOSE_PUB) - .build(); - log.info("userAgent {}", userAgent); - final CreateRuntimeConfig runtimeConfig = CreateRuntimeConfig.builder() - .runtimeServerAddress("127.0.0.1:10000") - .userAgent(userAgent) - .build(); - log.info("{}", runtimeConfig); - final SimpleEntry simpleEntry = - eventMeshSDKOperation.createClient(runtimeConfig); - Assertions.assertEquals("127.0.0.1:10000", simpleEntry.getKey()); + SimpleEntry simpleEntry = null; + try { + final UserAgent userAgent = UserAgent.builder() + .env("test") + .host("localhost") + .password("123456") + .username("eventmesh") + .group("EventmeshTestGroup") + .path("/") + .port(8365) + .subsystem("501") + .pid(32893) + .version("2.1") + .idc("A") + .purpose(EventMeshCommon.USER_AGENT_PURPOSE_PUB) + .build(); + log.info("userAgent {}", userAgent); + final CreateRuntimeConfig runtimeConfig = CreateRuntimeConfig.builder() + .runtimeServerAddress("127.0.0.1:10000") + .userAgent(userAgent) + .build(); + log.info("{}", runtimeConfig); + simpleEntry = eventMeshSDKOperation.createClient(runtimeConfig); + Assertions.assertEquals("127.0.0.1:10000", simpleEntry.getKey()); + } catch (Exception e) { + log.error("create runtime tcp EventMeshMessage client failed", e); + if (simpleEntry != null) { + simpleEntry.getValue().close(); + } + } } }