openvidu-test-e2e: fix Pro e2e tests

pull/550/head
pabloFuente 2020-10-13 14:00:54 +02:00
parent 5e5d886e59
commit dfa12ffbb8
3 changed files with 19 additions and 16 deletions

View File

@ -28,7 +28,7 @@ public class MyUser {
}
public void dispose() {
this.eventManager.stopPolling(true);
this.eventManager.stopPolling(true, true);
this.browserUser.dispose();
}

View File

@ -101,7 +101,7 @@ public class OpenViduEventManager {
public void uncaughtException(Thread th, Throwable ex) {
if (ex.getClass().getSimpleName().equals("UnhandledAlertException")
&& ex.getMessage().contains("unexpected alert open")) {
stopPolling(false);
stopPolling(false, false);
System.err
.println("Alert opened (" + ex.getMessage() + "). Waiting 1 second and restarting polling");
try {
@ -138,14 +138,16 @@ public class OpenViduEventManager {
this.pollingThread.start();
}
public void stopPolling(boolean stopThread) {
public void stopPolling(boolean stopThread, boolean cleanExistingEvents) {
if (stopThread) {
this.isInterrupted.set(true);
this.pollingThread.interrupt();
}
this.eventCallbacks.clear();
this.eventCountdowns.clear();
this.eventNumbers.clear();
if (cleanExistingEvents) {
this.eventCallbacks.clear();
this.eventCountdowns.clear();
this.eventNumbers.clear();
}
}
public void on(String eventName, Consumer<JsonObject> callback) {
@ -195,12 +197,12 @@ public class OpenViduEventManager {
}
public void resetEventThread() throws InterruptedException {
this.stopPolling(true);
this.stopPolling(true, true);
this.pollingLatch.await();
this.execService.shutdownNow();
this.execService.awaitTermination(10, TimeUnit.SECONDS);
this.execService = Executors.newCachedThreadPool();
this.stopPolling(false);
this.stopPolling(false, true);
this.clearAllCurrentEvents();
this.isInterrupted.set(false);
this.pollingLatch = new CountDownLatch(1);

View File

@ -38,6 +38,7 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
@BeforeAll()
protected static void setupAll() {
checkFfmpegInstallation();
loadEnvironmentVariables();
setupBrowserDrivers();
cleanFoldersAndSetUpOpenViduJavaClient();
@ -252,14 +253,6 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
user.getDriver().findElement(By.cssSelector("#openvidu-instance-0 .join-btn")).sendKeys(Keys.ENTER);
user.getEventManager().waitUntilEventReaches("connectionCreated", 1);
user.getEventManager().waitUntilEventReaches("accessAllowed", 1);
Assert.assertTrue("Session object should have changed", session.fetch());
connection = session.getActiveConnections().get(0);
Assert.assertEquals("Wrong role in Connection object", OpenViduRole.SUBSCRIBER, connection.getRole());
Assert.assertFalse("Wrong record in Connection object", connection.record());
try {
user.getWaiter().until(ExpectedConditions.alertIsPresent());
Alert alert = user.getDriver().switchTo().alert();
@ -271,6 +264,14 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
}
Thread.sleep(500);
user.getEventManager().waitUntilEventReaches("connectionCreated", 1);
user.getEventManager().waitUntilEventReaches("accessAllowed", 1);
Assert.assertTrue("Session object should have changed", session.fetch());
connection = session.getActiveConnections().get(0);
Assert.assertEquals("Wrong role in Connection object", OpenViduRole.SUBSCRIBER, connection.getRole());
Assert.assertFalse("Wrong record in Connection object", connection.record());
/** UPDATE CONNECTION **/
// Test with REST API