mirror of
https://github.com/VibedByKaKi/t3-code-android-nightly.git
synced 2026-10-17 07:47:44 +02:00
102 lines
3.3 KiB
TypeScript
102 lines
3.3 KiB
TypeScript
import * as GCP from "@/GCP";
|
|
import * as Test from "@/Test/Alchemy";
|
|
import * as oracle from "@distilled.cloud/gcp/oracledatabase_v1";
|
|
import { expect } from "alchemy-test";
|
|
import * as Effect from "effect/Effect";
|
|
import { MinimumLogLevel } from "effect/References";
|
|
import * as Schedule from "effect/Schedule";
|
|
import { GcpEnvironment } from "@/GCP/Environment";
|
|
|
|
const { test } = Test.make({ providers: GCP.providers() });
|
|
|
|
const logLevel = Effect.provideService(
|
|
MinimumLogLevel,
|
|
process.env.DEBUG ? "Debug" : "Info",
|
|
);
|
|
|
|
// Oracle Database@Google Cloud is not enabled in the test project
|
|
// (ServiceDisabled) and needs an Oracle Cloud subscription. Set
|
|
// GCP_TEST_ORACLE=1 in a project that has one.
|
|
const runLifecycle = !!process.env.GCP_TEST_ORACLE && !process.env.FAST;
|
|
|
|
const SSH_KEY =
|
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl alchemy-test";
|
|
|
|
const waitUntilGone = (name: string) =>
|
|
oracle.getProjectsLocationsDbSystems({ name }).pipe(
|
|
Effect.as("found" as const),
|
|
Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
|
|
Effect.repeat({
|
|
schedule: Schedule.spaced("2 seconds"),
|
|
until: (status) => status === "gone",
|
|
times: 10,
|
|
}),
|
|
);
|
|
|
|
test.provider.skipIf(runLifecycle)(
|
|
"getProjectsLocationsDbSystems without Oracle Database enabled fails with ServiceDisabled",
|
|
(stack) =>
|
|
Effect.gen(function* () {
|
|
const { project } = yield* GcpEnvironment.current;
|
|
|
|
yield* stack.destroy();
|
|
|
|
const error = yield* Effect.flip(
|
|
oracle.getProjectsLocationsDbSystems({
|
|
name: `projects/${project}/locations/us-central1/dbSystems/alchemy-oracle-missing`,
|
|
}),
|
|
);
|
|
expect(error._tag).toEqual("ServiceDisabled");
|
|
|
|
yield* stack.destroy();
|
|
}).pipe(logLevel),
|
|
{
|
|
tags: ["provider:gcp", "provider:gcp:oracledatabase", "live"],
|
|
timeout: 90_000,
|
|
},
|
|
);
|
|
|
|
test.provider.skipIf(!runLifecycle)(
|
|
"create, update, and delete a db system",
|
|
(stack) =>
|
|
Effect.gen(function* () {
|
|
const { project } = yield* GcpEnvironment.current;
|
|
|
|
yield* stack.destroy();
|
|
|
|
const created = yield* stack.deploy(
|
|
Effect.gen(function* () {
|
|
return yield* GCP.OracleDatabase.DbSystem("BaseDb", {
|
|
location: "us-central1",
|
|
displayName: "alchemy-test-dbsystem",
|
|
odbSubnet: `projects/${project}/locations/us-central1/odbNetworks/missing/odbSubnets/client`,
|
|
shape: "VM.Standard.E4.Flex",
|
|
sshPublicKeys: [SSH_KEY],
|
|
computeCount: 2,
|
|
initialDataStorageSizeGb: 256,
|
|
licenseModel: "LICENSE_INCLUDED",
|
|
databaseEdition: "ENTERPRISE_EDITION",
|
|
labels: { env: "test" },
|
|
});
|
|
}),
|
|
);
|
|
|
|
expect(created.name).toContain("/dbSystems/");
|
|
expect(created.dbSystemId).toEqual(expect.any(String));
|
|
expect(created.labels).toMatchObject({ env: "test" });
|
|
|
|
const fetched = yield* oracle.getProjectsLocationsDbSystems({
|
|
name: created.name,
|
|
});
|
|
expect(fetched.name).toEqual(created.name);
|
|
|
|
yield* stack.destroy();
|
|
|
|
const gone = yield* waitUntilGone(created.name);
|
|
expect(gone).toEqual("gone");
|
|
}).pipe(logLevel),
|
|
{
|
|
tags: ["provider:gcp", "provider:gcp:oracledatabase", "live"],
|
|
timeout: 120_000,
|
|
},
|
|
);
|