Skip to content

Commit 6982e85

Browse files
hvadehracopybara-github
authored andcommitted
Pick a random unused port in StarlarkDebugIntegrationTest
PiperOrigin-RevId: 587042424 Change-Id: I4bcef0dd30ebe6b953d7dfafb3fe2e2f4679dfbe
1 parent a54816a commit 6982e85

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/test/java/com/google/devtools/build/lib/starlarkdebug/server/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ java_test(
8686
"//src/main/java/com/google/devtools/build/lib/vfs",
8787
"//src/main/java/com/google/devtools/build/skyframe",
8888
"//src/test/java/com/google/devtools/build/lib/buildtool/util",
89+
"//src/test/java/com/google/devtools/build/lib/remote/util:integration_test_utils",
8990
"//src/test/java/com/google/devtools/build/lib/testutil:JunitUtils",
9091
"//third_party:guava",
9192
"//third_party:junit4",

src/test/java/com/google/devtools/build/lib/starlarkdebug/server/StarlarkDebugIntegrationTest.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.google.devtools.build.lib.events.Event;
2828
import com.google.devtools.build.lib.events.EventCollector;
2929
import com.google.devtools.build.lib.events.EventKind;
30+
import com.google.devtools.build.lib.remote.util.IntegrationTestUtils;
3031
import com.google.devtools.build.lib.runtime.BlazeRuntime;
3132
import com.google.devtools.build.lib.starlarkdebug.module.StarlarkDebuggerModule;
3233
import com.google.devtools.build.lib.starlarkdebugging.StarlarkDebuggingProtos.Breakpoint;
@@ -62,7 +63,15 @@
6263
public class StarlarkDebugIntegrationTest extends BuildIntegrationTestCase {
6364
private static final AtomicInteger sequenceIds = new AtomicInteger(1);
6465

65-
private static final int DEBUG_PORT = 7300;
66+
private static final int DEBUG_PORT = getRandomPort();
67+
68+
private static int getRandomPort() {
69+
try {
70+
return IntegrationTestUtils.pickUnusedRandomPort();
71+
} catch (IOException | InterruptedException e) {
72+
throw new RuntimeException(e);
73+
}
74+
}
6675

6776
private final ExecutorService executor = Executors.newFixedThreadPool(1);
6877
private final Collection<Event> eventCollector = new ConcurrentLinkedQueue<>();

0 commit comments

Comments
 (0)