From dfa12ffbb8ffa090f4eb5006171d7d28d2e4cf35 Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Tue, 13 Oct 2020 14:00:54 +0200 Subject: [PATCH] openvidu-test-e2e: fix Pro e2e tests --- .../test/java/io/openvidu/test/e2e/MyUser.java | 2 +- .../openvidu/test/e2e/OpenViduEventManager.java | 16 +++++++++------- .../test/e2e/OpenViduProTestAppE2eTest.java | 17 +++++++++-------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/MyUser.java b/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/MyUser.java index 3a7952b1..8ed6a980 100644 --- a/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/MyUser.java +++ b/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/MyUser.java @@ -28,7 +28,7 @@ public class MyUser { } public void dispose() { - this.eventManager.stopPolling(true); + this.eventManager.stopPolling(true, true); this.browserUser.dispose(); } diff --git a/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduEventManager.java b/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduEventManager.java index 4105fdab..db1a8d22 100644 --- a/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduEventManager.java +++ b/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduEventManager.java @@ -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 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); diff --git a/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduProTestAppE2eTest.java b/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduProTestAppE2eTest.java index 3ab0585b..132a0a6e 100644 --- a/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduProTestAppE2eTest.java +++ b/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduProTestAppE2eTest.java @@ -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