Update tests
This commit is contained in:
parent
08663710d9
commit
2be16f8628
|
@ -38,7 +38,7 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha --opts test/opts/mocha.opts",
|
"test": "mocha --opts test/opts/mocha.opts",
|
||||||
"posttest": "node examples/version.js"
|
"posttest": "node test/opts/version.js"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=4"
|
"node": ">=4"
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"install": "node package/oracledbinstall.js",
|
"install": "node package/oracledbinstall.js",
|
||||||
"test": "mocha --opts test/opts/mocha.opts",
|
"test": "mocha --opts test/opts/mocha.opts",
|
||||||
"posttest": "node examples/version.js"
|
"posttest": "node test/opts/version.js"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=4"
|
"node": ">=4"
|
||||||
|
|
|
@ -22,12 +22,11 @@ for relevant licenses.
|
||||||
## 1. Preparations
|
## 1. Preparations
|
||||||
|
|
||||||
See [INSTALL](https://oracle.github.io/node-oracledb/INSTALL.html)
|
See [INSTALL](https://oracle.github.io/node-oracledb/INSTALL.html)
|
||||||
for installation requirements and more details.
|
for installation details.
|
||||||
|
|
||||||
Note: the
|
Note: the
|
||||||
[test suite](https://github.com/oracle/node-oracledb/tree/master/test)
|
[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
|
is on GitHub. NPM module has not contained the tests since node-oracledb 1.9.1.
|
||||||
installing from npmjs.com with `npm install oracledb`.
|
|
||||||
|
|
||||||
### 1.1 Create a working directory
|
### 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
|
### 1.4 Configure Database credentials
|
||||||
|
|
||||||
The database credentials for node-oracledb test suite are defined in `dbconfig.js`.
|
The file `test\dbconfig.js` contains the configuration. Change the credential information to yours.
|
||||||
They can also be set via environment variables shown in that file.
|
|
||||||
|
|
||||||
|
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.
|
||||||
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`.
|
|
||||||
|
|
||||||
Note: the test suite requires a schema with privileges CREATE TABLE, CREATE SESSION,
|
Note: the test suite requires a schema with privileges CREATE TABLE, CREATE SESSION,
|
||||||
CREATE PROCEDURE, CREATE SEQUENCE, CREATE TRIGGER.
|
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
|
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).
|
name to [`test/opts/mocha.opts`](https://github.com/oracle/node-oracledb/blob/master/test/opts/mocha.opts).
|
||||||
|
|
||||||
## 4. Compatibility
|
## 4. Troubleshooting
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
You may encounter some troubles when running the test suite. These troubles
|
You may encounter some troubles when running the test suite. These troubles
|
||||||
might be caused by the concurrency issue of Mocha framework, network latencies,
|
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
|
or database server issues. This section gives some issues that we ever saw
|
||||||
and our solutions.
|
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
|
This error occurs when Node.js programs try to change database objects which
|
||||||
hold locks. The workaround would be:
|
hold locks. The workaround would be:
|
||||||
|
@ -149,7 +123,7 @@ test files.
|
||||||
(2) Try not to use 'beforeEach' blocks for object operations to avoid
|
(2) Try not to use 'beforeEach' blocks for object operations to avoid
|
||||||
the interference between cases.
|
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
|
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.
|
configured limit. You can alter the session limit on the database server side.
|
||||||
|
@ -166,7 +140,7 @@ do
|
||||||
done
|
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
|
You may encounter this error when the test suite sends more connection
|
||||||
requests per second than the database is configured to handle.
|
requests per second than the database is configured to handle.
|
||||||
|
|
|
@ -39,18 +39,18 @@ describe('161. changePassword.js', function() {
|
||||||
|
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
|
|
||||||
if (!dbConfig.DBA_PRIVILEGE) { this.skip(); }
|
if (!dbConfig.test.DBA_PRIVILEGE) { this.skip(); }
|
||||||
|
|
||||||
async.series([
|
async.series([
|
||||||
function(cb) {
|
function(cb) {
|
||||||
if (!dbConfig.DBA_PRIVILEGE) { done(); }
|
if (!dbConfig.test.DBA_PRIVILEGE) { done(); }
|
||||||
else { cb(); }
|
else { cb(); }
|
||||||
},
|
},
|
||||||
// SYSDBA connection
|
// SYSDBA connection
|
||||||
function(cb) {
|
function(cb) {
|
||||||
var credential = {
|
var credential = {
|
||||||
user: dbConfig.DBA_user,
|
user: dbConfig.test.DBA_user,
|
||||||
password: dbConfig.DBA_password,
|
password: dbConfig.test.DBA_password,
|
||||||
connectionString: dbConfig.connectString,
|
connectionString: dbConfig.connectString,
|
||||||
privilege: oracledb.SYSDBA
|
privilege: oracledb.SYSDBA
|
||||||
};
|
};
|
||||||
|
@ -91,7 +91,7 @@ describe('161. changePassword.js', function() {
|
||||||
after(function(done) {
|
after(function(done) {
|
||||||
async.series([
|
async.series([
|
||||||
function(cb) {
|
function(cb) {
|
||||||
if (!dbConfig.DBA_PRIVILEGE) { done(); }
|
if (!dbConfig.test.DBA_PRIVILEGE) { done(); }
|
||||||
else { cb(); }
|
else { cb(); }
|
||||||
},
|
},
|
||||||
function(cb) {
|
function(cb) {
|
||||||
|
|
|
@ -22,27 +22,81 @@
|
||||||
* dbConfig.js
|
* dbConfig.js
|
||||||
*
|
*
|
||||||
* DESCRIPTION
|
* DESCRIPTION
|
||||||
* Holds the dbConfigs used by node-oracledb tests to connect to
|
* This file conduct the configuration work for all the tests.
|
||||||
* the database. The user requires privileges to connect and create
|
* There are TWO options for users to choose:
|
||||||
* tables.
|
|
||||||
*
|
*
|
||||||
* 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 = {};
|
var config = {};
|
||||||
|
|
||||||
config.user = process.env.NODE_ORACLEDB_USER || 'hr';
|
/***************** OPTION 1 - Edit credentials at this section ******************/
|
||||||
config.password = process.env.NODE_ORACLEDB_PASSWORD || 'hr';
|
config.user = 'hr';
|
||||||
config.connectString = process.env.NODE_ORACLEDB_CONNECTIONSTRING || 'localhost/orcl';
|
config.password = 'hr';
|
||||||
|
config.connectString = 'localhost/orcl';
|
||||||
|
|
||||||
// Has external authentication set up? Negative by default.
|
config.test = {};
|
||||||
config.externalAuth = process.env.NODE_ORACLEDB_EXTERNALAUTH || false;
|
|
||||||
|
|
||||||
// Have you got DBA privilege? Negative by default.
|
// Have you set up the External Authentication? Negative by default.
|
||||||
config.DBA_PRIVILEGE = process.env.NODE_DBA_PRIVILEGE || false;
|
config.test.externalAuth = false;
|
||||||
|
|
||||||
config.DBA_user = process.env.NODE_ORACLEDB_DBA_USER || 'sys';
|
// Do you have DBA privilege? Negative by default.
|
||||||
config.DBA_password = process.env.NODE_ORACLEDB_DBA_PASSWORD || 'oracle';
|
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;
|
module.exports = config;
|
||||||
|
|
|
@ -39,18 +39,18 @@ describe('160. editionTest.js', function() {
|
||||||
|
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
|
|
||||||
if (!dbConfig.DBA_PRIVILEGE) { this.skip(); }
|
if (!dbConfig.test.DBA_PRIVILEGE) { this.skip(); }
|
||||||
|
|
||||||
async.series([
|
async.series([
|
||||||
function(cb) {
|
function(cb) {
|
||||||
if (!dbConfig.DBA_PRIVILEGE) { done(); }
|
if (!dbConfig.test.DBA_PRIVILEGE) { done(); }
|
||||||
else { cb(); }
|
else { cb(); }
|
||||||
},
|
},
|
||||||
// SYSDBA connection
|
// SYSDBA connection
|
||||||
function(cb) {
|
function(cb) {
|
||||||
var credential = {
|
var credential = {
|
||||||
user: dbConfig.DBA_user,
|
user: dbConfig.test.DBA_user,
|
||||||
password: dbConfig.DBA_password,
|
password: dbConfig.test.DBA_password,
|
||||||
connectionString: dbConfig.connectString,
|
connectionString: dbConfig.connectString,
|
||||||
privilege: oracledb.SYSDBA
|
privilege: oracledb.SYSDBA
|
||||||
};
|
};
|
||||||
|
@ -234,7 +234,7 @@ describe('160. editionTest.js', function() {
|
||||||
|
|
||||||
async.series([
|
async.series([
|
||||||
function(cb) {
|
function(cb) {
|
||||||
if (!dbConfig.DBA_PRIVILEGE) { done(); }
|
if (!dbConfig.test.DBA_PRIVILEGE) { done(); }
|
||||||
else { cb(); }
|
else { cb(); }
|
||||||
},
|
},
|
||||||
function(cb) {
|
function(cb) {
|
||||||
|
|
|
@ -239,7 +239,7 @@ describe('5. externalAuth.js', function() {
|
||||||
describe('5.2 tests only work when externalAuth is configured on DB', function() {
|
describe('5.2 tests only work when externalAuth is configured on DB', function() {
|
||||||
|
|
||||||
before(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) {
|
it("5.2.1 can get connection from oracledb with external authentication", function(done) {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
--require should
|
--require should
|
||||||
--require async
|
--require async
|
||||||
--reporter spec
|
--reporter dot
|
||||||
--ui bdd
|
--ui bdd
|
||||||
--timeout 100000
|
--timeout 1000000
|
||||||
|
|
||||||
test/connection.js
|
test/connection.js
|
||||||
test/pool.js
|
test/pool.js
|
||||||
|
|
|
@ -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);
|
||||||
|
});
|
Loading…
Reference in New Issue