Skip to content

Commit

Permalink
E2E: Limit teardown to one minute
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Yen <mark.yen@suse.com>
  • Loading branch information
mook-as committed Jun 28, 2023
1 parent c4c2242 commit 9df4428
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
6 changes: 6 additions & 0 deletions e2e/containers.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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 } });

Expand Down
5 changes: 5 additions & 0 deletions e2e/lockedFields.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
9 changes: 8 additions & 1 deletion e2e/preferences.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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();

Expand Down
7 changes: 6 additions & 1 deletion e2e/utils/TestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }`);
Expand Down

0 comments on commit 9df4428

Please sign in to comment.