The best way to control Claude Code, Codex and more from any computer or phone

main
ts 93 lines 3.36 KB
Raw
1 import * as GCP from "@alchemy.run/gcp";
2 import { expect } from "@alchemy.run/test";
3 import * as Test from "@alchemy.run/test/Alchemy";
4 import * as datastream from "@distilled.cloud/gcp/datastream_v1";
5 import * as Effect from "effect/Effect";
6 import { withNetworkSlot } from "../networkQuota.ts";
7 import { LOCATION, logLevel, currentProject, runSlowLifecycle, waitUntilGone } from "./common.ts";
8
9 const { test } = Test.make({ providers: GCP.providers() });
10
11 test.provider(
12 "getProjectsLocationsPrivateConnectionsRoutes on a missing route fails with a typed tag",
13 (stack) =>
14 Effect.gen(function* () {
15 const project = yield* currentProject;
16 yield* stack.destroy();
17
18 const error = yield* Effect.flip(
19 datastream.getProjectsLocationsPrivateConnectionsRoutes({
20 name: `projects/${project}/locations/${LOCATION}/privateConnections/alchemy-missing-pconn/routes/alchemy-missing-route`,
21 }),
22 );
23 expect(error._tag).toEqual("NotFound");
24
25 yield* stack.destroy();
26 }).pipe(logLevel),
27 {
28 tags: ["provider:gcp", "provider:gcp:datastream", "live"],
29 timeout: 90_000,
30 },
31 );
32
33 test.provider.skipIf(!runSlowLifecycle)(
34 "create and delete a private connection route",
35 (stack) =>
36 Effect.gen(function* () {
37 yield* stack.destroy();
38
39 const created = yield* stack.deploy(
40 Effect.gen(function* () {
41 const network = yield* GCP.Compute.Network("DsRouteVpc", {
42 autoCreateSubnetworks: false,
43 });
44 const peering = yield* GCP.Datastream.PrivateConnection("DsRoutePeer", {
45 location: LOCATION,
46 displayName: "ds-route-peer",
47 force: true,
48 vpcPeeringConfig: {
49 vpc: network.networkName,
50 subnet: "10.9.1.0/29",
51 },
52 });
53 const route = yield* GCP.Datastream.PrivateConnectionsRoute("DbHost", {
54 privateConnection: peering.name,
55 location: LOCATION,
56 displayName: "db-host",
57 labels: { env: "test" },
58 destinationAddress: "10.0.0.8",
59 destinationPort: 3306,
60 });
61 return { network, peering, route };
62 }),
63 );
64
65 expect(created.route.routeId).toEqual(expect.any(String));
66 expect(created.route.name).toEqual(`${created.peering.name}/routes/${created.route.routeId}`);
67 expect(created.route.privateConnection).toEqual(created.peering.name);
68 expect(created.route.displayName).toEqual("db-host");
69 expect(created.route.labels).toMatchObject({ env: "test" });
70 expect(created.route.destinationAddress).toEqual("10.0.0.8");
71 expect(created.route.destinationPort).toEqual(3306);
72
73 const fetched = yield* datastream.getProjectsLocationsPrivateConnectionsRoutes({
74 name: created.route.name,
75 });
76 expect(fetched.name).toEqual(created.route.name);
77 expect(fetched.displayName).toEqual("db-host");
78 expect(fetched.destinationAddress).toEqual("10.0.0.8");
79 expect(fetched.labels?.env).toEqual("test");
80
81 yield* stack.destroy();
82 const gone = yield* waitUntilGone(
83 datastream.getProjectsLocationsPrivateConnectionsRoutes({
84 name: created.route.name,
85 }),
86 );
87 expect(gone).toEqual("gone");
88 }).pipe(logLevel, withNetworkSlot),
89 {
90 tags: ["provider:gcp", "provider:gcp:datastream", "live"],
91 timeout: 900_000,
92 },
93 );