@@ -46,16 +46,21 @@ describe('stress tests', () => {
46
46
const DATABASE_URI = fromEnvOrDefault ( 'STRESS_TEST_DATABASE_URI' , 'bolt://localhost' ) ;
47
47
const LOGGING_ENABLED = fromEnvOrDefault ( 'STRESS_TEST_LOGGING_ENABLED' , false ) ;
48
48
49
- let originalJasmineTimeout ;
49
+ let originalTimeout ;
50
50
let driver ;
51
51
52
52
beforeEach ( done => {
53
+ originalTimeout = jasmine . DEFAULT_TIMEOUT_INTERVAL ;
54
+ jasmine . DEFAULT_TIMEOUT_INTERVAL = TEST_MODE . maxRunTimeMs ;
55
+
53
56
driver = neo4j . driver ( DATABASE_URI , sharedNeo4j . authToken ) ;
54
57
55
58
cleanupDb ( driver ) . then ( ( ) => done ( ) ) ;
56
59
} ) ;
57
60
58
61
afterEach ( done => {
62
+ jasmine . DEFAULT_TIMEOUT_INTERVAL = originalTimeout ;
63
+
59
64
cleanupDb ( driver ) . then ( ( ) => {
60
65
driver . close ( ) ;
61
66
done ( ) ;
@@ -79,7 +84,7 @@ describe('stress tests', () => {
79
84
. then ( ( ) => done ( ) )
80
85
. catch ( error => done . fail ( error ) ) ;
81
86
} ) ;
82
- } , TEST_MODE . maxRunTimeMs ) ;
87
+ } ) ;
83
88
84
89
function createCommands ( context ) {
85
90
const uniqueCommands = createUniqueCommands ( context ) ;
@@ -100,11 +105,15 @@ describe('stress tests', () => {
100
105
readQueryCommand ( context ) ,
101
106
readQueryWithBookmarkCommand ( context ) ,
102
107
readQueryInTxCommand ( context ) ,
108
+ readQueryInTxFunctionCommand ( context ) ,
103
109
readQueryInTxWithBookmarkCommand ( context ) ,
110
+ readQueryInTxFunctionWithBookmarkCommand ( context ) ,
104
111
writeQueryCommand ( context ) ,
105
112
writeQueryWithBookmarkCommand ( context ) ,
106
113
writeQueryInTxCommand ( context ) ,
107
- writeQueryInTxWithBookmarkCommand ( context )
114
+ writeQueryInTxFunctionCommand ( context ) ,
115
+ writeQueryInTxWithBookmarkCommand ( context ) ,
116
+ writeQueryInTxFunctionWithBookmarkCommand ( context )
108
117
] ;
109
118
}
110
119
@@ -120,10 +129,18 @@ describe('stress tests', () => {
120
129
return queryInTxCommand ( context , READ_QUERY , ( ) => noParams ( ) , READ , false ) ;
121
130
}
122
131
132
+ function readQueryInTxFunctionCommand ( context ) {
133
+ return queryInTxFunctionCommand ( context , READ_QUERY , ( ) => noParams ( ) , READ , false ) ;
134
+ }
135
+
123
136
function readQueryInTxWithBookmarkCommand ( context ) {
124
137
return queryInTxCommand ( context , READ_QUERY , ( ) => noParams ( ) , READ , true ) ;
125
138
}
126
139
140
+ function readQueryInTxFunctionWithBookmarkCommand ( context ) {
141
+ return queryInTxFunctionCommand ( context , READ_QUERY , ( ) => noParams ( ) , READ , true ) ;
142
+ }
143
+
127
144
function writeQueryCommand ( context ) {
128
145
return queryCommand ( context , WRITE_QUERY , ( ) => randomParams ( ) , WRITE , false ) ;
129
146
}
@@ -136,10 +153,18 @@ describe('stress tests', () => {
136
153
return queryInTxCommand ( context , WRITE_QUERY , ( ) => randomParams ( ) , WRITE , false ) ;
137
154
}
138
155
156
+ function writeQueryInTxFunctionCommand ( context ) {
157
+ return queryInTxFunctionCommand ( context , WRITE_QUERY , ( ) => randomParams ( ) , WRITE , false ) ;
158
+ }
159
+
139
160
function writeQueryInTxWithBookmarkCommand ( context ) {
140
161
return queryInTxCommand ( context , WRITE_QUERY , ( ) => randomParams ( ) , WRITE , true ) ;
141
162
}
142
163
164
+ function writeQueryInTxFunctionWithBookmarkCommand ( context ) {
165
+ return queryInTxFunctionCommand ( context , WRITE_QUERY , ( ) => randomParams ( ) , WRITE , true ) ;
166
+ }
167
+
143
168
function queryCommand ( context , query , paramsSupplier , accessMode , useBookmark ) {
144
169
return callback => {
145
170
const commandId = context . nextCommandId ( ) ;
@@ -163,6 +188,36 @@ describe('stress tests', () => {
163
188
} ;
164
189
}
165
190
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
+
166
221
function queryInTxCommand ( context , query , paramsSupplier , accessMode , useBookmark ) {
167
222
return callback => {
168
223
const commandId = context . nextCommandId ( ) ;
0 commit comments