| 1 | import * as AWS from "@/AWS"; |
| 2 | import { Addon } 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 |
| 11 | // add-ons, then hydrates each via `describeAddon`. It requires no deployed |
| 12 | // resource — in a clean account/region it returns `[]`, otherwise a |
| 13 | // well-formed array of full Add-on Attributes. This proves the enumeration |
| 14 | // wiring (listClusters -> listAddons -> describeAddon) compiles and runs live |
| 15 | // without needing a ~10-minute cluster create. |
| 16 | test.provider( |
| 17 | "list returns a well-formed array of add-ons", |
| 18 | (stack) => |
| 19 | Effect.gen(function* () { |
| 20 | yield* stack.destroy(); |
| 21 | |
| 22 | const provider = yield* Provider.findProvider(Addon); |
| 23 | const all = yield* provider.list(); |
| 24 | |
| 25 | expect(Array.isArray(all)).toBe(true); |
| 26 | for (const addon of all) { |
| 27 | expect(typeof addon.addonArn).toBe("string"); |
| 28 | expect(typeof addon.addonName).toBe("string"); |
| 29 | expect(typeof addon.clusterName).toBe("string"); |
| 30 | } |
| 31 | }), |
| 32 | { tags: ["provider:aws", "provider:aws:eks", "live"] }, |
| 33 | ); |
| 34 | |
| 35 | // Full deploy test: an EKS cluster takes ~10+ minutes to provision, which is |
| 36 | // far too heavy for CI. Gate the deploy behind a pre-existing cluster supplied |
| 37 | // via AWS_TEST_EKS_CLUSTER; an entitled account with a standing cluster runs |
| 38 | // this unchanged. Deploys `metrics-server`, asserts it appears in the |
| 39 | // exhaustively-paginated `list()`, then tears down. |
| 40 | test.provider.skipIf(!process.env.AWS_TEST_EKS_CLUSTER)( |
| 41 | "list enumerates the deployed add-on", |
| 42 | (stack) => |
| 43 | Effect.gen(function* () { |
| 44 | yield* stack.destroy(); |
| 45 | |
| 46 | const clusterName = process.env.AWS_TEST_EKS_CLUSTER!; |
| 47 | |
| 48 | const addon = yield* stack.deploy( |
| 49 | Effect.gen(function* () { |
| 50 | return yield* Addon("ListAddon", { |
| 51 | clusterName, |
| 52 | addonName: "metrics-server", |
| 53 | }); |
| 54 | }), |
| 55 | ); |
| 56 | |
| 57 | const provider = yield* Provider.findProvider(Addon); |
| 58 | const all = yield* provider.list(); |
| 59 | |
| 60 | expect( |
| 61 | all.some( |
| 62 | (a) => |
| 63 | a.clusterName === addon.clusterName && |
| 64 | a.addonName === addon.addonName, |
| 65 | ), |
| 66 | ).toBe(true); |
| 67 | |
| 68 | yield* stack.destroy(); |
| 69 | }), |
| 70 | { tags: ["provider:aws", "provider:aws:eks", "live"], timeout: 600_000 }, |
| 71 | ); |