Skip to content

Commit 44966cc

Browse files
committed
test(e2e): added deploying to crc cluster test case
Signed-off-by: Daniel Villanueva <davillan@redhat.com>
1 parent 58fcbf6 commit 44966cc

File tree

1 file changed

+118
-8
lines changed

1 file changed

+118
-8
lines changed

tests/src/openshift-local-extension.spec.ts

Lines changed: 118 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**********************************************************************
2-
* Copyright (C) 2024 Red Hat, Inc.
2+
* Copyright (C) 2025 Red Hat, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,8 +16,8 @@
1616
* SPDX-License-Identifier: Apache-2.0
1717
***********************************************************************/
1818

19-
import type { NavigationBar } from '@podman-desktop/tests-playwright';
20-
import { expect as playExpect, ExtensionCardPage, RunnerOptions, test, ResourceConnectionCardPage, PreferencesPage } from '@podman-desktop/tests-playwright';
19+
import type { ContainerInteractiveParams, NavigationBar } from '@podman-desktop/tests-playwright';
20+
import { expect as playExpect, ExtensionCardPage, RunnerOptions, test, ResourceConnectionCardPage, PreferencesPage, ContainerState, ContainerDetailsPage, deleteContainer, deleteImage, deletePod } from '@podman-desktop/tests-playwright';
2121

2222
import { OpenShiftLocalExtensionPage } from './model/pages/openshift-local-extension-page';
2323

@@ -35,6 +35,17 @@ const disabledExtensionStatus = 'DISABLED';
3535
const notInstalledExtensionStatus = 'NOT-INSTALLED';
3636
const skipInstallation = process.env.SKIP_INSTALLATION ? process.env.SKIP_INSTALLATION : false;
3737

38+
const kubernetesContext = 'microshift';
39+
const imageName1 = 'quay.io/sclorg/httpd-24-micro-c9s';
40+
const imageName2 = 'ghcr.io/linuxcontainers/alpine';
41+
const containerName1 = 'container-to-deploy-1';
42+
const containerName2 = 'container-to-deploy-2';
43+
const deployedPodName1 = 'container-1-pod';
44+
const deployedPodName2 = 'container-2-pod';
45+
const containerStartParams: ContainerInteractiveParams = {
46+
attachTerminal: false,
47+
};
48+
3849
test.use({
3950
runnerOptions: new RunnerOptions({ customFolder: 'crc-tests-pd', autoUpdate: false, autoCheckUpdates: false }),
4051
});
@@ -46,8 +57,18 @@ test.beforeAll(async ({ runner, page, welcomePage }) => {
4657
preferencesPage = new PreferencesPage(page);
4758
});
4859

