diff --git a/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBAlterTimeSeriesTypeIT.java b/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBAlterTimeSeriesTypeIT.java index 969ab28fd7a6c..8737df331d993 100644 --- a/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBAlterTimeSeriesTypeIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBAlterTimeSeriesTypeIT.java @@ -375,12 +375,14 @@ private void doWriteAndAlterWriteForAccumulatorQuery(TSDataType from, TSDataType Collections.singletonList("s1"), Collections.singletonList(from), Collections.singletonList(ColumnCategory.FIELD)); + // Batch fixture writes without crossing data type changes or flush boundaries. for (int i = 1; i <= 512; i++) { - tablet.addTimestamp(0, i); - tablet.addValue("s1", 0, genValue(from, i)); - session.insertTablet(tablet); - tablet.reset(); + int rowIndex = tablet.getRowSize(); + tablet.addTimestamp(rowIndex, i); + tablet.addValue("s1", rowIndex, genValue(from, i)); } + session.insertTablet(tablet); + tablet.reset(); session.executeNonQueryStatement("FLUSH"); // alter the type to "to" @@ -413,11 +415,12 @@ private void doWriteAndAlterWriteForAccumulatorQuery(TSDataType from, TSDataType Collections.singletonList(to), Collections.singletonList(ColumnCategory.FIELD)); for (int i = 513; i <= 1024; i++) { - tablet.addTimestamp(0, i); - tablet.addValue("s1", 0, genValue(to, i)); - session.insertTablet(tablet); - tablet.reset(); + int rowIndex = tablet.getRowSize(); + tablet.addTimestamp(rowIndex, i); + tablet.addValue("s1", rowIndex, genValue(to, i)); } + session.insertTablet(tablet); + tablet.reset(); session.executeNonQueryStatement("FLUSH"); standardAccumulatorQueryByTimeOnlyInvolveOldDataTypeTest(session, from, to); @@ -1186,23 +1189,23 @@ public void testNonAlignDeviceSequenceDataQuery(TSDataType from, TSDataType to) // session.executeNonQueryStatement("FLUSH"); for (int i = 1; i <= 512; i++) { int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(0, i); + tablet.addTimestamp(rowIndex, i); tablet.addValue("s1", rowIndex, genValue(from, i)); tablet.addValue("s2", rowIndex, genValue(from, i * 2)); - session.insertTablet(tablet); - tablet.reset(); } + session.insertTablet(tablet); + tablet.reset(); session.executeNonQueryStatement("FLUSH"); for (int i = 513; i <= 1024; i++) { int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(0, i); + tablet.addTimestamp(rowIndex, i); tablet.addValue("s1", rowIndex, genValue(from, i)); tablet.addValue("s2", rowIndex, genValue(from, i * 2)); - session.insertTablet(tablet); - tablet.reset(); } + session.insertTablet(tablet); + tablet.reset(); String columns; if (UNSUPPORT_MIN_AND_MAX_QUERY_DATA_TYPE_LIST.contains(from) @@ -1323,23 +1326,23 @@ public void testAlignDeviceSequenceDataQuery(TSDataType from, TSDataType to) thr // session.executeNonQueryStatement("FLUSH"); for (int i = 1; i <= 512; i++) { int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(0, i); + tablet.addTimestamp(rowIndex, i); tablet.addValue("s1", rowIndex, genValue(from, i)); tablet.addValue("s2", rowIndex, genValue(from, i * 2)); - session.insertTablet(tablet); - tablet.reset(); } + session.insertTablet(tablet); + tablet.reset(); session.executeNonQueryStatement("FLUSH"); for (int i = 513; i <= 1024; i++) { int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(0, i); + tablet.addTimestamp(rowIndex, i); tablet.addValue("s1", rowIndex, genValue(from, i)); tablet.addValue("s2", rowIndex, genValue(from, i * 2)); - session.insertTablet(tablet); - tablet.reset(); } + session.insertTablet(tablet); + tablet.reset(); String columns; if (UNSUPPORT_MIN_AND_MAX_QUERY_DATA_TYPE_LIST.contains(from) @@ -1452,23 +1455,23 @@ public void testNonAlignDeviceUnSequenceDataQuery(TSDataType from, TSDataType to for (int i = 513; i <= 1024; i++) { int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(0, i); + tablet.addTimestamp(rowIndex, i); tablet.addValue("s1", rowIndex, genValue(from, i)); tablet.addValue("s2", rowIndex, genValue(from, i * 2)); - session.insertTablet(tablet); - tablet.reset(); } + session.insertTablet(tablet); + tablet.reset(); session.executeNonQueryStatement("FLUSH"); for (int i = 1; i <= 512; i++) { int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(0, i); + tablet.addTimestamp(rowIndex, i); tablet.addValue("s1", rowIndex, genValue(from, i)); tablet.addValue("s2", rowIndex, genValue(from, i * 2)); - session.insertTablet(tablet); - tablet.reset(); } + session.insertTablet(tablet); + tablet.reset(); // session.executeNonQueryStatement("FLUSH"); String columns; @@ -1585,23 +1588,23 @@ public void testAlignDeviceUnSequenceDataQuery(TSDataType from, TSDataType to) t for (int i = 513; i <= 1024; i++) { int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(0, i); + tablet.addTimestamp(rowIndex, i); tablet.addValue("s1", rowIndex, genValue(from, i)); tablet.addValue("s2", rowIndex, genValue(from, i * 2)); - session.insertTablet(tablet); - tablet.reset(); } + session.insertTablet(tablet); + tablet.reset(); session.executeNonQueryStatement("FLUSH"); for (int i = 1; i <= 512; i++) { int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(0, i); + tablet.addTimestamp(rowIndex, i); tablet.addValue("s1", rowIndex, genValue(from, i)); tablet.addValue("s2", rowIndex, genValue(from, i * 2)); - session.insertTablet(tablet); - tablet.reset(); } + session.insertTablet(tablet); + tablet.reset(); // session.executeNonQueryStatement("FLUSH"); String columns; @@ -1715,23 +1718,23 @@ public void testNonAlignDeviceUnSequenceOverlappedDataQuery(TSDataType from, TSD for (int i = 513; i <= 1024; i++) { int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(0, i); + tablet.addTimestamp(rowIndex, i); tablet.addValue("s1", rowIndex, genValue(from, i)); tablet.addValue("s2", rowIndex, genValue(from, i * 2)); - session.insertTablet(tablet); - tablet.reset(); } + session.insertTablet(tablet); + tablet.reset(); session.executeNonQueryStatement("FLUSH"); for (int i = 1; i <= 520; i++) { int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(0, i); + tablet.addTimestamp(rowIndex, i); tablet.addValue("s1", rowIndex, genValue(from, i)); tablet.addValue("s2", rowIndex, genValue(from, i * 2)); - session.insertTablet(tablet); - tablet.reset(); } + session.insertTablet(tablet); + tablet.reset(); // session.executeNonQueryStatement("FLUSH"); String columns; @@ -1849,23 +1852,23 @@ public void testAlignDeviceUnSequenceOverlappedDataQuery(TSDataType from, TSData for (int i = 513; i <= 1024; i++) { int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(0, i); + tablet.addTimestamp(rowIndex, i); tablet.addValue("s1", rowIndex, genValue(from, i)); tablet.addValue("s2", rowIndex, genValue(from, i * 2)); - session.insertTablet(tablet); - tablet.reset(); } + session.insertTablet(tablet); + tablet.reset(); session.executeNonQueryStatement("FLUSH"); for (int i = 1; i <= 520; i++) { int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(0, i); + tablet.addTimestamp(rowIndex, i); tablet.addValue("s1", rowIndex, genValue(from, i)); tablet.addValue("s2", rowIndex, genValue(from, i * 2)); - session.insertTablet(tablet); - tablet.reset(); } + session.insertTablet(tablet); + tablet.reset(); // session.executeNonQueryStatement("FLUSH"); String columns; 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 79a2f1c984769..5eb22c598e08f 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 @@ -1697,7 +1697,7 @@ public static void assertDataEventuallyOnEnv( // Keep retrying if there are execution failures await() .pollInSameThread() - .pollDelay(1L, TimeUnit.SECONDS) + .pollDelay(0L, TimeUnit.SECONDS) .pollInterval(1L, TimeUnit.SECONDS) .atMost(timeoutSeconds, TimeUnit.SECONDS) .untilAsserted( @@ -1741,7 +1741,7 @@ public static void assertDataEventuallyOnEnv( // Keep retrying if there are execution failures await() .pollInSameThread() - .pollDelay(1L, TimeUnit.SECONDS) + .pollDelay(0L, TimeUnit.SECONDS) .pollInterval(1L, TimeUnit.SECONDS) .atMost(timeoutSeconds, TimeUnit.SECONDS) .untilAsserted( @@ -1777,7 +1777,7 @@ public static void assertDataSizeEventuallyOnEnv( // Keep retrying if there are execution failures await() .pollInSameThread() - .pollDelay(1L, TimeUnit.SECONDS) + .pollDelay(0L, TimeUnit.SECONDS) .pollInterval(1L, TimeUnit.SECONDS) .atMost(timeoutSeconds, TimeUnit.SECONDS) .untilAsserted( @@ -1821,7 +1821,7 @@ public static void assertDataEventuallyOnEnv( // Keep retrying if there are execution failures await() .pollInSameThread() - .pollDelay(1L, TimeUnit.SECONDS) + .pollDelay(0L, TimeUnit.SECONDS) .pollInterval(1L, TimeUnit.SECONDS) .atMost(timeoutSeconds, TimeUnit.SECONDS) .untilAsserted( @@ -1902,7 +1902,7 @@ public static void assertDataEventuallyOnEnv( // Keep retrying if there are execution failures await() .pollInSameThread() - .pollDelay(1L, TimeUnit.SECONDS) + .pollDelay(0L, TimeUnit.SECONDS) .pollInterval(1L, TimeUnit.SECONDS) .atMost(timeoutSeconds, TimeUnit.SECONDS) .untilAsserted( @@ -1983,7 +1983,7 @@ public static void assertDataEventuallyOnEnv( // Keep retrying if there are execution failures await() .pollInSameThread() - .pollDelay(1L, TimeUnit.SECONDS) + .pollDelay(0L, TimeUnit.SECONDS) .pollInterval(1L, TimeUnit.SECONDS) .atMost(timeoutSeconds, TimeUnit.SECONDS) .untilAsserted( @@ -2027,7 +2027,7 @@ public static void assertDataEventuallyOnEnv( // Keep retrying if there are execution failures await() .pollInSameThread() - .pollDelay(1L, TimeUnit.SECONDS) + .pollDelay(0L, TimeUnit.SECONDS) .pollInterval(1L, TimeUnit.SECONDS) .atMost(timeoutSeconds, TimeUnit.SECONDS) .untilAsserted( diff --git a/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/tablemodel/manual/enhanced/IoTDBPipeClusterIT.java b/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/tablemodel/manual/enhanced/IoTDBPipeClusterIT.java index cde83cc4da6db..1e3961bd61a09 100644 --- a/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/tablemodel/manual/enhanced/IoTDBPipeClusterIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/tablemodel/manual/enhanced/IoTDBPipeClusterIT.java @@ -165,9 +165,8 @@ private void testMachineDowntime(String sink) { TableModelUtils.assertCountData("test", "test", 1, receiverEnv); receiverEnv.getDataNodeWrapper(0).stop(); - - // Ensure that the kill -9 operation is completed - Thread.sleep(5000); + // stop() waits for process exit; verify it succeeded before checking failover. + Assert.assertFalse(receiverEnv.getDataNodeWrapper(0).isAlive()); TableModelUtils.insertData("test", "test", 1, 2, senderEnv); } catch (Exception e) { fail(e.getMessage()); diff --git a/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/enhanced/IoTDBPipeClusterIT.java b/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/enhanced/IoTDBPipeClusterIT.java index b64a43fc04d6b..f17f63214cf15 100644 --- a/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/enhanced/IoTDBPipeClusterIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/enhanced/IoTDBPipeClusterIT.java @@ -175,9 +175,8 @@ private void testMachineDowntime(String sink) { Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode()); receiverEnv.getDataNodeWrapper(0).stop(); - - // Ensure that the kill -9 operation is completed - Thread.sleep(5000); + // stop() waits for process exit; verify it succeeded before checking failover. + Assert.assertFalse(receiverEnv.getDataNodeWrapper(0).isAlive()); for (DataNodeWrapper nodeWrapper : receiverEnv.getDataNodeWrapperList()) { if (!nodeWrapper.isAlive()) { continue; diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBAlterColumnTypeIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBAlterColumnTypeIT.java index d9a1f617b0213..00c3df4f39078 100644 --- a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBAlterColumnTypeIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBAlterColumnTypeIT.java @@ -341,12 +341,14 @@ private void doWriteAndAlterWriteForAccumulatorQuery(TSDataType from, TSDataType Collections.singletonList("s1"), Collections.singletonList(from), Collections.singletonList(ColumnCategory.FIELD)); + // Batch fixture writes without crossing data type changes or flush boundaries. for (int i = 1; i <= 512; i++) { - tablet.addTimestamp(0, i); - tablet.addValue("s1", 0, genValue(from, i)); - session.insert(tablet); - tablet.reset(); + int rowIndex = tablet.getRowSize(); + tablet.addTimestamp(rowIndex, i); + tablet.addValue("s1", rowIndex, genValue(from, i)); } + session.insert(tablet); + tablet.reset(); session.executeNonQueryStatement("FLUSH"); // alter the type to "to" @@ -373,11 +375,12 @@ private void doWriteAndAlterWriteForAccumulatorQuery(TSDataType from, TSDataType Collections.singletonList(to), Collections.singletonList(ColumnCategory.FIELD)); for (int i = 513; i <= 1024; i++) { - tablet.addTimestamp(0, i); - tablet.addValue("s1", 0, genValue(to, i)); - session.insert(tablet); - tablet.reset(); + int rowIndex = tablet.getRowSize(); + tablet.addTimestamp(rowIndex, i); + tablet.addValue("s1", rowIndex, genValue(to, i)); } + session.insert(tablet); + tablet.reset(); session.executeNonQueryStatement("FLUSH"); standardAccumulatorQueryByTimeOnlyInvolveOldDataTypeTest(session, from, to); @@ -1365,23 +1368,23 @@ public void testAlignDeviceSequenceDataQuery(TSDataType from, TSDataType to) thr // session.executeNonQueryStatement("FLUSH"); for (int i = 1; i <= 512; i++) { int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(0, i); + tablet.addTimestamp(rowIndex, i); tablet.addValue("s1", rowIndex, genValue(from, i)); tablet.addValue("s2", rowIndex, genValue(from, i * 2)); - session.insert(tablet); - tablet.reset(); } + session.insert(tablet); + tablet.reset(); session.executeNonQueryStatement("FLUSH"); for (int i = 513; i <= 1024; i++) { int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(0, i); + tablet.addTimestamp(rowIndex, i); tablet.addValue("s1", rowIndex, genValue(from, i)); tablet.addValue("s2", rowIndex, genValue(from, i * 2)); - session.insert(tablet); - tablet.reset(); } + session.insert(tablet); + tablet.reset(); SessionDataSet dataSet = session.executeQueryStatement( @@ -1467,23 +1470,23 @@ public void testAlignDeviceUnSequenceDataQuery(TSDataType from, TSDataType to) t for (int i = 513; i <= 1024; i++) { int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(0, i); + tablet.addTimestamp(rowIndex, i); tablet.addValue("s1", rowIndex, genValue(from, i)); tablet.addValue("s2", rowIndex, genValue(from, i * 2)); - session.insert(tablet); - tablet.reset(); } + session.insert(tablet); + tablet.reset(); session.executeNonQueryStatement("FLUSH"); for (int i = 1; i <= 512; i++) { int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(0, i); + tablet.addTimestamp(rowIndex, i); tablet.addValue("s1", rowIndex, genValue(from, i)); tablet.addValue("s2", rowIndex, genValue(from, i * 2)); - session.insert(tablet); - tablet.reset(); } + session.insert(tablet); + tablet.reset(); // session.executeNonQueryStatement("FLUSH"); SessionDataSet dataSet = @@ -1572,23 +1575,23 @@ public void testAlignDeviceUnSequenceOverlappedDataQuery(TSDataType from, TSData for (int i = 513; i <= 1024; i++) { int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(0, i); + tablet.addTimestamp(rowIndex, i); tablet.addValue("s1", rowIndex, genValue(from, i)); tablet.addValue("s2", rowIndex, genValue(from, i * 2)); - session.insert(tablet); - tablet.reset(); } + session.insert(tablet); + tablet.reset(); session.executeNonQueryStatement("FLUSH"); for (int i = 1; i <= 520; i++) { int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(0, i); + tablet.addTimestamp(rowIndex, i); tablet.addValue("s1", rowIndex, genValue(from, i)); tablet.addValue("s2", rowIndex, genValue(from, i * 2)); - session.insert(tablet); - tablet.reset(); } + session.insert(tablet); + tablet.reset(); // session.executeNonQueryStatement("FLUSH"); SessionDataSet dataSet = diff --git a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSchemaTemplateIT.java b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSchemaTemplateIT.java index ef7bffdb9f06a..f994e65163d51 100644 --- a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSchemaTemplateIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSchemaTemplateIT.java @@ -41,6 +41,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.junit.runners.Parameterized; import java.io.IOException; import java.util.ArrayList; @@ -63,20 +64,33 @@ public IoTDBSessionSchemaTemplateIT(final SchemaTestMode schemaTestMode) { super(schemaTestMode); } + // Keep one cluster per schema engine mode, and clear its schema between test methods. + @Parameterized.BeforeParam + public static void before() throws Exception { + setUpEnvironment(); + EnvFactory.getEnv().initClusterEnvironment(); + } + + @Parameterized.AfterParam + public static void after() throws Exception { + EnvFactory.getEnv().cleanClusterEnvironment(); + tearDownEnvironment(); + } + @Before public void setUp() throws Exception { - setUpEnvironmentBeforeMethod(); - EnvFactory.getEnv().initClusterEnvironment(); session = EnvFactory.getEnv().getSessionConnection(); } @After public void tearDown() throws Exception { - if (session != null) { - session.close(); + try { + if (session != null) { + session.close(); + } + } finally { + clearSchema(); } - EnvFactory.getEnv().cleanClusterEnvironment(); - tearDownEnvironment(); } @Test diff --git a/integration-test/src/test/java/org/apache/iotdb/subscription/it/IoTDBSubscriptionITConstant.java b/integration-test/src/test/java/org/apache/iotdb/subscription/it/IoTDBSubscriptionITConstant.java index 3162139fb665e..6c7eb061789c6 100644 --- a/integration-test/src/test/java/org/apache/iotdb/subscription/it/IoTDBSubscriptionITConstant.java +++ b/integration-test/src/test/java/org/apache/iotdb/subscription/it/IoTDBSubscriptionITConstant.java @@ -31,7 +31,8 @@ public class IoTDBSubscriptionITConstant { - private static final long AWAITILITY_POLL_DELAY_SECOND = 1L; + // Conditions may already hold when the assertion starts; only wait between retries. + private static final long AWAITILITY_POLL_DELAY_SECOND = 0L; private static final long AWAITILITY_POLL_INTERVAL_SECOND = 1L; private static final long AWAITILITY_AT_MOST_SECOND = 600L;