Skip to content

Commit

Permalink
Reorganize the extended test suite and prepare for 6.7.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
sharadraju committed Dec 18, 2024
1 parent 4aabadb commit 22bbf43
Show file tree
Hide file tree
Showing 21 changed files with 245 additions and 358 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# node-oracledb version 6.7.1-dev

**This release is under development and information may be incomplete**
# node-oracledb version 6.7.1

The node-oracledb add-on for Node.js powers high performance Oracle Database
applications. Applications can be written in TypeScript, or directly in
JavaScript.

Use node-oracledb 6.7.1-dev to connect Node.js 14.6, or later, to Oracle
Use node-oracledb 6.7.1 to connect Node.js 14.6, or later, to Oracle
Database. Older versions of node-oracledb may work with older versions of
Node.js.

Expand Down
5 changes: 5 additions & 0 deletions doc/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Common Changes
#) Fixed bug that may cause runtime issues in some JavaScript frameworks.
See `Issue #1706 <https://github.com/oracle/node-oracledb/issues/1706>`__.

#) Added test cases with an extended test suite, more examples and
documentation improvements.

Thin Mode Changes
+++++++++++++++++

Expand Down Expand Up @@ -97,6 +100,8 @@ Common Changes
#) Remove the 'Critical Dependency' warning from webpack builds.
See `Issue #1678 <https://github.com/oracle/node-oracledb/issues/1678>`__.

#) Test and documentation updates.

Thin Mode Changes
+++++++++++++++++

