-
Notifications
You must be signed in to change notification settings - Fork 26
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
Connections fix #27
Connections fix #27
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ var VoltClient = require('../../lib/client'); | |
var VoltConfiguration = require('../../lib/configuration'); | ||
var VoltProcedure = require('../../lib/query'); | ||
var VoltQuery = require('../../lib/query'); | ||
const debug = require("debug")("voltdb-client-nodejs:TypeTest"); | ||
|
||
var util = require('util'); | ||
var testCase = require('nodeunit'); | ||
|
@@ -46,40 +47,41 @@ function config() { | |
exports.typetest = { | ||
|
||
setUp : function(callback) { | ||
if(client == null) { | ||
console.log('typetest setup called'); | ||
//if(client == null) { | ||
debug('typetest setup called'); | ||
client = new VoltClient(config()); | ||
client.connect(function startup(code, event, results) { | ||
console.log('dasda connected'); | ||
debug('dasda connected'); | ||
callback(); | ||
}); | ||
} else { | ||
callback(); | ||
} | ||
//} else { | ||
// callback(); | ||
//} | ||
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. Are these lines commented out by accident or on purpose? 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. Hey, previously you couldn't clean up a VoltClient so there was a check to see if the client needed to be created (i.e. create client only if client == null). It's not needed anymore, in fact the test a bit more test-ey (is that a word?) as it creates and tears down the connection a few times. Can prob remove those lines entirely... I guess I left them there as this PR is only one of probably a few more before the client is working nicely. Shall I remove commented lines? 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. I see. Thanks for the clarification. I think you can remove them. |
||
}, | ||
tearDown : function(callback) { | ||
console.log('typetest teardown called'); | ||
debug('typetest teardown called'); | ||
client.exit(); | ||
callback(); | ||
}, | ||
'Init test' : function(test) { | ||
console.log('init test'); | ||
debug('init test'); | ||
test.expect(2); | ||
|
||
var initProc = new VoltProcedure('InitTestType', ['int']); | ||
var query = initProc.getQuery(); | ||
query.setParameters([0]); | ||
|
||
client.callProcedure(query, function read(code, event, results) { | ||
console.log('results', results); | ||
debug('results %o', results); | ||
test.equals(code, null , 'did I get called'); | ||
test.done(); | ||
}, function write(code, event, results) { | ||
test.equals(code, null, 'Write didn\'t had an error'); | ||
console.log('write ok'); | ||
debug('write ok'); | ||
}); | ||
}, | ||
'select test' : function(test) { | ||
console.log('select test'); | ||
debug('select test'); | ||
test.expect(11); | ||
|
||
var initProc = new VoltProcedure('TYPETEST.select', ['int']); | ||
|
@@ -89,8 +91,8 @@ exports.typetest = { | |
client.callProcedure(query, function read(code, event, results) { | ||
|
||
var testBuffer = new Buffer(4); | ||
console.log('results inspection: ', results.table[0][0].TEST_TIMESTAMP); | ||
console.log('inspect', util.inspect(results.table[0][0])); | ||
debug('results inspection: %o', results.table[0][0].TEST_TIMESTAMP); | ||
debug('inspect %s', util.inspect(results.table[0][0])); | ||
|
||
test.equals(code, null, 'Invalid status: ' + results.status + 'should be 1'); | ||
|
||
|
@@ -109,7 +111,7 @@ exports.typetest = { | |
|
||
test.done(); | ||
}, function write(code, event, results) { | ||
console.log('write ok'); | ||
debug('write ok'); | ||
test.ok(true, 'Write didn\'t get called'); | ||
}); | ||
} | ||
|
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.
I think the only problem would be when trying to close a connection failed to connect. If any error is handled on close(), it should be fine.
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.
Change was made specifically for failed connections... i.e. the flush fn would keep firing and keep generating errors and there was no way to stop it. Seems ok now, even with a bad socket.
Can add a bit more defensive code around clean up if you feel would be better?
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.
Yes, I think that's a good idea. Then you can remove this TODO. Thanks!