openvidu-test-e2e: extend waitForContainerIpAddress method

pull/780/head
pabloFuente 2023-02-21 15:41:10 +01:00
parent 1111c62bfe
commit 0fc9b05f93
1 changed files with 16 additions and 9 deletions

View File

@ -25,7 +25,6 @@ import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.apache.commons.validator.routines.InetAddressValidator;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.openqa.selenium.By; import org.openqa.selenium.By;
@ -883,17 +882,25 @@ public class OpenViduTestE2e {
throws TimeoutException, UnknownHostException, InterruptedException { throws TimeoutException, UnknownHostException, InterruptedException {
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
long maxTime = currentTime + (secondsTimeout * 1000); long maxTime = currentTime + (secondsTimeout * 1000);
InetAddressValidator validator = InetAddressValidator.getInstance(); try {
while (System.currentTimeMillis() < maxTime) { while (System.currentTimeMillis() < maxTime) {
try { try {
String ip = MediaNodeDockerUtils.getContainerIp(containerNameOrId); String ip = MediaNodeDockerUtils.getContainerIp(containerNameOrId);
if (validator.isValid(ip)) { if (ip.isBlank()) {
log.warn("Container IP address is empty for container {}", containerNameOrId);
} else {
return ip; return ip;
} }
} catch (Exception e) { } catch (Exception e) {
log.error("Error obtaining container IP address for container {}: {}", containerNameOrId,
e.getMessage());
} }
Thread.sleep(50); Thread.sleep(50);
} }
} finally {
log.info("Logging docker inspect info");
log.info(commandLine.executeCommand("docker inspect " + containerNameOrId, 10));
}
throw new TimeoutException(); throw new TimeoutException();
} }