Skip to content

Commit 989eece

Browse files
committed
Add test for sessionless
1 parent 48f07cb commit 989eece

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

test/sessionless.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,54 @@ describe('316. sessionless.js', function() {
396396
const res = await verifyConn.execute(`SELECT * FROM ${tableName} WHERE INTCOL IN (60, 61)`);
397397
await verifyConn.close();
398398

399+
assert.strictEqual(res.rows.length, 2);
400+
await pool.close();
401+
});
402+
it('316.4.2 same pooled connection with rollbacks/suspends', async function() {
403+
const pool = await oracledb.createPool({
404+
...dbConfig,
405+
poolMin: 0,
406+
poolMax: 1
407+
});
408+
409+
const transactionId = '316.4.2';
410+
let poolConn = await pool.getConnection();
411+
412+
await poolConn.beginSessionlessTransaction({transactionId, timeout: 5});
413+
await poolConn.execute(`INSERT INTO ${tableName} VALUES(60, 'POOL_CONN')`);
414+
await poolConn.close();
415+
416+
// begin transaction on same pooled connection(after release and re-acquire)
417+
poolConn = await pool.getConnection();
418+
await poolConn.beginSessionlessTransaction({transactionId, timeout: 5});
419+
await poolConn.execute(`INSERT INTO ${tableName} VALUES(60, 'POOL_CONN')`);
420+
await poolConn.suspendSessionlessTransaction();
421+
await poolConn.close();
422+
423+
// resume transaction on same pooled connection(after release and
424+
// re-acquire) with suspendOnSuccess
425+
poolConn = await pool.getConnection();
426+
await poolConn.resumeSessionlessTransaction(transactionId, {timeout: 0});
427+
await poolConn.execute(`INSERT INTO ${tableName} VALUES(61, 'POOL_CONN')`
428+
, {}, {suspendOnSuccess: true});
429+
await poolConn.close();
430+
431+
// commit from same reacquired connection
432+
poolConn = await pool.getConnection();
433+
await poolConn.resumeSessionlessTransaction(transactionId, {timeout: 0, deferRoundTrip: true});
434+
await poolConn.commit();
435+
await poolConn.close();
436+
437+
const verifyConn = await pool.getConnection();
438+
const res = await verifyConn.execute(`SELECT * FROM ${tableName} WHERE INTCOL IN (60, 61)`);
439+
await verifyConn.close();
440+
399441
assert.strictEqual(res.rows.length, 2);
400442
await pool.close();
401443
});
402444
});
403445

446+
404447
describe('316.5 Timeout and Error Handling', function() {
405448
it('316.5.1 transaction timeout behavior', async function() {
406449
const transactionId = '316.5.1';

0 commit comments

Comments
 (0)