Expand Down
2 changes: 1 addition & 1 deletion lib/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ module.exports = {
VERSION_MAJOR: 6,
VERSION_MINOR: 7,
VERSION_PATCH: 1,
VERSION_SUFFIX: '-dev'
VERSION_SUFFIX: ''
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oracledb",
"version": "6.7.1-dev",
"version": "6.7.1",
"description": "A Node.js module for Oracle Database access from JavaScript and TypeScript",
"license": "(Apache-2.0 OR UPL-1.0)",
"homepage": "http://oracle.github.io/node-oracledb/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
Error.stackTraceLimit = 50;

const oracledb = require('oracledb');
const dbConfig = require('../../../dbconfig.js');
const dbConfig = require('../../dbconfig.js');

async function createCloseConns(num) {
const promises = [];
Expand Down
19 changes: 3 additions & 16 deletions test/ext/release-check-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,17 @@ The tests in test/ext/release-check-tests/ serve as a supplement for our public
This directory and its sub-directories may:

- require specific database configurations (utf-8 support, extended character set, multiple schemas, etc.)
- print logs no matter what (pool._logStats())
- print logs no matter what (pool.logStatistics())
- consume fairly long time

## Before run private tests
Some private tests need `SYSDBA` privileges. Please modify test/ext/release-check-tests/test/dbaconfig.js
to change the dba username and password of your database before run private tests.
## Run edge-case tests

## Run private tests
Run the private mocha test suites with:
mocha --opts test/ext/release-check-tests/test/opts/mocha.opts
mocha --opts test/ext/release-check-tests/edge-max-cases/opts/mocha.opts

## Tests in test/ext/release-check-tests/standalone/
These tests need to check the result manually.

## Tests in test/ext/release-check-tests/test/ and test/ext/release-check-tests/standalone/
## Tests in test/ext/release-check-tests/

These tests will be included in code coverage calculations.

## DRCP connection test

Test in test/ext/release-check-tests/test/drcpConnection.js
Before running the test, make sure DRCP is configured on server side and client url.

## MAX_STRING_SIZE=EXTENDED tests

Tests in test/ext/release-check-tests/extended-character-set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@

const oracledb = require('oracledb');
const assert = require('assert');
const dbConfig = require('../../../dbconfig.js');
const testsUtil = require('../../../testsUtil.js');
const dbConfig = require('../../dbconfig.js');
const testsUtil = require('../../testsUtil.js');

describe('308. bfileTestType.js', function() {
let conn, dbaConn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
'use strict';

const oracledb = require('oracledb');
const dbConfig = require('../../../dbconfig.js');
const testsUtil = require('../../../testsUtil.js');
const random = require('../../../random.js');
const dbConfig = require('../../dbconfig.js');
const testsUtil = require('../../testsUtil.js');
const random = require('../../random.js');
const assert = require('assert');

describe('279.1 simulate break while reading Multiple packets', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

const oracledb = require('oracledb');
const assert = require('assert');
const dbConfig = require('../../../dbconfig.js');
const random = require('../../../random.js');
const dbConfig = require('../../dbconfig.js');
const random = require('../../random.js');

describe('brk.js', function() {
this.timeout(100000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@

const assert = require('assert');
const oracledb = require('oracledb');
const dbConfig = require('../../../dbconfig.js');
const testsUtil = require('../../../testsUtil.js');
const random = require('../../../random.js');
const dbConfig = require('../../dbconfig.js');
const testsUtil = require('../../testsUtil.js');
const random = require('../../random.js');

describe('1. vectorDatabaseLink.js', function() {
if (!process.env.NODE_ORACLEDB_CONNECTIONSTRING1) {
Expand Down
185 changes: 185 additions & 0 deletions test/ext/release-check-tests/dbObjectMemLeakCheck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
/*
* The issue is reported here
* https://github.com/oracle/node-oracledb/issues/1711
*
* It basically verifies if the object type created for a given type is freed along with
* its attributes. If memory has increased more than 10MB , issue is present
* and program asserts.
*
* The program runs for 5 mins and exits which means memory is not leaking.
*
* Run the program using node --expose-gc dbObjectMemLeakCheck.js
*/

const oracledb = require("oracledb");
const dbConfig = require('../../dbconfig.js');
let pool = {};
const plsql = `
declare
P_IN MY_CUSTOM_TYPE;
P_IN_OUT MY_CUSTOM_TYPE;
begin
MY_CUSTOM_PROC(P_IN => :P_IN, P_IN_OUT => :P_IN_OUT);
end;`;
const binds = {
"P_IN": {
"type": "MY_CUSTOM_TYPE", "val": { "ID": 123, "NAME": "hello" },
"dir": 3001
}, "P_IN_OUT": {
"type": "MY_CUSTOM_TYPE",
"val": { "ID": 456, "NAME": "world" }, "dir": 3002
}
};

async function setUp() {
let connection;
try {
connection = await pool.getConnection();

let sql = `CREATE OR REPLACE TYPE my_custom_type AS OBJECT (
id NUMBER,
name VARCHAR2(100)
);`;

await connection.execute(sql);

sql = `CREATE OR REPLACE PROCEDURE my_custom_proc (
p_in IN my_custom_type,
p_in_out IN OUT my_custom_type
) IS
BEGIN
p_in_out.id := p_in_out.id + p_in.id;
p_in_out.name := p_in_out.name || p_in.name;
END my_custom_proc;
`;
await connection.execute(sql);
} finally {
await connection.close();
}
}

/*
* Added just to avoid unused variable objClass
*/
function nullLogger() {
// Do nothing
}

async function terminate() {
if (pool) {
await pool.close(10);
}
}

async function initPool() {
try {
pool = await oracledb.createPool({
...dbConfig,
poolMin: 20,
poolMax: 64,
poolIncrement: 2,
poolTimeout: 60
});
console.log("Connection pool initialized successfully.");
} catch (err) {
console.error("Connection pool initialization failed:", err);
}
}

async function executeProcedure() {
let connection;
try {
connection = await pool.getConnection();
await connection.execute(plsql, binds);
} catch (err) {
console.error("Failed to execute stored procedure:", err);
} finally {
if (connection) {
await connection.close();
}
}
}

async function executeCreateObjclass() {
let connection;
let objClass;
try {
connection = await pool.getConnection();
objClass = await connection.getDbObjectClass("MY_CUSTOM_TYPE");
} catch (err) {
console.error("connection.getDbObjectClass failed with error:", err);
} finally {
if (connection) {
await connection.close();
}
}
nullLogger(typeof objClass);
}

async function executeProcedureWithReftoObjType() {
let connection;
let objClass;
try {
connection = await pool.getConnection();
await connection.execute(plsql, binds);
} catch (err) {
console.error("Failed to execute stored procedure:", err);
} finally {
if (connection) {
await connection.close();
}
}
nullLogger(typeof objClass);
}

// It runs the given function in loop.
// The loop simulates a storm of 50 webrequests coming
// in every second.
// We run this for 5 minutes and if memory has not exceeded
// threshHold, we treat it as success else throw an error.
//
async function runTestLoop(fn) {
const counter = 50; // concurrent requests.
const threshHold = 10;
const initialMem = process.memoryUsage().heapUsed / 1024 / 1024;
let finalMem;

const intervalId = setInterval(() => {
global.gc();
for (let i = 0; i < counter; i++) {
fn();
global.gc();
}
finalMem = process.memoryUsage().heapUsed / 1024 / 1024;
console.log(`Memory Usage: ${finalMem.toFixed(2)} MB`);

if (finalMem - initialMem > threshHold) {
console.warn('Memory usage exceeded 10 MB! Stopping execution.');
clearInterval(intervalId); // Stops the interval
throw new Error(`Memory Usage Exceeded 10MB ${fn.name}: Intial:
${initialMem} and Final: ${finalMem}`);
}
}, 1000);

// wait for 5 mins
await new Promise(r => setTimeout(r, 300000));
clearInterval(intervalId);
console.log(`Timer for 5 Mins finished. No Memory Leaks Found for
${fn.name}: Intial: ${initialMem} and Final: ${finalMem}`);
}

async function main() {
try {
await initPool();
await setUp();
await runTestLoop(executeProcedure);
await runTestLoop(executeProcedureWithReftoObjType);
await runTestLoop(executeCreateObjclass);
} catch (err) {
console.log(err);
} finally {
await terminate();
}
}

main();
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

const oracledb = require('oracledb');
const assert = require('assert');
const dbConfig = require('../../../dbconfig.js');
const dbConfig = require('../../dbconfig.js');

describe('276. deadConnDetection.js', function() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
'use strict';

const oracledb = require('oracledb');
const dbConfig = require('../../../dbconfig.js');
const testsUtil = require('../../../testsUtil.js');
const dbConfig = require('../../dbconfig.js');
const testsUtil = require('../../testsUtil.js');

describe('1. fastauth.js', function() {

Expand Down
Loading

0 comments on commit 22bbf43

Please sign in to comment.