@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 105 lines 3.39 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 aiplatform from "@distilled.cloud/gcp/aiplatform_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 // Legacy Featurestore online serving provisioning takes ~6 minutes.
15 const runLifecycle = !!process.env.GCP_TEST_SLOW && !process.env.FAST;
16
17 const waitUntilGone = (name: string) =>
18 aiplatform.getProjectsLocationsFeaturestores({ name }).pipe(
19 Effect.as("found" as const),
20 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
21 Effect.repeat({
22 schedule: Schedule.spaced("2 seconds"),
23 until: (status) => status === "gone",
24 times: 10,
25 }),
26 );
27
28 test.provider(
29 "getProjectsLocationsFeaturestores on a missing store fails with a typed tag",
30 (stack) =>
31 Effect.gen(function* () {
32 const { project } = yield* GcpEnvironment.current;
33 const parent = `projects/${project}/locations/us-central1`;
34 yield* stack.destroy();
35
36 const error = yield* Effect.flip(
37 aiplatform.getProjectsLocationsFeaturestores({
38 name: `${parent}/featurestores/alchemy_missing`,
39 }),
40 );
41 expect(error._tag).toEqual("NotFound");
42 const page = yield* aiplatform.listProjectsLocationsFeaturestores({
43 parent,
44 pageSize: 10,
45 });
46 expect((page.featurestores ?? []).map((item) => item.name)).not.toContain(
47 `${parent}/featurestores/alchemy_missing`,
48 );
49
50 yield* stack.destroy();
51 }).pipe(logLevel),
52 {
53 tags: ["provider:gcp", "provider:gcp:aiplatform", "live"],
54 timeout: 90_000,
55 },
56 );
57
58 test.provider.skipIf(!runLifecycle)(
59 "create, update, and delete a featurestore",
60 (stack) =>
61 Effect.gen(function* () {
62 yield* stack.destroy();
63
64 const created = yield* stack.deploy(
65 Effect.gen(function* () {
66 return yield* GCP.AIPlatform.Featurestore("Features", {
67 location: "us-central1",
68 labels: { env: "test" },
69 });
70 }),
71 );
72
73 expect(created.name).toContain("/featurestores/");
74 expect(created.location).toEqual("us-central1");
75 expect(created.labels).toMatchObject({ env: "test" });
76
77 const fetched = yield* aiplatform.getProjectsLocationsFeaturestores({
78 name: created.name,
79 });
80 expect(fetched.name).toEqual(created.name);
81 expect(fetched.labels?.env).toEqual("test");
82
83 const updated = yield* stack.deploy(
84 Effect.gen(function* () {
85 return yield* GCP.AIPlatform.Featurestore("Features", {
86 featurestoreId: created.featurestoreId,
87 location: "us-central1",
88 labels: { env: "prod", role: "features" },
89 });
90 }),
91 );
92
93 expect(updated.name).toEqual(created.name);
94 expect(updated.labels).toMatchObject({ env: "prod", role: "features" });
95
96 yield* stack.destroy();
97
98 const gone = yield* waitUntilGone(created.name);
99 expect(gone).toEqual("gone");
100 }).pipe(logLevel),
101 {
102 tags: ["provider:gcp", "provider:gcp:aiplatform", "live"],
103 timeout: 600_000,
104 },
105 );