From 9df442819f34b292c1a04d465a7136a20e383906 Mon Sep 17 00:00:00 2001 From: Mark Yen Date: Tue, 27 Jun 2023 10:15:37 -0700 Subject: [PATCH] E2E: Limit teardown to one minute Signed-off-by: Mark Yen --- e2e/containers.e2e.spec.ts | 6 ++++++ e2e/lockedFields.e2e.spec.ts | 5 +++++ e2e/preferences.e2e.spec.ts | 9 ++++++++- e2e/utils/TestUtils.ts | 7 ++++++- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/e2e/containers.e2e.spec.ts b/e2e/containers.e2e.spec.ts index 0152cb4ac08..9a70ede12bf 100644 --- a/e2e/containers.e2e.spec.ts +++ b/e2e/containers.e2e.spec.ts @@ -6,6 +6,7 @@ import { NavPage } from './pages/nav-page'; import { createDefaultSettings, startRancherDesktop, teardown, tool } from './utils/TestUtils'; import { Settings } from '@pkg/config/settings'; +import { reopenLogs } from '@pkg/utils/logging'; import type { ElectronApplication, Page } from '@playwright/test'; @@ -18,6 +19,11 @@ let page: Page; test.describe.serial('Container Engine', () => { let electronApp: ElectronApplication; + test.beforeAll(async() => { + await tool('rdctl', 'factory-reset', '--verbose'); + reopenLogs(); + }); + test.beforeAll(async() => { createDefaultSettings({ application: { adminAccess: false } }); diff --git a/e2e/lockedFields.e2e.spec.ts b/e2e/lockedFields.e2e.spec.ts index 480ce06b098..7e8cbff3bbf 100644 --- a/e2e/lockedFields.e2e.spec.ts +++ b/e2e/lockedFields.e2e.spec.ts @@ -99,6 +99,11 @@ test.describe('Locked fields', () => { test.afterAll(() => teardown(electronApp, __filename)); + test.afterAll(async() => { + await tool('rdctl', 'factory-reset', '--verbose'); + reopenLogs(); + }); + test('should start up', async() => { const navPage = new NavPage(page); diff --git a/e2e/preferences.e2e.spec.ts b/e2e/preferences.e2e.spec.ts index 04f890f4497..0622516070a 100644 --- a/e2e/preferences.e2e.spec.ts +++ b/e2e/preferences.e2e.spec.ts @@ -4,7 +4,9 @@ import { test, expect, _electron } from '@playwright/test'; import { NavPage } from './pages/nav-page'; import { PreferencesPage } from './pages/preferences'; -import { createDefaultSettings, startRancherDesktop, teardown } from './utils/TestUtils'; +import { createDefaultSettings, startRancherDesktop, teardown, tool } from './utils/TestUtils'; + +import { reopenLogs } from '@pkg/utils/logging'; import type { ElectronApplication, Page } from '@playwright/test'; @@ -30,6 +32,11 @@ test.describe.serial('Main App Test', () => { test.afterAll(() => teardown(electronApp, __filename)); + test.afterAll(async() => { + await tool('rdctl', 'factory-reset', '--verbose'); + reopenLogs(); + }); + test('should open preferences modal', async() => { expect(preferencesWindow).toBeDefined(); diff --git a/e2e/utils/TestUtils.ts b/e2e/utils/TestUtils.ts index 0c3b2f44ae3..d8bfafe70ec 100644 --- a/e2e/utils/TestUtils.ts +++ b/e2e/utils/TestUtils.ts @@ -147,7 +147,12 @@ export async function teardown(app: ElectronApplication, filename: string) { try { await context.tracing.stop({ path: reportAsset(filename) }); await packageLogs(filename); - await app.close(); + // Allow one minute for shutdown + await Promise.race([ + app.close(), + util.promisify(setTimeout)(60 * 1000), + ]); + await tool('rdctl', 'shutdown'); } finally { if (proc.kill('SIGTERM') || proc.kill('SIGKILL')) { console.log(`Manually stopped process ${ pid }`);