openvidu-test-e2e: make broadcast IP an env variable

pull/780/head
pabloFuente 2023-02-20 21:35:49 +01:00
parent 2b9b532656
commit 175585b2f1
3 changed files with 29 additions and 19 deletions

View File

@ -116,7 +116,8 @@ function openviduE2ETests {
-DREMOTE_URL_FIREFOX="http://${DOCKER_HOST_IP}:6667/wd/hub/" \ -DREMOTE_URL_FIREFOX="http://${DOCKER_HOST_IP}:6667/wd/hub/" \
-DREMOTE_URL_OPERA="http://${DOCKER_HOST_IP}:6668/wd/hub/" \ -DREMOTE_URL_OPERA="http://${DOCKER_HOST_IP}:6668/wd/hub/" \
-DREMOTE_URL_EDGE="http://${DOCKER_HOST_IP}:6669/wd/hub/" \ -DREMOTE_URL_EDGE="http://${DOCKER_HOST_IP}:6669/wd/hub/" \
-DEXTERNAL_CUSTOM_LAYOUT_PARAMS="sessionId,CUSTOM_LAYOUT_SESSION,secret,MY_SECRET" test -DEXTERNAL_CUSTOM_LAYOUT_PARAMS="sessionId,CUSTOM_LAYOUT_SESSION,secret,MY_SECRET" \
test
elif [[ "${MEDIA_SERVER}" == "mediasoup" ]]; then elif [[ "${MEDIA_SERVER}" == "mediasoup" ]]; then
@ -135,7 +136,8 @@ function openviduE2ETests {
-DREMOTE_URL_EDGE="http://${DOCKER_HOST_IP}:6669/wd/hub/" \ -DREMOTE_URL_EDGE="http://${DOCKER_HOST_IP}:6669/wd/hub/" \
-DEXTERNAL_CUSTOM_LAYOUT_PARAMS="sessionId,CUSTOM_LAYOUT_SESSION,secret,MY_SECRET" \ -DEXTERNAL_CUSTOM_LAYOUT_PARAMS="sessionId,CUSTOM_LAYOUT_SESSION,secret,MY_SECRET" \
-DOPENVIDU_PRO_LICENSE="${OPENVIDU_PRO_LICENSE}" \ -DOPENVIDU_PRO_LICENSE="${OPENVIDU_PRO_LICENSE}" \
-DOPENVIDU_PRO_LICENSE_API="${OPENVIDU_PRO_LICENSE_API}" test -DOPENVIDU_PRO_LICENSE_API="${OPENVIDU_PRO_LICENSE_API}" \
test
else else
echo "Not valid media server" echo "Not valid media server"

View File

@ -85,6 +85,7 @@ public class OpenViduTestE2e {
protected static String OPENVIDU_PRO_SPEECH_TO_TEXT = "vosk"; protected static String OPENVIDU_PRO_SPEECH_TO_TEXT = "vosk";
protected static String DOCKERHUB_PRIVATE_REGISTRY_PASSWORD = "not_valid"; protected static String DOCKERHUB_PRIVATE_REGISTRY_PASSWORD = "not_valid";
protected static String EXTERNAL_CUSTOM_LAYOUT_PARAMS = "sessionId,CUSTOM_LAYOUT_SESSION,secret,MY_SECRET"; protected static String EXTERNAL_CUSTOM_LAYOUT_PARAMS = "sessionId,CUSTOM_LAYOUT_SESSION,secret,MY_SECRET";
protected static String BROADCAST_IP = "172.17.0.1";
protected static String AWS_REGION = "fakeRegion"; protected static String AWS_REGION = "fakeRegion";
protected static String AWS_ACCESS_KEY_ID = "fakeKey"; protected static String AWS_ACCESS_KEY_ID = "fakeKey";
@ -357,6 +358,12 @@ public class OpenViduTestE2e {
OPENVIDU_DEPLOYMENT = openviduDeployment; OPENVIDU_DEPLOYMENT = openviduDeployment;
} }
log.info("Using URL {} to connect to OpenVidu deployment", OPENVIDU_DEPLOYMENT); log.info("Using URL {} to connect to OpenVidu deployment", OPENVIDU_DEPLOYMENT);
String broadcastIp = System.getProperty("BROADCAST_IP");
if (broadcastIp != null) {
BROADCAST_IP = broadcastIp;
}
log.info("Using IP {} to broadcast", BROADCAST_IP);
} }
protected BrowserUser setupBrowser(String browser) throws Exception { protected BrowserUser setupBrowser(String browser) throws Exception {

View File

@ -1093,13 +1093,13 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
startRtmpServer(); startRtmpServer();
// Start broadcast // Start broadcast
try { try {
OV.startBroadcast("NOT_EXISTS", "rtmp://172.17.0.1/live"); OV.startBroadcast("NOT_EXISTS", "rtmp://" + BROADCAST_IP + "/live");
Assertions.fail("Expected OpenViduHttpException exception"); Assertions.fail("Expected OpenViduHttpException exception");
} catch (OpenViduHttpException exception) { } catch (OpenViduHttpException exception) {
Assertions.assertEquals(HttpURLConnection.HTTP_NOT_FOUND, exception.getStatus(), "Wrong HTTP status"); Assertions.assertEquals(HttpURLConnection.HTTP_NOT_FOUND, exception.getStatus(), "Wrong HTTP status");
} }
try { try {
OV.startBroadcast(session.getSessionId(), "rtmp://172.17.0.1/live"); OV.startBroadcast(session.getSessionId(), "rtmp://" + BROADCAST_IP + "/live");
Assertions.fail("Expected OpenViduHttpException exception"); Assertions.fail("Expected OpenViduHttpException exception");
} catch (OpenViduHttpException exception) { } catch (OpenViduHttpException exception) {
Assertions.assertEquals(HttpURLConnection.HTTP_NOT_ACCEPTABLE, exception.getStatus(), Assertions.assertEquals(HttpURLConnection.HTTP_NOT_ACCEPTABLE, exception.getStatus(),
@ -1115,7 +1115,7 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
session = OV.getActiveSession("TestSession"); session = OV.getActiveSession("TestSession");
Assertions.assertFalse(session.fetch()); Assertions.assertFalse(session.fetch());
OV.startBroadcast("TestSession", "rtmp://172.17.0.1/live", OV.startBroadcast("TestSession", "rtmp://" + BROADCAST_IP + "/live",
new RecordingProperties.Builder().resolution("1280x800").build()); new RecordingProperties.Builder().resolution("1280x800").build());
user.getEventManager().waitUntilEventReaches("broadcastStarted", 1); user.getEventManager().waitUntilEventReaches("broadcastStarted", 1);
Assertions.assertFalse(session.fetch()); Assertions.assertFalse(session.fetch());
@ -2819,7 +2819,7 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
Thread.sleep(750); Thread.sleep(750);
WebElement broadcastUrlField = user.getDriver().findElement(By.id("broadcasturl-id-field")); WebElement broadcastUrlField = user.getDriver().findElement(By.id("broadcasturl-id-field"));
broadcastUrlField.clear(); broadcastUrlField.clear();
broadcastUrlField.sendKeys("rtmp://172.17.0.1/live"); broadcastUrlField.sendKeys("rtmp://" + BROADCAST_IP + "/live");
user.getDriver().findElement(By.id("start-broadcast-btn")).click(); user.getDriver().findElement(By.id("start-broadcast-btn")).click();
user.getWaiter() user.getWaiter()
.until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value", "Error [404]")); .until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value", "Error [404]"));
@ -2885,9 +2885,9 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
restClient.rest(HttpMethod.POST, "/openvidu/api/broadcast/start", body, HttpURLConnection.HTTP_BAD_REQUEST); restClient.rest(HttpMethod.POST, "/openvidu/api/broadcast/start", body, HttpURLConnection.HTTP_BAD_REQUEST);
body = "{'session':'TestSession'}"; body = "{'session':'TestSession'}";
restClient.rest(HttpMethod.POST, "/openvidu/api/broadcast/start", body, HttpURLConnection.HTTP_BAD_REQUEST); restClient.rest(HttpMethod.POST, "/openvidu/api/broadcast/start", body, HttpURLConnection.HTTP_BAD_REQUEST);
body = "{'broadcastUrl':'rtmp://172.17.0.1/live'}"; body = "{'broadcastUrl':'rtmp://" + BROADCAST_IP + "/live'}";
restClient.rest(HttpMethod.POST, "/openvidu/api/broadcast/start", body, HttpURLConnection.HTTP_BAD_REQUEST); restClient.rest(HttpMethod.POST, "/openvidu/api/broadcast/start", body, HttpURLConnection.HTTP_BAD_REQUEST);
body = "{'session':false,'broadcastUrl':'rtmp://172.17.0.1/live'}"; body = "{'session':false,'broadcastUrl':'rtmp://" + BROADCAST_IP + "/live'}";
restClient.rest(HttpMethod.POST, "/openvidu/api/broadcast/start", body, HttpURLConnection.HTTP_BAD_REQUEST); restClient.rest(HttpMethod.POST, "/openvidu/api/broadcast/start", body, HttpURLConnection.HTTP_BAD_REQUEST);
body = "{'session':'TestSession','broadcastUrl':123}"; body = "{'session':'TestSession','broadcastUrl':123}";
restClient.rest(HttpMethod.POST, "/openvidu/api/broadcast/start", body, HttpURLConnection.HTTP_BAD_REQUEST); restClient.rest(HttpMethod.POST, "/openvidu/api/broadcast/start", body, HttpURLConnection.HTTP_BAD_REQUEST);
@ -2895,25 +2895,25 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
restClient.commonRestString(HttpMethod.POST, "/openvidu/api/broadcast/start", body, restClient.commonRestString(HttpMethod.POST, "/openvidu/api/broadcast/start", body,
HttpURLConnection.HTTP_BAD_REQUEST); HttpURLConnection.HTTP_BAD_REQUEST);
// 404 // 404
body = "{'session':'NOT_EXISTS','broadcastUrl':'rtmp://172.17.0.1/live'}"; body = "{'session':'NOT_EXISTS','broadcastUrl':'rtmp://" + BROADCAST_IP + "/live'}";
restClient.rest(HttpMethod.POST, "/openvidu/api/broadcast/start", body, HttpURLConnection.HTTP_NOT_FOUND); restClient.rest(HttpMethod.POST, "/openvidu/api/broadcast/start", body, HttpURLConnection.HTTP_NOT_FOUND);
// 406 // 406
String notActiveSessionId = restClient String notActiveSessionId = restClient
.rest(HttpMethod.POST, "/openvidu/api/sessions", body, HttpURLConnection.HTTP_OK).get("id") .rest(HttpMethod.POST, "/openvidu/api/sessions", body, HttpURLConnection.HTTP_OK).get("id")
.getAsString(); .getAsString();
body = "{'session':'" + notActiveSessionId + "','broadcastUrl':'rtmp://172.17.0.1/live'}"; body = "{'session':'" + notActiveSessionId + "','broadcastUrl':'rtmp://" + BROADCAST_IP + "/live'}";
restClient.rest(HttpMethod.POST, "/openvidu/api/broadcast/start", body, restClient.rest(HttpMethod.POST, "/openvidu/api/broadcast/start", body,
HttpURLConnection.HTTP_NOT_ACCEPTABLE); HttpURLConnection.HTTP_NOT_ACCEPTABLE);
// 422 // 422
body = "{'session':'TestSession','broadcastUrl':'rtmp://172.17.0.1/live','resolution':'99x1280'}"; body = "{'session':'TestSession','broadcastUrl':'rtmp://" + BROADCAST_IP + "/live','resolution':'99x1280'}";
restClient.rest(HttpMethod.POST, "/openvidu/api/broadcast/start", body, 422); restClient.rest(HttpMethod.POST, "/openvidu/api/broadcast/start", body, 422);
// 500 (Connection refused) // 500 (Connection refused)
body = "{'session':'TestSession','broadcastUrl':'rtmps://172.17.0.1/live'}"; body = "{'session':'TestSession','broadcastUrl':'rtmps://" + BROADCAST_IP + "/live'}";
String errorResponse = restClient.commonRestString(HttpMethod.POST, "/openvidu/api/broadcast/start", body, String errorResponse = restClient.commonRestString(HttpMethod.POST, "/openvidu/api/broadcast/start", body,
HttpURLConnection.HTTP_INTERNAL_ERROR); HttpURLConnection.HTTP_INTERNAL_ERROR);
Assertions.assertTrue( Assertions.assertTrue(
errorResponse.contains("Cannot open connection") errorResponse.contains("Cannot open connection")
&& errorResponse.contains("rtmps://172.17.0.1/live: Connection refused"), && errorResponse.contains("rtmps://" + BROADCAST_IP + "/live: Connection refused"),
"Broadcast error message does not contain expected message"); "Broadcast error message does not contain expected message");
// 500 (Input/output error) // 500 (Input/output error)
body = "{'session':'TestSession','broadcastUrl':'rtmp://not.exists'}"; body = "{'session':'TestSession','broadcastUrl':'rtmp://not.exists'}";
@ -2922,22 +2922,22 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
Assertions.assertTrue(errorResponse.contains("rtmp://not.exists: Input/output error"), Assertions.assertTrue(errorResponse.contains("rtmp://not.exists: Input/output error"),
"Broadcast error message does not contain expected message"); "Broadcast error message does not contain expected message");
// 500 (Protocol not found) // 500 (Protocol not found)
body = "{'session':'TestSession','broadcastUrl':'schemefail://172.17.0.1/live'}"; body = "{'session':'TestSession','broadcastUrl':'schemefail://" + BROADCAST_IP + "/live'}";
errorResponse = restClient.commonRestString(HttpMethod.POST, "/openvidu/api/broadcast/start", body, errorResponse = restClient.commonRestString(HttpMethod.POST, "/openvidu/api/broadcast/start", body,
HttpURLConnection.HTTP_INTERNAL_ERROR); HttpURLConnection.HTTP_INTERNAL_ERROR);
Assertions.assertTrue(errorResponse.contains("schemefail://172.17.0.1/live: Protocol not found"), Assertions.assertTrue(errorResponse.contains("schemefail://" + BROADCAST_IP + "/live: Protocol not found"),
"Broadcast error message does not contain expected message"); "Broadcast error message does not contain expected message");
// Concurrent broadcast // Concurrent broadcast
final int PETITIONS = 20; final int PETITIONS = 20;
List<String> responses = new ArrayList<>(); List<String> responses = new ArrayList<>();
List<Exception> exceptions = new ArrayList<>(); List<Exception> exceptions = new ArrayList<>();
CountDownLatch latch = new CountDownLatch(PETITIONS); CountDownLatch latch = new CountDownLatch(PETITIONS);
body = "{'session':'TestSession','broadcastUrl':'rtmp://172.17.0.1/live'}"; body = "{'session':'TestSession','broadcastUrl':'rtmp://" + BROADCAST_IP + "/live'}";
for (int i = 0; i < PETITIONS; i++) { for (int i = 0; i < PETITIONS; i++) {
new Thread(() -> { new Thread(() -> {
try { try {
String response = restClient.commonRestString(HttpMethod.POST, "/openvidu/api/broadcast/start", String response = restClient.commonRestString(HttpMethod.POST, "/openvidu/api/broadcast/start",
"{'session':'TestSession','broadcastUrl':'rtmp://172.17.0.1/live'}", "{'session':'TestSession','broadcastUrl':'rtmp://" + BROADCAST_IP + "/live'}",
HttpURLConnection.HTTP_OK); HttpURLConnection.HTTP_OK);
responses.add(response); responses.add(response);
} catch (Exception e) { } catch (Exception e) {
@ -2950,11 +2950,11 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
if (!latch.await(30, TimeUnit.SECONDS)) { if (!latch.await(30, TimeUnit.SECONDS)) {
Assertions.fail("Concurrent start of broadcasts did not return in timeout"); Assertions.fail("Concurrent start of broadcasts did not return in timeout");
} }
Assertions.assertEquals(PETITIONS - 1, exceptions.size(), "Wrong number of councurrent started broadcasts");
for (Exception e : exceptions) { for (Exception e : exceptions) {
Assertions.assertTrue(e.getMessage().contains("expected to return status 200 but got 409"), Assertions.assertTrue(e.getMessage().contains("expected to return status 200 but got 409"),
"Exception message wasn't 409. It was: " + e.getMessage()); "Exception message wasn't 409. It was: " + e.getMessage());
} }
Assertions.assertEquals(PETITIONS - 1, exceptions.size(), "Wrong number of councurrent started broadcasts");
// 409 // 409
restClient.commonRestString(HttpMethod.POST, "/openvidu/api/broadcast/start", body, restClient.commonRestString(HttpMethod.POST, "/openvidu/api/broadcast/start", body,
HttpURLConnection.HTTP_CONFLICT); HttpURLConnection.HTTP_CONFLICT);
@ -3243,7 +3243,8 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
} }
if (startBroadcast) { if (startBroadcast) {
restClient.rest(HttpMethod.POST, "/openvidu/api/broadcast/start", restClient.rest(HttpMethod.POST, "/openvidu/api/broadcast/start",
"{'session':'TestSession','broadcastUrl':'rtmp://172.17.0.1/live'}", HttpURLConnection.HTTP_OK); "{'session':'TestSession','broadcastUrl':'rtmp://" + BROADCAST_IP + "/live'}",
HttpURLConnection.HTTP_OK);
user.getEventManager().waitUntilEventReaches("broadcastStarted", 2); user.getEventManager().waitUntilEventReaches("broadcastStarted", 2);
CustomWebhook.waitForEvent("broadcastStarted", 3); CustomWebhook.waitForEvent("broadcastStarted", 3);
} }