Skip to content

Commit

Permalink
openvidu-test-e2e: added force codec and ingress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloFuente committed Dec 2, 2024
1 parent d7f1d85 commit d1cca5e
Show file tree
Hide file tree
Showing 5 changed files with 416 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@
import org.testcontainers.containers.wait.strategy.WaitStrategy;
import org.testcontainers.utility.DockerImageName;

import io.livekit.server.IngressServiceClient;
import io.livekit.server.RoomServiceClient;
import io.openvidu.test.browsers.BrowserUser;
import io.openvidu.test.browsers.ChromeUser;
import io.openvidu.test.browsers.EdgeUser;
import io.openvidu.test.browsers.FirefoxUser;
import io.openvidu.test.browsers.utils.BrowserNames;
import io.openvidu.test.browsers.utils.CommandLineExecutor;
import livekit.LivekitIngress.IngressInfo;
import livekit.LivekitModels.Room;
import okhttp3.OkHttpClient;
import retrofit2.Response;

public class OpenViduTestE2e {
Expand Down Expand Up @@ -76,6 +79,7 @@ public class OpenViduTestE2e {
protected static Collection<GenericContainer<?>> containers = new HashSet<>();

protected static RoomServiceClient LK;
protected static IngressServiceClient LK_INGRESS;

private static boolean isMediaServerRestartTest = false;

Expand Down Expand Up @@ -149,33 +153,36 @@ protected static void setUpLiveKitClient() throws NoSuchAlgorithmException {
+ uri.getAuthority() + uri.getPath();

LK = RoomServiceClient.create(url.toString(), LIVEKIT_API_KEY, LIVEKIT_API_SECRET, false,
(okHttpClientBuilder) -> {
TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
@Override
public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) {
}
(okHttpClientBuilder) -> okHttpClientBuilder(okHttpClientBuilder));
LK_INGRESS = IngressServiceClient.create(url.toString(), LIVEKIT_API_KEY, LIVEKIT_API_SECRET, false);
}

@Override
public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) {
}
private static OkHttpClient okHttpClientBuilder(okhttp3.OkHttpClient.Builder okHttpClientBuilder) {
TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
@Override
public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) {
}

@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return new java.security.cert.X509Certificate[] {};
}
} };
SSLContext sslContext = null;
try {
sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
} catch (KeyManagementException | NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
okHttpClientBuilder.sslSocketFactory(sslContext.getSocketFactory(),
(X509TrustManager) trustAllCerts[0]);
okHttpClientBuilder.hostnameVerifier((hostname, session) -> true);
});
@Override
public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) {
}

@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return new java.security.cert.X509Certificate[] {};
}
} };
SSLContext sslContext = null;
try {
sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
} catch (KeyManagementException | NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
okHttpClientBuilder.sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustAllCerts[0]);
okHttpClientBuilder.hostnameVerifier((hostname, session) -> true);
return okHttpClientBuilder.build();
}

protected static void loadEnvironmentVariables() {
Expand Down Expand Up @@ -422,6 +429,29 @@ protected void closeAllRooms(RoomServiceClient client) {
}
}

protected void deleteAllIngresses(IngressServiceClient client) {
try {
Response<List<IngressInfo>> response = client.listIngress().execute();
if (response.isSuccessful()) {
List<IngressInfo> ingressList = response.body();
if (ingressList != null) {
client.listIngress().execute().body().forEach(i -> {
log.info("Deleting existing ingress " + i.getName());
try {
log.info("Response: " + client.deleteIngress(i.getIngressId()).execute().code());
} catch (IOException e) {
log.error("Error deleting ingress " + i.getName(), e);
}
});
}
} else {
log.error("Error listing ingresses: " + response.errorBody());
}
} catch (Exception e) {
log.error("Error deleting ingresses: {}", e.getMessage());
}
}

private void checkMediafilePath(Path path) throws Exception {
if (!Files.exists(path)) {
throw new Exception("File " + path.toAbsolutePath().toString() + " does not exist");
Expand Down
Loading

0 comments on commit d1cca5e

Please sign in to comment.