Skip to content

Commit 20df4bf

Browse files
committed
changes
1 parent d2dbad0 commit 20df4bf

File tree

3 files changed

+65
-58
lines changed

3 files changed

+65
-58
lines changed

e2e/app/sidebar/genomic-extractions-sidebar.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,19 @@ export default class GenomicExtractionsSidebar extends BaseSidebar {
3535
// Look for the spinner in the table. Return true when it's found. Otherwise return false.
3636
return this.page
3737
.waitForXPath(statusSpinnerXpath, {
38+
visible: true,
3839
timeout: timeout
3940
})
4041
.then(() => true)
4142
.catch(() => false);
4243
}
4344

44-
/**
45-
* Open sidebar, wait for finished status, close sidebar.
46-
*/
47-
async waitForJobDone(datasetName: string, timeout?: number): Promise<boolean> {
48-
await this.open();
49-
const inProgress = await this.isInProgress(datasetName, timeout);
50-
await this.close();
51-
return !inProgress;
52-
}
53-
5445
/**
5546
* Look for job's success icon in Genomic Extraction History table in Extraction sidebar.
5647
*/
5748
async isJobSuccess(datasetName: string): Promise<boolean> {
58-
await this.open();
5949
const statusSuccessXpath = await this.getStatusSuccessXpath(datasetName);
60-
return await this.page
50+
return this.page
6151
.waitForXPath(statusSuccessXpath, {
6252
visible: true,
6353
timeout: 5000

e2e/app/sidebar/runtime-panel.ts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -374,31 +374,23 @@ export default class RuntimePanel extends BaseSidebar {
374374
}
375375

376376
/**
377-
* Open Runtime sidebar, check status for running.
377+
* Open Runtime sidebar, wait for running or error status.
378378
*/
379-
async waitForRunningAndClose(timeout?: number): Promise<boolean> {
380-
const runtimeSidebar = new RuntimePanel(this.page);
381-
await runtimeSidebar.open();
382-
try {
383-
await runtimeSidebar.waitForStartStopIconState(StartStopIconState.Running, timeout);
384-
return true;
385-
} catch (err) {
386-
return false;
387-
} finally {
388-
await runtimeSidebar.close();
389-
}
379+
async waitForRunning(timeout?: number): Promise<boolean> {
380+
return Promise.race([
381+
this.waitForStartStopIconState(StartStopIconState.Running, timeout),
382+
this.waitForStartStopIconState(StartStopIconState.Error, timeout)
383+
])
384+
.then(() => true)
385+
.catch(() => false);
390386
}
391387

392388
async isRunning(): Promise<boolean> {
393389
const xpath = this.buildStatusIconDataTestId(StartStopIconState.Running);
394390
return this.page
395391
.waitForXPath(xpath, { visible: true, timeout: 1000 })
396-
.then(() => {
397-
return true;
398-
})
399-
.catch(() => {
400-
return false;
401-
});
392+
.then(() => true)
393+
.catch(() => false);
402394
}
403395

404396
async isStopped(): Promise<boolean> {

e2e/tests/nightly/genomic-extraction-to-vcf.spec.ts

Lines changed: 53 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import { takeScreenshot } from 'utils/save-file-utils';
2222
import expect from 'expect';
2323
import { range } from 'lodash';
2424

25-
// 70 minutes. Test could take a long time.
25+
// 60 minutes. Test could take a long time.
2626
// 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);
2828

2929
describe('Genomics Extraction Test', () => {
3030
beforeEach(async () => {
@@ -170,7 +170,8 @@ describe('Genomics Extraction Test', () => {
170170

171171
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
172172
// 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);
174175

175176
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
176177
// RUN NOTEBOOK CODE.
@@ -211,43 +212,67 @@ describe('Genomics Extraction Test', () => {
211212
// Not waiting for delete to finish.
212213
});
213214

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;
216217
const pollInterval = 10 * 1000;
217-
let isRuntimeReady = false;
218-
let isExtractionJobReady = false;
219218
const runtimeSidebar = new RuntimePanel(page);
220-
const genomicSidebar = new GenomicExtractionsSidebar(page);
219+
221220
const startTime = Date.now();
222221
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;
231231
}
232232
}
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.');
237236
return true;
238237
}
238+
const timeSpentInMin = Math.round((Date.now() - startTime) / 1000) / 60;
239+
logger.info(`Waited [ ${timeSpentInMin} ] minutes for runtime to start running.`);
239240
await page.waitForTimeout(pollInterval);
240241
}
241242

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);
246251

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+
}
250275

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.');
252277
}
253278
});

0 commit comments

Comments
 (0)