Files
hyperframes/packages/aws-lambda/src/siteManifest.test.ts
T
Miguel Ángel da4386f0d0 perf(aws-lambda): cloud renders plan without reading video bytes and start chunks sooner (#6194)
* perf(engine): a remote source's tail decodes run many at a time, not one per half-core

* perf(producer): the plan logs where its extract stage spends its time

* perf(engine): a window that ends inside its source takes its frame count without a decode

* test(engine): pin the tail-decode slot test to the windows that decode

* style(engine): format the tail-probe window check

* test(engine): deferred counts match extraction on a B-frame NTSC source; VFR is not deferred

* style(engine): format the tail-probe tests

* perf(aws-lambda): a site stores each video's ffprobe JSON, and the plan reads it instead of probing

* test(aws-lambda): a site stores and hands out each video's probe

* style(aws-lambda): format the probe-facts upload and tests

* perf(engine): a site's stored probe also holds the final-frame timestamp the plan would probe for

* test(engine): drop an unused import

* test(aws-lambda): the stored probe holds the ffprobe JSON and the final frame

* test(aws-lambda): the stored probe holds the ffprobe JSON and the final frame

* perf(producer): a distributed chunk encodes while it captures

* perf(producer): the audio task logs where its mix spends its time

One line per audio stage: prepare, groups, mix, master, encode and the peak check, in ms.

* perf(engine): locked warmup ticks stop sleeping once the page is ready

* perf(engine): a window reaching a stored video's end takes its frame count from stored facts

* fix(producer): the cloud audio task logs its phases

* perf(engine): stored facts keep the last packet length so late-start windows skip the tail decode

* fix(engine): a probe spawns without waiting when no stored facts are declared

* chore(aws-lambda): shorten comments over the line limit

* fix(engine): warmup keeps pacing after a failed tick; stored final frames check ffprobe major

* test(engine): the recorded ffprobe major matches the build's own banner

* test(engine): the version-banner probes go through a named binary like the other spawns
2026-10-24 14:30:16 +00:00

89 lines
2.9 KiB
TypeScript

import { afterEach, beforeEach, describe, expect, it } from "bun:test";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { S3Client } from "@aws-sdk/client-s3";
import { audioSidecarUri, contentStoreUri, probeFactsUri } from "./contentStore.js";
import { FakeS3 } from "./sdk/__fixtures__/fakeS3.js";
import { downloadSiteFiles, serializeSiteManifest, siteManifestUri } from "./siteManifest.js";
const VIDEO_SHA = "a".repeat(64);
let dir: string;
beforeEach(() => {
dir = mkdtempSync(join(tmpdir(), "hf-site-manifest-"));
});
afterEach(() => rmSync(dir, { recursive: true, force: true }));
/** A real client, so it can pre-sign offline, whose requests go to the fake. */
function clientOver(fake: FakeS3): S3Client {
const client = new S3Client({
region: "us-east-2",
credentials: { accessKeyId: "AKIDTEST", secretAccessKey: "test-secret" },
});
client.send = fake.send.bind(fake) as S3Client["send"];
return client;
}
function siteWithVideo(fake: FakeS3): string {
const manifestUri = siteManifestUri("bucket", "site1");
const id = manifestUri.replace("s3://", "");
fake.existing.add(id);
fake.bodies.set(
id,
Buffer.from(
serializeSiteManifest([{ path: "takes/camera.mov", sha256: VIDEO_SHA, sizeBytes: 9 }]),
),
);
return manifestUri;
}
describe("downloadSiteFiles", () => {
it("hands a remote video's audio sidecar along with the video's own URL, when one is stored", async () => {
const fake = new FakeS3();
const manifestUri = siteWithVideo(fake);
fake.existing.add(audioSidecarUri("bucket", VIDEO_SHA).replace("s3://", ""));
const remote = await downloadSiteFiles(
clientOver(fake),
manifestUri,
join(dir, "project"),
true,
);
const file = remote["takes/camera.mov"];
expect(file?.url).toContain(contentStoreUri("bucket", VIDEO_SHA).split("/").pop() ?? "");
expect(file?.audioSidecarUrl).toContain(`${VIDEO_SHA}.audio.m4a`);
});
it("hands only the video when no sidecar is stored", async () => {
const fake = new FakeS3();
const manifestUri = siteWithVideo(fake);
const remote = await downloadSiteFiles(
clientOver(fake),
manifestUri,
join(dir, "project"),
true,
);
expect(remote["takes/camera.mov"]?.url).toBeString();
expect(remote["takes/camera.mov"]?.audioSidecarUrl).toBeUndefined();
});
it("hands a remote video's stored probe along with it, when one is stored", async () => {
const fake = new FakeS3();
const manifestUri = siteWithVideo(fake);
fake.existing.add(probeFactsUri("bucket", VIDEO_SHA).replace("s3://", ""));
const remote = await downloadSiteFiles(
clientOver(fake),
manifestUri,
join(dir, "project"),
true,
);
expect(remote["takes/camera.mov"]?.probeFactsUrl).toContain(`${VIDEO_SHA}.probe.v2.json`);
});
});