Skip to content

Commit 6d8c4d2

Browse files
committed
Add extended test suite, additional test cases + some housekeeping
1 parent 2335ae8 commit 6d8c4d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+10580
-84
lines changed

doc/src/api_manual/connection.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,7 +2312,7 @@ Connection Methods
23122312
:ref:`privilege <getconnectiondbattrsprivilege>` set to
23132313
:ref:`oracledb.SYSPRELIM <oracledbconstantsprivilege>`, along with
23142314
either :ref:`oracledb.SYSDBA <oracledbconstantsprivilege>` or
2315-
:ref:`oracledb.SYSOPER <oracledbconstantsprivilege>`. For example
2315+
:ref:`oracledb.SYSOPER <oracledbconstantsprivilege>`. For example,
23162316
``oracledb.SYSDBA | oracledb.SYSPRELIM``.
23172317

23182318
See :ref:`Database Start Up and Shut Down <startupshutdown>`.
@@ -2356,15 +2356,15 @@ Connection Methods
23562356
* - ``force``
23572357
- Shuts down a running database using :ref:`oracledb.SHUTDOWN_MODE_ABORT <oracledbconstantsshutdown>` before restarting the database instance. The next database start up may require instance recovery.
23582358

2359-
The default for ``force`` is *false*.
2360-
* - ``pfile``
2361-
- After the database is started, access is restricted to users who have the CREATE_SESSION and RESTRICTED SESSION privileges.
2362-
23632359
The default is *false*.
2364-
* - ``restrict``
2360+
* - ``pfile``
23652361
- The path and filename for a local text file containing `Oracle Database initialization parameters <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-8BAD86FC-27C5-4103-8151-AC5BADF274E3>`__.
23662362

23672363
If ``pfile`` is not set, then the database server-side parameter file is used.
2364+
* - ``restrict``
2365+
- After the database is started, access is restricted to users who have the CREATE_SESSION and RESTRICTED SESSION privileges.
2366+
2367+
The default is *false*.
23682368

23692369
**Callback**:
23702370

doc/src/release_notes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ For deprecated and desupported features, see
1111
node-oracledb `v6.7.1 <https://github.com/oracle/node-oracledb/compare/v6.7.0...v6.7.1>`__ (TBD)
1212
---------------------------------------------------------------------------------------------------------
1313

14-
Thin Mode Changes
15-
+++++++++++++++++
14+
Common Changes
15+
++++++++++++++
1616

1717
#) Fixed bug that may cause runtime issues in some JavaScript frameworks.
1818
See `Issue #1706 <https://github.com/oracle/node-oracledb/issues/1706>`__.

lib/oracledb.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2015, 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2015, 2024, Oracle and/or its affiliates.
22

33
//-----------------------------------------------------------------------------
44
//

