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

tomsun28 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git


The following commit(s) were added to refs/heads/master by this push:
     new 0ae41860e3 test: fix two flaky tests (#4250)
0ae41860e3 is described below

commit 0ae41860e39451fd0c029446405a51e704908dfd
Author: NekoPunch <[email protected]>
AuthorDate: Sun Jul 26 03:21:10 2026 -0700

    test: fix two flaky tests (#4250)
---
 .../common/http/CommonHttpClientVirtualThreadTest.java       | 12 +++++++++---
 .../java/org/apache/hertzbeat/common/util/AesUtilTest.java   |  7 ++-----
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git 
a/hertzbeat-collector/hertzbeat-collector-common/src/test/java/org/apache/hertzbeat/collector/collect/common/http/CommonHttpClientVirtualThreadTest.java
 
b/hertzbeat-collector/hertzbeat-collector-common/src/test/java/org/apache/hertzbeat/collector/collect/common/http/CommonHttpClientVirtualThreadTest.java
index 2ec28df452..1bdace1667 100644
--- 
a/hertzbeat-collector/hertzbeat-collector-common/src/test/java/org/apache/hertzbeat/collector/collect/common/http/CommonHttpClientVirtualThreadTest.java
+++ 
b/hertzbeat-collector/hertzbeat-collector-common/src/test/java/org/apache/hertzbeat/collector/collect/common/http/CommonHttpClientVirtualThreadTest.java
@@ -104,17 +104,23 @@ class CommonHttpClientVirtualThreadTest {
 
     @Test
     void dispatchConnectionPoolCleanupClosesExpiredAndIdleConnections() throws 
Exception {
-        CountDownLatch latch = new CountDownLatch(1);
+        CountDownLatch expiredConnectionsClosed = new CountDownLatch(1);
+        CountDownLatch idleConnectionsClosed = new CountDownLatch(1);
         PoolingHttpClientConnectionManager manager = 
mock(PoolingHttpClientConnectionManager.class);
         doAnswer(invocation -> {
-            latch.countDown();
+            expiredConnectionsClosed.countDown();
             return null;
         }).when(manager).closeExpiredConnections();
+        doAnswer(invocation -> {
+            idleConnectionsClosed.countDown();
+            return null;
+        }).when(manager).closeIdleConnections(40, TimeUnit.SECONDS);
         CommonHttpClient.setConnectionManagerForTest(manager);
 
         CommonHttpClient.dispatchConnectionPoolCleanup();
 
-        assertTrue(latch.await(5, TimeUnit.SECONDS));
+        assertTrue(expiredConnectionsClosed.await(5, TimeUnit.SECONDS));
+        assertTrue(idleConnectionsClosed.await(5, TimeUnit.SECONDS));
         verify(manager, times(1)).closeExpiredConnections();
         verify(manager, times(1)).closeIdleConnections(40, TimeUnit.SECONDS);
     }
diff --git 
a/hertzbeat-common-core/src/test/java/org/apache/hertzbeat/common/util/AesUtilTest.java
 
b/hertzbeat-common-core/src/test/java/org/apache/hertzbeat/common/util/AesUtilTest.java
index 7ff913701c..01a4019f94 100644
--- 
a/hertzbeat-common-core/src/test/java/org/apache/hertzbeat/common/util/AesUtilTest.java
+++ 
b/hertzbeat-common-core/src/test/java/org/apache/hertzbeat/common/util/AesUtilTest.java
@@ -106,11 +106,8 @@ class AesUtilTest {
         String invalidBase64Text = "InvalidBase64";
         assertFalse(isCiphertext(invalidBase64Text, VALID_KEY));
 
-        // Test with invalid key
-        originalText = "This is a secret message";
-        encryptedText = aesEncode(originalText, VALID_KEY);
-        String invalidKey = "6543210987654321";
-        assertFalse(isCiphertext(encryptedText, invalidKey));
+        // Valid base64 that cannot be decrypted: 3 bytes is not a block 
multiple
+        assertFalse(isCiphertext("AAAA", VALID_KEY));
     }
 
     @Test


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

Reply via email to