@@ -40,13 +40,15 @@ describe('240. errorTest.js', function() {
4040
4141 let conn ;
4242
43- before ( async ( ) => {
43+ beforeEach ( async ( ) => {
4444 conn = await oracledb . getConnection ( dbConfig ) ;
4545 } ) ;
4646
47- after ( async ( ) => {
48- if ( conn )
47+ afterEach ( async ( ) => {
48+ if ( conn ) {
4949 await conn . close ( ) ;
50+ conn = null ;
51+ }
5052 } ) ;
5153
5254 it ( '240.1 checks the offset value of the error' , async ( ) => {
@@ -154,4 +156,43 @@ describe('240. errorTest.js', function() {
154156 conn = undefined ;
155157 } ) ; // 240.5
156158
159+ it ( '240.6 isRecoverable property - kill session immediate' , async function ( ) {
160+ // isRecoverable requires Oracle Client 12.1 or later and Oracle Database
161+ // 12.1 or later.
162+ // It also does not work with CMAN-TDM or DRCP.
163+ const isRunnable = await testsUtil . checkPrerequisites ( 1200000000 , 1200000000 ) ;
164+ if ( ! isRunnable || ! dbConfig . test . DBA_PRIVILEGE ||
165+ dbConfig . test . drcp || dbConfig . test . isCmanTdm ) this . skip ( ) ;
166+ const dbaConfig = {
167+ user : dbConfig . test . DBA_user ,
168+ password : dbConfig . test . DBA_password ,
169+ connectionString : dbConfig . connectString ,
170+ privilege : oracledb . SYSDBA
171+ } ;
172+ const sysDBAConn = await oracledb . getConnection ( dbaConfig ) ;
173+
174+ const result = await conn . execute (
175+ `select unique
176+ 'alter system kill session '''||sid||','||serial#||''' IMMEDIATE;'
177+ from v$session_connect_info
178+ where sid = sys_context('USERENV', 'SID')
179+ ` ) ;
180+ // get the SQL to kill the session
181+ const killSql = result . rows [ 0 ] [ 0 ] ;
182+ // remove the semicolon at the end of the fetched SQL and then execute it
183+ await sysDBAConn . execute ( killSql . substring ( 0 , killSql . length - 1 ) ) ;
184+ await sysDBAConn . close ( ) ;
185+
186+ await assert . rejects (
187+ async ( ) => await conn . commit ( ) ,
188+ ( err ) => {
189+ assert . strictEqual ( err . isRecoverable , true ) ;
190+ return true ;
191+ }
192+ ) ;
193+ // Using close() on a connection with a killed session throws
194+ // an 'ORA-01012: NOT LOGGED ON' error in Thick mode
195+ if ( ! oracledb . thin )
196+ conn = undefined ;
197+ } ) ; // 240.6
157198} ) ;
0 commit comments