Skip to content

Commit cb3509e

Browse files
committed
Do not assume that node removal will occur *after* refreshSlotsCache() is finished
1 parent 038b3a9 commit cb3509e

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

test/functional/cluster/index.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -370,27 +370,28 @@ describe("cluster", () => {
370370
});
371371
cluster.on("ready", () => {
372372
expect(cluster.nodes("master")).to.have.lengthOf(2);
373+
expect(cluster.nodes("all")).to.have.lengthOf(3);
373374
slotTable = [
374375
[0, 5460, ["127.0.0.1", 30003]],
375376
[5461, 10922, ["127.0.0.1", 30002]],
376377
];
377-
cluster.refreshSlotsCache(() => {
378-
cluster.once("-node", function (removed) {
379-
expect(removed.options.port).to.eql(30001);
380-
expect(cluster.nodes("master")).to.have.lengthOf(2);
381-
expect(
382-
[
383-
cluster.nodes("master")[0].options.port,
384-
cluster.nodes("master")[1].options.port,
385-
].sort()
386-
).to.eql([30002, 30003]);
387-
cluster.nodes("master").forEach(function (node) {
388-
expect(node.options).to.have.property("readOnly", false);
389-
});
390-
cluster.disconnect();
391-
done();
378+
cluster.once("-node", function (removed) {
379+
expect(removed.options.port).to.eql(30001);
380+
expect(cluster.nodes("master")).to.have.lengthOf(2);
381+
expect(cluster.nodes("all")).to.have.lengthOf(2);
382+
expect(
383+
[
384+
cluster.nodes("master")[0].options.port,
385+
cluster.nodes("master")[1].options.port,
386+
].sort()
387+
).to.eql([30002, 30003]);
388+
cluster.nodes("master").forEach(function (node) {
389+
expect(node.options).to.have.property("readOnly", false);
392390
});
391+
cluster.disconnect();
392+
done();
393393
});
394+
cluster.refreshSlotsCache();
394395
});
395396
});
396397
});

0 commit comments

Comments
 (0)