From 2001142a57d7affc5c9366ab43e87dd77aba53c4 Mon Sep 17 00:00:00 2001 From: Vladimir Lazar <106525396+cbr7@users.noreply.github.com> Date: Thu, 25 Jul 2024 17:13:10 +0200 Subject: [PATCH] chore(test): special handling for iso builds (#669) * chore(test): special handling for iso builds --- tests/playwright/src/bootc-extension.spec.ts | 30 +++++++++++++++----- tests/playwright/src/model/bootc-page.ts | 11 +++---- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/tests/playwright/src/bootc-extension.spec.ts b/tests/playwright/src/bootc-extension.spec.ts index 38309dcc..1f9345ea 100644 --- a/tests/playwright/src/bootc-extension.spec.ts +++ b/tests/playwright/src/bootc-extension.spec.ts @@ -48,6 +48,8 @@ const isWindows = os.platform() === 'win32'; const containerFilePath = path.resolve(__dirname, '..', 'resources', 'bootable-containerfile'); const contextDirectory = path.resolve(__dirname, '..', 'resources'); const skipInstallation = process.env.SKIP_INSTALLATION; +const buildISOImage = process.env.BUILD_ISO_IMAGE; +let timeoutForBuild = 600000; beforeEach(async ctx => { ctx.pdRunner = pdRunner; @@ -124,9 +126,18 @@ describe('BootC Extension', async () => { await playExpect.poll(async () => await imagesPage.waitForImageExists(imageName)).toBeTruthy(); }, 150000); - test.skipIf(isLinux).each(['QCOW2', 'AMI', 'RAW', 'VMDK', 'ISO'])( - `Building bootable image type: %s`, - async type => { + describe.skipIf(isLinux).each(['QCOW2', 'AMI', 'RAW', 'VMDK', 'ISO'])('Building images ', async type => { + test(`Building bootable image type: ${type}`, async context => { + if (type === 'ISO') { + if (buildISOImage) { + timeoutForBuild = 1200000; + console.log(`Building ISO image requested, extending timeout to ${timeoutForBuild}`); + } else { + console.log(`Building ISO image not requested, skipping test`); + context.skip(); + } + } + const imagesPage = await navBar.openImages(); await playExpect(imagesPage.heading).toBeVisible(); @@ -136,7 +147,13 @@ describe('BootC Extension', async () => { const pathToStore = path.resolve(__dirname, '..', 'tests', 'output', 'images', `${type}-${architecture}`); [page, webview] = await handleWebview(); const bootcPage = new BootcPage(page, webview); - const result = await bootcPage.buildDiskImage(`${imageName}:${imageTag}`, pathToStore, type, architecture); + const result = await bootcPage.buildDiskImage( + `${imageName}:${imageTag}`, + pathToStore, + type, + architecture, + timeoutForBuild, + ); console.log( `Building disk image for platform ${os.platform()} and architecture ${architecture} and type ${type} is ${result}`, ); @@ -147,9 +164,8 @@ describe('BootC Extension', async () => { console.log('Expected to pass on Linux, Windows and macOS'); playExpect(result).toBeTruthy(); } - }, - 620000, - ); + }, 1250000); + }); }, ); diff --git a/tests/playwright/src/model/bootc-page.ts b/tests/playwright/src/model/bootc-page.ts index 564d7bc8..3cb335ad 100644 --- a/tests/playwright/src/model/bootc-page.ts +++ b/tests/playwright/src/model/bootc-page.ts @@ -71,6 +71,7 @@ export class BootcPage { pathToStore: string, type: string, architecture: ArchitectureType, + timeout = 600000, ): Promise { let result = false; @@ -130,12 +131,12 @@ export class BootcPage { await this.buildButton.focus(); await this.buildButton.click(); - await playExpect(this.goBackButton).toBeEnabled(); + await playExpect(this.goBackButton).toBeEnabled({ timeout: 30000 }); await this.goBackButton.click(); - await playExpect(this.bootcListPage).toBeVisible(); + await playExpect(this.bootcListPage).toBeVisible({ timeout: 10000 }); await playExpect(this.getTypeOfLatestBuildImage).toContainText(type.toLocaleLowerCase(), { timeout: 10000 }); - await this.waitUntilCurrentBuildIsFinished(); + await this.waitUntilCurrentBuildIsFinished(timeout); if ((await this.getCurrentStatusOfLatestEntry()) === 'error') { console.log('Error building image! Retuning false.'); return false; @@ -170,13 +171,13 @@ export class BootcPage { return ''; } - async waitUntilCurrentBuildIsFinished(): Promise { + async waitUntilCurrentBuildIsFinished(timeout = 600000): Promise { await waitUntil( async () => (await this.getCurrentStatusOfLatestEntry()) === 'error' || (await this.getCurrentStatusOfLatestEntry()) === 'success', { - timeout: 600000, + timeout: timeout, diff: 2500, message: `Build didn't finish before timeout!`, },