test/connection.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -763,11 +763,11 @@ describe('1. connection.js', function() {
763763

764764
res = await conn2.execute(sqlDriverName);
765765
/*
766-
In Oracle 12.1 DB, The driver name (CLIENT_DRIVER column in V$SESSION_CONNECT_INFO view)
766+
In Oracle 12.1.1 DB, The driver name (CLIENT_DRIVER column in V$SESSION_CONNECT_INFO view)
767767
can be set only upto 8 characters.
768768
*/
769769
let serverVersion = conn2.oracleServerVersion;
770-
if (serverVersion < 1202000000)
770+
if (serverVersion < 1201000200)
771771
assert.deepStrictEqual(res.rows[0][0], 'mydriver');
772772
else assert.deepStrictEqual(res.rows[0][0], 'mydriver1');
773773

@@ -802,11 +802,11 @@ describe('1. connection.js', function() {
802802

803803
res = await conn3.execute(sqlDriverName);
804804
/*
805-
In Oracle 12.1 DB, The driver name (CLIENT_DRIVER column in V$SESSION_CONNECT_INFO view)
805+
In Oracle 12.1.1 DB, The driver name (CLIENT_DRIVER column in V$SESSION_CONNECT_INFO view)
806806
can be set only upto 8 characters.
807807
*/
808808
serverVersion = conn2.oracleServerVersion;
809-
if (serverVersion < 1202000000)
809+
if (serverVersion < 1201000200)
810810
assert.deepStrictEqual(res.rows[0][0], 'mydriver');
811811
else assert.deepStrictEqual(res.rows[0][0], 'mydriver3');
812812

@@ -851,11 +851,11 @@ describe('1. connection.js', function() {
851851

852852
res = await conn.execute(sqlDriverName);
853853
/*
854-
In Oracle 12.1 DB, The driver name (CLIENT_DRIVER column in V$SESSION_CONNECT_INFO view)
854+
In Oracle 12.1.1 DB, The driver name (CLIENT_DRIVER column in V$SESSION_CONNECT_INFO view)
855855
can be set only upto 8 characters.
856856
*/
857857
const serverVersion = conn.oracleServerVersion;
858-
if (serverVersion < 1202000000)
858+
if (serverVersion < 1201000200)
859859
assert.strictEqual(res.rows[0][0], "node-ora");
860860
else assert.strictEqual(res.rows[0][0], "node-oracledb : " + oracledb.versionString + " thn");
861861

test/dataTypeAssist.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,9 +751,18 @@ assist.createSchemaString = function(size) {
751751
return schema_prefix + buffer.toString() + schema_prefix;
752752
};
753753

754-
755754
assist.compare2Buffers = function(originalBuf, compareBuf) {
756-
return originalBuf.equals(compareBuf);
755+
if (originalBuf.length !== compareBuf.length) {
756+
return false;
757+
}
758+
759+
for (let i = 0; i < originalBuf.length; i++) {
760+
if (originalBuf[i] !== compareBuf[i]) {
761+
return false;
762+
}
763+
}
764+
765+
return true;
757766
};
758767

759768
assist.setUp = async function(connection, tableName, array) {

test/ext/implicitPool.js

Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
/* Copyright (c) 2024, Oracle and/or its affiliates. */
2+
3+
/******************************************************************************
4+
*
5+
* This software is dual-licensed to you under the Universal Permissive License
6+
* (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
7+
* 2.0 as shown at https://www.apache.org/licenses/LICENSE-2.0. You may choose
8+
* either license.
9+
*
10+
* If you elect to accept the software under the Apache License, Version 2.0,
11+
* the following applies:
12+
*
13+
* Licensed under the Apache License, Version 2.0 (the `License`);
14+
* you may not use this file except in compliance with the License.
15+
* You may obtain a copy of the License at
16+
*
17+
* https://www.apache.org/licenses/LICENSE-2.0
18+
*
19+
* Unless required by applicable law or agreed to in writing, software
20+
* distributed under the License is distributed on an `AS IS` BASIS,
21+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
* See the License for the specific language governing permissions and
23+
* limitations under the License.
24+
*
25+
* NAME
26+
* implicitPool.js
27+
*
28+
* DESCRIPTION
29+
* Testing implicit pooling
30+
* stop and start pool before starting test to reset stats for comparision.
31+
*
32+
* NODE_ORACLEDB_CONNECTIONSTRING1
33+
* 'host/servicename:POOLED?POOL_CONNECTION_CLASS=classname & POOL_BOUNDARY=STATEMENT'
34+
* '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hostname)(PORT=port))(CONNECT_DATA=(SERVICE_NAME=servicename)(SERVER=POOLED)(POOL_BOUNDARY=STATEMENT)))'
35+
*
36+
* NODE_ORACLEDB_CONNECTIONSTRING2
37+
* 'host/servicename:POOLED?POOL_CONNECTION_CLASS=classname & POOL_BOUNDARY=TRANSACTION'
38+
* '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hostname)(PORT=port))(CONNECT_DATA=(SERVICE_NAME=servicename)(SERVER=POOLED)(POOL_BOUNDARY=TRANSACTION)))'
39+
*
40+
* NODE_ORACLEDB_CONNECTIONSTRING3
41+
* 'host/servicename:POOLED?POOL_CONNECTION_CLASS=classname & POOL_BOUNDARY=STATEMENT & POOL_PURITY=NEW'
42+
* '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hostname)(PORT=port))(CONNECT_DATA=(SERVICE_NAME=servicename)(SERVER=POOLED)(POOL_BOUNDARY=STATEMENT)(POOL_PURITY=NEW)))'
43+
*
44+
* NODE_ORACLEDB_CONNECTIONSTRING4
45+
* 'host/servicename:POOLED?POOL_CONNECTION_CLASS=classname & POOL_BOUNDARY=TRANSACTION & POOL_PURITY=NEW'
46+
* '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hostname)(PORT=port))(CONNECT_DATA=(SERVICE_NAME=servicename)(SERVER=POOLED)(POOL_BOUNDARY=TRANSACTION)(POOL_PURITY=NEW)))'
47+
*
48+
* NODE_ORACLEDB_CONNECTIONSTRING5
49+
* 'host/servicename:POOLED?POOL_CONNECTION_CLASS=classname & POOL_BOUNDARY=XYZ & POOL_PURITY=NEW'
50+
* '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hostname)(PORT=port))(CONNECT_DATA=(SERVICE_NAME=servicename)(POOL_BOUNDARY=XYZ)))'
51+
******************************************************************************/
52+
'use strict';
53+
54+
const oracledb = require('oracledb');
55+
const assert = require('assert');
56+
const dbConfig = require('./dbconfig.js');
57+
58+
describe('1. implicitPool.js', function() {
59+
60+
let connection = null;
61+
let dbaConn = null;
62+
let pool = null;
63+
before(async function() {
64+
65+
const dbaCredential = {
66+
user: dbConfig.test.DBA_user,
67+
password: dbConfig.test.DBA_password,
68+
connectString: dbConfig.connectString,
69+
privilege: oracledb.SYSDBA,
70+
};
71+
dbaConn = await oracledb.getConnection(dbaCredential);
72+
await dbaConn.execute(`alter session set container=CDB$ROOT`);
73+
});
74+
75+
after(async function() {
76+
await dbaConn.close();
77+
});
78+
79+
it('1.1 pool: execute multiple queries with purity=SELF and POOL_BOUNDARY=TRANSACTION', async function() {
80+
oracledb.connectionClass = 'obj1';
81+
// connect string with SERVER=POOLED, purity=SELF and POOL_BOUNDARY=TRANSACTION
82+
const config = {
83+
user: dbConfig.user,
84+
password: dbConfig.password,
85+
connectString: process.env.NODE_ORACLEDB_CONNECTIONSTRING1
86+
};
87+
pool = await oracledb.createPool(config);
88+
connection = await pool.getConnection();
89+
let i = 6;
90+
while (i-- > 0) {
91+
await connection.execute("SELECT 1 FROM DUAL");
92+
}
93+
const user = config.user.toUpperCase();
94+
const result = await dbaConn.execute(`select cclass_name, num_requests, num_hits, num_misses from v$cpool_cc_stats where cclass_name='${user}.obj1'`);
95+
assert.deepStrictEqual(result.rows[0][2], 5);
96+
await connection.close();
97+
await pool.close(0);
98+
});
99+
100+
it('1.2 pool: execute multiple queries with purity=SELF and POOL_BOUNDARY=STATEMENT', async function() {
101+
oracledb.connectionClass = 'obj2';
102+
// connect string with SERVER=POOLED, purity=SELF and POOL_BOUNDARY=STATEMENT
103+
const config = {
104+
user: dbConfig.user,
105+
password: dbConfig.password,
106+
connectString: process.env.NODE_ORACLEDB_CONNECTIONSTRING2
107+
};
108+
pool = await oracledb.createPool(config);
109+
connection = await pool.getConnection();
110+
let i = 6;
111+
while (i-- > 0) {
112+
await connection.execute("SELECT 1 FROM DUAL");
113+
}
114+
const user = config.user.toUpperCase();
115+
const result = await dbaConn.execute(`select cclass_name, num_requests, num_hits, num_misses from v$cpool_cc_stats where cclass_name='${user}.obj2'`);
116+
assert.deepStrictEqual(result.rows[0][2], 5);
117+
118+
await connection.close();
119+
await pool.close(0);
120+
});
121+
122+
it('1.3 pool: execute multiple queries with purity=NEW and POOL_BOUNDARY=STATEMENT', async function() {
123+
oracledb.connectionClass = 'obj3';
124+
// connect string with SERVER=POOLED, purity=NEW and POOL_BOUNDARY=STATEMENT
125+
const config = {
126+
user: dbConfig.user,
127+
password: dbConfig.password,
128+
connectString: process.env.NODE_ORACLEDB_CONNECTIONSTRING3
129+
};
130+
pool = await oracledb.createPool(config);
131+
connection = await pool.getConnection();
132+
let i = 6;
133+
while (i-- > 0) {
134+
await connection.execute("SELECT 1 FROM DUAL");
135+
}
136+
const user = config.user.toUpperCase();
137+
const result = await dbaConn.execute(`select cclass_name, num_requests, num_hits, num_misses from v$cpool_cc_stats where cclass_name='${user}.obj3'`);
138+
assert.deepStrictEqual(result.rows[0][3], 6);
139+
140+
await connection.close();
141+
await pool.close(0);
142+
});
143+
144+
it('1.4 pool: execute multiple queries with purity=NEW and POOL_BOUNDARY=TRANSACTION', async function() {
145+
oracledb.connectionClass = 'obj4';
146+
// connect string with SERVER=POOLED, purity=NEW and POOL_BOUNDARY=STATEMENT
147+
const config = {
148+
user: dbConfig.user,
149+
password: dbConfig.password,
150+
connectString: process.env.NODE_ORACLEDB_CONNECTIONSTRING4
151+
};
152+
pool = await oracledb.createPool(config);
153+
connection = await pool.getConnection();
154+
let i = 6;
155+
while (i-- > 0) {
156+
await connection.execute("SELECT 1 FROM DUAL");
157+
}
158+
const user = config.user.toUpperCase();
159+
const result = await dbaConn.execute(`select cclass_name, num_requests, num_hits, num_misses from v$cpool_cc_stats where cclass_name='${user}.obj4'`);
160+
assert.deepStrictEqual(result.rows[0][3], 6);
161+
await connection.close();
162+
await pool.close(0);
163+
});
164+
165+
it('1.5 standalone: execute multiple queries with purity=NEW and POOL_BOUNDARY=STATEMENT', async function() {
166+
oracledb.connectionClass = 'obj5';
167+
// connect string with SERVER=POOLED, purity=NEW and POOL_BOUNDARY=STATEMENT
168+
const config = {
169+
user: dbConfig.user,
170+
password: dbConfig.password,
171+
connectString: process.env.NODE_ORACLEDB_CONNECTIONSTRING3
172+
};
173+
connection = await oracledb.getConnection(config);
174+
let i = 6;
175+
while (i-- > 0) {
176+
await connection.execute("SELECT 1 FROM DUAL");
177+
}
178+
const user = config.user.toUpperCase();
179+
const result = await dbaConn.execute(`select cclass_name, num_requests, num_hits, num_misses from v$cpool_cc_stats where cclass_name='${user}.obj5'`);
180+
assert.deepStrictEqual(result.rows[0][3], 6);
181+
await connection.close();
182+
});
183+
184+
it('1.6 standalone: execute multiple queries with purity=NEW and POOL_BOUNDARY=TRANSACTION', async function() {
185+
oracledb.connectionClass = 'obj6';
186+
// connect string with SERVER=POOLED, purity=NEW and POOL_BOUNDARY=TRANSACTION
187+
const config = {
188+
user: dbConfig.user,
189+
password: dbConfig.password,
190+
connectString: process.env.NODE_ORACLEDB_CONNECTIONSTRING4
191+
};
192+
connection = await oracledb.getConnection(config);
193+
let i = 6;
194+
while (i-- > 0) {
195+
await connection.execute("SELECT 1 FROM DUAL");
196+
}
197+
const user = config.user.toUpperCase();
198+
const result = await dbaConn.execute(`select cclass_name, num_requests, num_hits, num_misses from v$cpool_cc_stats where cclass_name='${user}.obj6'`);
199+
assert.deepStrictEqual(result.rows[0][3], 6);
200+
201+
await connection.close();
202+
});
203+
204+
it('1.7 standalone: execute multiple queries with purity=SELF and POOL_BOUNDARY=TRANSACTION', async function() {
205+
oracledb.connectionClass = 'obj7';
206+
// connect string with SERVER=POOLED, purity=SELF and POOL_BOUNDARY=TRANSACTION
207+
const config = {
208+
user: dbConfig.user,
209+
password: dbConfig.password,
210+
connectString: process.env.NODE_ORACLEDB_CONNECTIONSTRING1
211+
};
212+
connection = await oracledb.getConnection(config);
213+
let i = 6;
214+
while (i-- > 0) {
215+
await connection.execute("SELECT 1 FROM DUAL");
216+
}
217+
const user = config.user.toUpperCase();
218+
const result = await dbaConn.execute(`select cclass_name, num_requests, num_hits, num_misses from v$cpool_cc_stats where cclass_name='${user}.obj7'`);
219+
assert.deepStrictEqual(result.rows[0][2], 5);
220+
221+
await connection.close();
222+
});
223+
224+
it('1.8 standalone: execute multiple queries with purity=SELF and POOL_BOUNDARY=STATEMENT', async function() {
225+
oracledb.connectionClass = 'obj8';
226+
// connect string with SERVER=POOLED, purity=SELF and POOL_BOUNDARY=STATEMENT
227+
const config = {
228+
user: dbConfig.user,
229+
password: dbConfig.password,
230+
connectString: process.env.NODE_ORACLEDB_CONNECTIONSTRING2
231+
};
232+
connection = await oracledb.getConnection(config);
233+
let i = 6;
234+
while (i-- > 0) {
235+
await connection.execute("SELECT 1 FROM DUAL");
236+
}
237+
const user = config.user.toUpperCase();
238+
const result = await dbaConn.execute(`select cclass_name, num_requests, num_hits, num_misses from v$cpool_cc_stats where cclass_name='${user}.obj8'`);
239+
assert.deepStrictEqual(result.rows[0][2], 5);
240+
241+
await connection.close();
242+
});
243+
244+
it('1.9 standalone: invalid pool boundary', async function() {
245+
const config = {
246+
user: dbConfig.user,
247+
password: dbConfig.password,
248+
connectString: process.env.NODE_ORACLEDB_CONNECTIONSTRING5
249+
};
250+
251+
await assert.rejects(
252+
async () => await oracledb.getConnection(config),
253+
/ORA-24545:/);
254+
});
255+
256+
it('1.10 pool: invalid pool boundary', async function() {
257+
const config = {
258+
user: dbConfig.user,
259+
password: dbConfig.password,
260+
connectString: process.env.NODE_ORACLEDB_CONNECTIONSTRING5
261+
};
262+
263+
const pool = await oracledb.createPool(config);
264+
await assert.rejects(
265+
async () => await pool.getConnection(), /ORA-24545:/);
266+
});
267+
});

0 commit comments

Comments
 (0)