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

Caideyipi pushed a commit to branch codex/cp-18899-dev13-assertions
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit da6cf8cd8d9b186a337e72ee02401d6c81e634d5
Author: Caideyipi <[email protected]>
AuthorDate: Wed Nov 4 10:00:32 2026 +0800

    [To dev/1.3] Restore continuous assertion polling (#18899)
    
    Backport the continuous assertion fix and necessary caller corrections
    from #18899. Execute fail-fast checks for the requested observation period
    and adapt regression coverage to the tree-model helper available in 1.3.
    
    Preserve the 1.3 user and privilege result formats. Table-only helpers,
    missing overloads, and independent asynchronous deletion and status polling
    changes are outside this explicitly scoped backport.
    
    Manually adapted partial cherry-pick from
    https://github.com/apache/iotdb/pull/18899.
    
    (cherry picked from commit c9c16af42f696eb9fcecf287704c7825d2524e2c)
---
 .../apache/iotdb/db/it/utils/IoTDBTestUtilsIT.java | 71 ++++++++++++++++++++++
 .../org/apache/iotdb/db/it/utils/TestUtils.java    |  9 +--
 .../iotdb/pipe/it/manual/IoTDBPipeInclusionIT.java | 22 +++++--
 .../pipe/it/manual/IoTDBPipeMetaHistoricalIT.java  |  2 +-
 4 files changed, 93 insertions(+), 11 deletions(-)

diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/utils/IoTDBTestUtilsIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/db/it/utils/IoTDBTestUtilsIT.java
new file mode 100644
index 00000000000..f3bcdee904d
--- /dev/null
+++ 
b/integration-test/src/test/java/org/apache/iotdb/db/it/utils/IoTDBTestUtilsIT.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.it.utils;
+
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.itbase.category.LocalStandaloneIT;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.util.Collections;
+import java.util.concurrent.TimeUnit;
+
+import static org.junit.Assert.assertThrows;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({LocalStandaloneIT.class, ClusterIT.class})
+public class IoTDBTestUtilsIT {
+
+  @BeforeClass
+  public static void setUp() throws Exception {
+    EnvFactory.getEnv().initClusterEnvironment();
+  }
+
+  @AfterClass
+  public static void tearDown() {
+    EnvFactory.getEnv().cleanClusterEnvironment();
+  }
+
+  @Test
+  public void testAssertDataAlwaysFailsOnMismatch() {
+    assertThrows(
+        AssertionError.class,
+        () ->
+            TestUtils.assertDataAlwaysOnEnv(
+                EnvFactory.getEnv(), "count databases", "unexpected,", 
Collections.emptySet(), 1));
+  }
+
+  @Test
+  public void testAssertDataAlwaysObservationPeriod() {
+    final long start = System.nanoTime();
+    TestUtils.assertDataAlwaysOnEnv(
+        EnvFactory.getEnv(), "count databases", "count,", 
Collections.singleton("0,"), 1);
+    assertTrue(
+        "The assertion must observe queries for the requested period",
+        System.nanoTime() - start >= TimeUnit.SECONDS.toNanos(1));
+  }
+}
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/utils/TestUtils.java 
b/integration-test/src/test/java/org/apache/iotdb/db/it/utils/TestUtils.java
index b2a7ba4d22e..e15e24f85e2 100644
--- a/integration-test/src/test/java/org/apache/iotdb/db/it/utils/TestUtils.java
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/utils/TestUtils.java
@@ -983,12 +983,12 @@ public class TestUtils {
       long consistentSeconds) {
     try (Connection connection = env.getConnection();
         Statement statement = connection.createStatement()) {
-      // Keep retrying if there are execution failures
       await()
           .pollInSameThread()
-          .pollDelay(1L, TimeUnit.SECONDS)
+          .pollDelay(0L, TimeUnit.SECONDS)
           .pollInterval(1L, TimeUnit.SECONDS)
-          .atMost(consistentSeconds, TimeUnit.SECONDS)
+          .during(consistentSeconds, TimeUnit.SECONDS)
+          .atMost(consistentSeconds + 5, TimeUnit.SECONDS)
           .failFast(
               () -> {
                 try {
@@ -997,7 +997,8 @@ public class TestUtils {
                 } catch (Exception e) {
                   Assert.fail();
                 }
-              });
+              })
+          .until(() -> true);
     } catch (Exception e) {
       e.printStackTrace();
       fail();
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/pipe/it/manual/IoTDBPipeInclusionIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/pipe/it/manual/IoTDBPipeInclusionIT.java
index 1385829578f..d00f5edbfd6 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/pipe/it/manual/IoTDBPipeInclusionIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/pipe/it/manual/IoTDBPipeInclusionIT.java
@@ -96,7 +96,10 @@ public class IoTDBPipeInclusionIT extends 
AbstractPipeDualManualIT {
           null);
 
       TestUtils.assertDataAlwaysOnEnv(
-          receiverEnv, "select * from root.**", "Time,", 
Collections.emptySet());
+          receiverEnv,
+          "select * from root.**",
+          "Time,root.ln.wf01.wt01.status,",
+          Collections.emptySet());
     }
   }
 
