Skip to content

Commit

Permalink
Do not assume that node removal will occur *after* refreshSlotsCache(…
Browse files Browse the repository at this point in the history
…) is finished

Signed-off-by: Martin Slota <[email protected]>
  • Loading branch information
martinslota committed Jun 10, 2024
1 parent d5d85e9 commit d3f83c5
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions test/functional/cluster/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});
Expand Down

0 comments on commit d3f83c5

Please sign in to comment.