| 1 | import * as AWS from "@/AWS"; |
| 2 | import * as Test from "@/Test/Alchemy"; |
| 3 | import * as ElastiCache from "@distilled.cloud/aws/elasticache"; |
| 4 | import { expect } from "alchemy-test"; |
| 5 | import * as Effect from "effect/Effect"; |
| 6 | import { |
| 7 | assertReplicationGroupGone, |
| 8 | getProvisionedNetwork, |
| 9 | shareProvisionedNetwork, |
| 10 | } from "./ProvisionedFixture.ts"; |
| 11 | |
| 12 | const { test, beforeAll, afterAll } = Test.make({ |
| 13 | providers: AWS.providers(), |
| 14 | }); |
| 15 | shareProvisionedNetwork({ beforeAll, afterAll }); |
| 16 | test.provider.skipIf(!process.env.AWS_TEST_SLOW)( |
| 17 | "create, update, verify, and destroy a provisioned Redis OSS replication group", |
| 18 | (stack) => |
| 19 | Effect.gen(function* () { |
| 20 | yield* stack.destroy(); |
| 21 | const net = yield* getProvisionedNetwork; |
| 22 | const deploy = (description: string) => |
| 23 | stack.deploy( |
| 24 | Effect.gen(function* () { |
| 25 | const cache = yield* AWS.ElastiCache.ReplicationGroup("Cache", { |
| 26 | description, |
| 27 | engine: "redis", |
| 28 | nodeType: "cache.t4g.micro", |
| 29 | subnetGroupName: net.subnetGroupName, |
| 30 | securityGroupIds: [net.securityGroupId], |
| 31 | replicasPerNodeGroup: 0, |
| 32 | transitEncryptionEnabled: true, |
| 33 | tags: { fixture: "elasticache-provisioned-redis" }, |
| 34 | }); |
| 35 | return { cache }; |
| 36 | }), |
| 37 | ); |
| 38 | |
| 39 | const { cache } = yield* deploy("alchemy Redis OSS cache"); |
| 40 | const created = yield* ElastiCache.describeReplicationGroups({ |
| 41 | ReplicationGroupId: cache.replicationGroupId, |
| 42 | }); |
| 43 | expect(created.ReplicationGroups?.[0]?.Engine).toBe("redis"); |
| 44 | expect(created.ReplicationGroups?.[0]?.Status).toBe("available"); |
| 45 | |
| 46 | const { cache: updated } = yield* deploy("alchemy Redis OSS cache v2"); |
| 47 | expect(updated.replicationGroupId).toBe(cache.replicationGroupId); |
| 48 | |
| 49 | yield* stack.destroy(); |
| 50 | yield* assertReplicationGroupGone(cache.replicationGroupId); |
| 51 | }), |
| 52 | { |
| 53 | tags: [ |
| 54 | "provider:aws", |
| 55 | "provider:aws:ec2", |
| 56 | "provider:aws:elasticache", |
| 57 | "live", |
| 58 | ], |
| 59 | timeout: 2_700_000, |
| 60 | }, |
| 61 | ); |