@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 78 lines 2.79 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 compute from "@distilled.cloud/gcp/compute_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 const runLifecycle = !process.env.FAST;
15
16 const waitUntilGone = (project: string, globalVmExtensionPolicy: string) =>
17 compute.getGlobalVmExtensionPolicies({ project, globalVmExtensionPolicy }).pipe(
18 Effect.as("found" as const),
19 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
20 Effect.repeat({
21 schedule: Schedule.spaced("2 seconds"),
22 until: (status) => status === "gone",
23 times: 10,
24 }),
25 );
26
27 test.provider.skipIf(!runLifecycle)(
28 "create, update, and delete a global VM extension policy",
29 (stack) =>
30 Effect.gen(function* () {
31 yield* stack.destroy();
32
33 const created = yield* stack.deploy(
34 Effect.gen(function* () {
35 return yield* GCP.Compute.GlobalVmExtensionPolicy("Ops", {
36 description: "ops agent",
37 extensionPolicies: { "ops-agent": {} },
38 rolloutOperation: {
39 rolloutInput: { predefinedRolloutPlan: "FAST_ROLLOUT" },
40 },
41 priority: 10,
42 });
43 }),
44 );
45
46 expect(created.policyName).toEqual(expect.any(String));
47 expect(created.description).toEqual("ops agent");
48 expect(created.priority).toEqual(10);
49
50 const fetched = yield* compute.getGlobalVmExtensionPolicies({
51 project: created.project,
52 globalVmExtensionPolicy: created.policyName,
53 });
54 expect(fetched.name).toEqual(created.policyName);
55 expect(fetched.description).toContain("[alchemy ");
56
57 const updated = yield* stack.deploy(
58 Effect.gen(function* () {
59 return yield* GCP.Compute.GlobalVmExtensionPolicy("Ops", {
60 policyName: created.policyName,
61 description: "updated ops agent",
62 extensionPolicies: { "ops-agent": {} },
63 rolloutOperation: {
64 rolloutInput: { predefinedRolloutPlan: "FAST_ROLLOUT" },
65 },
66 priority: 20,
67 });
68 }),
69 );
70 expect(updated.description).toEqual("updated ops agent");
71 expect(updated.priority).toEqual(20);
72
73 yield* stack.destroy();
74 const gone = yield* waitUntilGone(created.project, created.policyName);
75 expect(gone).toEqual("gone");
76 }).pipe(logLevel),
77 { tags: ["provider:gcp", "provider:gcp:compute", "live"], timeout: 900_000 },
78 );