mirror of https://github.com/OpenVidu/openvidu.git
tests-e2e: Updated Individual dynamic record test
parent
51414219a9
commit
232cb89303
|
@ -123,7 +123,7 @@ public class RecordingUtils {
|
||||||
+ Arrays.toString(folder.listFiles()));
|
+ Arrays.toString(folder.listFiles()));
|
||||||
|
|
||||||
File file1 = new File(recPath + recording.getName() + ".zip");
|
File file1 = new File(recPath + recording.getName() + ".zip");
|
||||||
File file2 = new File(recPath + ".recording." + recording.getId());
|
File file2 = new File(recPath + recording.getName() + ".json");
|
||||||
|
|
||||||
Assertions.assertTrue(file1.exists() && file1.length() > 0,
|
Assertions.assertTrue(file1.exists() && file1.length() > 0,
|
||||||
"File " + file1.getAbsolutePath() + " does not exist or is empty");
|
"File " + file1.getAbsolutePath() + " does not exist or is empty");
|
||||||
|
@ -206,7 +206,8 @@ public class RecordingUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (resolution != null) {
|
if (resolution != null) {
|
||||||
Assertions.assertEquals(resolution, metadata.getVideoWidth() + "x" + metadata.getVideoHeight());
|
Assertions.assertEquals(resolution, metadata.getVideoWidth() + "x" +
|
||||||
|
metadata.getVideoHeight());
|
||||||
}
|
}
|
||||||
if (frameRate != null) {
|
if (frameRate != null) {
|
||||||
Assertions.assertEquals(frameRate.intValue(), metadata.getFrameRate());
|
Assertions.assertEquals(frameRate.intValue(), metadata.getFrameRate());
|
||||||
|
@ -222,10 +223,15 @@ public class RecordingUtils {
|
||||||
// Check duration with 1 decimal precision
|
// Check duration with 1 decimal precision
|
||||||
DecimalFormat df = new DecimalFormat("#0.0");
|
DecimalFormat df = new DecimalFormat("#0.0");
|
||||||
df.setRoundingMode(RoundingMode.UP);
|
df.setRoundingMode(RoundingMode.UP);
|
||||||
log.info("Duration of {} according to ffmpeg: {} s", file.getName(), metadata.getDuration());
|
log.info("Duration of {} according to ffmpeg: {} s", file.getName(),
|
||||||
log.info("Duration of {} according to 'duration' property: {} s", file.getName(), duration);
|
metadata.getDuration());
|
||||||
log.info("Difference in s duration: {}", Math.abs(metadata.getDuration() - duration));
|
log.info("Duration of {} according to 'duration' property: {} s",
|
||||||
|
file.getName(), duration);
|
||||||
|
log.info("Difference in s duration: {}", Math.abs(metadata.getDuration() -
|
||||||
|
duration));
|
||||||
final double difference = 10;
|
final double difference = 10;
|
||||||
|
System.out.println("Duration of " + file.getName() + " according to ffmpeg: " + metadata.getDuration() + " s");
|
||||||
|
System.out.println("Duration of " + file.getName() + " according to 'duration' property: " + duration + " s");
|
||||||
Assertions.assertTrue(Math.abs((metadata.getDuration() - duration)) < difference,
|
Assertions.assertTrue(Math.abs((metadata.getDuration() - duration)) < difference,
|
||||||
"Difference between recording entity duration (" + duration + ") and real video duration ("
|
"Difference between recording entity duration (" + duration + ") and real video duration ("
|
||||||
+ metadata.getDuration() + ") is greater than " + difference + " in file " + file.getName());
|
+ metadata.getDuration() + ") is greater than " + difference + " in file " + file.getName());
|
||||||
|
|
|
@ -251,15 +251,18 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
|
||||||
|
|
||||||
CustomHttpClient restClient = new CustomHttpClient(OpenViduTestAppE2eTest.OPENVIDU_URL, "OPENVIDUAPP",
|
CustomHttpClient restClient = new CustomHttpClient(OpenViduTestAppE2eTest.OPENVIDU_URL, "OPENVIDUAPP",
|
||||||
OpenViduTestAppE2eTest.OPENVIDU_SECRET);
|
OpenViduTestAppE2eTest.OPENVIDU_SECRET);
|
||||||
// JsonObject config = restClient.rest(HttpMethod.GET, "/openvidu/api/config", HttpURLConnection.HTTP_OK);
|
// JsonObject config = restClient.rest(HttpMethod.GET, "/openvidu/api/config",
|
||||||
|
// HttpURLConnection.HTTP_OK);
|
||||||
|
|
||||||
// String defaultOpenViduWebhookEndpoint = null;
|
// String defaultOpenViduWebhookEndpoint = null;
|
||||||
// Integer defaultOpenViduRecordingAutostopTimeout = null;
|
// Integer defaultOpenViduRecordingAutostopTimeout = null;
|
||||||
// if (config.has("OPENVIDU_WEBHOOK_ENDPOINT")) {
|
// if (config.has("OPENVIDU_WEBHOOK_ENDPOINT")) {
|
||||||
// defaultOpenViduWebhookEndpoint = config.get("OPENVIDU_WEBHOOK_ENDPOINT").getAsString();
|
// defaultOpenViduWebhookEndpoint =
|
||||||
|
// config.get("OPENVIDU_WEBHOOK_ENDPOINT").getAsString();
|
||||||
// }
|
// }
|
||||||
// if (config.has("OPENVIDU_RECORDING_AUTOSTOP_TIMEOUT")) {
|
// if (config.has("OPENVIDU_RECORDING_AUTOSTOP_TIMEOUT")) {
|
||||||
// defaultOpenViduRecordingAutostopTimeout = config.get("OPENVIDU_RECORDING_AUTOSTOP_TIMEOUT").getAsInt();
|
// defaultOpenViduRecordingAutostopTimeout =
|
||||||
|
// config.get("OPENVIDU_RECORDING_AUTOSTOP_TIMEOUT").getAsInt();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -596,7 +599,8 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
|
||||||
// oldConfig.put("OPENVIDU_WEBHOOK_ENDPOINT", defaultOpenViduWebhookEndpoint);
|
// oldConfig.put("OPENVIDU_WEBHOOK_ENDPOINT", defaultOpenViduWebhookEndpoint);
|
||||||
// }
|
// }
|
||||||
// if (defaultOpenViduRecordingAutostopTimeout != null) {
|
// if (defaultOpenViduRecordingAutostopTimeout != null) {
|
||||||
// oldConfig.put("OPENVIDU_RECORDING_AUTOSTOP_TIMEOUT", defaultOpenViduRecordingAutostopTimeout);
|
// oldConfig.put("OPENVIDU_RECORDING_AUTOSTOP_TIMEOUT",
|
||||||
|
// defaultOpenViduRecordingAutostopTimeout);
|
||||||
// }
|
// }
|
||||||
restartOpenViduServer(oldConfig);
|
restartOpenViduServer(oldConfig);
|
||||||
}
|
}
|
||||||
|
@ -694,86 +698,87 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
|
||||||
// configured to NOT be recorded
|
// configured to NOT be recorded
|
||||||
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/" + sessionName + "/connection/" + connectionId2,
|
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/" + sessionName + "/connection/" + connectionId2,
|
||||||
"{'record':true}", HttpURLConnection.HTTP_OK);
|
"{'record':true}", HttpURLConnection.HTTP_OK);
|
||||||
Thread.sleep(1000);
|
|
||||||
|
Thread.sleep(2000);
|
||||||
|
|
||||||
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/" + sessionName + "/connection/" + connectionId2,
|
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/" + sessionName + "/connection/" + connectionId2,
|
||||||
"{'record':false}", HttpURLConnection.HTTP_OK);
|
"{'record':false}", HttpURLConnection.HTTP_OK);
|
||||||
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/" + sessionName + "/connection/" + connectionId2,
|
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/" + sessionName + "/connection/" + connectionId2,
|
||||||
"{'record':true}", HttpURLConnection.HTTP_OK);
|
"{'record':true}", HttpURLConnection.HTTP_OK);
|
||||||
Thread.sleep(1000);
|
|
||||||
|
Thread.sleep(2000);
|
||||||
|
|
||||||
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/" + sessionName + "/connection/" + connectionId2,
|
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/" + sessionName + "/connection/" + connectionId2,
|
||||||
"{'record':false}", HttpURLConnection.HTTP_OK);
|
"{'record':false}", HttpURLConnection.HTTP_OK);
|
||||||
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/" + sessionName + "/connection/" + connectionId2,
|
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/" + sessionName + "/connection/" + connectionId2,
|
||||||
"{'record':true}", HttpURLConnection.HTTP_OK);
|
"{'record':true}", HttpURLConnection.HTTP_OK);
|
||||||
Thread.sleep(1000);
|
|
||||||
|
Thread.sleep(2000);
|
||||||
|
|
||||||
restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/stop/" + sessionName, HttpURLConnection.HTTP_OK);
|
restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/stop/" + sessionName, HttpURLConnection.HTTP_OK);
|
||||||
user.getEventManager().waitUntilEventReaches("recordingStopped", 3);
|
user.getEventManager().waitUntilEventReaches("recordingStopped", 3);
|
||||||
|
|
||||||
gracefullyLeaveParticipants(user, 3);
|
gracefullyLeaveParticipants(user, 3);
|
||||||
|
|
||||||
|
String recPath = "/opt/openvidu/recordings/" + sessionName + "/";
|
||||||
// Commented until we fix the analysis of individual recordings
|
Recording recording = new OpenVidu(OpenViduTestAppE2eTest.OPENVIDU_URL, OpenViduTestAppE2eTest.OPENVIDU_SECRET)
|
||||||
|
.getRecording(sessionName);
|
||||||
// String recPath = "/opt/openvidu/recordings/" + sessionName + "/";
|
this.recordingUtils.checkIndividualRecording(recPath, recording, 4, "aac", "h264", true);
|
||||||
// Recording recording = new OpenVidu(OpenViduTestAppE2eTest.OPENVIDU_URL, OpenViduTestAppE2eTest.OPENVIDU_SECRET)
|
|
||||||
// .getRecording(sessionName);
|
|
||||||
// this.recordingUtils.checkIndividualRecording(recPath, recording, 4, "opus", "vp8", true);
|
|
||||||
|
|
||||||
|
|
||||||
// Analyze INDIVIDUAL recording metadata
|
// Analyze INDIVIDUAL recording metadata
|
||||||
// new Unzipper().unzipFile(recPath, recording.getName() + ".zip");
|
new Unzipper().unzipFile(recPath, recording.getName() + ".zip");
|
||||||
// File jsonSyncFile = new File(recPath + recording.getName() + ".json");
|
File jsonSyncFile = new File(recPath + recording.getName() + ".json");
|
||||||
// JsonReader reader = new JsonReader(new FileReader(jsonSyncFile));
|
JsonReader reader = new JsonReader(new FileReader(jsonSyncFile));
|
||||||
// JsonObject jsonMetadata = new Gson().fromJson(reader, JsonObject.class);
|
JsonObject jsonMetadata = new Gson().fromJson(reader, JsonObject.class);
|
||||||
// JsonArray syncArray = jsonMetadata.get("files").getAsJsonArray();
|
JsonArray syncArray = jsonMetadata.get("files").getAsJsonArray();
|
||||||
// int count1 = 0;
|
int count1 = 0;
|
||||||
// int count2 = 0;
|
int count2 = 0;
|
||||||
|
|
||||||
// Set<String> regexNames = Stream.of("^" + streamId2 + "\\.(webm|mkv|mp4)$",
|
Set<String> regexNames = Stream.of("^" + streamId2 + "\\.(webm|mkv|mp4)$",
|
||||||
// "^" + streamId2 + "-1\\.(webm|mkv|mp4)$", "^" + streamId2 + "-2\\.(webm|mkv|mp4)$")
|
"^" + streamId2 + "-1\\.(webm|mkv|mp4)$", "^" + streamId2 + "-2\\.(webm|mkv|mp4)$")
|
||||||
// .collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
// for (JsonElement fileJson : syncArray) {
|
for (JsonElement fileJson : syncArray) {
|
||||||
// JsonObject file = fileJson.getAsJsonObject();
|
JsonObject file = fileJson.getAsJsonObject();
|
||||||
// String fileStreamId = file.get("streamId").getAsString();
|
String fileStreamId = file.get("streamId").getAsString();
|
||||||
// if (fileStreamId.equals(streamId1[0])) {
|
if (fileStreamId.equals(streamId1[0])) {
|
||||||
// // Normal recorded user
|
// Normal recorded user
|
||||||
// Assertions.assertEquals(connectionId1[0], file.get("connectionId").getAsString(),
|
Assertions.assertEquals(connectionId1[0], file.get("connectionId").getAsString(),
|
||||||
// "Wrong connectionId file metadata property");
|
"Wrong connectionId file metadata property");
|
||||||
// long msDuration = file.get("endTimeOffset").getAsLong() - file.get("startTimeOffset").getAsLong();
|
// long msDuration = file.get("endTimeOffset").getAsLong() - file.get("startTimeOffset").getAsLong();
|
||||||
// Assertions.assertTrue(msDuration - 4000 < 750,
|
// Assertions.assertTrue(msDuration - 8000 < 750,
|
||||||
// "Wrong recording duration of individual file. Difference: " + (msDuration - 4000));
|
// "Wrong recording duration of individual file. Difference: " + (msDuration - 8000));
|
||||||
// count1++;
|
count1++;
|
||||||
// } else if (fileStreamId.equals(streamId2)) {
|
} else if (fileStreamId.equals(streamId2)) {
|
||||||
// // Dynamically recorded user
|
// Dynamically recorded user
|
||||||
// Assertions.assertEquals(connectionId2, file.get("connectionId").getAsString(),
|
Assertions.assertEquals(connectionId2, file.get("connectionId").getAsString(),
|
||||||
// "Wrong connectionId file metadata property");
|
"Wrong connectionId file metadata property");
|
||||||
// long msDuration = file.get("endTimeOffset").getAsLong() - file.get("startTimeOffset").getAsLong();
|
// long msDuration = file.get("endTimeOffset").getAsLong() - file.get("startTimeOffset").getAsLong();
|
||||||
// Assertions.assertTrue(Math.abs(msDuration - 1000) < 150,
|
// Assertions.assertTrue(Math.abs(msDuration - 1000) < 150,
|
||||||
// "Wrong recording duration of individual file. Difference: " + Math.abs(msDuration - 1000));
|
// "Wrong recording duration of individual file. Difference: " + Math.abs(msDuration - 1000));
|
||||||
|
|
||||||
// String fileName = file.get("name").getAsString();
|
String fileName = file.get("name").getAsString();
|
||||||
|
|
||||||
// boolean found = false;
|
boolean found = false;
|
||||||
// Iterator<String> regexNamesIterator = regexNames.iterator();
|
Iterator<String> regexNamesIterator = regexNames.iterator();
|
||||||
// while (regexNamesIterator.hasNext()) {
|
while (regexNamesIterator.hasNext()) {
|
||||||
// if (Pattern.compile(regexNamesIterator.next()).matcher(fileName).matches()) {
|
if (Pattern.compile(regexNamesIterator.next()).matcher(fileName).matches()) {
|
||||||
// found = true;
|
found = true;
|
||||||
// regexNamesIterator.remove();
|
regexNamesIterator.remove();
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Assertions.assertTrue(found,
|
Assertions.assertTrue(found,
|
||||||
// "File name " + fileName + " not found among regex " + regexNames.toString());
|
"File name " + fileName + " not found among regex " + regexNames.toString());
|
||||||
// count2++;
|
count2++;
|
||||||
// } else {
|
} else {
|
||||||
// Assertions.fail("Metadata file element does not belong to a known stream (" + fileStreamId + ")");
|
Assertions.fail("Metadata file element does not belong to a known stream (" + fileStreamId + ")");
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// Assertions.assertEquals(1, count1, "Wrong number of recording files for stream " + streamId1[0]);
|
Assertions.assertEquals(1, count1, "Wrong number of recording files for stream " + streamId1[0]);
|
||||||
// Assertions.assertEquals(3, count2, "Wrong number of recording files for stream " + streamId2);
|
Assertions.assertEquals(3, count2, "Wrong number of recording files for stream " + streamId2);
|
||||||
// Assertions.assertTrue(regexNames.isEmpty(), "Some expected file name didn't existed: " + regexNames.toString());
|
Assertions.assertTrue(regexNames.isEmpty(), "Some expected file name didn't existed: " + regexNames.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue