@cloudhal/schedules 0.6.1 → 0.6.2
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/src/testing.d.ts +44 -0
- package/dist/src/testing.js +1472 -0
- package/package.json +13 -5
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared suites (RFC-0008 §16, §17), run from vitest files against better-sqlite3 and Miniflare D1
|
|
3
|
+
* like the storage, analytics and comments suites:
|
|
4
|
+
*
|
|
5
|
+
* - `describeScheduleStoreConformance` — `SqlScheduleStore`: releases (create, the `rl1:` hash,
|
|
6
|
+
* transitions with CAS, re-pin, cancel, holds and overlaps, lazy expiry), automations (create,
|
|
7
|
+
* pause/resume with CAS), settings and the kill switch, usage counted from audit rows, system
|
|
8
|
+
* jobs, the heartbeat and retention. Every record read back is checked against its contract.
|
|
9
|
+
* - `describeSchedulerConformance` — `runDue` over the real store with fake work seams: releases on
|
|
10
|
+
* time and never early (S2), at most one effect under concurrent ticks on two stores sharing one
|
|
11
|
+
* database (S3), conflicts (S4), the hour limit and retries (S8), lease expiry and recovery, the
|
|
12
|
+
* kill switch, one release at a time per site in time order (D15), built-in steps and agent-task
|
|
13
|
+
* windows, watermarks, the heartbeat, and the statement count of every path within the Workers
|
|
14
|
+
* Free `TickBudget` (S17).
|
|
15
|
+
*/
|
|
16
|
+
import type { Automation, Release, ScheduleRun } from "@cloudhal/core-contracts";
|
|
17
|
+
import type { SqlDriver, SqlStatement } from "@cloudhal/storage";
|
|
18
|
+
import { type ReleaseExecution, type ReleaseExecutionInput, type ReleaseExecutor } from "./scheduler.js";
|
|
19
|
+
export interface ScheduleStoreFactory {
|
|
20
|
+
/** A fresh, migrated, empty database. */
|
|
21
|
+
create(): Promise<SqlDriver>;
|
|
22
|
+
/** A second driver over the same database (another isolate or process). Default: the same driver. */
|
|
23
|
+
peer?(driver: SqlDriver): SqlDriver;
|
|
24
|
+
dispose?(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
/** A driver that counts statements: every read, every write and every statement of a batch. */
|
|
27
|
+
export interface CountingDriver extends SqlDriver {
|
|
28
|
+
readonly statements: SqlStatement[];
|
|
29
|
+
reset(): void;
|
|
30
|
+
}
|
|
31
|
+
export declare function countingDriver(inner: SqlDriver): CountingDriver;
|
|
32
|
+
/** A `ReleaseExecutor` stand-in (the seam `publishRelease` fills in rollout step 5). */
|
|
33
|
+
export interface FakeReleaseExecutor extends ReleaseExecutor {
|
|
34
|
+
readonly calls: ReleaseExecutionInput[];
|
|
35
|
+
behavior: (input: ReleaseExecutionInput) => ReleaseExecution | Promise<ReleaseExecution>;
|
|
36
|
+
}
|
|
37
|
+
export declare function fakeReleaseExecutor(behavior?: (input: ReleaseExecutionInput) => ReleaseExecution | Promise<ReleaseExecution>, cost?: number): FakeReleaseExecutor;
|
|
38
|
+
export declare function expectContractRelease(r: Release): void;
|
|
39
|
+
export declare function expectContractAutomation(a: Automation): void;
|
|
40
|
+
export declare function expectContractRun(r: ScheduleRun): void;
|
|
41
|
+
export declare function describeScheduleStoreConformance(label: string, factory: ScheduleStoreFactory): void;
|
|
42
|
+
/** Statement counts measured per path (filled while the scheduler suite runs; see the README). */
|
|
43
|
+
export declare const MEASURED_STATEMENTS: Record<string, number>;
|
|
44
|
+
export declare function describeSchedulerConformance(label: string, factory: ScheduleStoreFactory): void;
|