You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/06/23 02:16:25 UTC

[GitHub] [iotdb] ericpai commented on a diff in pull request #6382: [IOTDB-3558] Dump node stacks if IT test request timeout

ericpai commented on code in PR #6382:
URL: https://github.com/apache/iotdb/pull/6382#discussion_r904457425


##########
integration-test/src/main/java/org/apache/iotdb/it/env/AbstractEnv.java:
##########
@@ -200,14 +193,53 @@ public void cleanAfterTest() {
     cleanupEnvironment();
   }
 
-  @Override
-  public Connection getConnection() throws SQLException {
-    return new ClusterTestConnection(getWriteConnection(null), getReadConnections(null));
+  public final int[] searchAvailablePorts() {
+    do {
+      int randomPortStart = 1000 + (int) (Math.random() * (1999 - 1000));
+      randomPortStart = randomPortStart * 10 + 1;
+      File lockFile = new File(getLockFilePath(randomPortStart));
+      if (lockFile.exists()) {
+        continue;
+      }
+
+      List<Integer> requiredPorts =
+          IntStream.rangeClosed(randomPortStart, randomPortStart + 9)
+              .boxed()
+              .collect(Collectors.toList());
+      String cmd = getSearchAvailablePortCmd(requiredPorts);
+
+      try {
+        Process proc = Runtime.getRuntime().exec(cmd);
+        if (proc.waitFor() == 1 && lockFile.createNewFile()) {
+          return requiredPorts.stream().mapToInt(Integer::intValue).toArray();
+        }
+      } catch (IOException | InterruptedException ex) {
+        // ignore

Review Comment:
   Good catch! It has been fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org