Skip to content

Commit

Permalink
test (jkube-kit/remote-dev) : Fix intermittent failures of RemoteDeve…
Browse files Browse the repository at this point in the history
…lopmentServiceTest

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
  • Loading branch information
rohanKanojia committed Jan 24, 2024
1 parent be0ce2e commit 4df383a
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;

import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.times;
Expand Down Expand Up @@ -118,8 +121,11 @@ void startFailsIfLocalPortInUse() {
remoteDevelopmentService = new RemoteDevelopmentService(
logger, kubernetesClient, RemoteDevelopmentConfig.builder().remoteService(remoteService).build());
assertThatThrownBy(() -> {
try (ServerSocket localPortInUse = new ServerSocket(localPort)) {
try (ServerSocket localPortInUse = new ServerSocket(localPort, 50, InetAddress.getByName("localhost"))) {
// When
try (Socket socket = new Socket("localhost", localPortInUse.getLocalPort())) {
assertThat(socket.isBound()).isTrue();
}
remoteDevelopmentService.start();
}
})
Expand Down

0 comments on commit 4df383a

Please sign in to comment.