| 1 | import * as AWS from "@/AWS"; |
| 2 | import { RouteTable, Vpc } from "@/AWS/EC2"; |
| 3 | import * as Provider from "@/Provider"; |
| 4 | import * as Test from "./VpcTest.ts"; |
| 5 | import { expect } from "alchemy-test"; |
| 6 | import * as Effect from "effect/Effect"; |
| 7 | import { MinimumLogLevel } from "effect/References"; |
| 8 | import { assertRouteTableGone, assertVpcGone } from "./Gone.ts"; |
| 9 | |
| 10 | const { test } = Test.make({ providers: AWS.providers() }); |
| 11 | |
| 12 | const logLevel = Effect.provideService( |
| 13 | MinimumLogLevel, |
| 14 | process.env.DEBUG ? "Debug" : "Info", |
| 15 | ); |
| 16 | |
| 17 | test.provider( |
| 18 | "list enumerates the deployed RouteTable", |
| 19 | (stack) => |
| 20 | Effect.gen(function* () { |
| 21 | yield* stack.destroy(); |
| 22 | |
| 23 | const { vpc, routeTable } = yield* stack.deploy( |
| 24 | Effect.gen(function* () { |
| 25 | const vpc = yield* Vpc("ListRouteTableVpc", { |
| 26 | cidrBlock: "10.0.0.0/16", |
| 27 | }); |
| 28 | const routeTable = yield* RouteTable("ListRouteTable", { |
| 29 | vpcId: vpc.vpcId, |
| 30 | }); |
| 31 | return { vpc, routeTable }; |
| 32 | }), |
| 33 | ); |
| 34 | |
| 35 | const provider = yield* Provider.findProvider(RouteTable); |
| 36 | const all = yield* provider.list(); |
| 37 | |
| 38 | expect(all.some((x) => x.routeTableId === routeTable.routeTableId)).toBe( |
| 39 | true, |
| 40 | ); |
| 41 | |
| 42 | yield* stack.destroy(); |
| 43 | |
| 44 | yield* assertRouteTableGone(routeTable.routeTableId); |
| 45 | yield* assertVpcGone(vpc.vpcId); |
| 46 | }).pipe(logLevel), |
| 47 | // VPC + RouteTable create, an account-wide DescribeRouteTables, then two |
| 48 | // destroys (with VPC dependency-ordered teardown) can exceed the default |
| 49 | // 120s under full-suite EC2 throttling load. All waits are bounded; give |
| 50 | // the end-to-end run headroom. (Observed blowing 180s during a full-suite |
| 51 | // run where concurrent EC2 suites saturated the account's request budget |
| 52 | // and VPC quota; a timeout mid-destroy also leaks the VPC.) |
| 53 | { tags: ["provider:aws", "provider:aws:ec2", "live"], timeout: 300_000 }, |
| 54 | ); |