This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new d72743f [IOTDB-1825] IT fails on IoTDBTriggerExecutionIT caused by
connection broken (#4135)
d72743f is described below
commit d72743f4d9ae92d94075c4814eabb93a148400a6
Author: Steve Yurong Su <[email protected]>
AuthorDate: Wed Oct 13 09:10:13 2021 +0800
[IOTDB-1825] IT fails on IoTDBTriggerExecutionIT caused by connection
broken (#4135)
---
.../db/integration/IoTDBTriggerExecutionIT.java | 78 +++++++++++++++++++---
1 file changed, 67 insertions(+), 11 deletions(-)
diff --git
a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTriggerExecutionIT.java
b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTriggerExecutionIT.java
index 9d72782..b5fb623 100644
---
a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTriggerExecutionIT.java
+++
b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTriggerExecutionIT.java
@@ -99,11 +99,10 @@ public class IoTDBTriggerExecutionIT {
}
private void stopDataGenerator() throws InterruptedException {
- dataGenerator.interrupt();
- dataGenerator.join();
- if (exception != null) {
- fail(exception.getMessage());
+ if (!dataGenerator.isInterrupted()) {
+ dataGenerator.interrupt();
}
+ dataGenerator.join();
}
@Before
@@ -158,7 +157,7 @@ public class IoTDBTriggerExecutionIT {
}
@Test
- public void checkFireTimes() {
+ public void checkFireTimes() throws InterruptedException {
try (Connection connection =
DriverManager.getConnection(
Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
@@ -186,6 +185,11 @@ public class IoTDBTriggerExecutionIT {
Thread.sleep(500);
stopDataGenerator();
+ // IOTDB-1825: if the background data generator's connection is closed,
the following checks
+ // will be meaningless, in which case we ignore the checks
+ if (exception != null) {
+ return;
+ }
int[] counters2 = getCounters(6);
LOGGER.info(Arrays.toString(counters2));
int expectedTimes = counters2[0] - counters1[0];
@@ -194,6 +198,8 @@ public class IoTDBTriggerExecutionIT {
}
} catch (SQLException | TriggerManagementException | InterruptedException
e) {
fail(e.getMessage());
+ } finally {
+ stopDataGenerator();
}
}
@@ -216,6 +222,11 @@ public class IoTDBTriggerExecutionIT {
Thread.sleep(500);
+ // IOTDB-1825: if the background data generator's connection is closed,
the following checks
+ // will be meaningless, in which case we ignore the checks
+ if (exception != null) {
+ return;
+ }
int[] counters1 = getCounters(3);
LOGGER.info(Arrays.toString(counters1));
for (int i = 0; i < 3; ++i) {
@@ -231,6 +242,11 @@ public class IoTDBTriggerExecutionIT {
statement.execute(
"create trigger trigger-6 after insert on root.vehicle.d1.s6 as
\"org.apache.iotdb.db.engine.trigger.example.Counter\"");
+ // IOTDB-1825: if the background data generator's connection is closed,
the following checks
+ // will be meaningless, in which case we ignore the checks
+ if (exception != null) {
+ return;
+ }
int[] counters2 = getCounters(3);
LOGGER.info(Arrays.toString(counters2));
for (int i = 0; i < 3; ++i) {
@@ -238,9 +254,9 @@ public class IoTDBTriggerExecutionIT {
}
} catch (SQLException | TriggerManagementException e) {
fail(e.getMessage());
+ } finally {
+ stopDataGenerator();
}
-
- stopDataGenerator();
}
@Test
@@ -262,6 +278,11 @@ public class IoTDBTriggerExecutionIT {
Thread.sleep(500);
+ // IOTDB-1825: if the background data generator's connection is closed,
the following checks
+ // will be meaningless, in which case we ignore the checks
+ if (exception != null) {
+ return;
+ }
int[] counters1 = getCounters(3);
LOGGER.info(Arrays.toString(counters1));
for (int i = 0; i < 3; ++i) {
@@ -293,6 +314,11 @@ public class IoTDBTriggerExecutionIT {
Thread.sleep(500);
+ // IOTDB-1825: if the background data generator's connection is closed,
the following checks
+ // will be meaningless, in which case we ignore the checks
+ if (exception != null) {
+ return;
+ }
int[] counters2 = getCounters(3);
LOGGER.info(Arrays.toString(counters2));
for (int i = 0; i < 3; ++i) {
@@ -300,9 +326,9 @@ public class IoTDBTriggerExecutionIT {
}
} catch (SQLException | TriggerManagementException e) {
fail(e.getMessage());
+ } finally {
+ stopDataGenerator();
}
-
- stopDataGenerator();
}
@Test
@@ -345,6 +371,12 @@ public class IoTDBTriggerExecutionIT {
int[] counters2 = getCounters(6);
LOGGER.info(Arrays.toString(counters2));
+
+ // IOTDB-1825: if the background data generator's connection is closed,
the following checks
+ // will be meaningless, in which case we ignore the checks
+ if (exception != null) {
+ return;
+ }
for (int i = 0; i < 3; ++i) {
assertEquals(counters1[i], counters2[i]);
}
@@ -358,6 +390,11 @@ public class IoTDBTriggerExecutionIT {
Thread.sleep(500);
+ // IOTDB-1825: if the background data generator's connection is closed,
the following checks
+ // will be meaningless, in which case we ignore the checks
+ if (exception != null) {
+ return;
+ }
int[] counters3 = getCounters(6);
LOGGER.info(Arrays.toString(counters3));
for (int i = 0; i < 3; ++i) {
@@ -373,6 +410,11 @@ public class IoTDBTriggerExecutionIT {
Thread.sleep(500);
+ // IOTDB-1825: if the background data generator's connection is closed,
the following checks
+ // will be meaningless, in which case we ignore the checks
+ if (exception != null) {
+ return;
+ }
int[] counters4 = getCounters(6);
LOGGER.info(Arrays.toString(counters4));
for (int i = 0; i < 6; ++i) {
@@ -390,12 +432,17 @@ public class IoTDBTriggerExecutionIT {
int[] counters5 = getCounters(6);
Thread.sleep(500);
int[] counters6 = getCounters(6);
+ // IOTDB-1825: if the background data generator's connection is closed,
the following checks
+ // will be meaningless, in which case we ignore the checks
+ if (exception != null) {
+ return;
+ }
assertEquals(Arrays.toString(counters5), Arrays.toString(counters6));
} catch (SQLException | TriggerManagementException e) {
fail(e.getMessage());
+ } finally {
+ stopDataGenerator();
}
-
- stopDataGenerator();
}
private static int[] getCounters(int limit) throws
TriggerManagementException {
@@ -433,6 +480,11 @@ public class IoTDBTriggerExecutionIT {
Thread.sleep(500);
+ // IOTDB-1825: if the background data generator's connection is closed,
the following checks
+ // will be meaningless, in which case we ignore the checks
+ if (exception != null) {
+ return;
+ }
int[] counters1 = getCounters(6);
LOGGER.info(Arrays.toString(counters1));
for (int i = 0; i < 6; ++i) {
@@ -490,6 +542,8 @@ public class IoTDBTriggerExecutionIT {
}
} catch (SQLException | TriggerManagementException | MetadataException e) {
fail(e.getMessage());
+ } finally {
+ stopDataGenerator();
}
}
@@ -563,6 +617,8 @@ public class IoTDBTriggerExecutionIT {
}
} catch (SQLException | TriggerManagementException | MetadataException e) {
fail(e.getMessage());
+ } finally {
+ stopDataGenerator();
}
}
}