Skip to content

Commit

Permalink
chore(test): handle extra popup on mac (podman-desktop#8968)
Browse files Browse the repository at this point in the history
* chore(test): handle some e2e issues on mac cicd
Signed-off-by: Vladimir Lazar <[email protected]>
  • Loading branch information
cbr7 authored Sep 19, 2024
1 parent f9fdf74 commit 87c5065
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@
* SPDX-License-Identifier: Apache-2.0
***********************************************************************/

import * as os from 'node:os';

import { expect as playExpect, test } from '../utility/fixtures';
import { deletePodmanMachine } from '../utility/operations';
import { isLinux, isMac } from '../utility/platform';
import { waitForPodmanMachineStartup } from '../utility/wait';

const PODMAN_MACHINE_NAME: string = 'podman-machine-default';

test.skip(isLinux || process.env.TEST_PODMAN_MACHINE !== 'true', 'Tests suite should not run on Linux platform');

test.skip(
os.platform() === 'linux' || process.env.TEST_PODMAN_MACHINE !== 'true',
'Tests suite should not run on Linux platform',
isMac,
'Due to issue https://github.com/containers/podman-desktop/issues/8984 which causes problems on cicd on macOs this test suite is deactived on macs until a fix is provided',
);

test.beforeAll(async ({ runner, welcomePage, page }) => {
Expand All @@ -36,6 +38,7 @@ test.beforeAll(async ({ runner, welcomePage, page }) => {
(process.env.TEST_PODMAN_MACHINE !== undefined && process.env.TEST_PODMAN_MACHINE === 'true') ||
(process.env.MACHINE_CLEANUP !== undefined && process.env.MACHINE_CLEANUP === 'true')
) {
await waitForPodmanMachineStartup(page);
await deletePodmanMachine(page, PODMAN_MACHINE_NAME);
}
});
Expand Down
10 changes: 9 additions & 1 deletion tests/playwright/src/specs/podman-machine-onboarding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import { ResourcesPage } from '../model/pages/resources-page';
import type { SettingsBar } from '../model/pages/settings-bar';
import { expect as playExpect, test } from '../utility/fixtures';
import { deletePodmanMachine } from '../utility/operations';
import { isLinux, isMac } from '../utility/platform';
import { waitForPodmanMachineStartup } from '../utility/wait';

const PODMAN_MACHINE_STARTUP_TIMEOUT: number = 360_000;
const PODMAN_FULL_STARTUP_TIMEOUT = PODMAN_MACHINE_STARTUP_TIMEOUT + 30000;
Expand All @@ -41,7 +43,12 @@ let podmanOnboardingPage: PodmanOnboardingPage;

let notificationPodmanSetup: Locator;

test.skip(os.platform() === 'linux', 'Tests suite should not run on Linux platform');
test.skip(isLinux, 'Tests suite should not run on Linux platform');

test.skip(
isMac,
'Due to issue https://github.com/containers/podman-desktop/issues/8984 which causes problems on cicd on macOs this test suite is deactived on macs until a fix is provided',
);

test.beforeAll(async ({ runner, welcomePage, page }) => {
runner.setVideoAndTraceName('podman-machine-e2e');
Expand All @@ -53,6 +60,7 @@ test.beforeAll(async ({ runner, welcomePage, page }) => {
(process.env.TEST_PODMAN_MACHINE !== undefined && process.env.TEST_PODMAN_MACHINE === 'true') ||
(process.env.MACHINE_CLEANUP !== undefined && process.env.MACHINE_CLEANUP === 'true')
) {
await waitForPodmanMachineStartup(page);
await deletePodmanMachine(page, PODMAN_MACHINE_NAME);
}
});
Expand Down
7 changes: 2 additions & 5 deletions tests/playwright/src/specs/podman-machine-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { ResourceConnectionCardPage } from '../model/pages/resource-connection-c
import { ResourcesPage } from '../model/pages/resources-page';
import { expect as playExpect, test } from '../utility/fixtures';
import { deletePodmanMachine, handleConfirmationDialog } from '../utility/operations';
import { isWindows } from '../utility/platform';
import { waitForPodmanMachineStartup } from '../utility/wait';

const DEFAULT_PODMAN_MACHINE = 'Podman Machine';
Expand Down Expand Up @@ -165,9 +164,7 @@ test.describe.serial(`Podman machine switching validation `, () => {
test('Clean up rootless podman machine', async ({ page }) => {
await deletePodmanMachine(page, ROOTLESS_PODMAN_MACHINE_VISIBLE);

if (isWindows) {
await handleConfirmationDialog(page, 'Podman', true, 'Yes');
await handleConfirmationDialog(page, 'Podman', true, 'OK');
}
await handleConfirmationDialog(page, 'Podman', true, 'Yes');
await handleConfirmationDialog(page, 'Podman', true, 'OK');
});
});
24 changes: 19 additions & 5 deletions tests/playwright/src/utility/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ export async function deletePodmanMachine(page: Page, machineVisibleName: string
{ timeout: 15000 },
);
if (await podmanResourceCard.resourceElement.isVisible()) {
await playExpect(podmanResourceCard.resourceElementConnectionActions).toBeVisible({ timeout: 3000 });
await playExpect(podmanResourceCard.resourceElementConnectionStatus).toBeVisible({ timeout: 3000 });
await playExpect(podmanResourceCard.resourceElementConnectionActions).toBeVisible();
await playExpect(podmanResourceCard.resourceElementConnectionStatus).toBeVisible();
if ((await podmanResourceCard.resourceElementConnectionStatus.innerText()) === ResourceElementState.Starting) {
console.log('Podman machine is in starting currently, will send stop command via CLI');
// eslint-disable-next-line sonarjs/os-command
Expand All @@ -205,7 +205,18 @@ export async function deletePodmanMachine(page: Page, machineVisibleName: string
console.log('Podman machine stopped via CLI');
}
if ((await podmanResourceCard.resourceElementConnectionStatus.innerText()) === ResourceElementState.Running) {
await podmanResourceCard.performConnectionAction(ResourceElementActions.Stop);
try {
await podmanResourceCard.performConnectionAction(ResourceElementActions.Stop);
await waitUntil(
async () =>
(await podmanResourceCard.resourceElementConnectionStatus.innerText()).includes(ResourceElementState.Off),
{ timeout: 30000, sendError: true },
);
} catch (error) {
console.log('Podman machine stop failed, will try to stop it via CLI');
// eslint-disable-next-line sonarjs/os-command
execSync(`podman machine stop ${machineVisibleName}`);
}
await playExpect(podmanResourceCard.resourceElementConnectionStatus).toHaveText(ResourceElementState.Off, {
timeout: 30_000,
});
Expand All @@ -218,16 +229,19 @@ export async function deletePodmanMachine(page: Page, machineVisibleName: string
}

export async function getVolumeNameForContainer(page: Page, containerName: string): Promise<string | undefined> {
let volumeName;
let volumeSummaryContent;
try {
const navigationBar = new NavigationBar(page);
const volumePage = await navigationBar.openVolumes();
const rows = await volumePage.getAllTableRows();

for (let i = rows.length - 1; i > 0; i--) {
const volumeName = await rows[i].getByRole('cell').nth(3).getByRole('button').textContent();
volumeName = await rows[i].getByRole('cell').nth(3).getByRole('button').textContent();
if (volumeName) {
const volumeDetails = await volumePage.openVolumeDetails(volumeName);
await volumeDetails.activateTab(VolumeDetailsPage.SUMMARY_TAB);
const volumeSummaryContent = await volumeDetails.tabContent.allTextContents();
volumeSummaryContent = await volumeDetails.tabContent.allTextContents();
for (const content of volumeSummaryContent) {
if (content.includes(containerName)) {
await volumeDetails.backLink.click();
Expand Down

0 comments on commit 87c5065

Please sign in to comment.