Update tests

This commit is contained in:
Christopher Jones 2018-04-03 07:41:52 +10:00
parent 08663710d9
commit 2be16f8628
9 changed files with 145 additions and 64 deletions

View File

@ -38,7 +38,7 @@
},
"scripts": {
"test": "mocha --opts test/opts/mocha.opts",
"posttest": "node examples/version.js"
"posttest": "node test/opts/version.js"
},
"engines": {
"node": ">=4"

View File

@ -36,7 +36,7 @@
"scripts": {
"install": "node package/oracledbinstall.js",
"test": "mocha --opts test/opts/mocha.opts",
"posttest": "node examples/version.js"
"posttest": "node test/opts/version.js"
},
"engines": {
"node": ">=4"

View File

@ -22,12 +22,11 @@ for relevant licenses.
## 1. Preparations
See [INSTALL](https://oracle.github.io/node-oracledb/INSTALL.html)
for installation requirements and more details.
for installation details.
Note: the
[test suite](https://github.com/oracle/node-oracledb/tree/master/test)
is in GitHub. From node-oracledb 1.9.1 it is not included when
installing from npmjs.com with `npm install oracledb`.
is on GitHub. NPM module has not contained the tests since node-oracledb 1.9.1.
### 1.1 Create a working directory
@ -63,27 +62,10 @@ The test suite uses [mocha](https://www.npmjs.com/package/mocha),
### 1.4 Configure Database credentials
The database credentials for node-oracledb test suite are defined in `dbconfig.js`.
They can also be set via environment variables shown in that file.
The file `test\dbconfig.js` contains the configuration. Change the credential information to yours.
```
vi <some-directory>/node-oracledb/test/dbconfig.js
```
```javascript
module.exports = {
user : process.env.NODE_ORACLEDB_USER || "hr",
password : process.env.NODE_ORACLEDB_PASSWORD || "welcome",
connectString : process.env.NODE_ORACLEDB_CONNECTIONSTRING || "localhost/orcl"
};
```
To enable external authentication tests, please make sure Oracle Database
and the authentication service have been appropriately configured. See
[Documentation for External Authentication](https://oracle.github.io/node-oracledb/doc/api.html#extauth)
for more details. And then, set the environment variable `NODE_ORACLEDB_EXTERNALAUTH`
to be `true`.
To enable external authentication tests, firstly make sure the Oracle external authentication service is correctly configured.
See [Documentation for External Authentication](https://oracle.github.io/node-oracledb/doc/api.html#extauth) for details.
Note: the test suite requires a schema with privileges CREATE TABLE, CREATE SESSION,
CREATE PROCEDURE, CREATE SEQUENCE, CREATE TRIGGER.
@ -124,22 +106,14 @@ shows the numbering of tests.
In order to include your tests in the suite, add each new test file
name to [`test/opts/mocha.opts`](https://github.com/oracle/node-oracledb/blob/master/test/opts/mocha.opts).
## 4. Compatibility
We basically test with the following environment options:
- Oracle Instant Clients: 11.2.0.4, 12.1.0.2, 12.2.0.1
- Operating Systems (X64): macOS, Linux, Windows
- Node.js LTS versions
## 5. Troubleshooting
## 4. Troubleshooting
You may encounter some troubles when running the test suite. These troubles
might be caused by the concurrency issue of Mocha framework, network latencies,
or database server issues. This section gives some issues that we ever saw
and our solutions.
### 5.1 ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired
### 4.1 ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired
This error occurs when Node.js programs try to change database objects which
hold locks. The workaround would be:
@ -149,7 +123,7 @@ test files.
(2) Try not to use 'beforeEach' blocks for object operations to avoid
the interference between cases.
### 5.2 ORA-00018: maximum number of sessions exceeded
### 4.2 ORA-00018: maximum number of sessions exceeded
This error occurs when the test suite takes up more sessions than the
configured limit. You can alter the session limit on the database server side.
@ -166,7 +140,7 @@ do
done
```
### 5.3 ORA-28865: SSL connection closed
### 4.3 ORA-28865: SSL connection closed
You may encounter this error when the test suite sends more connection
requests per second than the database is configured to handle.

View File

@ -39,18 +39,18 @@ describe('161. changePassword.js', function() {
before(function(done) {
if (!dbConfig.DBA_PRIVILEGE) { this.skip(); }
if (!dbConfig.test.DBA_PRIVILEGE) { this.skip(); }
async.series([
function(cb) {
if (!dbConfig.DBA_PRIVILEGE) { done(); }
if (!dbConfig.test.DBA_PRIVILEGE) { done(); }
else { cb(); }
},
// SYSDBA connection
function(cb) {
var credential = {
user: dbConfig.DBA_user,
password: dbConfig.DBA_password,
user: dbConfig.test.DBA_user,
password: dbConfig.test.DBA_password,
connectionString: dbConfig.connectString,
privilege: oracledb.SYSDBA
};
@ -91,7 +91,7 @@ describe('161. changePassword.js', function() {
after(function(done) {
async.series([
function(cb) {
if (!dbConfig.DBA_PRIVILEGE) { done(); }
if (!dbConfig.test.DBA_PRIVILEGE) { done(); }
else { cb(); }
},
function(cb) {

View File

@ -22,27 +22,81 @@
* dbConfig.js
*
* DESCRIPTION
* Holds the dbConfigs used by node-oracledb tests to connect to
* the database. The user requires privileges to connect and create
* tables.
* This file conduct the configuration work for all the tests.
* There are TWO options for users to choose:
*
* See examples/dbconfig.js for details about connection dbConfigs.
* 1. Edit the credential section of this file.
* 2. Set these environment variables:
* NODE_ORACLEDB_USER, NODE_ORACLEDB_PASSWORD, NODE_ORACLEDB_CONNECTIONSTRING,
* NODE_ORACLEDB_EXTERNALAUTH,
* NODE_ORACLEDB_DBA_PRIVILEGE,
* NODE_ORACLEDB_DBA_USER, NODE_ORACLEDB_DBA_PASSWORD
*
*****************************************************************************/
var config = {};
config.user = process.env.NODE_ORACLEDB_USER || 'hr';
config.password = process.env.NODE_ORACLEDB_PASSWORD || 'hr';
config.connectString = process.env.NODE_ORACLEDB_CONNECTIONSTRING || 'localhost/orcl';
/***************** OPTION 1 - Edit credentials at this section ******************/
config.user = 'hr';
config.password = 'hr';
config.connectString = 'localhost/orcl';
// Has external authentication set up? Negative by default.
config.externalAuth = process.env.NODE_ORACLEDB_EXTERNALAUTH || false;
config.test = {};
// Have you got DBA privilege? Negative by default.
config.DBA_PRIVILEGE = process.env.NODE_DBA_PRIVILEGE || false;
// Have you set up the External Authentication? Negative by default.
config.test.externalAuth = false;
config.DBA_user = process.env.NODE_ORACLEDB_DBA_USER || 'sys';
config.DBA_password = process.env.NODE_ORACLEDB_DBA_PASSWORD || 'oracle';
// Do you have DBA privilege? Negative by default.
config.test.DBA_PRIVILEGE = false;
config.test.DBA_user = 'sys';
config.test.DBA_password = 'oracle';
/****************** OPTION 2 - Set environment variables **********************/
if (process.env.NODE_ORACLEDB_USER) {
config.user = process.env.NODE_ORACLEDB_USER;
}
if (process.env.NODE_ORACLEDB_PASSWORD) {
config.password = process.env.NODE_ORACLEDB_PASSWORD;
}
if (process.env.NODE_ORACLEDB_CONNECTIONSTRING) {
config.connectString = process.env.NODE_ORACLEDB_CONNECTIONSTRING;
}
if (process.env.NODE_ORACLEDB_EXTERNALAUTH) {
var eauth = process.env.NODE_ORACLEDB_EXTERNALAUTH;
eauth = String(eauth);
eauth = eauth.toLowerCase();
if (eauth == 'true') {
config.test.externalAuth = true;
} else {
config.test.externalAuth = false;
}
}
if (process.env.NODE_ORACLEDB_DBA_PRIVILEGE) {
var priv = process.env.NODE_ORACLEDB_DBA_PRIVILEGE;
priv = String(priv);
priv = priv.toLowerCase();
if (priv == 'true') {
config.test.DBA_PRIVILEGE = true;
} else {
config.test.DBA_PRIVILEGE = false;
}
}
if (process.env.NODE_ORACLEDB_DBA_USER) {
config.test.DBA_user = process.env.NODE_ORACLEDB_DBA_USER;
}
if (process.env.NODE_ORACLEDB_DBA_PASSWORD) {
config.test.DBA_password = process.env.NODE_ORACLEDB_DBA_PASSWORD;
}
module.exports = config;

View File

@ -39,18 +39,18 @@ describe('160. editionTest.js', function() {
before(function(done) {
if (!dbConfig.DBA_PRIVILEGE) { this.skip(); }
if (!dbConfig.test.DBA_PRIVILEGE) { this.skip(); }
async.series([
function(cb) {
if (!dbConfig.DBA_PRIVILEGE) { done(); }
if (!dbConfig.test.DBA_PRIVILEGE) { done(); }
else { cb(); }
},
// SYSDBA connection
function(cb) {
var credential = {
user: dbConfig.DBA_user,
password: dbConfig.DBA_password,
user: dbConfig.test.DBA_user,
password: dbConfig.test.DBA_password,
connectionString: dbConfig.connectString,
privilege: oracledb.SYSDBA
};
@ -234,7 +234,7 @@ describe('160. editionTest.js', function() {
async.series([
function(cb) {
if (!dbConfig.DBA_PRIVILEGE) { done(); }
if (!dbConfig.test.DBA_PRIVILEGE) { done(); }
else { cb(); }
},
function(cb) {

View File

@ -239,7 +239,7 @@ describe('5. externalAuth.js', function() {
describe('5.2 tests only work when externalAuth is configured on DB', function() {
before(function() {
if ( !(process.env.NODE_ORACLEDB_EXTERNALAUTH) ) this.skip();
if ( !dbConfig.test.externalAuth ) this.skip();
});
it("5.2.1 can get connection from oracledb with external authentication", function(done) {

View File

@ -1,8 +1,8 @@
--require should
--require async
--reporter spec
--reporter dot
--ui bdd
--timeout 100000
--timeout 1000000
test/connection.js
test/pool.js
@ -186,4 +186,4 @@ test/insertAll.js
test/end2endTracing.js
test/editionTest.js
test/changePassword.js
test/changePassword.js

53
test/opts/version.js Normal file
View File

@ -0,0 +1,53 @@
/* Copyright (c) 2015, 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.
*
* NAME
* version.js
*
* DESCRIPTION
* Shows the node-oracledb version attributes
*
*****************************************************************************/
var oracledb = require('oracledb');
var dbConfig = require('../dbconfig.js');
console.log("Run at: " + new Date());
console.log("Node.js version: " + process.version + " (" + process.platform, process.arch + ")");
// console.log("Node-oracledb version:", oracledb.version); // numeric version format is useful for comparisons
// console.log("Node-oracledb version suffix:", oracledb.versionSuffix); // e.g. "-beta.1", or empty for production releases
console.log("Node-oracledb version:", oracledb.versionString); // version (including the suffix)
//console.log("Oracle Client library version:", oracledb.oracleClientVersion); // numeric version format
console.log("Oracle Client library version:", oracledb.oracleClientVersionString);
oracledb.getConnection(
{
user : dbConfig.user,
password : dbConfig.password,
connectString : dbConfig.connectString
},
function(err, connection) {
if (err) {
console.error(err.message);
return;
}
// console.log("Oracle Database version:", connection.oracleServerVersion); // numeric version format
console.log("Oracle Database version:", connection.oracleServerVersionString);
});