@rotorsoft/act-tck 1.31.0 → 1.32.0

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.js CHANGED
@@ -1799,6 +1799,106 @@ var runStoreTck = (options) => {
1799
1799
  expect8(seen).not.toContain("correlated");
1800
1800
  });
1801
1801
  });
1802
+ describe8.skipIf(!caps.work_set)("subscription work set", () => {
1803
+ const claimable = async (stream) => {
1804
+ const leased = await store.claim(100, 0, `w-${uid()}`, 1);
1805
+ const mine = leased.find((l) => l.stream === stream);
1806
+ if (mine) await store.ack([{ ...mine, at: mine.at }]);
1807
+ return mine !== void 0;
1808
+ };
1809
+ it7("claims a marked stream without probing the event log", async () => {
1810
+ const s = `ws-mark-${uid()}`;
1811
+ await store.subscribe([{ stream: s, source: `ws-src-${uid()}` }]);
1812
+ expect8(await claimable(s)).toBe(false);
1813
+ await store.subscribe([{ stream: s, correlated_at: 7 }]);
1814
+ expect8(await claimable(s)).toBe(true);
1815
+ const s2 = `ws-mark-nosrc-${uid()}`;
1816
+ await store.subscribe([{ stream: s2, correlated_at: 7 }]);
1817
+ expect8(await claimable(s2)).toBe(true);
1818
+ });
1819
+ it7("never regresses the mark, for every value on the number line", async () => {
1820
+ const s = `ws-mono-${uid()}`;
1821
+ await store.subscribe([
1822
+ { stream: s, source: `ws-none-${uid()}`, correlated_at: 10 }
1823
+ ]);
1824
+ const leased = await store.claim(100, 0, `w-${uid()}`, 1e4);
1825
+ await store.ack([
1826
+ { ...leased.find((l) => l.stream === s), at: 5 }
1827
+ ]);
1828
+ expect8(await claimable(s)).toBe(true);
1829
+ await store.subscribe([{ stream: s, correlated_at: 4 }]);
1830
+ expect8(await claimable(s)).toBe(true);
1831
+ await store.subscribe([{ stream: s, correlated_at: 5 }]);
1832
+ expect8(await claimable(s)).toBe(true);
1833
+ await store.subscribe([{ stream: s, correlated_at: -3 }]);
1834
+ expect8(await claimable(s)).toBe(true);
1835
+ await store.subscribe([{ stream: s, correlated_at: 0 }]);
1836
+ expect8(await claimable(s)).toBe(true);
1837
+ const leased2 = await store.claim(100, 0, `w-${uid()}`, 1e4);
1838
+ await store.ack([
1839
+ { ...leased2.find((l) => l.stream === s), at: 10 }
1840
+ ]);
1841
+ expect8(await claimable(s)).toBe(false);
1842
+ await store.subscribe([{ stream: s, correlated_at: 11 }]);
1843
+ expect8(await claimable(s)).toBe(true);
1844
+ });
1845
+ it7("retires a stream when ack catches the watermark up to the mark", async () => {
1846
+ const s = `ws-retire-${uid()}`;
1847
+ await store.subscribe([
1848
+ { stream: s, source: `ws-none-${uid()}`, correlated_at: 5 }
1849
+ ]);
1850
+ const leased = await store.claim(100, 0, `w-${uid()}`, 1e4);
1851
+ const mine = leased.find((l) => l.stream === s);
1852
+ expect8(mine).toBeDefined();
1853
+ await store.ack([{ ...mine, at: 5 }]);
1854
+ expect8(await claimable(s)).toBe(false);
1855
+ await store.subscribe([{ stream: s, correlated_at: 6 }]);
1856
+ expect8(await claimable(s)).toBe(true);
1857
+ });
1858
+ it7("keeps the mark across reset, so a rebuild is claimable", async () => {
1859
+ const s = `ws-reset-${uid()}`;
1860
+ await store.subscribe([
1861
+ { stream: s, source: `ws-none-${uid()}`, correlated_at: 3 }
1862
+ ]);
1863
+ const leased = await store.claim(100, 0, `w-${uid()}`, 1e4);
1864
+ await store.ack([
1865
+ { ...leased.find((l) => l.stream === s), at: 3 }
1866
+ ]);
1867
+ expect8(await claimable(s)).toBe(false);
1868
+ await store.reset([s]);
1869
+ expect8(await claimable(s)).toBe(true);
1870
+ });
1871
+ it7("keeps the mark across unblock, defer, and prioritize", async () => {
1872
+ const s = `ws-ops-${uid()}`;
1873
+ await store.subscribe([
1874
+ { stream: s, source: `ws-none-${uid()}`, correlated_at: 9 }
1875
+ ]);
1876
+ const leased = await store.claim(100, 0, `w-${uid()}`, 1e4);
1877
+ const mine = leased.find((l) => l.stream === s);
1878
+ await store.block([{ ...mine, error: "poison" }]);
1879
+ expect8(await claimable(s)).toBe(false);
1880
+ expect8(await store.unblock([s])).toBe(1);
1881
+ expect8(await claimable(s)).toBe(true);
1882
+ await store.defer([s], Date.now() + 6e4);
1883
+ expect8(await claimable(s)).toBe(false);
1884
+ await store.defer([s], Date.now() - 1);
1885
+ expect8(await claimable(s)).toBe(true);
1886
+ await store.prioritize({ stream: s, stream_exact: true }, 5);
1887
+ expect8(await claimable(s)).toBe(true);
1888
+ });
1889
+ it7("falls back to the legacy probe for an unmarked stream", async () => {
1890
+ const s = `ws-legacy-${uid()}`;
1891
+ const src = `ws-legacy-src-${uid()}`;
1892
+ await store.subscribe([{ stream: s, source: src }]);
1893
+ expect8(await claimable(s)).toBe(false);
1894
+ await store.commit(
1895
+ src,
1896
+ [inc(1)],
1897
+ make_meta({ stream: src })
1898
+ );
1899
+ expect8(await claimable(s)).toBe(true);
1900
+ });
1901
+ });
1802
1902
  it7("claims a subscribed stream and ack releases the lease", async () => {
1803
1903
  const s = `claim-${uid()}`;
1804
1904
  await store.subscribe([{ stream: s }]);