From 06b6e0057b3cc529a0991a4bdd9cf9b2981ada1d Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Tue, 27 Mar 2018 16:37:25 +1100 Subject: [PATCH] Add tests for end-to-end tracing attributes --- test/end2endTracing.js | 95 ++++++++++++++++++++++++++++++++++++++++++ test/list.txt | 7 +++- test/opts/mocha.opts | 4 +- 3 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 test/end2endTracing.js diff --git a/test/end2endTracing.js b/test/end2endTracing.js new file mode 100644 index 00000000..0511f4b9 --- /dev/null +++ b/test/end2endTracing.js @@ -0,0 +1,95 @@ +/* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. */ + +/****************************************************************************** + * + * You may not use the identified files except in compliance with the Apache + * License, Version 2.0 (the "License.") + * + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + * The node-oracledb test suite uses 'mocha', 'should' and 'async'. + * See LICENSE.md for relevant licenses. + * + * NAME + * 159. end2endTracing.js + * + * DESCRIPTION + * Test settings of end-to-end tracing attributes. + * + *****************************************************************************/ +'use strict'; + +var oracledb = require('oracledb'); +var should = require('should'); +var dbConfig = require('./dbconfig.js'); + +describe('159. end2endTracing.js', function() { + + var conn; + before(function(done) { + oracledb.getConnection( + dbConfig, + function(err, connection) { + should.not.exist(err); + conn = connection; + done(); + } + ); + }); + + after(function(done) { + conn.close(function(err) { + should.not.exist(err); + done(); + }); + }); + + var verify = function(sql, expect, callback) { + conn.execute( + sql, + function(err, result) { + should.not.exist(err); + should.strictEqual( + result.rows[0][0], + expect + ); + callback(); + } + ); + }; + + it('159.1 set the end-to-end tracing attribute - module', function(done) { + + var sql = "select sys_context('userenv', 'module') from dual"; + var testValue = "MODULE"; + conn.module = testValue; + verify(sql, testValue, done); + + }); + + it('159.2 set the tracing attribute - action', function(done) { + + var sql = "select sys_context('userenv', 'action') from dual"; + var testValue = "ACTION"; + conn.action = testValue; + verify(sql, testValue, done); + + }); + + it('159.3 set the tracing attribure - clientId', function(done) { + + var sql = "select sys_context('userenv', 'client_identifier') from dual"; + var testValue = "CLIENTID"; + conn.clientId = testValue; + verify(sql, testValue, done); + + }); +}); \ No newline at end of file diff --git a/test/list.txt b/test/list.txt index d7910ee9..fa76d9ec 100755 --- a/test/list.txt +++ b/test/list.txt @@ -4077,4 +4077,9 @@ Overview of node-oracledb functional tests 158. insertAll.js 158.1 original case from the issue 158.2 inserts into one table - 158.3 inserts into multiple tables \ No newline at end of file + 158.3 inserts into multiple tables + +159. end2endTracing.js + 159.1 set the end-to-end tracing attribute - module + 159.2 set the tracing attribute - action + 159.3 set the tracing attribure - clientId \ No newline at end of file diff --git a/test/opts/mocha.opts b/test/opts/mocha.opts index dea3dc50..68cc1732 100644 --- a/test/opts/mocha.opts +++ b/test/opts/mocha.opts @@ -182,4 +182,6 @@ test/fetchArraySize7.js test/fetchArraySize8.js test/fetchArraySize9.js test/maxRows.js -test/insertAll.js \ No newline at end of file +test/insertAll.js + +test/end2endTracing.js \ No newline at end of file