Skip to content

🎥 Make videos programmatically with React

fix tests

Jonny Burger828155ba117c
diff --git a/packages/renderer/src/test/rust-memory-usage.test.ts b/packages/renderer/src/test/rust-memory-usage.test.ts
index 8ba68d5ee4..e87b13ba7e 100644
--- a/packages/renderer/src/test/rust-memory-usage.test.ts
+++ b/packages/renderer/src/test/rust-memory-usage.test.ts
@@ -8,10 +8,14 @@ test('Memory usage should be determined ', async () => {
return;
}
- const compositor = startLongRunningCompositor(400, 'info', false);
+ const compositor = startLongRunningCompositor(
+ 40 * 24 * 1024 * 1024,
+ 'info',
+ false,
+ );
expect(
- getMemoryUsageByPid((compositor.pid as Number).toString())
+ getMemoryUsageByPid((compositor.pid as Number).toString()),
).toBeLessThan(10 * 1024 * 1024);
await compositor.executeCommand('ExtractFrame', {
@@ -24,7 +28,7 @@ test('Memory usage should be determined ', async () => {
const stats = await compositor.executeCommand('GetOpenVideoStats', {});
const statsJson = JSON.parse(stats.toString('utf-8'));
expect(
- statsJson.frames_in_cache === 84 || statsJson.frames_in_cache === 85
+ statsJson.frames_in_cache === 84 || statsJson.frames_in_cache === 85,
).toBe(true);
expect(statsJson.open_streams).toBe(1);
expect(statsJson.open_videos).toBe(1);
@@ -39,33 +43,33 @@ test('Memory usage should be determined ', async () => {
const stats2 = await compositor.executeCommand('GetOpenVideoStats', {});
const statsJson2 = JSON.parse(stats2.toString('utf-8'));
expect(
- statsJson2.frames_in_cache === 185 || statsJson2.frames_in_cache === 184
+ statsJson2.frames_in_cache === 185 || statsJson2.frames_in_cache === 184,
).toBe(true);
expect(statsJson2.open_streams).toBe(2);
expect(statsJson2.open_videos).toBe(2);
await compositor.executeCommand('FreeUpMemory', {
- percent_of_memory: 0.5,
+ remaining_bytes: 100 * 24 * 1024 * 1024,
});
const stats3 = await compositor.executeCommand('GetOpenVideoStats', {});
const statsJson3 = JSON.parse(stats3.toString('utf-8'));
- expect(statsJson3.frames_in_cache).toBe(92);
+ expect(statsJson3.frames_in_cache).toBe(184);
await compositor.executeCommand('FreeUpMemory', {
- percent_of_memory: 0.5,
+ remaining_bytes: 100 * 24 * 1024 * 1024,
});
const stats4 = await compositor.executeCommand('GetOpenVideoStats', {});
const statsJson4 = JSON.parse(stats4.toString('utf-8'));
expect(statsJson4).toEqual({
- frames_in_cache: 46,
- open_streams: 1,
- open_videos: 1,
+ frames_in_cache: 184,
+ open_streams: 2,
+ open_videos: 2,
});
await compositor.executeCommand('FreeUpMemory', {
- percent_of_memory: 1,
+ remaining_bytes: 1,
});
const stats5 = await compositor.executeCommand('GetOpenVideoStats', {});
@@ -80,7 +84,7 @@ test('Memory usage should be determined ', async () => {
setTimeout(resolve, 3000);
});
expect(
- getMemoryUsageByPid((compositor.pid as Number).toString())
+ getMemoryUsageByPid((compositor.pid as Number).toString()),
).toBeLessThan(40 * 1024 * 1024);
await compositor.executeCommand('ExtractFrame', {
@@ -92,7 +96,11 @@ test('Memory usage should be determined ', async () => {
});
test('Should respect the maximum frame cache limit', async () => {
- const compositor = startLongRunningCompositor(50, 'info', false);
+ const compositor = startLongRunningCompositor(
+ 50 * 24 * 1024 * 1024,
+ 'info',
+ false,
+ );
await compositor.executeCommand('ExtractFrame', {
src: exampleVideos.bigBuckBunny,
@@ -104,7 +112,7 @@ test('Should respect the maximum frame cache limit', async () => {
const stats = await compositor.executeCommand('GetOpenVideoStats', {});
const statsJson = JSON.parse(stats.toString('utf-8'));
expect(statsJson).toEqual({
- frames_in_cache: 50,
+ frames_in_cache: 84,
open_streams: 1,
open_videos: 1,
});
@@ -115,10 +123,14 @@ test('Should be able to take commands for freeing up memory', async () => {
return;
}
- const compositor = startLongRunningCompositor(400, 'info', false);
+ const compositor = startLongRunningCompositor(
+ 100 * 24 * 1024 * 1024,
+ 'info',
+ false,
+ );
expect(
- getMemoryUsageByPid((compositor.pid as Number).toString())
+ getMemoryUsageByPid((compositor.pid as Number).toString()),
).toBeLessThan(10 * 1024 * 1024);
await compositor.executeCommand('ExtractFrame', {
@@ -129,13 +141,13 @@ test('Should be able to take commands for freeing up memory', async () => {
});
expect(
- getMemoryUsageByPid((compositor.pid as Number).toString())
+ getMemoryUsageByPid((compositor.pid as Number).toString()),
).toBeGreaterThan(100 * 1024 * 1024);
await compositor.executeCommand('CloseAllVideos', {});
expect(
- getMemoryUsageByPid((compositor.pid as Number).toString())
+ getMemoryUsageByPid((compositor.pid as Number).toString()),
).toBeLessThan(25 * 1024 * 1024);
});