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

main
ts 94 lines 3.77 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { DBClusterParameterGroup } from "@alchemy.run/aws/Neptune";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as neptune from "@distilled.cloud/aws/neptune";
6 import * as Effect from "effect/Effect";
7 import * as Schedule from "effect/Schedule";
8 import * as Stream from "effect/Stream";
9
10 const { test } = Test.make({ providers: AWS.providers() });
11
12 const assertGone = (name: string) =>
13 neptune.describeDBClusterParameterGroups({ DBClusterParameterGroupName: name }).pipe(
14 Effect.flatMap(() => Effect.fail(new Error(`parameter group '${name}' still exists`))),
15 Effect.catchTag("DBParameterGroupNotFoundFault", () => Effect.void),
16 Effect.retry({
17 schedule: Schedule.max([Schedule.fixed("2 seconds"), Schedule.recurs(10)]),
18 }),
19 );
20
21 const readUserParameters = (name: string) =>
22 neptune.describeDBClusterParameters
23 .pages({ DBClusterParameterGroupName: name, Source: "user" })
24 .pipe(
25 Stream.runCollect,
26 Effect.map((chunk) => Array.from(chunk).flatMap((page) => page.Parameters ?? [])),
27 );
28
29 test.provider(
30 "create, modify parameters, reset, delete a Neptune cluster parameter group",
31 (stack) =>
32 Effect.gen(function* () {
33 yield* stack.destroy();
34
35 const { group } = yield* stack.deploy(
36 Effect.gen(function* () {
37 const group = yield* DBClusterParameterGroup("Params", {
38 family: "neptune1.4",
39 description: "alchemy neptune cluster params",
40 parameters: { neptune_query_timeout: "180000" },
41 tags: { fixture: "neptune-cluster-params" },
42 });
43 return { group };
44 }),
45 );
46
47 expect(group.dbClusterParameterGroupName).toBeDefined();
48 expect(group.dbClusterParameterGroupArn).toContain(":cluster-pg:");
49 expect(group.family).toBe("neptune1.4");
50 expect(group.parameters).toEqual({ neptune_query_timeout: "180000" });
51
52 // Out-of-band verification: the override is recorded as a user param.
53 const userParams = yield* readUserParameters(group.dbClusterParameterGroupName);
54 expect(
55 userParams.find((p) => p.ParameterName === "neptune_query_timeout")?.ParameterValue,
56 ).toBe("180000");
57
58 // Update the parameter value in place.
59 const { group: updated } = yield* stack.deploy(
60 Effect.gen(function* () {
61 const group = yield* DBClusterParameterGroup("Params", {
62 family: "neptune1.4",
63 description: "alchemy neptune cluster params",
64 parameters: { neptune_query_timeout: "60000" },
65 tags: { fixture: "neptune-cluster-params" },
66 });
67 return { group };
68 }),
69 );
70 expect(updated.dbClusterParameterGroupName).toBe(group.dbClusterParameterGroupName);
71 const updatedParams = yield* readUserParameters(group.dbClusterParameterGroupName);
72 expect(
73 updatedParams.find((p) => p.ParameterName === "neptune_query_timeout")?.ParameterValue,
74 ).toBe("60000");
75
76 // Remove the override — the provider resets it to the engine default.
77 yield* stack.deploy(
78 Effect.gen(function* () {
79 const group = yield* DBClusterParameterGroup("Params", {
80 family: "neptune1.4",
81 description: "alchemy neptune cluster params",
82 tags: { fixture: "neptune-cluster-params" },
83 });
84 return { group };
85 }),
86 );
87 const resetParams = yield* readUserParameters(group.dbClusterParameterGroupName);
88 expect(resetParams.find((p) => p.ParameterName === "neptune_query_timeout")).toBeUndefined();
89
90 yield* stack.destroy();
91 yield* assertGone(group.dbClusterParameterGroupName);
92 }),
93 { tags: ["provider:aws", "provider:aws:neptune", "live"], timeout: 240_000 },
94 );