@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 107 lines 4.29 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { ObservabilityConfiguration } from "@alchemy.run/aws/AppRunner";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as apprunner from "@distilled.cloud/aws/apprunner";
6 import * as sts from "@distilled.cloud/aws/sts";
7 import * as Effect from "effect/Effect";
8 import * as Schedule from "effect/Schedule";
9
10 const { test } = Test.make({ providers: AWS.providers() });
11
12 // Ungated typed-error probe: proves the distilled error union carries the
13 // not-found tag this provider's read/delete paths depend on.
14 test.provider(
15 "describeObservabilityConfiguration on a nonexistent ARN fails with ResourceNotFoundException",
16 () =>
17 Effect.gen(function* () {
18 const { Account } = yield* sts.getCallerIdentity({});
19 const error = yield* Effect.flip(
20 apprunner.describeObservabilityConfiguration({
21 ObservabilityConfigurationArn: `arn:aws:apprunner:us-west-2:${Account}:observabilityconfiguration/alchemy-nonexistent-probe/1/00000000000000000000000000000000`,
22 }),
23 );
24 expect(error._tag).toBe("ResourceNotFoundException");
25 }),
26 { tags: ["provider:aws", "provider:aws:apprunner", "live"] },
27 );
28
29 // No ACTIVE revision of the named configuration remains. Unlike auto
30 // scaling configuration summaries, observability configuration summaries
31 // carry no Status field — the list only returns active revisions.
32 const assertConfigGone = (name: string) =>
33 Effect.gen(function* () {
34 const page = yield* apprunner.listObservabilityConfigurations({
35 ObservabilityConfigurationName: name,
36 });
37 const active = (page.ObservabilityConfigurationSummaryList ?? []).filter(
38 (s) => s.ObservabilityConfigurationName === name,
39 );
40 if (active.length > 0) {
41 return yield* Effect.fail(
42 new Error(
43 `Observability configuration '${name}' still has ${active.length} ACTIVE revision(s)`,
44 ),
45 );
46 }
47 }).pipe(
48 Effect.retry({
49 schedule: Schedule.max([Schedule.fixed("3 seconds"), Schedule.recurs(8)]),
50 }),
51 );
52
53 // Observability configurations are immutable revisions — fast and free, so
54 // the full lifecycle (create, no-op, replace-by-name, destroy) runs ungated.
55 test.provider(
56 "create, no-op, replace, and destroy an observability configuration",
57 (stack) =>
58 Effect.gen(function* () {
59 // Clean slate in case a previous run died mid-flight.
60 yield* stack.destroy();
61
62 const props = {
63 observabilityConfigurationName: "alchemy-test-obs",
64 traceConfiguration: { vendor: "AWSXRAY" as const },
65 };
66
67 // Create.
68 const created = yield* stack.deploy(ObservabilityConfiguration("Obs", props));
69 expect(created.observabilityConfigurationName).toBe("alchemy-test-obs");
70 expect(created.observabilityConfigurationArn).toContain(
71 ":observabilityconfiguration/alchemy-test-obs/",
72 );
73 expect(created.traceVendor).toBe("AWSXRAY");
74 expect(created.observabilityConfigurationRevision).toBeGreaterThanOrEqual(1);
75
76 // Out-of-band verification via distilled.
77 const described = yield* apprunner.describeObservabilityConfiguration({
78 ObservabilityConfigurationArn: created.observabilityConfigurationArn,
79 });
80 expect(described.ObservabilityConfiguration.Status?.toUpperCase()).toBe("ACTIVE");
81 expect(described.ObservabilityConfiguration.TraceConfiguration?.Vendor).toBe("AWSXRAY");
82
83 // No-op redeploy must not create a new revision.
84 const noop = yield* stack.deploy(ObservabilityConfiguration("Obs", props));
85 expect(noop.observabilityConfigurationRevision).toBe(
86 created.observabilityConfigurationRevision,
87 );
88
89 // Name change → replace; every revision of the old name is deleted.
90 const replaced = yield* stack.deploy(
91 ObservabilityConfiguration("Obs", {
92 ...props,
93 observabilityConfigurationName: "alchemy-test-obs-b",
94 }),
95 );
96 expect(replaced.observabilityConfigurationName).toBe("alchemy-test-obs-b");
97 yield* assertConfigGone("alchemy-test-obs");
98
99 // Destroy and verify deletion out-of-band.
100 yield* stack.destroy();
101 yield* assertConfigGone("alchemy-test-obs-b");
102 }),
103 {
104 tags: ["provider:aws", "provider:aws:apprunner", "live"],
105 timeout: 120_000,
106 },
107 );