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

main
ts 73 lines 2.84 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { Cluster } from "@alchemy.run/aws/EKS";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as Provider from "alchemy/Provider";
6 import * as Effect from "effect/Effect";
7
8 const { test } = Test.make({ providers: AWS.providers() });
9
10 // Ungated probe: `list()` enumerates every cluster in the ambient
11 // account/region by paginating `listClusters` (names only) and hydrating each
12 // via `readCluster` (describeCluster + listTagsForResource). It needs no
13 // deployed resource — in a clean account/region it returns `[]`, otherwise a
14 // well-formed array of full Cluster Attributes. This proves the enumeration
15 // wiring (listClusters -> describeCluster) compiles and runs live without
16 // paying the ~10-minute control-plane create.
17 test.provider(
18 "list returns a well-formed array of clusters",
19 (stack) =>
20 Effect.gen(function* () {
21 yield* stack.destroy();
22
23 const provider = yield* Provider.findProvider(Cluster);
24 const all = yield* provider.list();
25
26 expect(Array.isArray(all)).toBe(true);
27 for (const cluster of all) {
28 expect(typeof cluster.clusterArn).toBe("string");
29 expect(typeof cluster.clusterName).toBe("string");
30 expect(typeof cluster.roleArn).toBe("string");
31 }
32 }),
33 { tags: ["provider:aws", "provider:aws:eks", "live"] },
34 );
35
36 // Full deploy test: an EKS control plane takes ~10+ minutes to provision, far
37 // too heavy for CI. Gate the deploy behind env vars supplying a pre-existing
38 // IAM role ARN (AWS_TEST_EKS_ROLE_ARN) and at least two subnet IDs
39 // (AWS_TEST_EKS_SUBNET_IDS, comma-separated). An account with that standing
40 // infrastructure runs this unchanged: it deploys a cluster, waits for ACTIVE,
41 // asserts it appears in the exhaustively-paginated `list()`, then tears down.
42 test.provider.skipIf(!process.env.AWS_TEST_EKS_ROLE_ARN || !process.env.AWS_TEST_EKS_SUBNET_IDS)(
43 "list enumerates the deployed cluster",
44 (stack) =>
45 Effect.gen(function* () {
46 yield* stack.destroy();
47
48 const roleArn = process.env.AWS_TEST_EKS_ROLE_ARN!;
49 const subnetIds = process.env.AWS_TEST_EKS_SUBNET_IDS!.split(",");
50
51 const cluster = yield* stack.deploy(
52 Effect.gen(function* () {
53 return yield* Cluster("ListCluster", {
54 clusterName: "alchemy-test-eks-list",
55 roleArn,
56 resourcesVpcConfig: {
57 subnetIds,
58 endpointPublicAccess: true,
59 endpointPrivateAccess: true,
60 },
61 });
62 }),
63 );
64
65 const provider = yield* Provider.findProvider(Cluster);
66 const all = yield* provider.list();
67
68 expect(all.some((c) => c.clusterName === cluster.clusterName)).toBe(true);
69
70 yield* stack.destroy();
71 }),
72 { tags: ["provider:aws", "provider:aws:eks", "live"], timeout: 1_800_000 },
73 );