@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 129 lines 4.41 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 vmwareengine from "@distilled.cloud/gcp/vmwareengine_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 // Private clouds need VMware Engine node quota and bill thousands of dollars
15 // a month; set GCP_TEST_VMWAREENGINE=1 on an entitled project to opt in.
16 const runLifecycle = !!process.env.GCP_TEST_VMWAREENGINE && !process.env.FAST;
17
18 const waitUntilGone = (name: string) =>
19 vmwareengine.getProjectsLocationsPrivateClouds({ name }).pipe(
20 Effect.as("found" as const),
21 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
22 Effect.repeat({
23 schedule: Schedule.spaced("2 seconds"),
24 until: (status) => status === "gone",
25 times: 10,
26 }),
27 );
28
29 test.provider(
30 "getProjectsLocationsPrivateClouds on a missing private cloud fails with a typed tag",
31 (stack) =>
32 Effect.gen(function* () {
33 const { project } = yield* GcpEnvironment.current;
34
35 yield* stack.destroy();
36
37 const error = yield* Effect.flip(
38 vmwareengine.getProjectsLocationsPrivateClouds({
39 name: `projects/${project}/locations/us-central1-a/privateClouds/alchemy-pc-missing`,
40 }),
41 );
42 expect(error._tag).toEqual("NotFound");
43
44 yield* stack.destroy();
45 }).pipe(logLevel),
46 {
47 tags: ["provider:gcp", "provider:gcp:vmwareengine", "live"],
48 timeout: 90_000,
49 },
50 );
51
52 test.provider.skipIf(!runLifecycle)(
53 "create, update, and delete a private cloud",
54 (stack) =>
55 Effect.gen(function* () {
56 yield* stack.destroy();
57
58 const created = yield* stack.deploy(
59 Effect.gen(function* () {
60 const ven = yield* GCP.VMwareEngine.VmwareEngineNetwork("Ven", {
61 type: "STANDARD",
62 description: "cloud parent",
63 });
64 const cloud = yield* GCP.VMwareEngine.PrivateCloud("Sddc", {
65 location: "us-central1-a",
66 type: "STANDARD",
67 networkConfig: {
68 managementCidr: "192.168.1.0/24",
69 vmwareEngineNetwork: ven.name,
70 },
71 managementCluster: {
72 clusterId: "mgmt",
73 nodeTypeConfigs: { "standard-72": { nodeCount: 3 } },
74 },
75 description: "alchemy-test-pc",
76 });
77 return { ven, cloud };
78 }),
79 );
80
81 expect(created.cloud.name).toContain("/privateClouds/");
82 expect(created.cloud.location).toEqual("us-central1-a");
83 expect(created.cloud.description).toEqual("alchemy-test-pc");
84
85 const fetched = yield* vmwareengine.getProjectsLocationsPrivateClouds({
86 name: created.cloud.name,
87 });
88 expect(fetched.name).toEqual(created.cloud.name);
89 expect(fetched.description).toContain("alchemy-id=");
90 expect(fetched.description).toContain("alchemy-test-pc");
91
92 const updated = yield* stack.deploy(
93 Effect.gen(function* () {
94 const ven = yield* GCP.VMwareEngine.VmwareEngineNetwork("Ven", {
95 vmwareEngineNetworkId: created.ven.vmwareEngineNetworkId,
96 type: "STANDARD",
97 description: "cloud parent",
98 });
99 const cloud = yield* GCP.VMwareEngine.PrivateCloud("Sddc", {
100 privateCloudId: created.cloud.privateCloudId,
101 location: "us-central1-a",
102 type: "STANDARD",
103 networkConfig: {
104 managementCidr: "192.168.1.0/24",
105 vmwareEngineNetwork: ven.name,
106 },
107 managementCluster: {
108 clusterId: "mgmt",
109 nodeTypeConfigs: { "standard-72": { nodeCount: 3 } },
110 },
111 description: "alchemy-prod-pc",
112 });
113 return { ven, cloud };
114 }),
115 );
116
117 expect(updated.cloud.name).toEqual(created.cloud.name);
118 expect(updated.cloud.description).toEqual("alchemy-prod-pc");
119
120 yield* stack.destroy();
121
122 const gone = yield* waitUntilGone(created.cloud.name);
123 expect(gone).toEqual("gone");
124 }).pipe(logLevel),
125 {
126 tags: ["provider:gcp", "provider:gcp:vmwareengine", "live"],
127 timeout: 120_000,
128 },
129 );