fix: close realtime initialization visibility gaps
This commit is contained in:
@@ -29,7 +29,7 @@ const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../
|
||||
const migrationPaths = CLOUD_CORE_MIGRATIONS.map((migration) => migration.path);
|
||||
const latestMigrationPath = migrationPaths.at(-1);
|
||||
const defaultReportPath = tempReportPath("dev-runtime-migration-report.json");
|
||||
const issue = "pikasTech/HWLAB#164";
|
||||
const issue = "pikasTech/HWLAB#2464";
|
||||
|
||||
export async function runDevRuntimeMigrationCli(argv = process.argv.slice(2), options = {}) {
|
||||
const args = parseArgs(argv);
|
||||
@@ -495,6 +495,12 @@ function summarizeDbEnv(env = {}) {
|
||||
}
|
||||
|
||||
function buildApplyBoundary(args) {
|
||||
const schemaWriteScope = migrationPaths.map((migrationPath) =>
|
||||
`DEV Postgres schema objects declared by ${migrationPath}`
|
||||
);
|
||||
const ledgerWriteScope = CLOUD_CORE_MIGRATIONS.map((migration) =>
|
||||
`DEV ${CLOUD_RUNTIME_DURABLE_MIGRATION_TABLE} ledger row ${migration.id}`
|
||||
);
|
||||
return {
|
||||
defaultMode: "check",
|
||||
mode: args.mode,
|
||||
@@ -503,10 +509,7 @@ function buildApplyBoundary(args) {
|
||||
requiresForLiveDbRead: ["--confirm-dev", "HWLAB_CLOUD_DB_URL from hwlab-cloud-api-dev-db/database-url"],
|
||||
requiresForApply: ["--apply", "--confirm-dev", "--confirmed-non-production", "HWLAB_CLOUD_DB_URL from hwlab-cloud-api-dev-db/database-url"],
|
||||
writeScope: args.mode === "apply"
|
||||
? [
|
||||
"DEV Postgres schema objects declared by internal/db/migrations/0001_cloud_core_skeleton.sql",
|
||||
"DEV hwlab_schema_migrations ledger row 0001_cloud_core_skeleton"
|
||||
]
|
||||
? [...schemaWriteScope, ...ledgerWriteScope]
|
||||
: [],
|
||||
noWriteScope: [
|
||||
"Kubernetes Secret resources",
|
||||
|
||||
@@ -9,8 +9,10 @@ import {
|
||||
parseArgs
|
||||
} from "./dev-runtime-migration.mjs";
|
||||
import {
|
||||
CLOUD_CORE_MIGRATIONS,
|
||||
CLOUD_RUNTIME_DURABLE_MIGRATION_ID,
|
||||
CLOUD_RUNTIME_DURABLE_ADAPTER_SCHEMA_VERSION,
|
||||
CLOUD_RUNTIME_DURABLE_MIGRATION_TABLE,
|
||||
CLOUD_RUNTIME_DURABLE_TABLE_COLUMNS
|
||||
} from "../../internal/db/schema.ts";
|
||||
|
||||
@@ -34,6 +36,8 @@ test("source check is non-secret and does not attempt live DB access", async ()
|
||||
assert.equal(report.gates.schema.status, "ready");
|
||||
assert.equal(report.gates.migration.status, "ready");
|
||||
assert.equal(report.gates.readiness.status, "not_checked");
|
||||
assert.equal(report.issue, "pikasTech/HWLAB#2464");
|
||||
assert.deepEqual(report.applyBoundary.writeScope, []);
|
||||
assert.equal(report.safety.sourceStoresSecretValues, false);
|
||||
assert.equal(report.safety.printsSecretValues, false);
|
||||
assert.equal(JSON.stringify(report).includes("secret-password"), false);
|
||||
@@ -308,6 +312,13 @@ test("apply mode records ledger and verifies durable runtime readiness", async (
|
||||
assert.equal(report.gates.readiness.status, "ready");
|
||||
assert.equal(report.runtime.migration.appliedMigrationId, CLOUD_RUNTIME_DURABLE_MIGRATION_ID);
|
||||
assert.equal(report.runtime.migration.appliedSchemaVersion, CLOUD_RUNTIME_DURABLE_ADAPTER_SCHEMA_VERSION);
|
||||
assert.deepEqual(report.applyBoundary.writeScope, [
|
||||
...CLOUD_CORE_MIGRATIONS.map((migration) => `DEV Postgres schema objects declared by ${migration.path}`),
|
||||
...CLOUD_CORE_MIGRATIONS.map((migration) => `DEV ${CLOUD_RUNTIME_DURABLE_MIGRATION_TABLE} ledger row ${migration.id}`)
|
||||
]);
|
||||
assert.equal(report.applyBoundary.writeScope.length, CLOUD_CORE_MIGRATIONS.length * 2);
|
||||
assert.ok(report.applyBoundary.writeScope.some((entry) => entry.includes("0008_workbench_kafka_realtime.sql")));
|
||||
assert.ok(report.applyBoundary.writeScope.some((entry) => entry.endsWith(`ledger row ${CLOUD_RUNTIME_DURABLE_MIGRATION_ID}`)));
|
||||
assert.ok(queryClient.calls.some((call) => call.sql === "BEGIN"));
|
||||
assert.ok(queryClient.calls.some((call) => call.sql.includes("INSERT INTO hwlab_schema_migrations")));
|
||||
assert.ok(queryClient.calls.some((call) => call.sql === "COMMIT"));
|
||||
|
||||
Reference in New Issue
Block a user