diff --git a/kv/tests/kv_test.ts b/kv/tests/kv_test.ts index 0becde60..b1484378 100644 --- a/kv/tests/kv_test.ts +++ b/kv/tests/kv_test.ts @@ -64,12 +64,12 @@ import { Base64KeyCodec, NoopKvCodecs } from "../mod.ts"; import { kvPrefix, validateBucket, validateKey } from "../internal_mod.ts"; import { + _setup, cleanup, jetstreamServerConf, Lock, NatsServer, notCompatible, - setup, } from "../../test_helpers/mod.ts"; import { JSONCodec } from "jsr:@nats-io/nats-core@3.0.0-14/internal"; import type { @@ -157,9 +157,7 @@ Deno.test("kv - bucket name validation", () => { }); Deno.test("kv - list kv", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const jsm = await jetstreamManager(nc); await jsm.streams.add({ name: "A", subjects: ["a"] }); @@ -181,7 +179,7 @@ Deno.test("kv - list kv", async () => { await cleanup(ns, nc); }); Deno.test("kv - init creates stream", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -200,7 +198,7 @@ Deno.test("kv - init creates stream", async () => { }); Deno.test("kv - bind to existing KV", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -269,9 +267,7 @@ async function crud(bucket: Bucket): Promise { } Deno.test("kv - crud", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -283,9 +279,7 @@ Deno.test("kv - crud", async () => { }); Deno.test("kv - codec crud", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -307,9 +301,7 @@ Deno.test("kv - codec crud", async () => { }); Deno.test("kv - history", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -331,9 +323,7 @@ Deno.test("kv - history", async () => { }); Deno.test("kv - history multiple keys", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const n = nuid.next(); const js = jetstream(nc); const bucket = await new Kvm(js).create(n, { history: 2 }); @@ -356,9 +346,7 @@ Deno.test("kv - history multiple keys", async () => { }); Deno.test("kv - cleanups/empty", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -382,9 +370,7 @@ Deno.test("kv - cleanups/empty", async () => { }); Deno.test("kv - history cleanup", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -412,9 +398,7 @@ Deno.test("kv - history cleanup", async () => { }); Deno.test("kv - bucket watch", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -494,9 +478,7 @@ async function keyWatch(bucket: Bucket): Promise { } Deno.test("kv - key watch", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -512,9 +494,7 @@ Deno.test("kv - key watch", async () => { }); Deno.test("kv - codec key watch", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -552,9 +532,7 @@ async function keys(b: Bucket): Promise { } Deno.test("kv - keys", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -570,9 +548,7 @@ Deno.test("kv - keys", async () => { }); Deno.test("kv - codec keys", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -594,9 +570,7 @@ Deno.test("kv - codec keys", async () => { }); Deno.test("kv - ttl", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -621,9 +595,7 @@ Deno.test("kv - ttl", async () => { }); Deno.test("kv - no ttl", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -645,9 +617,7 @@ Deno.test("kv - no ttl", async () => { }); Deno.test("kv - complex key", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -691,9 +661,7 @@ Deno.test("kv - complex key", async () => { }); Deno.test("kv - remove key", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -719,9 +687,7 @@ Deno.test("kv - remove key", async () => { }); Deno.test("kv - remove subkey", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -744,9 +710,7 @@ Deno.test("kv - remove subkey", async () => { }); Deno.test("kv - create key", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -767,9 +731,7 @@ Deno.test("kv - create key", async () => { }); Deno.test("kv - update key", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -792,9 +754,7 @@ Deno.test("kv - update key", async () => { }); Deno.test("kv - internal consumer", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -819,9 +779,7 @@ Deno.test("kv - internal consumer", async () => { }); Deno.test("kv - is wildcard delete implemented", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -862,9 +820,7 @@ Deno.test("kv - is wildcard delete implemented", async () => { }); Deno.test("kv - delta", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -895,9 +851,7 @@ Deno.test("kv - delta", async () => { }); Deno.test("kv - watch and history headers only", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const js = jetstream(nc); const b = await new Kvm(js).create("bucket") as Bucket; const sc = StringCodec(); @@ -931,9 +885,7 @@ Deno.test("kv - watch and history headers only", async () => { }); Deno.test("kv - mem and file", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const js = jetstream(nc); const d = await new Kvm(js).create("default") as Bucket; assertEquals((await d.status()).backingStore, StorageType.File); @@ -955,7 +907,7 @@ Deno.test("kv - mem and file", async () => { }); Deno.test("kv - example", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const js = jetstream(nc); const sc = StringCodec(); @@ -1184,9 +1136,7 @@ Deno.test("kv - cross account watch", async () => { }); Deno.test("kv - watch iter stops", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const js = jetstream(nc); const b = await new Kvm(js).create("a") as Bucket; const watch = await b.watch(); @@ -1202,9 +1152,7 @@ Deno.test("kv - watch iter stops", async () => { }); Deno.test("kv - defaults to discard new - if server 2.7.2", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const js = jetstream(nc); const b = await new Kvm(js).create("a") as Bucket; const jsm = await jetstreamManager(nc); @@ -1219,9 +1167,7 @@ Deno.test("kv - defaults to discard new - if server 2.7.2", async () => { }); Deno.test("kv - initialized watch empty", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const js = jetstream(nc); const b = await new Kvm(js).create("a") as Bucket; @@ -1237,9 +1183,7 @@ Deno.test("kv - initialized watch empty", async () => { }); Deno.test("kv - initialized watch with messages", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const js = jetstream(nc); const b = await new Kvm(js).create("a") as Bucket; @@ -1263,9 +1207,7 @@ Deno.test("kv - initialized watch with messages", async () => { }); Deno.test("kv - initialized watch with modifications", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const js = jetstream(nc); const b = await new Kvm(js).create("a") as Bucket; @@ -1307,9 +1249,7 @@ Deno.test("kv - initialized watch with modifications", async () => { }); Deno.test("kv - watch init callback exceptions terminate the iterator", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const js = jetstream(nc); const b = await new Kvm(js).create("a") as Bucket; @@ -1338,9 +1278,7 @@ Deno.test("kv - watch init callback exceptions terminate the iterator", async () }); Deno.test("kv - get revision", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const js = jetstream(nc); const sc = StringCodec(); @@ -1374,9 +1312,7 @@ Deno.test("kv - get revision", async () => { }); Deno.test("kv - purge deletes", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const js = jetstream(nc); const b = await new Kvm(js).create("a") as Bucket; @@ -1423,9 +1359,7 @@ Deno.test("kv - replicas", async () => { }); Deno.test("kv - allow direct", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.9.0")) { return; @@ -1482,9 +1416,7 @@ Deno.test("kv - allow direct", async () => { }); Deno.test("kv - direct message", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.9.0")) { return; @@ -1530,7 +1462,7 @@ Deno.test("kv - direct message", async () => { }); Deno.test("kv - republish", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.9.0")) { return; } @@ -1560,9 +1492,7 @@ Deno.test("kv - republish", async () => { }); Deno.test("kv - ttl is in nanos", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const js = jetstream(nc); const b = await new Kvm(js).create("a", { ttl: 1000 }); @@ -1577,9 +1507,7 @@ Deno.test("kv - ttl is in nanos", async () => { }); Deno.test("kv - size", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const js = jetstream(nc); const b = await new Kvm(js).create("a", { ttl: 1000 }); @@ -1596,7 +1524,8 @@ Deno.test("kv - size", async () => { }); Deno.test("kv - mirror cross domain", async () => { - const { ns, nc } = await setup( + const { ns, nc } = await _setup( + connect, jetstreamServerConf({ server_name: "HUB", jetstream: { domain: "HUB" }, @@ -1605,7 +1534,8 @@ Deno.test("kv - mirror cross domain", async () => { // the ports file doesn't report leaf node const varz = await ns.varz() as unknown; - const { ns: lns, nc: lnc } = await setup( + const { ns: lns, nc: lnc } = await _setup( + connect, jetstreamServerConf({ server_name: "LEAF", jetstream: { domain: "LEAF" }, @@ -1739,7 +1669,7 @@ Deno.test("kv - mirror cross domain", async () => { }); Deno.test("kv - previous sequence", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -1759,7 +1689,7 @@ Deno.test("kv - previous sequence", async () => { }); Deno.test("kv - encoded entry", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -1777,7 +1707,7 @@ Deno.test("kv - encoded entry", async () => { }); Deno.test("kv - create after delete", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const js = jetstream(nc); const kv = await new Kvm(js).create("K"); @@ -1794,7 +1724,7 @@ Deno.test("kv - create after delete", async () => { }); Deno.test("kv - string payloads", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const js = jetstream(nc); const kv = await new Kvm(js).create("K"); @@ -1817,7 +1747,7 @@ Deno.test("kv - string payloads", async () => { }); Deno.test("kv - metadata", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.10.0")) { return; } @@ -1830,7 +1760,7 @@ Deno.test("kv - metadata", async () => { }); Deno.test("kv - watch updates only", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const js = jetstream(nc); const kv = await new Kvm(js).create("K"); @@ -1863,7 +1793,7 @@ Deno.test("kv - watch updates only", async () => { }); Deno.test("kv - watch multiple keys", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const js = jetstream(nc); const kv = await new Kvm(js).create("K"); @@ -1895,7 +1825,7 @@ Deno.test("kv - watch multiple keys", async () => { }); Deno.test("kv - watch history", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const js = jetstream(nc); const kv = await new Kvm(js).create("K", { history: 10 }); @@ -1933,7 +1863,7 @@ Deno.test("kv - watch history", async () => { }); Deno.test("kv - watch history no deletes", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const js = jetstream(nc); const kv = await new Kvm(js).create("K", { history: 10 }); @@ -1972,7 +1902,7 @@ Deno.test("kv - watch history no deletes", async () => { }); Deno.test("kv - republish header handling", async () => { - const { ns, nc } = await setup(jetstreamServerConf()); + const { ns, nc } = await _setup(connect, jetstreamServerConf()); const jsm = await jetstreamManager(nc); const n = nuid.next(); await jsm.streams.add({ @@ -2010,7 +1940,7 @@ Deno.test("kv - republish header handling", async () => { }); Deno.test("kv - compression", async () => { - const { ns, nc } = await setup(jetstreamServerConf()); + const { ns, nc } = await _setup(connect, jetstreamServerConf()); const js = jetstream(nc); const s2 = await new Kvm(js).create("compressed", { compression: true, @@ -2025,7 +1955,7 @@ Deno.test("kv - compression", async () => { }); Deno.test("kv - watch start at", async () => { - const { ns, nc } = await setup(jetstreamServerConf()); + const { ns, nc } = await _setup(connect, jetstreamServerConf()); const js = jetstream(nc); const kv = await new Kvm(js).create("a"); await kv.put("a", "1"); @@ -2046,9 +1976,7 @@ Deno.test("kv - watch start at", async () => { }); Deno.test("kv - delete key if revision", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -2070,9 +1998,7 @@ Deno.test("kv - delete key if revision", async () => { }); Deno.test("kv - purge key if revision", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -2094,9 +2020,7 @@ Deno.test("kv - purge key if revision", async () => { }); Deno.test("kv - bind no info", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -2127,9 +2051,7 @@ Deno.test("kv - bind no info", async () => { }); Deno.test("kv - watcher will name and filter", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -2150,9 +2072,7 @@ Deno.test("kv - watcher will name and filter", async () => { }); Deno.test("kv - honors checkAPI option", async () => { - const { ns, nc } = await setup( - jetstreamServerConf({}), - ); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); const js = jetstream(nc); const sub = nc.subscribe("$JS.API.INFO"); const si = syncIterator(sub); @@ -2168,9 +2088,7 @@ Deno.test("kv - honors checkAPI option", async () => { }); Deno.test("kv - watcher on server restart", async () => { - let { ns, nc } = await setup( - jetstreamServerConf({}), - ); + let { ns, nc } = await _setup(connect, jetstreamServerConf({})); const js = jetstream(nc); const kv = await new Kvm(js).create("A"); const iter = await kv.watch(); @@ -2198,7 +2116,7 @@ Deno.test("kv - watcher on server restart", async () => { // FIXME: this is a sanity example // Deno.test("jetstream - can access kv", async () => { -// const { ns, nc } = await setup(jetstreamServerConf({})); +// const { ns, nc } = await _setup(connect, jetstreamServerConf({})); // if (await notCompatible(ns, nc, "2.6.2")) { // return; // } @@ -2276,9 +2194,12 @@ Deno.test("kv - watcher on server restart", async () => { // }); Deno.test("kv - kv rejects in older servers", async () => { - const { ns, nc } = await setup(jetstreamServerConf({ - max_payload: 1024 * 1024, - })); + const { ns, nc } = await _setup( + connect, + jetstreamServerConf({ + max_payload: 1024 * 1024, + }), + ); const nci = nc as NatsConnectionImpl; const js = jetstream(nc); diff --git a/os/tests/objectstore_test.ts b/os/tests/objectstore_test.ts index 92381808..6148e650 100644 --- a/os/tests/objectstore_test.ts +++ b/os/tests/objectstore_test.ts @@ -14,10 +14,10 @@ */ import { + _setup, cleanup, jetstreamServerConf, notCompatible, - setup, } from "../../test_helpers/mod.ts"; import { assert, @@ -26,17 +26,20 @@ import { assertRejects, equal, } from "jsr:@std/assert"; +import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-2"; import { Base64UrlPaddedCodec, DataBuffer, Empty, headers, nanos, - NatsConnectionImpl, nuid, SHA256, StringCodec, } from "jsr:@nats-io/nats-core@3.0.0-14/internal"; +import type { + NatsConnectionImpl, +} from "jsr:@nats-io/nats-core@3.0.0-14/internal"; import { crypto } from "https://deno.land/std@0.221.0/crypto/mod.ts"; import type { ObjectInfo, ObjectStoreMeta } from "../types.ts"; import { jetstreamManager, StorageType } from "jsr:@nats-io/jetstream@3.0.0-3"; @@ -96,7 +99,7 @@ function digest(data: Uint8Array): string { } Deno.test("objectstore - basics", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -156,7 +159,7 @@ Deno.test("objectstore - basics", async () => { }); Deno.test("objectstore - default status", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -175,11 +178,14 @@ Deno.test("objectstore - default status", async () => { }); Deno.test("objectstore - chunked content", async () => { - const { ns, nc } = await setup(jetstreamServerConf({ - jetstream: { - max_memory_store: 10 * 1024 * 1024 + 33, - }, - })); + const { ns, nc } = await _setup( + connect, + jetstreamServerConf({ + jetstream: { + max_memory_store: 10 * 1024 * 1024 + 33, + }, + }), + ); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -201,7 +207,7 @@ Deno.test("objectstore - chunked content", async () => { }); Deno.test("objectstore - multi content", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -232,7 +238,7 @@ Deno.test("objectstore - multi content", async () => { }); Deno.test("objectstore - delete markers", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -256,7 +262,7 @@ Deno.test("objectstore - delete markers", async () => { }); Deno.test("objectstore - get on deleted returns error", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -283,7 +289,7 @@ Deno.test("objectstore - get on deleted returns error", async () => { }); Deno.test("objectstore - multi with delete", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -314,7 +320,7 @@ Deno.test("objectstore - multi with delete", async () => { }); Deno.test("objectstore - object names", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -333,7 +339,7 @@ Deno.test("objectstore - object names", async () => { }); Deno.test("objectstore - metadata", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -364,7 +370,7 @@ Deno.test("objectstore - metadata", async () => { }); Deno.test("objectstore - empty entry", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -390,7 +396,7 @@ Deno.test("objectstore - empty entry", async () => { }); Deno.test("objectstore - list", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -412,7 +418,7 @@ Deno.test("objectstore - list", async () => { }); Deno.test("objectstore - watch initially empty", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -463,7 +469,7 @@ Deno.test("objectstore - watch initially empty", async () => { }); Deno.test("objectstore - watch skip history", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -508,7 +514,7 @@ Deno.test("objectstore - watch skip history", async () => { }); Deno.test("objectstore - watch history", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -555,7 +561,7 @@ Deno.test("objectstore - watch history", async () => { }); Deno.test("objectstore - same store link", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -583,7 +589,7 @@ Deno.test("objectstore - same store link", async () => { }); Deno.test("objectstore - link of link rejected", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -609,7 +615,7 @@ Deno.test("objectstore - link of link rejected", async () => { }); Deno.test("objectstore - external link", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -635,7 +641,7 @@ Deno.test("objectstore - external link", async () => { }); Deno.test("objectstore - store link", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -651,9 +657,12 @@ Deno.test("objectstore - store link", async () => { }); Deno.test("objectstore - max chunk is max payload", async () => { - const { ns, nc } = await setup(jetstreamServerConf({ - max_payload: 8 * 1024, - })); + const { ns, nc } = await _setup( + connect, + jetstreamServerConf({ + max_payload: 8 * 1024, + }), + ); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -673,9 +682,12 @@ Deno.test("objectstore - max chunk is max payload", async () => { }); Deno.test("objectstore - default chunk is 128k", async () => { - const { ns, nc } = await setup(jetstreamServerConf({ - max_payload: 1024 * 1024, - })); + const { ns, nc } = await _setup( + connect, + jetstreamServerConf({ + max_payload: 1024 * 1024, + }), + ); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -695,9 +707,12 @@ Deno.test("objectstore - default chunk is 128k", async () => { }); Deno.test("objectstore - sanitize", async () => { - const { ns, nc } = await setup(jetstreamServerConf({ - max_payload: 1024 * 1024, - })); + const { ns, nc } = await _setup( + connect, + jetstreamServerConf({ + max_payload: 1024 * 1024, + }), + ); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -728,9 +743,12 @@ Deno.test("objectstore - sanitize", async () => { }); Deno.test("objectstore - partials", async () => { - const { ns, nc } = await setup(jetstreamServerConf({ - max_payload: 1024 * 1024, - })); + const { ns, nc } = await _setup( + connect, + jetstreamServerConf({ + max_payload: 1024 * 1024, + }), + ); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -767,9 +785,12 @@ Deno.test("objectstore - partials", async () => { }); Deno.test("objectstore - no store", async () => { - const { ns, nc } = await setup(jetstreamServerConf({ - max_payload: 1024 * 1024, - })); + const { ns, nc } = await _setup( + connect, + jetstreamServerConf({ + max_payload: 1024 * 1024, + }), + ); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -827,9 +848,12 @@ Deno.test("objectstore - no store", async () => { }); Deno.test("objectstore - hashtests", async () => { - const { ns, nc } = await setup(jetstreamServerConf({ - max_payload: 1024 * 1024, - })); + const { ns, nc } = await _setup( + connect, + jetstreamServerConf({ + max_payload: 1024 * 1024, + }), + ); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -869,9 +893,12 @@ Deno.test("objectstore - hashtests", async () => { }); Deno.test("objectstore - meta update", async () => { - const { ns, nc } = await setup(jetstreamServerConf({ - max_payload: 1024 * 1024, - })); + const { ns, nc } = await _setup( + connect, + jetstreamServerConf({ + max_payload: 1024 * 1024, + }), + ); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -914,9 +941,12 @@ Deno.test("objectstore - meta update", async () => { }); Deno.test("objectstore - cannot put links", async () => { - const { ns, nc } = await setup(jetstreamServerConf({ - max_payload: 1024 * 1024, - })); + const { ns, nc } = await _setup( + connect, + jetstreamServerConf({ + max_payload: 1024 * 1024, + }), + ); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -942,7 +972,7 @@ Deno.test("objectstore - cannot put links", async () => { }); Deno.test("objectstore - put purges old entries", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -976,7 +1006,7 @@ Deno.test("objectstore - put purges old entries", async () => { }); Deno.test("objectstore - put previous sequences", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -1020,7 +1050,7 @@ Deno.test("objectstore - put previous sequences", async () => { }); Deno.test("objectstore - put/get blob", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -1052,7 +1082,7 @@ Deno.test("objectstore - put/get blob", async () => { }); Deno.test("objectstore - ttl", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -1066,7 +1096,7 @@ Deno.test("objectstore - ttl", async () => { }); Deno.test("objectstore - allow direct", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.6.3")) { return; } @@ -1079,7 +1109,7 @@ Deno.test("objectstore - allow direct", async () => { }); Deno.test("objectstore - stream metadata and entry metadata", async () => { - const { ns, nc } = await setup(jetstreamServerConf({})); + const { ns, nc } = await _setup(connect, jetstreamServerConf({})); if (await notCompatible(ns, nc, "2.10.0")) { return; } @@ -1107,7 +1137,7 @@ Deno.test("objectstore - stream metadata and entry metadata", async () => { }); Deno.test("os - compression", async () => { - const { ns, nc } = await setup(jetstreamServerConf()); + const { ns, nc } = await _setup(connect, jetstreamServerConf()); const objm = new Objm(nc); const s2 = await objm.create("compressed", { compression: true, @@ -1122,9 +1152,12 @@ Deno.test("os - compression", async () => { }); Deno.test("os - os rejects in older servers", async () => { - const { ns, nc } = await setup(jetstreamServerConf({ - max_payload: 1024 * 1024, - })); + const { ns, nc } = await _setup( + connect, + jetstreamServerConf({ + max_payload: 1024 * 1024, + }), + ); const nci = nc as NatsConnectionImpl; const objm = new Objm(nc); diff --git a/service/tests/service-check.ts b/service/tests/service-check.ts index 12810541..83dd31af 100644 --- a/service/tests/service-check.ts +++ b/service/tests/service-check.ts @@ -14,9 +14,13 @@ */ import { cli } from "https://deno.land/x/cobra@v0.0.9/mod.ts"; -import { connect, StringCodec } from "jsr:@nats-io/nats-transport-deno@3.0.0-2"; +import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-2"; import type { NatsConnection } from "jsr:@nats-io/nats-transport-deno@3.0.0-2"; -import { collect, parseSemVer } from "jsr:@nats-io/nats-core@3.0.0-14/internal"; +import { + collect, + parseSemVer, + StringCodec, +} from "jsr:@nats-io/nats-core@3.0.0-14/internal"; import type { ServiceIdentity, ServiceInfo, ServiceStats } from "../mod.ts"; import { ServiceError, ServiceResponseType, ServiceVerb, Svc } from "../mod.ts"; diff --git a/service/tests/service_test.ts b/service/tests/service_test.ts index 43dc3318..8ffce555 100644 --- a/service/tests/service_test.ts +++ b/service/tests/service_test.ts @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { cleanup, setup } from "../../test_helpers/mod.ts"; +import { _setup, cleanup } from "../../test_helpers/mod.ts"; import { ServiceImpl } from "../service.ts"; import { assert, @@ -24,9 +24,21 @@ import { fail, } from "jsr:@std/assert"; -import { collect, delay } from "jsr:@nats-io/nats-core@3.0.0-14/internal"; +import { + collect, + createInbox, + delay, + ErrorCode, + JSONCodec, + nuid, + StringCodec, +} from "jsr:@nats-io/nats-core@3.0.0-14/internal"; import type { + Msg, + NatsConnection, NatsConnectionImpl, + NatsError, + QueuedIterator, SubscriptionImpl, } from "jsr:@nats-io/nats-core@3.0.0-14/internal"; import type { @@ -45,21 +57,7 @@ import { ServiceVerb, Svc, } from "../mod.ts"; -import { - connect, - createInbox, - ErrorCode, - JSONCodec, - nuid, - StringCodec, -} from "../../src/mod.ts"; - -import type { - Msg, - NatsConnection, - NatsError, - QueuedIterator, -} from "../../src/mod.ts"; +import { connect } from "jsr:@nats-io/nats-transport-deno@3.0.0-2"; Deno.test("service - control subject", () => { const test = (verb: ServiceVerb) => { @@ -81,7 +79,7 @@ Deno.test("service - control subject", () => { }); Deno.test("service - bad name", async () => { - const { ns, nc } = await setup({}, {}); + const { ns, nc } = await _setup(connect, {}, {}); const svc = new Svc(nc); const t = async (name: string, msg: string) => { await assertRejects( @@ -104,7 +102,7 @@ Deno.test("service - bad name", async () => { }); Deno.test("service - client", async () => { - const { ns, nc } = await setup({}, {}); + const { ns, nc } = await _setup(connect, {}, {}); const sc = StringCodec(); const subj = createInbox(); const svc = new Svc(nc); @@ -207,7 +205,7 @@ Deno.test("service - client", async () => { }); Deno.test("service - basics", async () => { - const { ns, nc } = await setup({}, {}); + const { ns, nc } = await _setup(connect, {}, {}); const svc = new Svc(nc); const conf: ServiceConfig = { name: "test", @@ -269,7 +267,7 @@ Deno.test("service - basics", async () => { }); Deno.test("service - stop error", async () => { - const { ns, nc } = await setup({ + const { ns, nc } = await _setup(connect, { authorization: { users: [{ user: "a", @@ -307,7 +305,7 @@ Deno.test("service - stop error", async () => { }); Deno.test("service - start error", async () => { - const { ns, nc } = await setup({ + const { ns, nc } = await _setup(connect, { authorization: { users: [{ user: "a", @@ -341,7 +339,7 @@ Deno.test("service - start error", async () => { }); Deno.test("service - callback error", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); const svc = new Svc(nc); const srv = await svc.add({ name: "test", @@ -362,7 +360,7 @@ Deno.test("service - callback error", async () => { }); Deno.test("service - service error is headers", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); const svc = new Svc(nc); const srv = await svc.add({ name: "test", @@ -381,7 +379,7 @@ Deno.test("service - service error is headers", async () => { }); Deno.test("service - sub stop", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); const svc = new Svc(nc); const service = await svc.add({ name: "test", @@ -405,7 +403,7 @@ Deno.test("service - sub stop", async () => { }); Deno.test("service - monitoring sub stop", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); const svc = new Svc(nc); const service = await svc.add({ name: "test", @@ -429,7 +427,7 @@ Deno.test("service - monitoring sub stop", async () => { }); Deno.test("service - custom stats handler", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); const svc = new Svc(nc); const srv = await svc.add({ name: "test", @@ -454,7 +452,7 @@ Deno.test("service - custom stats handler", async () => { }); Deno.test("service - bad stats handler", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); const config = { name: "test", @@ -478,7 +476,7 @@ Deno.test("service - bad stats handler", async () => { }); Deno.test("service - stats handler error", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); const svc = new Svc(nc); const srv = await svc.add({ name: "test", @@ -504,7 +502,7 @@ Deno.test("service - stats handler error", async () => { }); Deno.test("service - reset", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); const svc = new Svc(nc); const service = await svc.add({ @@ -546,7 +544,7 @@ Deno.test("service - reset", async () => { }); Deno.test("service - iter", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); const svc = new Svc(nc); const service = await svc.add({ @@ -582,7 +580,7 @@ Deno.test("service - iter", async () => { }); Deno.test("service - iter closed", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); const svc = new Svc(nc); const service = await svc.add({ @@ -605,7 +603,7 @@ Deno.test("service - iter closed", async () => { }); Deno.test("service - version must be semver", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); const test = (v?: string): Promise => { const svc = new Svc(nc); return svc.add({ @@ -642,7 +640,7 @@ Deno.test("service - version must be semver", async () => { }); Deno.test("service - service errors", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); const svc = new Svc(nc); const srv = await svc.add({ @@ -730,7 +728,7 @@ Deno.test("service - cross platform service test", async () => { }); Deno.test("service - stats name respects assigned name", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); const svc = new Svc(nc); const test = await svc.add({ @@ -751,7 +749,7 @@ Deno.test("service - stats name respects assigned name", async () => { }); Deno.test("service - multiple endpoints", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); const svc = new Svc(nc); const ms = await svc.add({ @@ -788,7 +786,7 @@ Deno.test("service - multiple endpoints", async () => { }); Deno.test("service - multi cb/iterator", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); const svc = new Svc(nc); const srv = await svc.add({ @@ -815,7 +813,7 @@ Deno.test("service - multi cb/iterator", async () => { }); Deno.test("service - group and endpoint names", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); const svc = new Svc(nc); const srv = await svc.add({ @@ -843,7 +841,7 @@ Deno.test("service - group and endpoint names", async () => { }); Deno.test("service - group subs", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); const svc = new Svc(nc); const srv = await svc.add({ @@ -872,7 +870,7 @@ Deno.test("service - group subs", async () => { }); Deno.test("service - metadata", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); const svc = new Svc(nc); const srv = await svc.add({ @@ -898,7 +896,7 @@ Deno.test("service - metadata", async () => { }); Deno.test("service - schema metadata", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); const svc = new Svc(nc); const srv = await svc.add({ @@ -919,7 +917,7 @@ Deno.test("service - schema metadata", async () => { }); Deno.test("service - json reviver", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); const svc = new Svc(nc); const srv = await svc.add({ @@ -972,7 +970,7 @@ async function testQueueName(nc: NatsConnection, subj: string, q?: string) { } Deno.test("service - custom queue group", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); await testQueueName(nc, "a"); await testQueueName(nc, "b", "q1"); await assertRejects( @@ -1023,7 +1021,7 @@ function checkQueueGroup(srv: Service, subj: string, queue: string) { } Deno.test("service - endpoint default queue group", async () => { - const { ns, nc } = await setup(); + const { ns, nc } = await _setup(connect); const svc = new Svc(nc); const srv = await svc.add({ diff --git a/src/tests/doublesubs_test.ts b/src/tests/doublesubs_test.ts index 2a20d631..67b30a0b 100644 --- a/src/tests/doublesubs_test.ts +++ b/src/tests/doublesubs_test.ts @@ -13,7 +13,6 @@ * limitations under the License. */ import { NatsServer } from "../../test_helpers/launcher.ts"; -import { Certs } from "../../test_helpers/certs.ts"; import { deferred, @@ -30,8 +29,6 @@ import { assertArrayIncludes, assertEquals } from "jsr:@std/assert"; import { connect } from "./connect.ts"; async function runDoubleSubsTest(tls: boolean) { - const cwd = Deno.cwd(); - const tlsConfig = await NatsServer.tlsConfig(); let opts = { trace: true, host: "0.0.0.0" }; diff --git a/src/tests/tls_test.ts b/src/tests/tls_test.ts index 88901aac..442afa08 100644 --- a/src/tests/tls_test.ts +++ b/src/tests/tls_test.ts @@ -27,7 +27,6 @@ import { Lock, NatsServer, } from "../../test_helpers/mod.ts"; -import { join, resolve } from "jsr:@std/path"; Deno.test("tls - fail if server doesn't support TLS", async () => { const ns = await NatsServer.start();