@@ -46,16 +46,21 @@ describe('stress tests', () => {
4646 const DATABASE_URI = fromEnvOrDefault ( 'STRESS_TEST_DATABASE_URI' , 'bolt://localhost' ) ;
4747 const LOGGING_ENABLED = fromEnvOrDefault ( 'STRESS_TEST_LOGGING_ENABLED' , false ) ;
4848
49- let originalJasmineTimeout ;
49+ let originalTimeout ;
5050 let driver ;
5151
5252 beforeEach ( done => {
53+ originalTimeout = jasmine . DEFAULT_TIMEOUT_INTERVAL ;
54+ jasmine . DEFAULT_TIMEOUT_INTERVAL = TEST_MODE . maxRunTimeMs ;
55+
5356 driver = neo4j . driver ( DATABASE_URI , sharedNeo4j . authToken ) ;
5457
5558 cleanupDb ( driver ) . then ( ( ) => done ( ) ) ;
5659 } ) ;
5760
5861 afterEach ( done => {
62+ jasmine . DEFAULT_TIMEOUT_INTERVAL = originalTimeout ;
63+
5964 cleanupDb ( driver ) . then ( ( ) => {
6065 driver . close ( ) ;
6166 done ( ) ;
@@ -79,7 +84,7 @@ describe('stress tests', () => {
7984 . then ( ( ) => done ( ) )
8085 . catch ( error => done . fail ( error ) ) ;
8186 } ) ;
82- } , TEST_MODE . maxRunTimeMs ) ;
87+ } ) ;
8388
8489 function createCommands ( context ) {
8590 const uniqueCommands = createUniqueCommands ( context ) ;
@@ -100,11 +105,15 @@ describe('stress tests', () => {
100105 readQueryCommand ( context ) ,
101106 readQueryWithBookmarkCommand ( context ) ,
102107 readQueryInTxCommand ( context ) ,
108+ readQueryInTxFunctionCommand ( context ) ,
103109 readQueryInTxWithBookmarkCommand ( context ) ,
110+ readQueryInTxFunctionWithBookmarkCommand ( context ) ,
104111 writeQueryCommand ( context ) ,
105112 writeQueryWithBookmarkCommand ( context ) ,
106113 writeQueryInTxCommand ( context ) ,
107- writeQueryInTxWithBookmarkCommand ( context )
114+ writeQueryInTxFunctionCommand ( context ) ,
115+ writeQueryInTxWithBookmarkCommand ( context ) ,
116+ writeQueryInTxFunctionWithBookmarkCommand ( context )
108117 ] ;
109118 }
110119
@@ -120,10 +129,18 @@ describe('stress tests', () => {
120129 return queryInTxCommand ( context , READ_QUERY , ( ) => noParams ( ) , READ , false ) ;
121130 }
122131
132+ function readQueryInTxFunctionCommand ( context ) {
133+ return queryInTxFunctionCommand ( context , READ_QUERY , ( ) => noParams ( ) , READ , false ) ;
134+ }
135+
123136 function readQueryInTxWithBookmarkCommand ( context ) {
124137 return queryInTxCommand ( context , READ_QUERY , ( ) => noParams ( ) , READ , true ) ;
125138 }
126139
140+ function readQueryInTxFunctionWithBookmarkCommand ( context ) {
141+ return queryInTxFunctionCommand ( context , READ_QUERY , ( ) => noParams ( ) , READ , true ) ;
142+ }
143+
127144 function writeQueryCommand ( context ) {
128145 return queryCommand ( context , WRITE_QUERY , ( ) => randomParams ( ) , WRITE , false ) ;
129146 }
@@ -136,10 +153,18 @@ describe('stress tests', () => {
136153 return queryInTxCommand ( context , WRITE_QUERY , ( ) => randomParams ( ) , WRITE , false ) ;
137154 }
138155
156+ function writeQueryInTxFunctionCommand ( context ) {
157+ return queryInTxFunctionCommand ( context , WRITE_QUERY , ( ) => randomParams ( ) , WRITE , false ) ;
158+ }
159+
139160 function writeQueryInTxWithBookmarkCommand ( context ) {
140161 return queryInTxCommand ( context , WRITE_QUERY , ( ) => randomParams ( ) , WRITE , true ) ;
141162 }
142163
164+ function writeQueryInTxFunctionWithBookmarkCommand ( context ) {
165+ return queryInTxFunctionCommand ( context , WRITE_QUERY , ( ) => randomParams ( ) , WRITE , true ) ;
166+ }
167+
143168 function queryCommand ( context , query , paramsSupplier , accessMode , useBookmark ) {
144169 return callback => {
145170 const commandId = context . nextCommandId ( ) ;
@@ -163,6 +188,36 @@ describe('stress tests', () => {
163188 } ;
164189 }
165190
191+ function queryInTxFunctionCommand ( context , query , paramsSupplier , accessMode , useBookmark ) {
192+ return callback => {
193+ const commandId = context . nextCommandId ( ) ;
194+ const params = paramsSupplier ( ) ;
195+ const session = newSession ( context , accessMode , useBookmark ) ;
196+
197+ context . log ( commandId , `About to run ${ accessMode } query in TX function` ) ;
198+
199+ let resultPromise ;
200+ if ( accessMode === READ ) {
201+ resultPromise = session . readTransaction ( tx => tx . run ( query , params ) ) ;
202+ } else {
203+ resultPromise = session . writeTransaction ( tx => tx . run ( query , params ) ) ;
204+ }
205+
206+ resultPromise . then ( result => {
207+ context . queryCompleted ( result , accessMode , session . lastBookmark ( ) ) ;
208+ context . log ( commandId , `Transaction function executed successfully` ) ;
209+
210+ session . close ( ( ) => {
211+ const possibleError = verifyQueryResult ( result ) ;
212+ callback ( possibleError ) ;
213+ } ) ;
214+ } ) . catch ( error => {
215+ context . log ( commandId , `Transaction function failed with error ${ JSON . stringify ( error ) } ` ) ;
216+ callback ( error ) ;
217+ } ) ;
218+ } ;
219+ }
220+
166221 function queryInTxCommand ( context , query , paramsSupplier , accessMode , useBookmark ) {
167222 return callback => {
168223 const commandId = context . nextCommandId ( ) ;
0 commit comments