This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch rel/0.13
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/rel/0.13 by this push:
new d00e4e7bfb [IOTDB-4577] Fix data archiving IT (#7538)
d00e4e7bfb is described below
commit d00e4e7bfba0c477e6ac08e9c25edee4e2949be0
Author: Alan Choo <[email protected]>
AuthorDate: Sat Oct 8 09:37:07 2022 +0800
[IOTDB-4577] Fix data archiving IT (#7538)
---
.../iotdb/db/integration/IoTDBArchivingIT.java | 21 ++++++++++++++++++---
.../iotdb/db/engine/archiving/ArchivingManager.java | 5 +++++
.../org/apache/iotdb/db/utils/EnvironmentUtils.java | 2 +-
3 files changed, 24 insertions(+), 4 deletions(-)
diff --git
a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBArchivingIT.java
b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBArchivingIT.java
index a46e3b99ed..6b31855666 100644
---
a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBArchivingIT.java
+++
b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBArchivingIT.java
@@ -20,6 +20,8 @@
package org.apache.iotdb.db.integration;
import org.apache.iotdb.db.engine.StorageEngine;
+import org.apache.iotdb.db.engine.archiving.ArchivingManager;
+import org.apache.iotdb.db.engine.archiving.ArchivingTask;
import org.apache.iotdb.db.utils.FileUtils;
import org.apache.iotdb.integration.env.EnvFactory;
import org.apache.iotdb.itbase.category.ClusterTest;
@@ -160,7 +162,7 @@ public class IoTDBArchivingIT {
+ testTargetDir.getPath()
+ "'");
- Thread.sleep(ARCHIVING_CHECK_TIME * 2);
+ waitUntilAllFinished();
try (ResultSet resultSet = statement.executeQuery("SELECT s1 FROM
root.ARCHIVING_SG1")) {
int cnt = 0;
@@ -195,7 +197,7 @@ public class IoTDBArchivingIT {
// test resume archive
statement.execute("RESUME ARCHIVING ON root.ARCHIVING_SG1");
- Thread.sleep(ARCHIVING_CHECK_TIME * 2);
+ waitUntilAllFinished();
try (ResultSet resultSet = statement.executeQuery("SELECT s1 FROM
root.ARCHIVING_SG1")) {
int cnt = 0;
@@ -232,7 +234,7 @@ public class IoTDBArchivingIT {
StorageEngine.getInstance().getArchivingManager().setCheckThreadTime(ARCHIVING_CHECK_TIME);
- Thread.sleep(ARCHIVING_CHECK_TIME * 2);
+ waitUntilAllFinished();
try (ResultSet resultSet = statement.executeQuery("SELECT s1 FROM
root.ARCHIVING_SG1")) {
int cnt = 0;
@@ -244,6 +246,19 @@ public class IoTDBArchivingIT {
}
}
+ private void waitUntilAllFinished() throws InterruptedException {
+ int cnt = 10;
+ for (ArchivingTask task :
ArchivingManager.getInstance().getArchivingTasks()) {
+ if (task.getStatus() != ArchivingTask.ArchivingTaskStatus.FINISHED) {
+ Thread.sleep(ARCHIVING_CHECK_TIME * 2);
+ cnt++;
+ if (cnt >= 50) {
+ throw new RuntimeException("Wait too long for all archiving task
finished.");
+ }
+ }
+ }
+ }
+
@Test
@Category({ClusterTest.class})
public void testShowArchiving() throws SQLException {
diff --git
a/server/src/main/java/org/apache/iotdb/db/engine/archiving/ArchivingManager.java
b/server/src/main/java/org/apache/iotdb/db/engine/archiving/ArchivingManager.java
index 9ac1dc3fc9..4e9b02b4fd 100644
---
a/server/src/main/java/org/apache/iotdb/db/engine/archiving/ArchivingManager.java
+++
b/server/src/main/java/org/apache/iotdb/db/engine/archiving/ArchivingManager.java
@@ -186,6 +186,11 @@ public class ArchivingManager {
currentTaskId = 0;
}
+ public void clear() {
+ close();
+ LOG_FILE.delete();
+ }
+
/** creates a copy of archivingTasks and returns */
public List<ArchivingTask> getArchivingTasks() {
try {
diff --git
a/server/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java
b/server/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java
index b439387eef..102b6fcb1d 100644
--- a/server/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java
+++ b/server/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java
@@ -145,7 +145,7 @@ public class EnvironmentUtils {
}
// clear archiving manager
- ArchivingManager.getInstance().close();
+ ArchivingManager.getInstance().clear();
IoTDBDescriptor.getInstance().getConfig().setSystemStatus(SystemStatus.NORMAL);
// We must disable MQTT service as it will cost a lot of time to be
shutdown, which may slow our