From d3f83c52cf9ef88d3ca8271356fd7f574777dad6 Mon Sep 17 00:00:00 2001 From: Martin Slota Date: Mon, 10 Jun 2024 18:55:55 +0200 Subject: [PATCH] Do not assume that node removal will occur *after* refreshSlotsCache() is finished Signed-off-by: Martin Slota --- test/functional/cluster/index.ts | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/test/functional/cluster/index.ts b/test/functional/cluster/index.ts index e31bdd91..c4b09a7d 100644 --- a/test/functional/cluster/index.ts +++ b/test/functional/cluster/index.ts @@ -370,27 +370,28 @@ describe("cluster", () => { }); cluster.on("ready", () => { expect(cluster.nodes("master")).to.have.lengthOf(2); + expect(cluster.nodes("all")).to.have.lengthOf(3); slotTable = [ [0, 5460, ["127.0.0.1", 30003]], [5461, 10922, ["127.0.0.1", 30002]], ]; - cluster.refreshSlotsCache(() => { - cluster.once("-node", function (removed) { - expect(removed.options.port).to.eql(30001); - expect(cluster.nodes("master")).to.have.lengthOf(2); - expect( - [ - cluster.nodes("master")[0].options.port, - cluster.nodes("master")[1].options.port, - ].sort() - ).to.eql([30002, 30003]); - cluster.nodes("master").forEach(function (node) { - expect(node.options).to.have.property("readOnly", false); - }); - cluster.disconnect(); - done(); + cluster.once("-node", function (removed) { + expect(removed.options.port).to.eql(30001); + expect(cluster.nodes("master")).to.have.lengthOf(2); + expect(cluster.nodes("all")).to.have.lengthOf(2); + expect( + [ + cluster.nodes("master")[0].options.port, + cluster.nodes("master")[1].options.port, + ].sort() + ).to.eql([30002, 30003]); + cluster.nodes("master").forEach(function (node) { + expect(node.options).to.have.property("readOnly", false); }); + cluster.disconnect(); + done(); }); + cluster.refreshSlotsCache(); }); }); });