Copilot commented on code in PR #10522:
URL: https://github.com/apache/gravitino/pull/10522#discussion_r2978752364


##########
integration-test-common/src/test/java/org/apache/gravitino/integration/test/container/GravitinoLocalStackContainer.java:
##########
@@ -57,7 +57,12 @@ public Builder() {
       super();
       this.image = DEFAULT_IMAGE;
       this.hostName = HOST_NAME;
-      this.exposePorts = ImmutableSet.of(PORT);
+      try {
+        int randomPort = RESTUtils.findAvailablePort(4566, 4666);
+        this.exposePorts = ImmutableSet.of(randomPort);
+      } catch (Exception e) {
+        throw new RuntimeException("Failed to find an available port for 
LocalStack container", e);
+      }

Review Comment:
   `RESTUtils.findAvailablePort(4566, 4666)` returns an available *host* port, 
but `BaseContainer.setupContainer()` treats `exposePorts` as the container’s 
*internal* ports (`container.addExposedPort(port)`). LocalStack listens on 4566 
by default (and existing tests build the endpoint with `:4566`), so exposing a 
random internal port will likely make `Wait.forListeningPort()` wait on a port 
where nothing is listening and break the container startup. Prefer always 
exposing 4566 (Testcontainers will still map it to a random host port), or if 
you truly need a different internal port then also configure LocalStack to 
listen on that port and update callers accordingly.



##########
integration-test-common/src/test/java/org/apache/gravitino/integration/test/container/GravitinoLocalStackContainer.java:
##########
@@ -57,7 +57,12 @@ public Builder() {
       super();
       this.image = DEFAULT_IMAGE;
       this.hostName = HOST_NAME;
-      this.exposePorts = ImmutableSet.of(PORT);
+      try {
+        int randomPort = RESTUtils.findAvailablePort(4566, 4666);
+        this.exposePorts = ImmutableSet.of(randomPort);
+      } catch (Exception e) {
+        throw new RuntimeException("Failed to find an available port for 
LocalStack container", e);
+      }

Review Comment:
   `RESTUtils.findAvailablePort` only declares `IOException`, so catching 
`Exception` here is overly broad and can hide unexpected failures. Prefer 
catching `IOException` (or letting it propagate) and avoid wrapping unrelated 
exceptions under the same message.



##########
integration-test-common/src/test/java/org/apache/gravitino/integration/test/container/GravitinoLocalStackContainer.java:
##########
@@ -57,7 +57,12 @@ public Builder() {
       super();
       this.image = DEFAULT_IMAGE;
       this.hostName = HOST_NAME;
-      this.exposePorts = ImmutableSet.of(PORT);
+      try {
+        int randomPort = RESTUtils.findAvailablePort(4566, 4666);
+        this.exposePorts = ImmutableSet.of(randomPort);

Review Comment:
   The PR title/description still contains the template placeholders and 
doesn’t explain the intent of switching LocalStack to a dynamic port range (and 
whether callers should keep using 4566 or a mapped port). Please update the PR 
description with the concrete motivation, expected behavior, and how it was 
tested so reviewers can validate the change correctly.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to