@rotorsoft/act-tck 1.36.17 → 1.36.19

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
@@ -2261,6 +2261,36 @@ var runStoreTck = (options) => {
2261
2261
  await fresh.dispose();
2262
2262
  }
2263
2263
  });
2264
+ it7("records the lease holder for a zero-length lease, so its ack lands", async () => {
2265
+ const fresh = await options.factory();
2266
+ try {
2267
+ await fresh.drop();
2268
+ await fresh.seed();
2269
+ const s = `lease-zero-${uid()}`;
2270
+ await fresh.subscribe([{ stream: s }]);
2271
+ const [committed] = await fresh.commit(
2272
+ s,
2273
+ [inc(1)],
2274
+ make_meta({ stream: s })
2275
+ );
2276
+ await correlate(fresh);
2277
+ const leased = await fresh.claim(1, 0, `w-${uid()}`, 0);
2278
+ const mine = leased.find((l) => l.stream === s);
2279
+ expect8(mine).toBeDefined();
2280
+ const acked = await fresh.ack([{ ...mine, at: committed.id }]);
2281
+ expect8(acked).toHaveLength(1);
2282
+ let at = -1;
2283
+ await fresh.query_streams(
2284
+ (p) => {
2285
+ at = p.at;
2286
+ },
2287
+ { stream: s, stream_exact: true }
2288
+ );
2289
+ expect8(at).toBe(committed.id);
2290
+ } finally {
2291
+ await fresh.dispose();
2292
+ }
2293
+ });
2264
2294
  it7("reports lagging=true from the lagging frontier and false from the leading frontier", async () => {
2265
2295
  const fresh = await options.factory();
2266
2296
  try {
@@ -3166,6 +3196,50 @@ var runStoreTck = (options) => {
3166
3196
  });
3167
3197
  expect8(seen).toEqual(["fast"]);
3168
3198
  });
3199
+ it7("keeps the lane when a lower-priority subscribe re-registers", async () => {
3200
+ const s = `lane-rank-${uid()}`;
3201
+ await store.subscribe([{ stream: s, lane: "fast", priority: 10 }]);
3202
+ await store.subscribe([{ stream: s, lane: "slow", priority: 0 }]);
3203
+ const seen = [];
3204
+ await store.query_streams(
3205
+ (p) => seen.push({ lane: p.lane, priority: p.priority }),
3206
+ { stream: s, stream_exact: true }
3207
+ );
3208
+ expect8(seen).toEqual([{ lane: "fast", priority: 10 }]);
3209
+ });
3210
+ it7("keeps the lane when a mark-only subscribe re-registers", async () => {
3211
+ const s = `lane-mark-${uid()}`;
3212
+ await store.subscribe([{ stream: s, lane: "fast", priority: 10 }]);
3213
+ await store.subscribe([{ stream: s, correlated_at: 7 }]);
3214
+ const seen = [];
3215
+ await store.query_streams(
3216
+ (p) => seen.push({ lane: p.lane, correlated_at: p.correlated_at }),
3217
+ { stream: s, stream_exact: true }
3218
+ );
3219
+ expect8(seen).toEqual([{ lane: "fast", correlated_at: 7 }]);
3220
+ });
3221
+ it7("re-lanes when the subscribe outranks the stored priority", async () => {
3222
+ const s = `lane-outrank-${uid()}`;
3223
+ await store.subscribe([{ stream: s, lane: "fast", priority: 0 }]);
3224
+ await store.subscribe([{ stream: s, lane: "slow", priority: 5 }]);
3225
+ const seen = [];
3226
+ await store.query_streams(
3227
+ (p) => seen.push({ lane: p.lane, priority: p.priority }),
3228
+ { stream: s, stream_exact: true }
3229
+ );
3230
+ expect8(seen).toEqual([{ lane: "slow", priority: 5 }]);
3231
+ });
3232
+ it7("re-lanes at equal priority, which is what keeps re-laning restart-driven", async () => {
3233
+ const s = `lane-equal-${uid()}`;
3234
+ await store.subscribe([{ stream: s, lane: "fast", priority: 7 }]);
3235
+ await store.subscribe([{ stream: s, lane: "slow", priority: 7 }]);
3236
+ const seen = [];
3237
+ await store.query_streams((p) => seen.push(p.lane), {
3238
+ stream: s,
3239
+ stream_exact: true
3240
+ });
3241
+ expect8(seen).toEqual(["slow"]);
3242
+ });
3169
3243
  it7("claim() filters by lane when supplied and returns lane on the Lease", async () => {
3170
3244
  const tag = uid();
3171
3245
  const src1 = `lane-claim-src1-${tag}`;
@@ -3609,6 +3683,25 @@ var runStoreTck = (options) => {
3609
3683
  }
3610
3684
  expect8([...visited].sort()).toEqual([...names].sort());
3611
3685
  });
3686
+ it7("limit: 0 returns no rows", async () => {
3687
+ const s = `qs-zero-${uid()}`;
3688
+ await store.subscribe([{ stream: s }]);
3689
+ const seen = [];
3690
+ const push = (p) => {
3691
+ seen.push(p.stream);
3692
+ };
3693
+ const filter = { stream: s, stream_exact: true };
3694
+ const control = await store.query_streams(push, filter);
3695
+ expect8(control.count).toBe(1);
3696
+ expect8(seen).toEqual([s]);
3697
+ seen.length = 0;
3698
+ const { count } = await store.query_streams(push, {
3699
+ ...filter,
3700
+ limit: 0
3701
+ });
3702
+ expect8(seen).toEqual([]);
3703
+ expect8(count).toBe(0);
3704
+ });
3612
3705
  it7("returns positions filtered by stream regex, exact, source, and source_exact", async () => {
3613
3706
  const tag = uid();
3614
3707
  const proj1 = `qs-${tag}-projection-tickets`;
@@ -3746,6 +3839,21 @@ var runStoreTck = (options) => {
3746
3839
  const unknown = await store.query_stats([`qst-${tag}-missing`]);
3747
3840
  expect8(unknown.size).toBe(0);
3748
3841
  });
3842
+ it7("limit: 0 returns no rows", async () => {
3843
+ const s = `qst-zero-${uid()}`;
3844
+ await store.commit(
3845
+ s,
3846
+ [inc(1)],
3847
+ make_meta({ stream: s })
3848
+ );
3849
+ const filter = { stream: s, stream_exact: true };
3850
+ const control = await store.query_stats(filter);
3851
+ expect8(control.size).toBe(1);
3852
+ const stats = await store.query_stats(filter, {
3853
+ limit: 0
3854
+ });
3855
+ expect8(stats.size).toBe(0);
3856
+ });
3749
3857
  it7("keyset pagination visits every stream regardless of name case (#1357)", async () => {
3750
3858
  const tag = uid();
3751
3859
  const names = [