Skip to content

Commit

Permalink
[FIX] [TEST] cross account test environment to allow acks to cross (#374
Browse files Browse the repository at this point in the history
)
  • Loading branch information
aricart authored Sep 28, 2022
1 parent cdee523 commit 8426af1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
10 changes: 9 additions & 1 deletion tests/jetstream_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1490,15 +1490,23 @@ Deno.test("jetstream - cross account subscribe", async () => {
const js = nc.jetstream({ apiPrefix: "IPA" });

const opts = bo.getOpts();
const acks: Promise<boolean>[] = [];
const d = deferred();
const sub = await js.subscribe(subj, opts);
await (async () => {
for await (const m of sub) {
m.ack();
acks.push(m.ackAck());
if (m.seq === 2) {
d.resolve();
}
}
})();
await d;
await Promise.all(acks);
const ci = await sub.consumerInfo();
assertEquals(ci.num_pending, 0);
assertEquals(ci.delivered.stream_seq, 2);
assertEquals(ci.ack_floor.stream_seq, 2);
await sub.destroy();
await assertRejects(
async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/jsm_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,7 @@ Deno.test("jsm - discard_new_per_subject option", async () => {
"discard new per subject requires discard new policy to be set",
);

let si = await jsm.streams.add({
const si = await jsm.streams.add({
name: "KV_A",
discard: DiscardPolicy.New,
discard_new_per_subject: true,
Expand Down
10 changes: 6 additions & 4 deletions tests/jstest_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ export function jetstreamExportServerConf(
JS: {
jetstream: "enabled",
users: [{ user: "js", password: "js" }],
exports: [{ service: "$JS.API.>" }, {
stream: "A.>",
accounts: ["A"],
}],
exports: [
{ service: "$JS.API.>" },
{ service: "$JS.ACK.>" },
{ stream: "A.>", accounts: ["A"] },
],
},
A: {
users: [{ user: "a", password: "s3cret" }],
imports: [
{ service: { subject: "$JS.API.>", account: "JS" }, to: prefix },
{ service: { subject: "$JS.ACK.>", account: "JS" } },
{ stream: { subject: "A.>", account: "JS" } },
],
},
Expand Down

0 comments on commit 8426af1

Please sign in to comment.