openvidu-test-e2e: more time for events in wehookTest

pull/669/head
pabloFuente 2021-11-13 01:18:40 +01:00
parent 90b075cc7f
commit 5cfdd5d039
2 changed files with 11 additions and 5 deletions

View File

@ -23,6 +23,7 @@ import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
@ -63,13 +64,13 @@ public class CustomWebhook {
CustomWebhook.events.clear();
}
public synchronized static JsonObject waitForEvent(String eventName, int maxSecondsWait) throws Exception {
public synchronized static JsonObject waitForEvent(String eventName, int maxSecondsWait) throws TimeoutException, InterruptedException {
if (events.get(eventName) == null) {
events.put(eventName, new LinkedBlockingDeque<>());
}
JsonObject event = CustomWebhook.events.get(eventName).poll(maxSecondsWait, TimeUnit.SECONDS);
if (event == null) {
throw new Exception("Timeout waiting for Webhook " + eventName);
throw new TimeoutException("Timeout waiting for Webhook " + eventName);
} else {
return event;
}

View File

@ -3790,9 +3790,9 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
user.getDriver().findElement(By.cssSelector("#openvidu-instance-1 .join-btn")).click();
event = CustomWebhook.waitForEvent("participantJoined", 2);
CustomWebhook.waitForEvent("webrtcConnectionCreated", 2);
CustomWebhook.waitForEvent("webrtcConnectionCreated", 2);
CustomWebhook.waitForEvent("webrtcConnectionCreated", 2);
CustomWebhook.waitForEvent("webrtcConnectionCreated", 5);
CustomWebhook.waitForEvent("webrtcConnectionCreated", 5);
CustomWebhook.waitForEvent("webrtcConnectionCreated", 5);
String connectionId2 = event.get("connectionId").getAsString();
@ -3888,6 +3888,11 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
Assert.assertEquals("Wrong session destroyed reason in webhook event", "sessionClosedByServer",
event.get("reason").getAsString());
} catch (TimeoutException e) {
log.error("Timeout: {}", e.getMessage());
e.printStackTrace();
System.out.println(getBase64Screenshot(user.getBrowserUser()));
Assert.fail(e.getMessage());
} finally {
CustomWebhook.shutDown();
}