-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support connection load balancing #51
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,79 @@ describe 'Vertica.connect', -> | |
assert.equal err.message, 'The connection was closed.' | ||
done() | ||
|
||
describe 'Connection Load Balancing', -> | ||
origLoadBalancingPolicy = '' | ||
|
||
beforeEach (done) -> | ||
if !fs.existsSync('./test/connection.json') | ||
throw new Error("Create test/connection.json to run functional tests") | ||
else | ||
connectionInfo = JSON.parse(fs.readFileSync('./test/connection.json')) | ||
Vertica.connect connectionInfo, (err, connection) -> | ||
assert.equal err, null | ||
assert.ok !connection.busy | ||
assert.ok connection.connected | ||
|
||
connection.query "SELECT GET_LOAD_BALANCE_POLICY()", (err, resultset) -> | ||
assert.ok resultset instanceof Vertica.Resultset | ||
assert.ok resultset.rows.length == 1 | ||
origLoadBalancingPolicy = resultset.rows[0][0] | ||
done() | ||
|
||
it "should connect even when load balancing is truned OFF", (done) -> | ||
Vertica.connect connectionInfo, (err, connection) -> | ||
assert.equal err, null | ||
assert.ok !connection.busy | ||
assert.ok connection.connected | ||
|
||
connection.query "SELECT SET_LOAD_BALANCE_POLICY('NONE')", (err, resultset) -> | ||
assert.equal err, null | ||
|
||
connectionInfo.loadBalance = true | ||
Vertica.connect connectionInfo, (err, conn) -> | ||
assert.equal err, null | ||
assert.ok !conn.busy | ||
assert.ok conn.connected | ||
|
||
done() | ||
|
||
assert.ok connection.busy | ||
assert.ok connection.connected | ||
|
||
it "should connect to different host at least once", (done) -> | ||
Vertica.connect connectionInfo, (err, connection) -> | ||
assert.equal err, null | ||
assert.ok !connection.busy | ||
assert.ok connection.connected | ||
|
||
connection.query "SELECT SET_LOAD_BALANCE_POLICY('ROUNDROBIN')", (err, resultset) -> | ||
assert.equal err, null | ||
|
||
connectionInfo.loadBalance = true | ||
Vertica.connect connectionInfo, (err, conn) -> | ||
assert.equal err, null | ||
assert.ok !conn.busy | ||
assert.ok conn.connected | ||
if connectionInfo.host == conn.redirctedHost | ||
Vertica.connect connectionInfo, (err, conn) -> | ||
assert.equal err, null | ||
assert.ok !conn.busy | ||
assert.ok conn.connected | ||
assert.notEqual conn.redirctedHost, connectionInfo.host | ||
|
||
done() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
assert.ok connection.busy | ||
assert.ok connection.connected | ||
|
||
afterEach (done) -> | ||
Vertica.connect connectionInfo, (err, connection) -> | ||
return done(err) if err? | ||
|
||
connection.query "SELECT SET_LOAD_BALANCE_POLICY('" + origLoadBalancingPolicy + "')", (err, rs) -> | ||
return done(err) if err? | ||
done() | ||
|
||
describe 'Statement interruption', -> | ||
beforeEach (done) -> | ||
if !fs.existsSync('./test/connection.json') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if
should be removed. Tests should be deterministic.