This is an automated email from the ASF dual-hosted git repository.

gongchao pushed a commit to branch update-dhsuh2
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git

commit c4a402f4d62e1c18cf8187fffa61bf2b35e8456b
Author: tomsun28 <[email protected]>
AuthorDate: Sun Feb 15 15:05:41 2026 +0800

    fix: fix the e2e log test
    
    Signed-off-by: tomsun28 <[email protected]>
---
 .../log/alert/LogPeriodicAlertE2eTest.java         | 35 ++++++++++++++++------
 .../log/alert/LogRealTimeAlertE2eTest.java         | 11 +++++++
 .../log/ingestion/LogIngestionE2eTest.java         | 11 +++++++
 .../log/storage/GreptimeLogStorageE2eTest.java     | 33 +++++++++++++++-----
 4 files changed, 73 insertions(+), 17 deletions(-)

diff --git 
a/hertzbeat-e2e/hertzbeat-log-e2e/src/test/java/org/apache/hertzbeat/log/alert/LogPeriodicAlertE2eTest.java
 
b/hertzbeat-e2e/hertzbeat-log-e2e/src/test/java/org/apache/hertzbeat/log/alert/LogPeriodicAlertE2eTest.java
index 8ad662c2b0..495aa48941 100644
--- 
a/hertzbeat-e2e/hertzbeat-log-e2e/src/test/java/org/apache/hertzbeat/log/alert/LogPeriodicAlertE2eTest.java
+++ 
b/hertzbeat-e2e/hertzbeat-log-e2e/src/test/java/org/apache/hertzbeat/log/alert/LogPeriodicAlertE2eTest.java
@@ -26,12 +26,14 @@ import 
org.apache.hertzbeat.common.entity.alerter.SingleAlert;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.condition.EnabledIf;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.mock.mockito.SpyBean;
 import org.springframework.boot.test.web.server.LocalServerPort;
 import org.springframework.test.context.DynamicPropertyRegistry;
 import org.springframework.test.context.DynamicPropertySource;
+import org.testcontainers.DockerClientFactory;
 import org.testcontainers.containers.GenericContainer;
 import org.testcontainers.containers.Network;
 import org.testcontainers.containers.wait.strategy.Wait;
@@ -61,8 +63,17 @@ import static org.mockito.Mockito.doAnswer;
 @SpringBootTest(classes = 
org.apache.hertzbeat.startup.HertzBeatApplication.class, webEnvironment = 
SpringBootTest.WebEnvironment.RANDOM_PORT)
 @Slf4j
 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
+@EnabledIf("isDockerAvailable")
 public class LogPeriodicAlertE2eTest {
 
+    static boolean isDockerAvailable() {
+        try {
+            return DockerClientFactory.instance().isDockerAvailable();
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
     private static final String VECTOR_IMAGE = "timberio/vector:latest-alpine";
     private static final int VECTOR_PORT = 8686;
     private static final String VECTOR_CONFIG_PATH = "/etc/vector/vector.yml";
@@ -85,18 +96,24 @@ public class LogPeriodicAlertE2eTest {
     private AlarmCommonReduce alarmCommonReduce;
 
     static GenericContainer<?> vector;
-    
+
     static GenericContainer<?> greptimedb;
 
     static {
-        greptimedb = new 
GenericContainer<>(DockerImageName.parse(GREPTIME_IMAGE))
-                .withExposedPorts(GREPTIME_HTTP_PORT, GREPTIME_GRPC_PORT)
-                .withCommand("standalone", "start",
-                        "--http-addr", "0.0.0.0:" + GREPTIME_HTTP_PORT,
-                        "--rpc-bind-addr", "0.0.0.0:" + GREPTIME_GRPC_PORT)
-                .waitingFor(Wait.forListeningPorts(GREPTIME_HTTP_PORT, 
GREPTIME_GRPC_PORT))
-                .withStartupTimeout(CONTAINER_STARTUP_TIMEOUT);
-        greptimedb.start();
+        try {
+            if (DockerClientFactory.instance().isDockerAvailable()) {
+                greptimedb = new 
GenericContainer<>(DockerImageName.parse(GREPTIME_IMAGE))
+                        .withExposedPorts(GREPTIME_HTTP_PORT, 
GREPTIME_GRPC_PORT)
+                        .withCommand("standalone", "start",
+                                "--http-addr", "0.0.0.0:" + GREPTIME_HTTP_PORT,
+                                "--rpc-bind-addr", "0.0.0.0:" + 
GREPTIME_GRPC_PORT)
+                        .waitingFor(Wait.forListeningPorts(GREPTIME_HTTP_PORT, 
GREPTIME_GRPC_PORT))
+                        .withStartupTimeout(CONTAINER_STARTUP_TIMEOUT);
+                greptimedb.start();
+            }
+        } catch (Exception e) {
+            log.warn("Docker not available, skipping GreptimeDB container 
startup: {}", e.getMessage());
+        }
     }
 
     @DynamicPropertySource
diff --git 
a/hertzbeat-e2e/hertzbeat-log-e2e/src/test/java/org/apache/hertzbeat/log/alert/LogRealTimeAlertE2eTest.java
 
b/hertzbeat-e2e/hertzbeat-log-e2e/src/test/java/org/apache/hertzbeat/log/alert/LogRealTimeAlertE2eTest.java
index 11b42b3781..ec7f5d137e 100644
--- 
a/hertzbeat-e2e/hertzbeat-log-e2e/src/test/java/org/apache/hertzbeat/log/alert/LogRealTimeAlertE2eTest.java
+++ 
b/hertzbeat-e2e/hertzbeat-log-e2e/src/test/java/org/apache/hertzbeat/log/alert/LogRealTimeAlertE2eTest.java
@@ -26,9 +26,11 @@ import 
org.apache.hertzbeat.common.entity.alerter.SingleAlert;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.condition.EnabledIf;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.mock.mockito.SpyBean;
 import org.springframework.boot.test.web.server.LocalServerPort;
+import org.testcontainers.DockerClientFactory;
 import org.testcontainers.containers.GenericContainer;
 import org.testcontainers.containers.Network;
 import org.testcontainers.containers.wait.strategy.Wait;
@@ -58,8 +60,17 @@ import static org.mockito.Mockito.doAnswer;
 @SpringBootTest(classes = 
org.apache.hertzbeat.startup.HertzBeatApplication.class, webEnvironment = 
SpringBootTest.WebEnvironment.RANDOM_PORT)
 @Slf4j
 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
+@EnabledIf("isDockerAvailable")
 public class LogRealTimeAlertE2eTest {
 
+    static boolean isDockerAvailable() {
+        try {
+            return DockerClientFactory.instance().isDockerAvailable();
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
     private static final String VECTOR_IMAGE = "timberio/vector:latest-alpine";
     private static final int VECTOR_PORT = 8686;
     private static final String VECTOR_CONFIG_PATH = "/etc/vector/vector.yml";
diff --git 
a/hertzbeat-e2e/hertzbeat-log-e2e/src/test/java/org/apache/hertzbeat/log/ingestion/LogIngestionE2eTest.java
 
b/hertzbeat-e2e/hertzbeat-log-e2e/src/test/java/org/apache/hertzbeat/log/ingestion/LogIngestionE2eTest.java
index dd95522405..bb2d556399 100644
--- 
a/hertzbeat-e2e/hertzbeat-log-e2e/src/test/java/org/apache/hertzbeat/log/ingestion/LogIngestionE2eTest.java
+++ 
b/hertzbeat-e2e/hertzbeat-log-e2e/src/test/java/org/apache/hertzbeat/log/ingestion/LogIngestionE2eTest.java
@@ -23,9 +23,11 @@ import org.apache.hertzbeat.common.queue.CommonDataQueue;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.condition.EnabledIf;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.web.server.LocalServerPort;
+import org.testcontainers.DockerClientFactory;
 import org.testcontainers.containers.GenericContainer;
 import org.testcontainers.containers.Network;
 import org.testcontainers.containers.wait.strategy.Wait;
@@ -47,8 +49,17 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
 @SpringBootTest(classes = 
org.apache.hertzbeat.startup.HertzBeatApplication.class, webEnvironment = 
SpringBootTest.WebEnvironment.RANDOM_PORT)
 @Slf4j
 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
+@EnabledIf("isDockerAvailable")
 public class LogIngestionE2eTest {
 
+    static boolean isDockerAvailable() {
+        try {
+            return DockerClientFactory.instance().isDockerAvailable();
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
     private static final String VECTOR_IMAGE = "timberio/vector:latest-alpine";
     private static final int VECTOR_PORT = 8686;
     private static final String VECTOR_CONFIG_PATH = "/etc/vector/vector.yml";
diff --git 
a/hertzbeat-e2e/hertzbeat-log-e2e/src/test/java/org/apache/hertzbeat/log/storage/GreptimeLogStorageE2eTest.java
 
b/hertzbeat-e2e/hertzbeat-log-e2e/src/test/java/org/apache/hertzbeat/log/storage/GreptimeLogStorageE2eTest.java
index 23dc0c02db..6e747d48ec 100644
--- 
a/hertzbeat-e2e/hertzbeat-log-e2e/src/test/java/org/apache/hertzbeat/log/storage/GreptimeLogStorageE2eTest.java
+++ 
b/hertzbeat-e2e/hertzbeat-log-e2e/src/test/java/org/apache/hertzbeat/log/storage/GreptimeLogStorageE2eTest.java
@@ -24,11 +24,13 @@ import 
org.apache.hertzbeat.warehouse.store.history.tsdb.greptime.GreptimeDbData
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.condition.EnabledIf;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.web.server.LocalServerPort;
 import org.springframework.test.context.DynamicPropertyRegistry;
 import org.springframework.test.context.DynamicPropertySource;
+import org.testcontainers.DockerClientFactory;
 import org.testcontainers.containers.GenericContainer;
 import org.testcontainers.containers.Network;
 import org.testcontainers.containers.wait.strategy.Wait;
@@ -50,8 +52,17 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
 @SpringBootTest(classes = 
org.apache.hertzbeat.startup.HertzBeatApplication.class, webEnvironment = 
SpringBootTest.WebEnvironment.RANDOM_PORT)
 @Slf4j
 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
+@EnabledIf("isDockerAvailable")
 public class GreptimeLogStorageE2eTest {
 
+    static boolean isDockerAvailable() {
+        try {
+            return DockerClientFactory.instance().isDockerAvailable();
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
     private static final String VECTOR_IMAGE = "timberio/vector:latest-alpine";
     private static final int VECTOR_PORT = 8686;
     private static final String VECTOR_CONFIG_PATH = "/etc/vector/vector.yml";
@@ -74,14 +85,20 @@ public class GreptimeLogStorageE2eTest {
     static GenericContainer<?> greptimedb;
 
     static {
-        greptimedb = new 
GenericContainer<>(DockerImageName.parse(GREPTIME_IMAGE))
-                .withExposedPorts(GREPTIME_HTTP_PORT, GREPTIME_GRPC_PORT)
-                .withCommand("standalone", "start",
-                        "--http-addr", "0.0.0.0:" + GREPTIME_HTTP_PORT,
-                        "--rpc-bind-addr", "0.0.0.0:" + GREPTIME_GRPC_PORT)
-                .waitingFor(Wait.forListeningPorts(GREPTIME_HTTP_PORT, 
GREPTIME_GRPC_PORT))
-                .withStartupTimeout(CONTAINER_STARTUP_TIMEOUT);
-        greptimedb.start();
+        try {
+            if (DockerClientFactory.instance().isDockerAvailable()) {
+                greptimedb = new 
GenericContainer<>(DockerImageName.parse(GREPTIME_IMAGE))
+                        .withExposedPorts(GREPTIME_HTTP_PORT, 
GREPTIME_GRPC_PORT)
+                        .withCommand("standalone", "start",
+                                "--http-addr", "0.0.0.0:" + GREPTIME_HTTP_PORT,
+                                "--rpc-bind-addr", "0.0.0.0:" + 
GREPTIME_GRPC_PORT)
+                        .waitingFor(Wait.forListeningPorts(GREPTIME_HTTP_PORT, 
GREPTIME_GRPC_PORT))
+                        .withStartupTimeout(CONTAINER_STARTUP_TIMEOUT);
+                greptimedb.start();
+            }
+        } catch (Exception e) {
+            log.warn("Docker not available, skipping GreptimeDB container 
startup: {}", e.getMessage());
+        }
     }
 
     @DynamicPropertySource


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to