The best way to control Claude Code, Codex and more from any computer or phone
| 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 vmmigration from "@distilled.cloud/gcp/vmmigration_v1"; |
| 5 | import * as Effect from "effect/Effect"; |
| 6 | import { dummyAws, logLevel, currentProject, runSourceLifecycle, waitUntilGone } from "./common.ts"; |
| 7 | |
| 8 | const { test } = Test.make({ providers: GCP.providers() }); |
| 9 | |
| 10 | test.provider( |
| 11 | "getProjectsLocationsSourcesDiskMigrationJobs on a missing job fails with a typed tag", |
| 12 | (stack) => |
| 13 | Effect.gen(function* () { |
| 14 | const project = yield* currentProject; |
| 15 | yield* stack.destroy(); |
| 16 | |
| 17 | const error = yield* Effect.flip( |
| 18 | vmmigration.getProjectsLocationsSourcesDiskMigrationJobs({ |
| 19 | name: `projects/${project}/locations/us-central1/sources/alchemy-missing-source/diskMigrationJobs/alchemy-missing-job`, |
| 20 | }), |
| 21 | ); |
| 22 | expect(error._tag).toEqual("NotFound"); |
| 23 | |
| 24 | yield* stack.destroy(); |
| 25 | }).pipe(logLevel), |
| 26 | { |
| 27 | tags: ["provider:gcp", "provider:gcp:vmmigration", "live"], |
| 28 | timeout: 90_000, |
| 29 | }, |
| 30 | ); |
| 31 | |
| 32 | test.provider.skipIf(!runSourceLifecycle)( |
| 33 | "create, update, and delete a vm migration disk migration job", |
| 34 | (stack) => |
| 35 | Effect.gen(function* () { |
| 36 | const project = yield* currentProject; |
| 37 | yield* stack.destroy(); |
| 38 | |
| 39 | const created = yield* stack.deploy( |
| 40 | Effect.gen(function* () { |
| 41 | const source = yield* GCP.VMMigration.Source("DiskSource", { |
| 42 | aws: dummyAws, |
| 43 | }); |
| 44 | const target = yield* GCP.VMMigration.Target("DiskLanding"); |
| 45 | return yield* GCP.VMMigration.SourcesDiskMigrationJob("Boot", { |
| 46 | source: source.name, |
| 47 | awsSourceDiskDetails: { volumeId: "vol-0123456789abcdef0" }, |
| 48 | targetDetails: { |
| 49 | targetProject: target.name, |
| 50 | targetDisk: { |
| 51 | zone: `projects/${project}/locations/us-central1-a`, |
| 52 | diskType: "COMPUTE_ENGINE_DISK_TYPE_STANDARD", |
| 53 | diskId: "alchemy-imported-boot", |
| 54 | }, |
| 55 | labels: { env: "test" }, |
| 56 | }, |
| 57 | }); |
| 58 | }), |
| 59 | ); |
| 60 | |
| 61 | expect(created.diskMigrationJobId).toEqual(expect.any(String)); |
| 62 | expect(created.name).toContain("/diskMigrationJobs/"); |
| 63 | expect(created.awsSourceDiskDetails?.volumeId).toEqual("vol-0123456789abcdef0"); |
| 64 | expect(created.targetDetails?.labels).toMatchObject({ env: "test" }); |
| 65 | |
| 66 | const fetched = yield* vmmigration.getProjectsLocationsSourcesDiskMigrationJobs({ |
| 67 | name: created.name, |
| 68 | }); |
| 69 | expect(fetched.name).toEqual(created.name); |
| 70 | expect(fetched.targetDetails?.labels?.env).toEqual("test"); |
| 71 | |
| 72 | const updated = yield* stack.deploy( |
| 73 | Effect.gen(function* () { |
| 74 | const source = yield* GCP.VMMigration.Source("DiskSource", { |
| 75 | aws: dummyAws, |
| 76 | }); |
| 77 | const target = yield* GCP.VMMigration.Target("DiskLanding"); |
| 78 | return yield* GCP.VMMigration.SourcesDiskMigrationJob("Boot", { |
| 79 | source: source.name, |
| 80 | diskMigrationJobId: created.diskMigrationJobId, |
| 81 | awsSourceDiskDetails: { volumeId: "vol-0123456789abcdef0" }, |
| 82 | targetDetails: { |
| 83 | targetProject: target.name, |
| 84 | targetDisk: { |
| 85 | zone: `projects/${project}/locations/us-central1-a`, |
| 86 | diskType: "COMPUTE_ENGINE_DISK_TYPE_SSD", |
| 87 | diskId: "alchemy-imported-boot", |
| 88 | }, |
| 89 | labels: { env: "prod" }, |
| 90 | }, |
| 91 | }); |
| 92 | }), |
| 93 | ); |
| 94 | |
| 95 | expect(updated.name).toEqual(created.name); |
| 96 | expect(updated.targetDetails?.labels).toMatchObject({ env: "prod" }); |
| 97 | |
| 98 | yield* stack.destroy(); |
| 99 | const gone = yield* waitUntilGone( |
| 100 | vmmigration.getProjectsLocationsSourcesDiskMigrationJobs({ |
| 101 | name: created.name, |
| 102 | }), |
| 103 | ); |
| 104 | expect(gone).toEqual("gone"); |
| 105 | }).pipe(logLevel), |
| 106 | { |
| 107 | tags: ["provider:gcp", "provider:gcp:vmmigration", "live"], |
| 108 | timeout: 120_000, |
| 109 | }, |
| 110 | ); |