1
1
/**********************************************************************
2
- * Copyright (C) 2024 Red Hat, Inc.
2
+ * Copyright (C) 2025 Red Hat, Inc.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
16
16
* SPDX-License-Identifier: Apache-2.0
17
17
***********************************************************************/
18
18
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' ;
21
21
22
22
import { OpenShiftLocalExtensionPage } from './model/pages/openshift-local-extension-page' ;
23
23
@@ -35,6 +35,17 @@ const disabledExtensionStatus = 'DISABLED';
35
35
const notInstalledExtensionStatus = 'NOT-INSTALLED' ;
36
36
const skipInstallation = process . env . SKIP_INSTALLATION ? process . env . SKIP_INSTALLATION : false ;
37
37
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
+
38
49
test . use ( {
39
50
runnerOptions : new RunnerOptions ( { customFolder : 'crc-tests-pd' , autoUpdate : false , autoCheckUpdates : false } ) ,
40
51
} ) ;
@@ -46,8 +57,18 @@ test.beforeAll(async ({ runner, page, welcomePage }) => {
46
57
preferencesPage = new PreferencesPage ( page ) ;
47
58
} ) ;
48
59
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
+ }
51
72
} ) ;
52
73
53
74
test . describe . serial ( 'Red Hat OpenShift Local extension verification' , ( ) => {
@@ -123,10 +144,10 @@ test.describe.serial('Red Hat OpenShift Local extension verification', () => {
123
144
await playExpect ( extensionCard . status ) . toHaveText ( disabledExtensionStatus ) ;
124
145
//checking dashboard assets
125
146
const dashboard = await navigationBar . openDashboard ( ) ;
126
- await playExpect ( dashboard . openshiftLocalProvider ) . toHaveCount ( 0 ) ;
147
+ await playExpect ( dashboard . openshiftLocalProvider ) . toHaveCount ( 0 , { timeout : 3_000 } ) ;
127
148
//checking settings/resources assets
128
149
await navigationBar . openSettings ( ) ;
129
- await playExpect ( resourcesPage . card ) . toHaveCount ( 0 ) ;
150
+ await playExpect ( resourcesPage . card ) . toHaveCount ( 0 , { timeout : 3_000 } ) ;
130
151
} ) ;
131
152
132
153
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', () => {
146
167
//checking dashboard assets
147
168
const dashboard = await navigationBar . openDashboard ( ) ;
148
169
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
150
171
//checking settings/resources assets
151
172
const settingsBar = await navigationBar . openSettings ( ) ;
152
173
await playExpect ( resourcesPage . card ) . toBeVisible ( ) ;
@@ -158,6 +179,95 @@ test.describe.serial('Red Hat OpenShift Local extension verification', () => {
158
179
} ) ;
159
180
} ) ;
160
181
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
+
161
271
test ( 'OpenShift Local extension can be removed' , async ( { navigationBar } ) => {
162
272
await removeExtension ( navigationBar ) ;
163
273
} ) ;
0 commit comments