Skip to content

Commit 2be16f8

Browse files
committed
Update tests
1 parent 0866371 commit 2be16f8

File tree

9 files changed

+145
-64
lines changed

9 files changed

+145
-64
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
},
3939
"scripts": {
4040
"test": "mocha --opts test/opts/mocha.opts",
41-
"posttest": "node examples/version.js"
41+
"posttest": "node test/opts/version.js"
4242
},
4343
"engines": {
4444
"node": ">=4"

package/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"scripts": {
3737
"install": "node package/oracledbinstall.js",
3838
"test": "mocha --opts test/opts/mocha.opts",
39-
"posttest": "node examples/version.js"
39+
"posttest": "node test/opts/version.js"
4040
},
4141
"engines": {
4242
"node": ">=4"

test/README.md

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@ for relevant licenses.
2222
## 1. Preparations
2323

2424
See [INSTALL](https://oracle.github.io/node-oracledb/INSTALL.html)
25-
for installation requirements and more details.
25+
for installation details.
2626

2727
Note: the
2828
[test suite](https://github.com/oracle/node-oracledb/tree/master/test)
29-
is in GitHub. From node-oracledb 1.9.1 it is not included when
30-
installing from npmjs.com with `npm install oracledb`.
29+
is on GitHub. NPM module has not contained the tests since node-oracledb 1.9.1.
3130

3231
### 1.1 Create a working directory
3332

@@ -63,27 +62,10 @@ The test suite uses [mocha](https://www.npmjs.com/package/mocha),
6362

6463
### 1.4 Configure Database credentials
6564

66-
The database credentials for node-oracledb test suite are defined in `dbconfig.js`.
67-
They can also be set via environment variables shown in that file.
65+
The file `test\dbconfig.js` contains the configuration. Change the credential information to yours.
6866

69-
70-
```
71-
vi <some-directory>/node-oracledb/test/dbconfig.js
72-
```
73-
74-
```javascript
75-
module.exports = {
76-
user : process.env.NODE_ORACLEDB_USER || "hr",
77-
password : process.env.NODE_ORACLEDB_PASSWORD || "welcome",
78-
connectString : process.env.NODE_ORACLEDB_CONNECTIONSTRING || "localhost/orcl"
79-
};
80-
```
81-
82-
To enable external authentication tests, please make sure Oracle Database
83-
and the authentication service have been appropriately configured. See
84-
[Documentation for External Authentication](https://oracle.github.io/node-oracledb/doc/api.html#extauth)
85-
for more details. And then, set the environment variable `NODE_ORACLEDB_EXTERNALAUTH`
86-
to be `true`.
67+
To enable external authentication tests, firstly make sure the Oracle external authentication service is correctly configured.
68+
See [Documentation for External Authentication](https://oracle.github.io/node-oracledb/doc/api.html#extauth) for details.
8769

8870
Note: the test suite requires a schema with privileges CREATE TABLE, CREATE SESSION,
8971
CREATE PROCEDURE, CREATE SEQUENCE, CREATE TRIGGER.
@@ -124,22 +106,14 @@ shows the numbering of tests.
124106
In order to include your tests in the suite, add each new test file
125107
name to [`test/opts/mocha.opts`](https://github.com/oracle/node-oracledb/blob/master/test/opts/mocha.opts).
126108

127-
## 4. Compatibility
128-
129-
We basically test with the following environment options:
130-
131-
- Oracle Instant Clients: 11.2.0.4, 12.1.0.2, 12.2.0.1
132-
- Operating Systems (X64): macOS, Linux, Windows
133-
- Node.js LTS versions
134-
135-
## 5. Troubleshooting
109+
## 4. Troubleshooting
136110

137111
You may encounter some troubles when running the test suite. These troubles
138112
might be caused by the concurrency issue of Mocha framework, network latencies,
139113
or database server issues. This section gives some issues that we ever saw
140114
and our solutions.
141115

142-
### 5.1 ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired
116+
### 4.1 ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired
143117

144118
This error occurs when Node.js programs try to change database objects which
145119
hold locks. The workaround would be:
@@ -149,7 +123,7 @@ test files.
149123
(2) Try not to use 'beforeEach' blocks for object operations to avoid
150124
the interference between cases.
151125

152-
### 5.2 ORA-00018: maximum number of sessions exceeded
126+
### 4.2 ORA-00018: maximum number of sessions exceeded
153127

154128
This error occurs when the test suite takes up more sessions than the
155129
configured limit. You can alter the session limit on the database server side.
@@ -166,7 +140,7 @@ do
166140
done
167141
```
168142

169-
### 5.3 ORA-28865: SSL connection closed
143+
### 4.3 ORA-28865: SSL connection closed
170144

171145
You may encounter this error when the test suite sends more connection
172146
requests per second than the database is configured to handle.

test/changePassword.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ describe('161. changePassword.js', function() {
3939

4040
before(function(done) {
4141

42-
if (!dbConfig.DBA_PRIVILEGE) { this.skip(); }
42+
if (!dbConfig.test.DBA_PRIVILEGE) { this.skip(); }
4343

4444
async.series([
4545
function(cb) {
46-
if (!dbConfig.DBA_PRIVILEGE) { done(); }
46+
if (!dbConfig.test.DBA_PRIVILEGE) { done(); }
4747
else { cb(); }
4848
},
4949
// SYSDBA connection
5050
function(cb) {
5151
var credential = {
52-
user: dbConfig.DBA_user,
53-
password: dbConfig.DBA_password,
52+
user: dbConfig.test.DBA_user,
53+
password: dbConfig.test.DBA_password,
5454
connectionString: dbConfig.connectString,
5555
privilege: oracledb.SYSDBA
5656
};
@@ -91,7 +91,7 @@ describe('161. changePassword.js', function() {
9191
after(function(done) {
9292
async.series([
9393
function(cb) {
94-
if (!dbConfig.DBA_PRIVILEGE) { done(); }
94+
if (!dbConfig.test.DBA_PRIVILEGE) { done(); }
9595
else { cb(); }
9696
},
9797
function(cb) {

test/dbconfig.js

Lines changed: 67 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,81 @@
2222
* dbConfig.js
2323
*
2424
* DESCRIPTION
25-
* Holds the dbConfigs used by node-oracledb tests to connect to
26-
* the database. The user requires privileges to connect and create
27-
* tables.
25+
* This file conduct the configuration work for all the tests.
26+
* There are TWO options for users to choose:
2827
*
29-
* See examples/dbconfig.js for details about connection dbConfigs.
28+
* 1. Edit the credential section of this file.
29+
* 2. Set these environment variables:
30+
* NODE_ORACLEDB_USER, NODE_ORACLEDB_PASSWORD, NODE_ORACLEDB_CONNECTIONSTRING,
31+
* NODE_ORACLEDB_EXTERNALAUTH,
32+
* NODE_ORACLEDB_DBA_PRIVILEGE,
33+
* NODE_ORACLEDB_DBA_USER, NODE_ORACLEDB_DBA_PASSWORD
3034
*
3135
*****************************************************************************/
3236

3337
var config = {};
3438

35-
config.user = process.env.NODE_ORACLEDB_USER || 'hr';
36-
config.password = process.env.NODE_ORACLEDB_PASSWORD || 'hr';
37-
config.connectString = process.env.NODE_ORACLEDB_CONNECTIONSTRING || 'localhost/orcl';
39+
/***************** OPTION 1 - Edit credentials at this section ******************/
40+
config.user = 'hr';
41+
config.password = 'hr';
42+
config.connectString = 'localhost/orcl';
3843

39-
// Has external authentication set up? Negative by default.
40-
config.externalAuth = process.env.NODE_ORACLEDB_EXTERNALAUTH || false;
44+
config.test = {};
4145

42-
// Have you got DBA privilege? Negative by default.
43-
config.DBA_PRIVILEGE = process.env.NODE_DBA_PRIVILEGE || false;
46+
// Have you set up the External Authentication? Negative by default.
47+
config.test.externalAuth = false;
4448

45-
config.DBA_user = process.env.NODE_ORACLEDB_DBA_USER || 'sys';
46-
config.DBA_password = process.env.NODE_ORACLEDB_DBA_PASSWORD || 'oracle';
49+
// Do you have DBA privilege? Negative by default.
50+
config.test.DBA_PRIVILEGE = false;
51+
config.test.DBA_user = 'sys';
52+
config.test.DBA_password = 'oracle';
53+
54+
55+
/****************** OPTION 2 - Set environment variables **********************/
56+
if (process.env.NODE_ORACLEDB_USER) {
57+
config.user = process.env.NODE_ORACLEDB_USER;
58+
}
59+
60+
if (process.env.NODE_ORACLEDB_PASSWORD) {
61+
config.password = process.env.NODE_ORACLEDB_PASSWORD;
62+
}
63+
64+
if (process.env.NODE_ORACLEDB_CONNECTIONSTRING) {
65+
config.connectString = process.env.NODE_ORACLEDB_CONNECTIONSTRING;
66+
}
67+
68+
if (process.env.NODE_ORACLEDB_EXTERNALAUTH) {
69+
var eauth = process.env.NODE_ORACLEDB_EXTERNALAUTH;
70+
eauth = String(eauth);
71+
eauth = eauth.toLowerCase();
72+
73+
if (eauth == 'true') {
74+
config.test.externalAuth = true;
75+
} else {
76+
config.test.externalAuth = false;
77+
}
78+
79+
}
80+
81+
if (process.env.NODE_ORACLEDB_DBA_PRIVILEGE) {
82+
var priv = process.env.NODE_ORACLEDB_DBA_PRIVILEGE;
83+
priv = String(priv);
84+
priv = priv.toLowerCase();
85+
86+
if (priv == 'true') {
87+
config.test.DBA_PRIVILEGE = true;
88+
} else {
89+
config.test.DBA_PRIVILEGE = false;
90+
}
91+
92+
}
93+
94+
if (process.env.NODE_ORACLEDB_DBA_USER) {
95+
config.test.DBA_user = process.env.NODE_ORACLEDB_DBA_USER;
96+
}
97+
98+
if (process.env.NODE_ORACLEDB_DBA_PASSWORD) {
99+
config.test.DBA_password = process.env.NODE_ORACLEDB_DBA_PASSWORD;
100+
}
47101

48102
module.exports = config;

test/editionTest.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ describe('160. editionTest.js', function() {
3939

4040
before(function(done) {
4141

42-
if (!dbConfig.DBA_PRIVILEGE) { this.skip(); }
42+
if (!dbConfig.test.DBA_PRIVILEGE) { this.skip(); }
4343

4444
async.series([
4545
function(cb) {
46-
if (!dbConfig.DBA_PRIVILEGE) { done(); }
46+
if (!dbConfig.test.DBA_PRIVILEGE) { done(); }
4747
else { cb(); }
4848
},
4949
// SYSDBA connection
5050
function(cb) {
5151
var credential = {
52-
user: dbConfig.DBA_user,
53-
password: dbConfig.DBA_password,
52+
user: dbConfig.test.DBA_user,
53+
password: dbConfig.test.DBA_password,
5454
connectionString: dbConfig.connectString,
5555
privilege: oracledb.SYSDBA
5656
};
@@ -234,7 +234,7 @@ describe('160. editionTest.js', function() {
234234

235235
async.series([
236236
function(cb) {
237-
if (!dbConfig.DBA_PRIVILEGE) { done(); }
237+
if (!dbConfig.test.DBA_PRIVILEGE) { done(); }
238238
else { cb(); }
239239
},
240240
function(cb) {

test/externalAuth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ describe('5. externalAuth.js', function() {
239239
describe('5.2 tests only work when externalAuth is configured on DB', function() {
240240

241241
before(function() {
242-
if ( !(process.env.NODE_ORACLEDB_EXTERNALAUTH) ) this.skip();
242+
if ( !dbConfig.test.externalAuth ) this.skip();
243243
});
244244

245245
it("5.2.1 can get connection from oracledb with external authentication", function(done) {

test/opts/mocha.opts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
--require should
22
--require async
3-
--reporter spec
3+
--reporter dot
44
--ui bdd
5-
--timeout 100000
5+
--timeout 1000000
66

77
test/connection.js
88
test/pool.js
@@ -186,4 +186,4 @@ test/insertAll.js
186186

187187
test/end2endTracing.js
188188
test/editionTest.js
189-
test/changePassword.js
189+
test/changePassword.js

test/opts/version.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. */
2+
3+
/******************************************************************************
4+
*
5+
* You may not use the identified files except in compliance with the Apache
6+
* License, Version 2.0 (the "License.")
7+
*
8+
* You may obtain a copy of the License at
9+
* http://www.apache.org/licenses/LICENSE-2.0.
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
*
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* NAME
19+
* version.js
20+
*
21+
* DESCRIPTION
22+
* Shows the node-oracledb version attributes
23+
*
24+
*****************************************************************************/
25+
26+
var oracledb = require('oracledb');
27+
var dbConfig = require('../dbconfig.js');
28+
29+
console.log("Run at: " + new Date());
30+
console.log("Node.js version: " + process.version + " (" + process.platform, process.arch + ")");
31+
32+
// console.log("Node-oracledb version:", oracledb.version); // numeric version format is useful for comparisons
33+
// console.log("Node-oracledb version suffix:", oracledb.versionSuffix); // e.g. "-beta.1", or empty for production releases
34+
console.log("Node-oracledb version:", oracledb.versionString); // version (including the suffix)
35+
36+
//console.log("Oracle Client library version:", oracledb.oracleClientVersion); // numeric version format
37+
console.log("Oracle Client library version:", oracledb.oracleClientVersionString);
38+
39+
oracledb.getConnection(
40+
{
41+
user : dbConfig.user,
42+
password : dbConfig.password,
43+
connectString : dbConfig.connectString
44+
},
45+
function(err, connection) {
46+
if (err) {
47+
console.error(err.message);
48+
return;
49+
}
50+
51+
// console.log("Oracle Database version:", connection.oracleServerVersion); // numeric version format
52+
console.log("Oracle Database version:", connection.oracleServerVersionString);
53+
});

0 commit comments

Comments
 (0)