This is an automated email from the ASF dual-hosted git repository.
hxd pushed a commit to branch fix_closed_channel_issue
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/fix_closed_channel_issue by
this push:
new ec44ce6 make SysTimeVersionControllerTest more stable
ec44ce6 is described below
commit ec44ce616ff3208be597b290caab328fd0ebb9bd
Author: xiangdong huang <[email protected]>
AuthorDate: Tue Mar 26 09:54:04 2019 +0800
make SysTimeVersionControllerTest more stable
---
.../db/engine/version/SysTimeVersionControllerTest.java | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git
a/iotdb/src/test/java/org/apache/iotdb/db/engine/version/SysTimeVersionControllerTest.java
b/iotdb/src/test/java/org/apache/iotdb/db/engine/version/SysTimeVersionControllerTest.java
index 1912d8a..f494da7 100644
---
a/iotdb/src/test/java/org/apache/iotdb/db/engine/version/SysTimeVersionControllerTest.java
+++
b/iotdb/src/test/java/org/apache/iotdb/db/engine/version/SysTimeVersionControllerTest.java
@@ -29,9 +29,15 @@ public class SysTimeVersionControllerTest {
public void test() {
VersionController versionController = SysTimeVersionController.INSTANCE;
long diff = versionController.currVersion() - System.currentTimeMillis();
- // TODO these comparisons can fail in very rare conditions, how to fix?
- assertTrue(diff >= -2 && diff <= 2);
- diff = versionController.nextVersion() - System.currentTimeMillis();
- assertTrue(diff >= -2 && diff <= 2);
+ // to aovid the test failure on a poor machine, we bear 200ms difference
here.
+ assertTrue(diff >= -200 && diff <= 200);
+ diff = versionController.nextVersion();
+ try {
+ Thread.sleep(200);
+ diff -= System.currentTimeMillis();
+ assertTrue(diff >= -1000 && diff <= -200);
+ } catch (InterruptedException e) {
+ //do nothing
+ }
}
}
\ No newline at end of file