@@ -166,8 +169,12 @@ public class IoTDBPipeInclusionIT extends 
AbstractPipeDualManualIT {
           Arrays.asList("insert into root.ln.wf01.wt01(time,status) 
values(now(),false)", "flush"),
           null);
 
+      // Keep the header independent of wildcard expansion order.
       TestUtils.assertDataAlwaysOnEnv(
-          receiverEnv, "select * from root.ln.**", "Time,", 
Collections.emptySet());
+          receiverEnv,
+          "select wf01.wt01.status, wf02.wt01.status from root.ln",
+          "Time,root.ln.wf01.wt01.status,root.ln.wf02.wt01.status,",
+          Collections.emptySet());
     }
   }
 
@@ -239,7 +246,10 @@ public class IoTDBPipeInclusionIT extends 
AbstractPipeDualManualIT {
           null);
 
       TestUtils.assertDataAlwaysOnEnv(
-          receiverEnv, "select * from root.ln.**", "Time,", 
Collections.emptySet());
+          receiverEnv,
+          "select * from root.ln.**",
+          "Time,root.ln.wf01.wt01.status,",
+          Collections.emptySet());
     }
   }
 
@@ -277,7 +287,7 @@ public class IoTDBPipeInclusionIT extends 
AbstractPipeDualManualIT {
       TestUtils.executeNonQuery(senderEnv, "create user `ln_write_user` 
'write_pwd'", null);
 
       TestUtils.assertDataAlwaysOnEnv(
-          receiverEnv, "list user", "user,", Collections.singleton("root,"));
+          receiverEnv, "list user", "User,", Collections.singleton("root,"));
     }
   }
 
@@ -320,10 +330,10 @@ public class IoTDBPipeInclusionIT extends 
AbstractPipeDualManualIT {
               "GRANT READ_DATA, WRITE_DATA ON root.** TO USER ln_write_user;"),
           null);
 
-      TestUtils.assertDataAlwaysOnEnv(
+      TestUtils.assertDataEventuallyOnEnv(
           receiverEnv,
           "LIST PRIVILEGES OF USER ln_write_user",
-          "ROLE,PATH,PRIVILEGES,GRANT OPTION,",
+          "Role,Path,Privileges,GrantOption,",
           new HashSet<>(
               Arrays.asList(
                   ",root.**,MANAGE_USER,true,",
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/pipe/it/manual/IoTDBPipeMetaHistoricalIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/pipe/it/manual/IoTDBPipeMetaHistoricalIT.java
index 0827d362179..baa295c3578 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/pipe/it/manual/IoTDBPipeMetaHistoricalIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/pipe/it/manual/IoTDBPipeMetaHistoricalIT.java
@@ -259,7 +259,7 @@ public class IoTDBPipeMetaHistoricalIT extends 
AbstractPipeDualManualIT {
           
"Database,SchemaReplicationFactor,DataReplicationFactor,TimePartitionOrigin,TimePartitionInterval,",
           Collections.emptySet());
       TestUtils.assertDataAlwaysOnEnv(
-          receiverEnv, "select * from root.**", "Time", 
Collections.emptySet());
+          receiverEnv, "select * from root.**", "Time,", 
Collections.emptySet());
 
       TestUtils.executeNonQuery(senderEnv, "CREATE ROLE test", null);
 

Reply via email to