The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
| 1 | import * as AWS from "@alchemy.run/aws"; |
| 2 | import { ComputeEnvironment } from "@alchemy.run/aws/Batch/ComputeEnvironment"; |
| 3 | import { JobQueue } from "@alchemy.run/aws/Batch/JobQueue"; |
| 4 | import { expect } from "@alchemy.run/test"; |
| 5 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 6 | import * as batch from "@distilled.cloud/aws/batch"; |
| 7 | import * as Effect from "effect/Effect"; |
| 8 | import { BatchTestNetwork } from "./TestNetwork.ts"; |
| 9 | |
| 10 | const { test } = Test.make({ providers: AWS.providers() }); |
| 11 | |
| 12 | const ceName = "alchemy-test-batch-jq-ce"; |
| 13 | const queueName = "alchemy-test-batch-jq"; |
| 14 | |
| 15 | const describeQueue = batch |
| 16 | .describeJobQueues({ jobQueues: [queueName] }) |
| 17 | .pipe(Effect.map((res) => res.jobQueues?.find((q) => q.status !== "DELETED"))); |
| 18 | |
| 19 | const describeCe = batch |
| 20 | .describeComputeEnvironments({ computeEnvironments: [ceName] }) |
| 21 | .pipe(Effect.map((res) => res.computeEnvironments?.find((ce) => ce.status !== "DELETED"))); |
| 22 | |
| 23 | const chain = (priority?: number) => |
| 24 | Effect.gen(function* () { |
| 25 | const network = yield* BatchTestNetwork; |
| 26 | const ce = yield* ComputeEnvironment("JqCE", { |
| 27 | computeEnvironmentName: ceName, |
| 28 | subnets: network.subnetIds, |
| 29 | securityGroupIds: network.securityGroupIds, |
| 30 | }); |
| 31 | return yield* JobQueue("Queue", { |
| 32 | jobQueueName: queueName, |
| 33 | computeEnvironments: [ce.computeEnvironmentArn], |
| 34 | ...(priority !== undefined ? { priority } : {}), |
| 35 | }); |
| 36 | }); |
| 37 | |
| 38 | test.provider( |
| 39 | "chain lifecycle: CE -> queue create, update priority, ordered destroy", |
| 40 | (stack) => |
| 41 | Effect.gen(function* () { |
| 42 | yield* stack.destroy(); |
| 43 | |
| 44 | // Create the CE -> queue chain. |
| 45 | const deployed = yield* stack.deploy(chain()); |
| 46 | expect(deployed.jobQueueArn).toContain(`job-queue/${queueName}`); |
| 47 | |
| 48 | // Out-of-band verification via distilled. |
| 49 | const created = yield* describeQueue; |
| 50 | expect(created?.status).toBe("VALID"); |
| 51 | expect(created?.state).toBe("ENABLED"); |
| 52 | expect(created?.priority).toBe(1); |
| 53 | expect(created?.computeEnvironmentOrder?.[0]?.computeEnvironment).toContain( |
| 54 | `compute-environment/${ceName}`, |
| 55 | ); |
| 56 | |
| 57 | // Update — priority syncs in place. |
| 58 | yield* stack.deploy(chain(5)); |
| 59 | const updated = yield* describeQueue; |
| 60 | expect(updated?.priority).toBe(5); |
| 61 | expect(updated?.status).toBe("VALID"); |
| 62 | |
| 63 | // Destroy — queue must fully drain before the CE delete succeeds |
| 64 | // (exercises the DISABLED -> wait -> delete -> wait-gone path and the |
| 65 | // CE's ComputeEnvironmentInUse retry window). |
| 66 | yield* stack.destroy(); |
| 67 | expect(yield* describeQueue).toBeUndefined(); |
| 68 | expect(yield* describeCe).toBeUndefined(); |
| 69 | }), |
| 70 | { |
| 71 | tags: ["provider:aws", "provider:aws:batch", "provider:aws:ec2", "live"], |
| 72 | timeout: 240_000, |
| 73 | }, |
| 74 | ); |