@@ -22,9 +22,9 @@ import { takeScreenshot } from 'utils/save-file-utils';
22
22
import expect from 'expect' ;
23
23
import { range } from 'lodash' ;
24
24
25
- // 70 minutes. Test could take a long time.
25
+ // 60 minutes. Test could take a long time.
26
26
// Since refresh token expires in 60 min. test may fail if running takes longer than 60 min.
27
- jest . setTimeout ( 70 * 60 * 1000 ) ;
27
+ jest . setTimeout ( 60 * 60 * 1000 ) ;
28
28
29
29
describe ( 'Genomics Extraction Test' , ( ) => {
30
30
beforeEach ( async ( ) => {
@@ -170,7 +170,8 @@ describe('Genomics Extraction Test', () => {
170
170
171
171
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
172
172
// LONG WAIT: Wait for VCF files extraction and runtime creation to finish.
173
- await waitForComplete ( page , datasetName , waitForCompletionMaxTime ) ;
173
+ await waitForRuntimeComplete ( page , waitForCompletionMaxTime ) ;
174
+ await waitForExtractionComplete ( page , datasetName , waitForCompletionMaxTime ) ;
174
175
175
176
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
176
177
// RUN NOTEBOOK CODE.
@@ -211,43 +212,67 @@ describe('Genomics Extraction Test', () => {
211
212
// Not waiting for delete to finish.
212
213
} ) ;
213
214
214
- // Check creation status.
215
- async function waitForComplete ( page : Page , datasetName : string , maxTime : number ) : Promise < boolean > {
215
+ async function waitForRuntimeComplete ( page : Page , maxTime : number ) : Promise < boolean > {
216
+ let isDone = false ;
216
217
const pollInterval = 10 * 1000 ;
217
- let isRuntimeReady = false ;
218
- let isExtractionJobReady = false ;
219
218
const runtimeSidebar = new RuntimePanel ( page ) ;
220
- const genomicSidebar = new GenomicExtractionsSidebar ( page ) ;
219
+
221
220
const startTime = Date . now ( ) ;
222
221
while ( Date . now ( ) - startTime <= maxTime ) {
223
- if ( ! isRuntimeReady ) {
224
- isRuntimeReady = await runtimeSidebar . waitForRunningAndClose ( pollInterval ) ;
225
- }
226
- // At the time of writing this test, it takes 30 - 40 minutes to create VCF files.
227
- if ( ! isExtractionJobReady ) {
228
- const isJobDone = await genomicSidebar . waitForJobDone ( datasetName , pollInterval ) ;
229
- if ( isJobDone ) {
230
- isExtractionJobReady = await genomicSidebar . isJobSuccess ( datasetName ) ;
222
+ let isSuccess = false ;
223
+ await runtimeSidebar . open ( ) ;
224
+ isDone = await runtimeSidebar . waitForRunning ( pollInterval ) ;
225
+ if ( isDone ) {
226
+ isSuccess = await runtimeSidebar . isRunning ( ) ;
227
+ if ( ! isSuccess ) {
228
+ // Take screenshot for manual verification.
229
+ await takeScreenshot ( page , 'genomic-extraction-test-runtime-sidebar' ) ;
230
+ break ;
231
231
}
232
232
}
233
- const timeSpentInMin = Math . round ( ( Date . now ( ) - startTime ) / 1000 ) / 60 ;
234
- logger . info ( `Waited [ ${ timeSpentInMin } ] minutes for runtime and genomic extraction job to finish.` ) ;
235
- if ( isRuntimeReady && isExtractionJobReady ) {
236
- logger . info ( 'Runtime is running and genomic extraction job is done.' ) ;
233
+ await runtimeSidebar . close ( ) ;
234
+ if ( isSuccess ) {
235
+ logger . info ( 'Runtime is running.' ) ;
237
236
return true ;
238
237
}
238
+ const timeSpentInMin = Math . round ( ( Date . now ( ) - startTime ) / 1000 ) / 60 ;
239
+ logger . info ( `Waited [ ${ timeSpentInMin } ] minutes for runtime to start running.` ) ;
239
240
await page . waitForTimeout ( pollInterval ) ;
240
241
}
241
242
242
- // Take screenshot for manual checking.
243
- await runtimeSidebar . open ( ) ;
244
- await takeScreenshot ( page , 'genomic-extraction-test-runtime-sidebar' ) ;
245
- await runtimeSidebar . close ( ) ;
243
+ throw new Error ( 'Runtime is not running or it has failed.' ) ;
244
+ }
245
+
246
+ // Check creation status.
247
+ async function waitForExtractionComplete ( page : Page , datasetName : string , maxTime : number ) : Promise < boolean > {
248
+ let isDone = false ;
249
+ const pollInterval = 10 * 1000 ;
250
+ const genomicSidebar = new GenomicExtractionsSidebar ( page ) ;
246
251
247
- await genomicSidebar . open ( ) ;
248
- await takeScreenshot ( page , 'genomic-extraction-test-history-sidebar' ) ;
249
- await genomicSidebar . close ( ) ;
252
+ const startTime = Date . now ( ) ;
253
+ while ( Date . now ( ) - startTime <= maxTime ) {
254
+ let isSuccess = false ;
255
+ await genomicSidebar . open ( ) ;
256
+ // At the time of writing this test, it takes 30 - 40 minutes to create the VCF file.
257
+ isDone = ! ( await genomicSidebar . isInProgress ( datasetName , pollInterval ) ) ;
258
+ if ( isDone ) {
259
+ isSuccess = await genomicSidebar . isJobSuccess ( datasetName ) ;
260
+ if ( ! isSuccess ) {
261
+ // Take screenshot for manual verification.
262
+ await takeScreenshot ( page , 'genomic-extraction-test-history-sidebar' ) ;
263
+ break ;
264
+ }
265
+ }
266
+ await genomicSidebar . close ( ) ;
267
+ if ( isSuccess ) {
268
+ logger . info ( 'Genomic extraction job completed successfully.' ) ;
269
+ return true ;
270
+ }
271
+ const timeSpentInMin = Math . round ( ( Date . now ( ) - startTime ) / 1000 ) / 60 ;
272
+ logger . info ( `Waited [ ${ timeSpentInMin } ] minutes for genomic extraction job to finish.` ) ;
273
+ await page . waitForTimeout ( pollInterval ) ;
274
+ }
250
275
251
- throw new Error ( 'Runtime is not running or/and genomic extraction job is not done.' ) ;
276
+ throw new Error ( 'Genomic extraction job is not done or it has failed .' ) ;
252
277
}
253
278
} ) ;
0 commit comments