@fabricorg/databricks-testkit 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +27 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -562,7 +562,7 @@ async function runLiveSuite(spec, runtime = {}) {
|
|
|
562
562
|
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
563
563
|
const ownedWarehouse = runtime.warehouse === void 0;
|
|
564
564
|
const client = runtime.client ?? createClientFromEnv(env);
|
|
565
|
-
const warehouse = runtime.warehouse ?? await createWorkspaceContext({ env, client });
|
|
565
|
+
const warehouse = runtime.warehouse ?? (hasWarehouseConfig(env) ? await createWorkspaceContext({ env, client }) : unavailableWarehouseContext());
|
|
566
566
|
const results = [];
|
|
567
567
|
try {
|
|
568
568
|
for (const check of spec.checks) {
|
|
@@ -616,6 +616,24 @@ async function runLiveSuite(spec, runtime = {}) {
|
|
|
616
616
|
if (spec.junitPath) await writeReport(spec.junitPath, renderJUnit(evidence));
|
|
617
617
|
return evidence;
|
|
618
618
|
}
|
|
619
|
+
function hasWarehouseConfig(env) {
|
|
620
|
+
return Boolean(env.DATABRICKS_WAREHOUSE_ID || env.DATABRICKS_HTTP_PATH);
|
|
621
|
+
}
|
|
622
|
+
function unavailableWarehouseContext() {
|
|
623
|
+
const unavailable = async () => {
|
|
624
|
+
throw new Error(
|
|
625
|
+
"This live check requires DATABRICKS_WAREHOUSE_ID or DATABRICKS_HTTP_PATH; REST-only checks can run without SQL warehouse configuration"
|
|
626
|
+
);
|
|
627
|
+
};
|
|
628
|
+
return {
|
|
629
|
+
profile: "live",
|
|
630
|
+
qual: (table) => table,
|
|
631
|
+
exec: unavailable,
|
|
632
|
+
query: unavailable,
|
|
633
|
+
loadFixture: unavailable,
|
|
634
|
+
close: async () => void 0
|
|
635
|
+
};
|
|
636
|
+
}
|
|
619
637
|
async function writeReport(path$1, contents) {
|
|
620
638
|
await promises.mkdir(path.dirname(path$1), { recursive: true });
|
|
621
639
|
await promises.writeFile(path$1, contents, "utf8");
|
|
@@ -690,6 +708,7 @@ function sqlRoundTripCheck() {
|
|
|
690
708
|
return {
|
|
691
709
|
id: "sql",
|
|
692
710
|
description: "SQL Statement Execution round-trip",
|
|
711
|
+
configured: (env) => Boolean(env.DATABRICKS_WAREHOUSE_ID || env.DATABRICKS_HTTP_PATH),
|
|
693
712
|
async run({ warehouse }) {
|
|
694
713
|
const rows = await warehouse.query("SELECT 1 AS dbx_test_ok");
|
|
695
714
|
if (Number(rows[0]?.dbx_test_ok) !== 1)
|
|
@@ -1298,6 +1317,7 @@ function failureRecoveryCheck() {
|
|
|
1298
1317
|
return {
|
|
1299
1318
|
id: "failure-recovery",
|
|
1300
1319
|
description: "A failed statement is isolated and a subsequent statement recovers",
|
|
1320
|
+
configured: (env) => Boolean(env.DATABRICKS_WAREHOUSE_ID || env.DATABRICKS_HTTP_PATH),
|
|
1301
1321
|
async run({ warehouse }) {
|
|
1302
1322
|
let failedAsExpected = false;
|
|
1303
1323
|
try {
|
|
@@ -1343,6 +1363,7 @@ function backupRestoreCheck() {
|
|
|
1343
1363
|
return {
|
|
1344
1364
|
id: "backup-restore",
|
|
1345
1365
|
description: "Delta DEEP CLONE backup restores a dropped scratch table",
|
|
1366
|
+
configured: (env) => Boolean(env.DATABRICKS_WAREHOUSE_ID || env.DATABRICKS_HTTP_PATH),
|
|
1346
1367
|
async run({ warehouse }) {
|
|
1347
1368
|
const source = warehouse.qual(safeName("backup_source"));
|
|
1348
1369
|
const backup = warehouse.qual(safeName("backup_clone"));
|
|
@@ -1365,6 +1386,7 @@ function rollbackCheck() {
|
|
|
1365
1386
|
return {
|
|
1366
1387
|
id: "rollback",
|
|
1367
1388
|
description: "Delta time-travel rollback restores a known-good table version",
|
|
1389
|
+
configured: (env) => Boolean(env.DATABRICKS_WAREHOUSE_ID || env.DATABRICKS_HTTP_PATH),
|
|
1368
1390
|
async run({ warehouse }) {
|
|
1369
1391
|
const table = warehouse.qual(safeName("rollback_probe"));
|
|
1370
1392
|
try {
|
|
@@ -1453,7 +1475,10 @@ function classicComputeCheck() {
|
|
|
1453
1475
|
});
|
|
1454
1476
|
const result = run.state?.result_state;
|
|
1455
1477
|
if (result !== "SUCCESS") {
|
|
1456
|
-
|
|
1478
|
+
const message = run.state?.state_message;
|
|
1479
|
+
throw new Error(
|
|
1480
|
+
`Classic compute run ${submitted.run_id} ended in ${result ?? "UNKNOWN"}${message ? `: ${message}` : ""}`
|
|
1481
|
+
);
|
|
1457
1482
|
}
|
|
1458
1483
|
return {
|
|
1459
1484
|
runId: submitted.run_id,
|