@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 72 lines 2.84 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import {
3 deleteChannelWithEndpoints,
4 listAllChannelGroups,
5 listGroupChannels,
6 retryWhileMpConflict,
7 } from "@alchemy.run/aws/MediaPackageV2/internal";
8 import { expect } from "@alchemy.run/test";
9 import * as Test from "@alchemy.run/test/Alchemy";
10 import * as mediapackagev2 from "@distilled.cloud/aws/mediapackagev2";
11 import * as Effect from "effect/Effect";
12
13 const { test } = Test.make({ providers: AWS.providers() });
14
15 // One-off orphan sweep for the account's MediaPackageV2 surface. Deletes
16 // EVERY channel group (reaping channels + origin endpoints first, exercising
17 // the provider's reap-children delete path) and asserts zero remain.
18 // Env-gated so it can never race the lifecycle suite's own deployments.
19 test.provider.skipIf(!process.env.MPV2_SWEEP)(
20 "sweep: reap every channel group and verify zero remain",
21 () =>
22 Effect.gen(function* () {
23 // Plant a deterministic orphan chain (group -> channel -> endpoint)
24 // out-of-band so the sweep provably reaps children before the group —
25 // the exact scenario that leaked under nuke.
26 yield* mediapackagev2
27 .createChannelGroup({ ChannelGroupName: "alchemy-mpv2-sweep-probe" })
28 .pipe(Effect.catchTag("ConflictException", () => Effect.void));
29 yield* mediapackagev2
30 .createChannel({
31 ChannelGroupName: "alchemy-mpv2-sweep-probe",
32 ChannelName: "probe-feed",
33 InputType: "HLS",
34 })
35 .pipe(Effect.catchTag("ConflictException", () => Effect.void));
36 yield* mediapackagev2
37 .createOriginEndpoint({
38 ChannelGroupName: "alchemy-mpv2-sweep-probe",
39 ChannelName: "probe-feed",
40 OriginEndpointName: "probe-playback",
41 ContainerType: "TS",
42 Segment: { SegmentDurationSeconds: 6 },
43 HlsManifests: [{ ManifestName: "index" }],
44 })
45 .pipe(Effect.catchTag("ConflictException", () => Effect.void));
46
47 const groups = yield* listAllChannelGroups();
48 expect(groups.length).toBeGreaterThanOrEqual(1);
49 yield* Effect.forEach(
50 groups,
51 (group) =>
52 Effect.gen(function* () {
53 const channels = yield* listGroupChannels(group.ChannelGroupName);
54 yield* Effect.forEach(
55 channels,
56 (channel) => deleteChannelWithEndpoints(group.ChannelGroupName, channel.ChannelName),
57 { concurrency: 5, discard: true },
58 );
59 yield* mediapackagev2
60 .deleteChannelGroup({ ChannelGroupName: group.ChannelGroupName })
61 .pipe(retryWhileMpConflict);
62 }),
63 { concurrency: 3, discard: true },
64 );
65 const remaining = yield* listAllChannelGroups();
66 expect(remaining).toHaveLength(0);
67 }),
68 {
69 tags: ["provider:aws", "provider:aws:mediapackagev2", "live"],
70 timeout: 120_000,
71 },
72 );