openvidu-test-e2e: relax synchronization of browser launch

pull/884/merge
pabloFuente 2026-06-03 12:09:32 +02:00
parent c67e820e93
commit 09cf208f73
2 changed files with 26 additions and 21 deletions

View File

@ -14,10 +14,10 @@ import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
@ -116,8 +116,8 @@ public class OpenViduTestE2e {
protected static final CommandLineExecutor commandLine = new CommandLineExecutor(); protected static final CommandLineExecutor commandLine = new CommandLineExecutor();
protected static final String RECORDING_IMAGE = "openvidu/openvidu-recording"; protected static final String RECORDING_IMAGE = "openvidu/openvidu-recording";
protected Collection<BrowserUser> browserUsers = new HashSet<>(); protected Collection<BrowserUser> browserUsers = ConcurrentHashMap.newKeySet();
protected static Collection<GenericContainer<?>> containers = new HashSet<>(); protected static Collection<GenericContainer<?>> containers = ConcurrentHashMap.newKeySet();
protected static RoomServiceClient LK; protected static RoomServiceClient LK;
protected static IngressServiceClient LK_INGRESS; protected static IngressServiceClient LK_INGRESS;
@ -512,18 +512,22 @@ public class OpenViduTestE2e {
return browserUser; return browserUser;
} }
private static synchronized boolean setupBrowserAux(BrowserNames browser, GenericContainer<?> container, boolean forceRestart) { private static final Map<BrowserNames, Object> browserSetupLocks = new ConcurrentHashMap<>();
private static boolean setupBrowserAux(BrowserNames browser, GenericContainer<?> container, boolean forceRestart) {
if (isRemote(browser)) { if (isRemote(browser)) {
String dockerImage = container.getDockerImageName(); synchronized (browserSetupLocks.computeIfAbsent(browser, b -> new Object())) {
String ps = commandLine.executeCommand("docker ps | grep " + dockerImage, 30); String dockerImage = container.getDockerImageName();
boolean containerAlreadyRunning = container.isRunning() || !ps.isBlank(); String ps = commandLine.executeCommand("docker ps | grep " + dockerImage, 30);
if (forceRestart && containerAlreadyRunning) { boolean containerAlreadyRunning = container.isRunning() || !ps.isBlank();
container.stop(); if (forceRestart && containerAlreadyRunning) {
} container.stop();
if (!containerAlreadyRunning) { }
container.start(); if (!containerAlreadyRunning) {
containers.add(container); container.start();
return true; containers.add(container);
return true;
}
} }
} }
return false; return false;

View File

@ -1338,7 +1338,7 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
final java.util.concurrent.atomic.AtomicLong subscriber1920AtMs = new java.util.concurrent.atomic.AtomicLong( final java.util.concurrent.atomic.AtomicLong subscriber1920AtMs = new java.util.concurrent.atomic.AtomicLong(
-1); -1);
final String publisherBrowser = subscriberBrowser == "chromeTwoInstances" ? "chromeTwoInstances" : "chrome"; final String publisherBrowser = "chromeTwoInstances".equals(subscriberBrowser) ? "chromeTwoInstances" : "chrome";
Future<?> task1 = executor.submit(() -> { Future<?> task1 = executor.submit(() -> {
try { try {
@ -3590,13 +3590,14 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
Assertions.fail(errMsg); Assertions.fail(errMsg);
} }
} finally { } finally {
// Close dialog // Best-effort close of the info dialog
user.getWaiter().until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("#close-dialog-btn")));
this.waitForBackdropAndClick(user, "#close-dialog-btn");
try { try {
Thread.sleep(500); if (!user.getDriver().findElements(By.cssSelector("#close-dialog-btn")).isEmpty()) {
} catch (InterruptedException e) { this.waitForBackdropAndClick(user, "#close-dialog-btn");
e.printStackTrace(); Thread.sleep(500);
}
} catch (Exception e) {
log.warn("Best-effort info-dialog close failed (ignored): {}", e.getMessage());
} }
} }
} }