mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 12:33:59 +00:00
BREAKING CHANGE: JobDescription, JobEventsRequest, FunctionErrorsRequest, and FunctionErrors gain optional Rust metadata/cursor fields. Existing struct literals must initialize them; use None when unavailable. Preserve typed attempt state, pinned retry lineage, result decoders and freshness fences, and retained diagnostic paging across SDKs. Keep Python job data access method-only.
49 lines
1.8 KiB
TypeScript
49 lines
1.8 KiB
TypeScript
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
|
|
import { Job } from "../lancedb/job";
|
|
import type { Job as NativeJob } from "../lancedb/native";
|
|
|
|
describe("Job attempt contract", () => {
|
|
test("preserves lineage and unknown detailed states", async () => {
|
|
const inner = {
|
|
jobId: "attempt-2",
|
|
operationId: "attempt-1",
|
|
attempt: 2,
|
|
retryOf: "attempt-1",
|
|
lifecycleState: "future_publication_state",
|
|
sourceTableVersion: 7,
|
|
executionEpoch: 3,
|
|
status: jest.fn().mockResolvedValue("future_publication_state"),
|
|
} as unknown as NativeJob;
|
|
const job = new Job(inner);
|
|
expect(job.jobId).toBe("attempt-2");
|
|
expect(job.operationId).toBe("attempt-1");
|
|
expect(job.attempt).toBe(2);
|
|
expect(job.retryOf).toBe("attempt-1");
|
|
expect(await job.statusTyped()).toBe("future_publication_state");
|
|
expect(job.sourceTableVersion).toBe(7);
|
|
expect(job.executionEpoch).toBe(3);
|
|
});
|
|
|
|
test("passes wait deadlines through without cancelling execution", async () => {
|
|
const wait = jest.fn().mockRejectedValue(new Error("Timeout error"));
|
|
const cancel = jest.fn();
|
|
const job = new Job({ wait, cancel } as unknown as NativeJob);
|
|
await expect(job.wait({ timeoutMs: 1 })).rejects.toThrow("Timeout");
|
|
expect(wait).toHaveBeenCalledWith(undefined, 1);
|
|
expect(cancel).not.toHaveBeenCalled();
|
|
});
|
|
test("retry retains the typed result decoder", async () => {
|
|
const successor = {
|
|
waitResult: jest.fn().mockResolvedValue({ value: 7 }),
|
|
} as unknown as NativeJob;
|
|
const inner = {
|
|
retry: jest.fn().mockResolvedValue(successor),
|
|
} as unknown as NativeJob;
|
|
const job = new Job(inner, (value) => (value as { value: number }).value);
|
|
const retry = await job.retry();
|
|
expect(await retry.wait()).toBe(7);
|
|
});
|
|
});
|