This is an automated email from the ASF dual-hosted git repository.
jt2594838 pushed a commit to branch dev/1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/dev/1.3 by this push:
new 867d60252b0 [To dev/1.3] Restore IT observation checks (#18899,
#19095) [do not squash] (#19112)
867d60252b0 is described below
commit 867d60252b08e8ba3e319f30d95a242275233829
Author: Caideyipi <[email protected]>
AuthorDate: Wed Nov 4 15:03:27 2026 +0800
[To dev/1.3] Restore IT observation checks (#18899, #19095) [do not squash]
(#19112)
* [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)
* [To dev/1.3] Count query time in IT observation periods (#19095)
Replace the Awaitility observation deadline with the source PR's monotonic
elapsed-time loop so successful slow queries count toward the requested
period. Preserve immediate mismatch failure and port the seven-second
query regression to the single tree-model helper available in 1.3.
The table-only assertion and overloads are absent in 1.3. The restart-cache
testWriteRestartAndDeleteDB scenario is also absent, so its session and
flush adjustments have no target counterpart.
(cherry picked from commit ca8074d15c824f2533d357778e40f773d02b5565)
---
.../apache/iotdb/db/it/utils/IoTDBTestUtilsIT.java | 122 +++++++++++++++++++++
.../org/apache/iotdb/db/it/utils/TestUtils.java | 40 ++++---
.../iotdb/pipe/it/manual/IoTDBPipeInclusionIT.java | 22 +++-
.../pipe/it/manual/IoTDBPipeMetaHistoricalIT.java | 2 +-
4 files changed, 164 insertions(+), 22 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..68ab36b346e
--- /dev/null
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/utils/IoTDBTestUtilsIT.java
@@ -0,0 +1,122 @@
+/*
+ * 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.apache.iotdb.itbase.env.BaseEnv;
+
+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.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Proxy;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.util.Collections;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.junit.Assert.assertEquals;
+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() {
+ assertObservationPeriod(
+ () ->
+ TestUtils.assertDataAlwaysOnEnv(
+ EnvFactory.getEnv(), "count databases", "count,",
Collections.singleton("0,"), 1));
+ }
+
+ @Test
+ public void testAssertDataAlwaysIncludesQueryTime() {
+ final AtomicInteger queries = new AtomicInteger();
+ final BaseEnv slowEnv = delayQueries(BaseEnv.class, EnvFactory.getEnv(),
queries);
+ assertObservationPeriod(
+ () ->
+ TestUtils.assertDataAlwaysOnEnv(
+ slowEnv, "count databases", "count,",
Collections.singleton("0,"), 1));
+ // A successful query taking longer than the observation period must not
cause a timeout.
+ assertEquals(1, queries.get());
+ }
+
+ private <T> T delayQueries(final Class<T> type, final T delegate, final
AtomicInteger queries) {
+ return type.cast(
+ Proxy.newProxyInstance(
+ type.getClassLoader(),
+ new Class<?>[] {type},
+ (proxy, method, args) -> {
+ if ("executeQuery".equals(method.getName())) {
+ queries.incrementAndGet();
+ TimeUnit.SECONDS.sleep(7);
+ }
+ final Object result;
+ try {
+ result = method.invoke(delegate, args);
+ } catch (InvocationTargetException e) {
+ throw e.getCause();
+ }
+ if (result instanceof Connection) {
+ return delayQueries(Connection.class, (Connection) result,
queries);
+ }
+ if (result instanceof Statement) {
+ return delayQueries(Statement.class, (Statement) result,
queries);
+ }
+ return result;
+ }));
+ }
+
+ private void assertObservationPeriod(final Runnable assertion) {
+ final long start = System.nanoTime();
+ assertion.run();
+ 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..7ce8f63c9a1 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,27 +983,37 @@ 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)
- .pollInterval(1L, TimeUnit.SECONDS)
- .atMost(consistentSeconds, TimeUnit.SECONDS)
- .failFast(
- () -> {
- try {
- TestUtils.assertResultSetEqual(
- executeQueryWithRetry(statement, sql), expectedHeader,
expectedResSet);
- } catch (Exception e) {
- Assert.fail();
- }
- });
+ assertAlways(
+ consistentSeconds,
+ () -> {
+ try {
+ TestUtils.assertResultSetEqual(
+ executeQueryWithRetry(statement, sql), expectedHeader,
expectedResSet);
+ } catch (Exception e) {
+ Assert.fail();
+ }
+ });
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
+ /** Observe for a bounded period, including time spent executing and
checking each query. */
+ private static void assertAlways(final long consistentSeconds, final
Runnable assertion)
+ throws InterruptedException {
+ final long start = System.nanoTime();
+ final long duration = TimeUnit.SECONDS.toNanos(consistentSeconds);
+ while (true) {
+ assertion.run();
+ final long remaining = duration - (System.nanoTime() - start);
+ if (remaining <= 0) {
+ return;
+ }
+ TimeUnit.NANOSECONDS.sleep(Math.min(remaining,
TimeUnit.SECONDS.toNanos(1)));
+ }
+ }
+
public static void stopForciblyAndRestartDataNodes() {
EnvFactory.getEnv().shutdownForciblyAllDataNodes();
EnvFactory.getEnv().startAllDataNodes();
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);