mirror of https://github.com/OpenVidu/openvidu.git
openvidu-test-e2e: get container IP using DockerClient
parent
f7f2708b1f
commit
1111c62bfe
|
@ -22,7 +22,7 @@ public class MediaNodeDockerUtils {
|
||||||
dockerClient.removeContainerCmd(containerId).withForce(true).exec();
|
dockerClient.removeContainerCmd(containerId).withForce(true).exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getMediaNodeIp(String containerId) {
|
public static String getContainerIp(String containerId) {
|
||||||
DockerClient dockerClient = getDockerClient();
|
DockerClient dockerClient = getDockerClient();
|
||||||
return dockerClient.inspectContainerCmd(containerId).exec().getNetworkSettings().getNetworks().get("bridge")
|
return dockerClient.inspectContainerCmd(containerId).exec().getNetworkSettings().getNetworks().get("bridge")
|
||||||
.getIpAddress();
|
.getIpAddress();
|
||||||
|
|
|
@ -864,8 +864,9 @@ public class OpenViduTestE2e {
|
||||||
* https://github.com/tiangolo/nginx-rtmp-docker
|
* https://github.com/tiangolo/nginx-rtmp-docker
|
||||||
*
|
*
|
||||||
* @return The IP address of the Docker container
|
* @return The IP address of the Docker container
|
||||||
|
* @throws InterruptedException
|
||||||
*/
|
*/
|
||||||
protected static String startRtmpServer() throws IOException, TimeoutException {
|
protected static String startRtmpServer() throws IOException, TimeoutException, InterruptedException {
|
||||||
File file = writeRtmpServerConfigInFile();
|
File file = writeRtmpServerConfigInFile();
|
||||||
String dockerRunCommand = "docker run -d --name broadcast-nginx -p 1935:1935 -v " + file.getAbsolutePath()
|
String dockerRunCommand = "docker run -d --name broadcast-nginx -p 1935:1935 -v " + file.getAbsolutePath()
|
||||||
+ ":/etc/nginx/nginx.conf tiangolo/nginx-rtmp";
|
+ ":/etc/nginx/nginx.conf tiangolo/nginx-rtmp";
|
||||||
|
@ -879,16 +880,19 @@ public class OpenViduTestE2e {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String waitForContainerIpAddress(String containerNameOrId, int secondsTimeout)
|
protected static String waitForContainerIpAddress(String containerNameOrId, int secondsTimeout)
|
||||||
throws TimeoutException, UnknownHostException {
|
throws TimeoutException, UnknownHostException, InterruptedException {
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
long maxTime = currentTime + (secondsTimeout * 1000);
|
long maxTime = currentTime + (secondsTimeout * 1000);
|
||||||
while (System.currentTimeMillis() < maxTime) {
|
|
||||||
String ip = commandLine.executeCommand(
|
|
||||||
"docker container inspect -f '{{ .NetworkSettings.IPAddress }}' " + containerNameOrId, 3);
|
|
||||||
InetAddressValidator validator = InetAddressValidator.getInstance();
|
InetAddressValidator validator = InetAddressValidator.getInstance();
|
||||||
|
while (System.currentTimeMillis() < maxTime) {
|
||||||
|
try {
|
||||||
|
String ip = MediaNodeDockerUtils.getContainerIp(containerNameOrId);
|
||||||
if (validator.isValid(ip)) {
|
if (validator.isValid(ip)) {
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
Thread.sleep(50);
|
||||||
}
|
}
|
||||||
throw new TimeoutException();
|
throw new TimeoutException();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue