Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/vertica-nodejs/lib/connection-parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,17 @@ class ConnectionParameters {
}

try {
this.client_os = os.platform()
this.client_os = [os.type(), os.release(), os.machine()].join(' ')
} catch (e) {
this.client_os = ""
if (e instanceof TypeError) {
try {
this.client_os = [os.type(), os.release(), os.arch()].join(' ')
} catch (ex) {
this.client_os = ""
}
} else {
this.client_os = ""
}
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ describe('vertica client label connection parameter', function () {
if (err){
console.log(err)
done(err)
}
}
assert.equal(res.rows[0]['GET_CLIENT_LABEL'], vertica.defaults.client_label)
client_default.end()
done()
})
})
})

it('can be specified and used in a client connection', function(done) {
// assert creating a client connection with specified label will persist
Expand All @@ -47,7 +47,7 @@ describe('vertica client label connection parameter', function () {
if (err){
console.log(err)
done(err)
}
}
assert.equal(res.rows[0]['GET_CLIENT_LABEL'], 'distinctLabel')
client_test.end()
done()
Expand Down Expand Up @@ -110,11 +110,25 @@ describe('vertica-nodejs handling auditing connection properties', function() {
const client = new vertica.Client()
client.connect()
client.query("SELECT client_pid, client_type, client_version, client_os, client_os_user_name, client_os_hostname FROM CURRENT_SESSION", (err, res) => {
var client_os
try {
client_os = [os.type(), os.release(), os.machine()].join(' ')
} catch (e) {
if (e instanceof TypeError) {
try {
client_os = [os.type(), os.release(), os.arch()].join(' ')
} catch (ex) {
client_os = ''
}
} else {
client_os = ''
}
}
if (err) done(err)
assert.equal(res.rows[0].client_pid, process.pid)
assert.equal(res.rows[0].client_type, "Node.js Driver")
assert.equal(res.rows[0].client_version, vertica.version)
assert.equal(res.rows[0].client_os, os.platform())
assert.equal(res.rows[0].client_os, client_os)
assert.equal(res.rows[0].client_os_user_name, os.userInfo().username)
assert.equal(res.rows[0].client_os_hostname, os.hostname())
client.end()
Expand All @@ -127,7 +141,7 @@ describe('vertica workload connection parameter', function() {
it('can be set and is sent in the startup packet', function(done) {
const client = new vertica.Client({workload: 'testNodeWorkload'})
client.connect()
client.query(`SELECT contents FROM dc_client_server_messages
client.query(`SELECT contents FROM dc_client_server_messages
WHERE session_id = current_session()
AND message_type = '^+'
AND contents like '%workload%'`, (err, res) => {
Expand Down