| 1 | import * as AWS from "@/AWS"; |
| 2 | import { PodIdentityAssociation } from "@/AWS/EKS"; |
| 3 | import * as Provider from "@/Provider"; |
| 4 | import * as Test from "@/Test/Alchemy"; |
| 5 | import { expect } from "alchemy-test"; |
| 6 | import * as Effect from "effect/Effect"; |
| 7 | |
| 8 | const { test } = Test.make({ providers: AWS.providers() }); |
| 9 | |
| 10 | // Ungated probe: `list()` enumerates every cluster, lists each cluster's pod |
| 11 | // identity associations, then hydrates each via `describePodIdentityAssociation`. |
| 12 | // It requires no deployed resource — in a clean account/region it returns `[]`, |
| 13 | // otherwise a well-formed array of full PodIdentityAssociation Attributes. This |
| 14 | // proves the enumeration wiring (listClusters -> listPodIdentityAssociations -> |
| 15 | // describePodIdentityAssociation) compiles and runs live without needing a |
| 16 | // ~10-minute cluster create. |
| 17 | test.provider( |
| 18 | "list returns a well-formed array of pod identity associations", |
| 19 | (stack) => |
| 20 | Effect.gen(function* () { |
| 21 | yield* stack.destroy(); |
| 22 | |
| 23 | const provider = yield* Provider.findProvider(PodIdentityAssociation); |
| 24 | const all = yield* provider.list(); |
| 25 | |
| 26 | expect(Array.isArray(all)).toBe(true); |
| 27 | for (const association of all) { |
| 28 | expect(typeof association.associationArn).toBe("string"); |
| 29 | expect(typeof association.associationId).toBe("string"); |
| 30 | expect(typeof association.clusterName).toBe("string"); |
| 31 | expect(typeof association.namespace).toBe("string"); |
| 32 | expect(typeof association.serviceAccount).toBe("string"); |
| 33 | expect(typeof association.roleArn).toBe("string"); |
| 34 | } |
| 35 | }), |
| 36 | { tags: ["provider:aws", "provider:aws:eks", "live"] }, |
| 37 | ); |
| 38 | |
| 39 | // Full deploy test: an EKS cluster takes ~10+ minutes to provision, which is far |
| 40 | // too heavy for CI. Gate the deploy behind a pre-existing cluster supplied via |
| 41 | // AWS_TEST_EKS_CLUSTER; an entitled account with a standing cluster runs this |
| 42 | // unchanged. Deploys an association, asserts it appears in the |
| 43 | // exhaustively-paginated `list()`, then tears down. |
| 44 | test.provider.skipIf(!process.env.AWS_TEST_EKS_CLUSTER)( |
| 45 | "list enumerates the deployed pod identity association", |
| 46 | (stack) => |
| 47 | Effect.gen(function* () { |
| 48 | yield* stack.destroy(); |
| 49 | |
| 50 | const clusterName = process.env.AWS_TEST_EKS_CLUSTER!; |
| 51 | const roleArn = process.env.AWS_TEST_EKS_POD_ROLE_ARN!; |
| 52 | |
| 53 | const association = yield* stack.deploy( |
| 54 | Effect.gen(function* () { |
| 55 | return yield* PodIdentityAssociation("ListPodIdentity", { |
| 56 | clusterName, |
| 57 | namespace: "default", |
| 58 | serviceAccount: "alchemy-test-list-sa", |
| 59 | roleArn, |
| 60 | }); |
| 61 | }), |
| 62 | ); |
| 63 | |
| 64 | const provider = yield* Provider.findProvider(PodIdentityAssociation); |
| 65 | const all = yield* provider.list(); |
| 66 | |
| 67 | expect( |
| 68 | all.some((a) => a.associationId === association.associationId), |
| 69 | ).toBe(true); |
| 70 | |
| 71 | yield* stack.destroy(); |
| 72 | }), |
| 73 | { tags: ["provider:aws", "provider:aws:eks", "live"], timeout: 600_000 }, |
| 74 | ); |