Skip to content

Commit

Permalink
Merge pull request #405 from camunda/366-use-dynamic-free-port
Browse files Browse the repository at this point in the history
chore: use ephemeral free port
  • Loading branch information
pihme authored Jun 16, 2022
2 parents 190f1d6 + dcbd94f commit 5d56825
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,24 @@
import io.camunda.zeebe.util.sched.clock.ControlledActorClock;
import io.grpc.Server;
import io.grpc.ServerBuilder;
import java.io.IOException;
import java.net.ServerSocket;
import java.util.concurrent.CompletableFuture;

public class EngineFactory {

public static ZeebeTestEngine create() {
return create(26499);
return create(findFreePort());
}

private static int findFreePort() {
final int freePort;
try (final var serverSocket = new ServerSocket(0)) {
freePort = serverSocket.getLocalPort();
} catch (final IOException e) {
throw new RuntimeException(e);
}
return freePort;
}

public static ZeebeTestEngine create(final int port) {
Expand Down

0 comments on commit 5d56825

Please sign in to comment.