49-
test.afterAll(async ({ runner }) => {
50-
await runner.close();
60+
test.afterAll(async ({ runner, page }) => {
61+
try {
62+
await deletePod(page, deployedPodName1);
63+
await deletePod(page, deployedPodName2);
64+
await deleteContainer(page, containerName1);
65+
await deleteContainer(page, containerName2);
66+
await deleteImage(page, imageName1);
67+
await deleteImage(page, imageName2);
68+
} finally {
69+
await runner.close();
70+
console.log('Runner closed');
71+
}
5172
});
5273

5374
test.describe.serial('Red Hat OpenShift Local extension verification', () => {
@@ -123,10 +144,10 @@ test.describe.serial('Red Hat OpenShift Local extension verification', () => {
123144
await playExpect(extensionCard.status).toHaveText(disabledExtensionStatus);
124145
//checking dashboard assets
125146
const dashboard = await navigationBar.openDashboard();
126-
await playExpect(dashboard.openshiftLocalProvider).toHaveCount(0);
147+
await playExpect(dashboard.openshiftLocalProvider).toHaveCount(0, {timeout: 3_000});
127148
//checking settings/resources assets
128149
await navigationBar.openSettings();
129-
await playExpect(resourcesPage.card).toHaveCount(0);
150+
await playExpect(resourcesPage.card).toHaveCount(0, {timeout: 3_000});
130151
});
131152

132153
test.fail('Extension can be disabled -- Settings/Preferences navbar value should be removed after extension removal, but isn\'t, BUG #393', async () => {
@@ -146,7 +167,7 @@ test.describe.serial('Red Hat OpenShift Local extension verification', () => {
146167
//checking dashboard assets
147168
const dashboard = await navigationBar.openDashboard();
148169
await playExpect(dashboard.openshiftLocalProvider).toBeVisible();
149-
await playExpect(dashboard.openshiftLocalStatusLabel).toHaveText(notInstalledExtensionStatus); // if locally, delete binary
170+
await playExpect(dashboard.openshiftLocalStatusLabel).toHaveText(notInstalledExtensionStatus); // if locally, delete binary or comment this
150171
//checking settings/resources assets
151172
const settingsBar = await navigationBar.openSettings();
152173
await playExpect(resourcesPage.card).toBeVisible();
@@ -158,6 +179,95 @@ test.describe.serial('Red Hat OpenShift Local extension verification', () => {
158179
});
159180
});
160181

182+
test.describe.serial('Deploy a container to a CRC cluster by pushing the image from Podman Desktop', () => {
183+
test('Pull image 1 and start the container', async ({ navigationBar }) => {
184+
const imagesPage = await navigationBar.openImages();
185+
await playExpect(imagesPage.heading).toBeVisible();
186+
187+
const pullImagePage = await imagesPage.openPullImage();
188+
const updatedImages = await pullImagePage.pullImage(imageName1);
189+
190+
const exists = await updatedImages.waitForImageExists(imageName1);
191+
playExpect(exists, `${imageName1} image not present in the list of images`).toBeTruthy();
192+
playExpect(await updatedImages.getCurrentStatusOfImage(imageName1)).toBe('UNUSED');
193+
194+
const containersPage = await imagesPage.startContainerWithImage(
195+
imageName1,
196+
containerName1,
197+
containerStartParams,
198+
);
199+
await playExpect.poll(async () => containersPage.containerExists(containerName1)).toBeTruthy();
200+
const containerDetails = await containersPage.openContainersDetails(containerName1);
201+
await playExpect(containerDetails.heading).toBeVisible();
202+
await playExpect.poll(async () => containerDetails.getState()).toBe(ContainerState.Running);
203+
});
204+
205+
test.fail('Push the image to the cluster', async ({ navigationBar, statusBar, page }) => {
206+
const imagesPage = await navigationBar.openImages();
207+
const pulledImage = await imagesPage.getImageRowByName(imageName1);
208+
if (pulledImage === undefined) {
209+
throw Error(`Image: '${name}' does not exist`);
210+
}
211+
const kebabMenuButton = pulledImage.getByRole('button', { name: 'kebab menu' });
212+
await playExpect(kebabMenuButton).toBeVisible();
213+
kebabMenuButton.click();
214+
//This step will fail => [BUG] option to push the image to OpenShift not shown #372
215+
const pushToClusterButton = imagesPage.getPage().getByTitle('Drop Down Menu Items').getByTitle('Push image to OpenShift Local cluster');
216+
await playExpect(pushToClusterButton).toBeVisible();
217+
//This step will fail => [BUG] Can't push images to OpenShift Local clusters (ssh key name issue) #495
218+
await pushToClusterButton.click();
219+
statusBar.tasksButton.click();
220+
const tasksManager = page.getByTitle("Tasks manager")
221+
await playExpect(tasksManager.getByTitle("/^Image ${imageName1} was successfully pushed to the OpenShift Local cluster /")).toBeVisible(); //not the actual message; locally this appears only if the crc cluster is started
222+
});
223+
224+
test.skip('Deploy the container to the crc cluster -- previous step expected to fail', async ({ page, navigationBar }) => {
225+
await navigationBar.openContainers();
226+
const containerDetailsPage = new ContainerDetailsPage(page, containerName1);
227+
await playExpect(containerDetailsPage.heading).toBeVisible();
228+
const deployToKubernetesPage = await containerDetailsPage.openDeployToKubernetesPage();
229+
await deployToKubernetesPage.deployPod(deployedPodName1, { useKubernetesServices: true, isOpenShiftCluster: true, useOpenShiftRoutes: true }, kubernetesContext);
230+
231+
const podsPage = await navigationBar.openPods();
232+
await playExpect.poll(async () => podsPage.deployedPodExists(deployedPodName1, 'kubernetes')).toBeTruthy();
233+
});
234+
235+
});
236+
237+
test.describe.serial('Deploy a container to a CRC cluster by pulling the image directly from the cluster', () => {
238+
test('Pull image 2 and start a container', async ({ navigationBar }) => {
239+
const imagesPage = await navigationBar.openImages();
240+
await playExpect(imagesPage.heading).toBeVisible();
241+
242+
const pullImagePage = await imagesPage.openPullImage();
243+
const updatedImages = await pullImagePage.pullImage(imageName2);
244+
245+
const exists = await updatedImages.waitForImageExists(imageName2);
246+
playExpect(exists, `${imageName2} image not present in the list of images`).toBeTruthy();
247+
playExpect(await updatedImages.getCurrentStatusOfImage(imageName2)).toBe('UNUSED');
248+
249+
const containersPage = await imagesPage.startContainerWithImage(
250+
imageName2,
251+
containerName2,
252+
containerStartParams,
253+
);
254+
await playExpect.poll(async () => containersPage.containerExists(containerName2)).toBeTruthy();
255+
const containerDetails = await containersPage.openContainersDetails(containerName2);
256+
await playExpect(containerDetails.heading).toBeVisible();
257+
await playExpect.poll(async () => containerDetails.getState()).toBe(ContainerState.Running);
258+
});
259+
260+
test('Deploy the container to the crc cluster', async ({ page, navigationBar }) => {
261+
const containerDetailsPage = new ContainerDetailsPage(page, containerName2);
262+
await playExpect(containerDetailsPage.heading).toBeVisible();
263+
const deployToKubernetesPage = await containerDetailsPage.openDeployToKubernetesPage();
264+
await deployToKubernetesPage.deployPod(deployedPodName2, { useKubernetesServices: true, isOpenShiftCluster: true, useOpenShiftRoutes: true }, kubernetesContext);
265+
266+
const podsPage = await navigationBar.openPods();
267+
await playExpect.poll(async () => podsPage.deployedPodExists(deployedPodName2, 'kubernetes')).toBeTruthy();
268+
});
269+
});
270+
161271
test('OpenShift Local extension can be removed', async ({ navigationBar }) => {
162272
await removeExtension(navigationBar);
163273
});

0 commit comments

Comments
 (0)