-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cluster): prefer master when there're two same node for a slot
- Loading branch information
Showing
3 changed files
with
37 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as sinon from "sinon"; | ||
import { expect } from "chai"; | ||
import ConnectionPool from "../../../lib/cluster/ConnectionPool"; | ||
|
||
describe("ConnectionPool", () => { | ||
describe("#reset", () => { | ||
it("prefers to master if there are two same node for a slot", () => { | ||
const pool = new ConnectionPool({}); | ||
const stub = sinon.stub(pool, "findOrCreate"); | ||
|
||
pool.reset([ | ||
{ host: "127.0.0.1", port: 30001, readOnly: true }, | ||
{ host: "127.0.0.1", port: 30001, readOnly: false } | ||
]); | ||
|
||
expect(stub.callCount).to.eql(1); | ||
expect(stub.firstCall.args[1]).to.eql(false); | ||
|
||
pool.reset([ | ||
{ host: "127.0.0.1", port: 30001, readOnly: false }, | ||
{ host: "127.0.0.1", port: 30001, readOnly: true } | ||
]); | ||
|
||
expect(stub.callCount).to.eql(2); | ||
expect(stub.firstCall.args[1]).to.eql(false); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters