mirror of https://github.com/OpenVidu/openvidu.git
Test properties now can be set by environment variables
parent
4b604f107c
commit
50a09b0958
|
@ -19,9 +19,12 @@ package io.openvidu.test.e2e;
|
||||||
|
|
||||||
import static java.lang.invoke.MethodHandles.lookup;
|
import static java.lang.invoke.MethodHandles.lookup;
|
||||||
import static org.slf4j.LoggerFactory.getLogger;
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
|
import static java.lang.System.getProperty;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.DisplayName;
|
import org.junit.jupiter.api.DisplayName;
|
||||||
import org.junit.jupiter.api.Tag;
|
import org.junit.jupiter.api.Tag;
|
||||||
|
@ -53,24 +56,44 @@ import io.openvidu.test.e2e.browser.FirefoxUser;
|
||||||
@ExtendWith(SeleniumExtension.class)
|
@ExtendWith(SeleniumExtension.class)
|
||||||
@RunWith(JUnitPlatform.class)
|
@RunWith(JUnitPlatform.class)
|
||||||
public class OpenViduTestAppE2eTest {
|
public class OpenViduTestAppE2eTest {
|
||||||
|
|
||||||
|
static String OPENVIDU_SECRET = "MY_SECRET";
|
||||||
|
static String OPENVIDU_URL = "https://localhost:8443/";
|
||||||
|
static String APP_URL = "http://localhost:4200/";
|
||||||
static Exception ex = null;
|
static Exception ex = null;
|
||||||
private final Object lock = new Object();
|
private final Object lock = new Object();
|
||||||
|
|
||||||
final Logger log = getLogger(lookup().lookupClass());
|
final static Logger log = getLogger(lookup().lookupClass());
|
||||||
|
|
||||||
final String OPENVIDU_URL = "https://localhost:8443/";
|
|
||||||
final String OPENVIDU_SECRET = "MY_SECRET";
|
|
||||||
|
|
||||||
final String DEFAULT_APP_URL = "http://localhost:4200/";
|
|
||||||
|
|
||||||
BrowserUser user;
|
BrowserUser user;
|
||||||
|
|
||||||
|
@BeforeAll()
|
||||||
|
static void setupAll() {
|
||||||
|
String appUrl = getProperty("app.url");
|
||||||
|
if (appUrl != null) {
|
||||||
|
APP_URL = appUrl;
|
||||||
|
}
|
||||||
|
log.info("Using URL {} to connect to openvidu-testapp", APP_URL);
|
||||||
|
|
||||||
|
String openviduUrl = getProperty("openvidu.url");
|
||||||
|
if (openviduUrl != null) {
|
||||||
|
OPENVIDU_URL = openviduUrl;
|
||||||
|
}
|
||||||
|
log.info("Using URL {} to connect to openvidu-server", OPENVIDU_URL);
|
||||||
|
|
||||||
|
String openvidusecret = getProperty("openvidu.secret");
|
||||||
|
if (openvidusecret != null) {
|
||||||
|
OPENVIDU_SECRET = openvidusecret;
|
||||||
|
}
|
||||||
|
log.info("Using secret {} to connect to openvidu-server", OPENVIDU_SECRET);
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setup() {
|
void setup() {
|
||||||
this.user = new ChromeUser("TestUser", 30);
|
|
||||||
|
|
||||||
user.getDriver().get(DEFAULT_APP_URL);
|
this.user = new ChromeUser("TestUser", 45);
|
||||||
|
|
||||||
|
user.getDriver().get(APP_URL);
|
||||||
|
|
||||||
WebElement urlInput = user.getDriver().findElement(By.id("openvidu-url"));
|
WebElement urlInput = user.getDriver().findElement(By.id("openvidu-url"));
|
||||||
urlInput.clear();
|
urlInput.clear();
|
||||||
|
@ -81,6 +104,11 @@ public class OpenViduTestAppE2eTest {
|
||||||
|
|
||||||
user.getEventManager().startPolling();
|
user.getEventManager().startPolling();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
void dispose() {
|
||||||
|
user.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("One2One [Video + Audio]")
|
@DisplayName("One2One [Video + Audio]")
|
||||||
|
@ -139,8 +167,6 @@ public class OpenViduTestAppE2eTest {
|
||||||
user.getDriver().findElement(By.id("remove-user-btn")).click();
|
user.getDriver().findElement(By.id("remove-user-btn")).click();
|
||||||
|
|
||||||
user.getEventManager().waitUntilNumberOfEvent("sessionDisconnected", 2);
|
user.getEventManager().waitUntilNumberOfEvent("sessionDisconnected", 2);
|
||||||
|
|
||||||
user.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -176,8 +202,6 @@ public class OpenViduTestAppE2eTest {
|
||||||
user.getDriver().findElement(By.id("remove-user-btn")).click();
|
user.getDriver().findElement(By.id("remove-user-btn")).click();
|
||||||
|
|
||||||
user.getEventManager().waitUntilNumberOfEvent("sessionDisconnected", 2);
|
user.getEventManager().waitUntilNumberOfEvent("sessionDisconnected", 2);
|
||||||
|
|
||||||
user.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -194,8 +218,6 @@ public class OpenViduTestAppE2eTest {
|
||||||
user.getDriver().findElements(By.className(("leave-btn"))).get(0).click();
|
user.getDriver().findElements(By.className(("leave-btn"))).get(0).click();
|
||||||
|
|
||||||
user.getEventManager().waitUntilNumberOfEvent("streamDestroyed", 3);
|
user.getEventManager().waitUntilNumberOfEvent("streamDestroyed", 3);
|
||||||
|
|
||||||
user.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -217,8 +239,6 @@ public class OpenViduTestAppE2eTest {
|
||||||
user.getDriver().findElement(By.className(("leave-btn"))).click();
|
user.getDriver().findElement(By.className(("leave-btn"))).click();
|
||||||
|
|
||||||
user.getEventManager().waitUntilNumberOfEvent("sessionDisconnected", 1);
|
user.getEventManager().waitUntilNumberOfEvent("sessionDisconnected", 1);
|
||||||
|
|
||||||
user.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -241,8 +261,6 @@ public class OpenViduTestAppE2eTest {
|
||||||
user.getDriver().findElement(By.className(("leave-btn"))).click();
|
user.getDriver().findElement(By.className(("leave-btn"))).click();
|
||||||
|
|
||||||
user.getEventManager().waitUntilNumberOfEvent("sessionDisconnected", 1);
|
user.getEventManager().waitUntilNumberOfEvent("sessionDisconnected", 1);
|
||||||
|
|
||||||
user.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -282,11 +300,10 @@ public class OpenViduTestAppE2eTest {
|
||||||
|
|
||||||
user.getDriver().findElement(By.id(("remove-user-btn"))).sendKeys(Keys.ENTER);
|
user.getDriver().findElement(By.id(("remove-user-btn"))).sendKeys(Keys.ENTER);
|
||||||
user.getEventManager().waitUntilNumberOfEvent("sessionDisconnected", 4);
|
user.getEventManager().waitUntilNumberOfEvent("sessionDisconnected", 4);
|
||||||
|
|
||||||
user.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
||||||
@DisplayName("Secure Test")
|
@DisplayName("Secure Test")
|
||||||
void secureTest() throws Exception {
|
void secureTest() throws Exception {
|
||||||
|
|
||||||
|
@ -343,26 +360,25 @@ public class OpenViduTestAppE2eTest {
|
||||||
|
|
||||||
user.getDriver().findElement(By.id(("remove-user-btn"))).sendKeys(Keys.ENTER);
|
user.getDriver().findElement(By.id(("remove-user-btn"))).sendKeys(Keys.ENTER);
|
||||||
user.getEventManager().waitUntilNumberOfEvent("sessionDisconnected", 4);
|
user.getEventManager().waitUntilNumberOfEvent("sessionDisconnected", 4);
|
||||||
|
|
||||||
user.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
||||||
@DisplayName("Cross-Browser test")
|
@DisplayName("Cross-Browser test")
|
||||||
void crossBrowserTest() throws Exception {
|
void crossBrowserTest() throws Exception {
|
||||||
|
|
||||||
Thread.UncaughtExceptionHandler h = new Thread.UncaughtExceptionHandler() {
|
Thread.UncaughtExceptionHandler h = new Thread.UncaughtExceptionHandler() {
|
||||||
public void uncaughtException(Thread th, Throwable ex) {
|
public void uncaughtException(Thread th, Throwable ex) {
|
||||||
System.out.println("Uncaught exception: " + ex);
|
System.out.println("Uncaught exception: " + ex);
|
||||||
synchronized(lock) {
|
synchronized (lock) {
|
||||||
OpenViduTestAppE2eTest.ex = new Exception(ex);
|
OpenViduTestAppE2eTest.ex = new Exception(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Thread t = new Thread(() -> {
|
Thread t = new Thread(() -> {
|
||||||
BrowserUser user2 = new FirefoxUser("TestUser", 10);
|
BrowserUser user2 = new FirefoxUser("TestUser", 30);
|
||||||
user2.getDriver().get(DEFAULT_APP_URL);
|
user2.getDriver().get(APP_URL);
|
||||||
WebElement urlInput = user2.getDriver().findElement(By.id("openvidu-url"));
|
WebElement urlInput = user2.getDriver().findElement(By.id("openvidu-url"));
|
||||||
urlInput.clear();
|
urlInput.clear();
|
||||||
urlInput.sendKeys(OPENVIDU_URL);
|
urlInput.sendKeys(OPENVIDU_URL);
|
||||||
|
@ -371,13 +387,13 @@ public class OpenViduTestAppE2eTest {
|
||||||
secretInput.sendKeys(OPENVIDU_SECRET);
|
secretInput.sendKeys(OPENVIDU_SECRET);
|
||||||
|
|
||||||
user2.getEventManager().startPolling();
|
user2.getEventManager().startPolling();
|
||||||
|
|
||||||
user2.getDriver().findElement(By.id("add-user-btn")).click();
|
user2.getDriver().findElement(By.id("add-user-btn")).click();
|
||||||
user2.getDriver().findElement(By.className("join-btn")).click();
|
user2.getDriver().findElement(By.className("join-btn")).click();
|
||||||
try {
|
try {
|
||||||
user2.getEventManager().waitUntilNumberOfEvent("videoPlaying", 2);
|
user2.getEventManager().waitUntilNumberOfEvent("videoPlaying", 2);
|
||||||
Assert.assertTrue(user2.getEventManager().assertMediaTracks(user2.getDriver().findElements(By.tagName("video")),
|
Assert.assertTrue(user2.getEventManager()
|
||||||
true, true));
|
.assertMediaTracks(user2.getDriver().findElements(By.tagName("video")), true, true));
|
||||||
user2.getEventManager().waitUntilNumberOfEvent("streamDestroyed", 1);
|
user2.getEventManager().waitUntilNumberOfEvent("streamDestroyed", 1);
|
||||||
user2.getDriver().findElement(By.id("remove-user-btn")).click();
|
user2.getDriver().findElement(By.id("remove-user-btn")).click();
|
||||||
user2.getEventManager().waitUntilNumberOfEvent("sessionDisconnected", 1);
|
user2.getEventManager().waitUntilNumberOfEvent("sessionDisconnected", 1);
|
||||||
|
@ -389,26 +405,22 @@ public class OpenViduTestAppE2eTest {
|
||||||
});
|
});
|
||||||
t.setUncaughtExceptionHandler(h);
|
t.setUncaughtExceptionHandler(h);
|
||||||
t.start();
|
t.start();
|
||||||
|
|
||||||
|
|
||||||
user.getDriver().findElement(By.id("add-user-btn")).click();
|
user.getDriver().findElement(By.id("add-user-btn")).click();
|
||||||
user.getDriver().findElement(By.className("join-btn")).click();
|
user.getDriver().findElement(By.className("join-btn")).click();
|
||||||
|
|
||||||
user.getEventManager().waitUntilNumberOfEvent("videoPlaying", 2);
|
user.getEventManager().waitUntilNumberOfEvent("videoPlaying", 2);
|
||||||
|
|
||||||
|
|
||||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||||
true, true));
|
true, true));
|
||||||
|
|
||||||
user.getDriver().findElement(By.id("remove-user-btn")).click();
|
user.getDriver().findElement(By.id("remove-user-btn")).click();
|
||||||
|
|
||||||
user.getEventManager().waitUntilNumberOfEvent("sessionDisconnected", 1);
|
user.getEventManager().waitUntilNumberOfEvent("sessionDisconnected", 1);
|
||||||
|
|
||||||
user.dispose();
|
|
||||||
|
|
||||||
t.join();
|
t.join();
|
||||||
|
|
||||||
synchronized(lock) {
|
synchronized (lock) {
|
||||||
if (OpenViduTestAppE2eTest.ex != null) {
|
if (OpenViduTestAppE2eTest.ex != null) {
|
||||||
throw OpenViduTestAppE2eTest.ex;
|
throw OpenViduTestAppE2eTest.ex;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue