@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

main
ts 106 lines 3.53 KB
Raw
1 import * as GCP from "@alchemy.run/gcp";
2 import { GcpEnvironment } from "@alchemy.run/gcp/Environment";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as oracle from "@distilled.cloud/gcp/oracledatabase_v1";
6 import * as Effect from "effect/Effect";
7 import { MinimumLogLevel } from "effect/References";
8 import * as Schedule from "effect/Schedule";
9
10 const { test } = Test.make({ providers: GCP.providers() });
11
12 const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info");
13
14 // Oracle Database@Google Cloud is not enabled in the test project
15 // (ServiceDisabled) and needs an Oracle Cloud subscription. Set
16 // GCP_TEST_ORACLE=1 in a project that has one.
17 const runLifecycle = !!process.env.GCP_TEST_ORACLE && !process.env.FAST;
18
19 const SSH_KEY =
20 "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl alchemy-test";
21
22 const waitUntilGone = (name: string) =>
23 oracle.getProjectsLocationsCloudVmClusters({ name }).pipe(
24 Effect.as("found" as const),
25 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
26 Effect.repeat({
27 schedule: Schedule.spaced("2 seconds"),
28 until: (status) => status === "gone",
29 times: 10,
30 }),
31 );
32
33 test.provider.skipIf(runLifecycle)(
34 "getProjectsLocationsCloudVmClusters without Oracle Database enabled fails with ServiceDisabled",
35 (stack) =>
36 Effect.gen(function* () {
37 const { project } = yield* GcpEnvironment.current;
38
39 yield* stack.destroy();
40
41 const error = yield* Effect.flip(
42 oracle.getProjectsLocationsCloudVmClusters({
43 name: `projects/${project}/locations/us-central1/cloudVmClusters/alchemy-oracle-missing`,
44 }),
45 );
46 expect(error._tag).toEqual("ServiceDisabled");
47
48 yield* stack.destroy();
49 }).pipe(logLevel),
50 {
51 tags: ["provider:gcp", "provider:gcp:oracledatabase", "live"],
52 timeout: 90_000,
53 },
54 );
55
56 test.provider.skipIf(!runLifecycle)(
57 "create, update, and delete a cloud vm cluster",
58 (stack) =>
59 Effect.gen(function* () {
60 const { project } = yield* GcpEnvironment.current;
61
62 yield* stack.destroy();
63
64 const created = yield* stack.deploy(
65 Effect.gen(function* () {
66 const infra = yield* GCP.OracleDatabase.CloudExadataInfrastructure("Exa", {
67 displayName: "alchemy-test-exa",
68 shape: "Exadata.X9M",
69 computeCount: 2,
70 storageCount: 3,
71 });
72 return yield* GCP.OracleDatabase.CloudVmCluster("Vms", {
73 location: "us-central1",
74 exadataInfrastructure: infra.name,
75 network: "default",
76 cidr: "10.10.0.0/24",
77 backupSubnetCidr: "10.10.1.0/24",
78 licenseType: "LICENSE_INCLUDED",
79 cpuCoreCount: 4,
80 giVersion: "19.0.0.0",
81 hostnamePrefix: "exa",
82 sshPublicKeys: [SSH_KEY],
83 labels: { env: "test" },
84 });
85 }),
86 );
87
88 expect(created.name).toContain("/cloudVmClusters/");
89 expect(created.cloudVmClusterId).toEqual(expect.any(String));
90 expect(created.labels).toMatchObject({ env: "test" });
91
92 const fetched = yield* oracle.getProjectsLocationsCloudVmClusters({
93 name: created.name,
94 });
95 expect(fetched.name).toEqual(created.name);
96
97 yield* stack.destroy();
98
99 const gone = yield* waitUntilGone(created.name);
100 expect(gone).toEqual("gone");
101 }).pipe(logLevel),
102 {
103 tags: ["provider:gcp", "provider:gcp:oracledatabase", "live"],
104 timeout: 120_000,
105 },
106 );